From 7f535078ef80a7b7efa3e3325bfccb994fbd00e8 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 31 Aug 2017 15:16:38 -0400 Subject: Rename packages to org.onap in 1.4.0-SNAPSHOT 19 - remove openecomp 72 - remediate Sonar scan issues 79 - removed unwanted left menu under Report 90 - apply approved license text Issue: PORTAL-19, PORTAL-72, PORTAL-79, PORTAL-90 Change-Id: I41a0ef5fba623d2242574bd15f2d9fb8029a496c Signed-off-by: Christopher Lott (cl778h) --- .../portalapp/controller/core/AdminController.java | 52 --- .../controller/core/AngularAdminController.java | 51 --- .../controller/core/BootstrapSampleController.java | 43 --- .../controller/core/CacheAdminController.java | 248 -------------- .../controller/core/FavoritesController.java | 118 ------- .../controller/core/FnMenuController.java | 227 ------------- .../controller/core/FuncMenuController.java | 175 ---------- .../controller/core/LogoutController.java | 113 ------- .../controller/core/ManifestController.java | 111 ------- .../controller/core/MenuListController.java | 255 --------------- .../controller/core/PostSearchController.java | 211 ------------ .../controller/core/ProfileController.java | 362 --------------------- .../controller/core/ProfileSearchController.java | 162 --------- .../portalapp/controller/core/RoleController.java | 354 -------------------- .../core/RoleFunctionListController.java | 184 ----------- .../controller/core/RoleListController.java | 180 ---------- .../controller/core/SDKLoginController.java | 99 ------ .../controller/core/SingleSignOnController.java | 230 ------------- .../controller/core/UsageListController.java | 165 ---------- .../controller/core/UserProfileController.java | 68 ---- .../controller/core/WelcomeController.java | 43 --- .../portalapp/controller/core/package-info.java | 6 - .../sample/AngularSinglePageController.java | 49 --- .../controller/sample/BroadcastController.java | 131 -------- .../controller/sample/BroadcastListController.java | 143 -------- .../controller/sample/CallflowController.java | 45 --- .../sample/CamundaCockpitController.java | 60 ---- .../sample/CollaborateListController.java | 85 ----- .../controller/sample/CollaborationController.java | 55 ---- .../controller/sample/DS2SampleController.java | 54 --- .../controller/sample/ElasticSearchController.java | 128 -------- .../controller/sample/ElementModelController.java | 87 ----- .../controller/sample/LeafletMapContoller.java | 43 --- .../controller/sample/NetMapController.java | 57 ---- .../controller/sample/PostDroolsController.java | 122 ------- .../sample/ReportDashboardController.java | 46 --- .../controller/sample/SamplePageController.java | 50 --- .../portalapp/controller/sample/package-info.java | 5 - .../java/org/openecomp/portalapp/model/Result.java | 37 --- .../org/openecomp/portalapp/scheduler/LogJob.java | 45 --- .../openecomp/portalapp/scheduler/LogRegistry.java | 57 ---- .../portalapp/service/IAdminAuthExtension.java | 65 ---- .../service/OnBoardingApiServiceImpl.java | 361 -------------------- .../portalapp/util/CustomLoggingFilter.java | 54 --- 44 files changed, 5236 deletions(-) delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java delete mode 100644 ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java (limited to 'ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp') diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java deleted file mode 100644 index c0904704..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -public class AdminController { - @Controller - @RequestMapping("/") - public class AngularSinglePageController extends RestrictedBaseController { - - @RequestMapping(value = { "/admin" }, method = RequestMethod.GET) - public ModelAndView view(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("admin", "model", model); - } - - @RequestMapping(value = { "/admin2" }, method = RequestMethod.GET) - public ModelAndView adminView(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("admin2", "model", model); - } - - - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java deleted file mode 100644 index 7441106f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class AngularAdminController extends RestrictedBaseController{ - - @RequestMapping(value = {"/userProfile" }, method = RequestMethod.GET) - public ModelAndView view(HttpServletRequest request) { - Map model = new HashMap(); - - return new ModelAndView("user_profile_list","model", model); - } - - @RequestMapping(value = {"/admin" }, method = RequestMethod.GET) - public ModelAndView adminView(HttpServletRequest request) { - Map model = new HashMap(); - - return new ModelAndView(getViewName(),"model", model); - } - -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java deleted file mode 100644 index 794af760..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/BootstrapSampleController.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for welcome view. The view is restricted to authenticated users. - * The view name defaults to the request name with no suffix, "bootstrap_sample", which - * resolves to page welcome.jsp. - */ -@Controller -@RequestMapping("/") -public class BootstrapSampleController extends RestrictedBaseController { - @RequestMapping(value = { "/bootstrap_sample" }, method = RequestMethod.GET) - public ModelAndView welcome(HttpServletRequest request) { - final String defaultViewName = null; - return new ModelAndView(defaultViewName); - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java deleted file mode 100644 index 81d35f3d..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.jcs.JCS; -import org.apache.jcs.admin.CacheRegionInfo; -import org.apache.jcs.admin.JCSAdminBean; -import org.apache.jcs.engine.behavior.ICacheElement; -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -@Controller -@RequestMapping("/") -public class CacheAdminController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CacheAdminController.class); - - private JCSAdminBean jcsAdminBean = new JCSAdminBean(); - - @RequestMapping(value = { "/jcs_admin" }, method = RequestMethod.GET) - public ModelAndView cacheAdmin(HttpServletRequest request) { - Map model = new HashMap(); - - model.put("model", getRegions()); - - return new ModelAndView(getViewName(), model); - } - - @RequestMapping(value = { "/get_regions" }, method = RequestMethod.GET) - public void getRegions(HttpServletRequest request, HttpServletResponse response) { - try { - JsonMessage msg = new JsonMessage(getRegions().toString()); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRegions failed", e); - } - } - - @RequestMapping(value = { "/jcs_admin/clearRegion" }, method = RequestMethod.GET) - public void clearRegion(HttpServletRequest request, HttpServletResponse response) throws Exception { - String cacheName = (String) request.getParameter("cacheName"); - clearCacheRegion(cacheName); - - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(getRegions().toString()); - } - - @RequestMapping(value = { "/jcs_admin/clearAll" }, method = RequestMethod.GET) - public void clearAll(HttpServletRequest request, HttpServletResponse response) throws Exception { - clearAllRegions(); - - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(getRegions().toString()); - } - - @RequestMapping(value = { "/jcs_admin/clearItem" }, method = RequestMethod.GET) - public void clearItem(HttpServletRequest request, HttpServletResponse response) throws Exception { - String keyName = (String) request.getParameter("keyName"); - String cacheName = (String) request.getParameter("cacheName"); - clearCacheRegionItem(cacheName, keyName); - - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(getRegions().toString()); - } - - @RequestMapping(value = { "/jcs_admin/showItemDetails" }, method = RequestMethod.GET) - public void showItemDetails(HttpServletRequest request, HttpServletResponse response) throws Exception { - String cacheName = (String) request.getParameter("cacheName"); - String keyName = (String) request.getParameter("keyName"); - String details = null; - - try { - details = getItemDetails(cacheName, keyName); - } catch (Exception e) { - details = "There was an error retrieving the region details. Please try again."; - logger.error(EELFLoggerDelegate.errorLogger, "showItemDetails failed for cache name " + cacheName, e); - } - JSONObject j = new JSONObject(details); - response.setContentType("application/json"); - // response.setContentType("text/plain"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - } - - @RequestMapping(value = { "/jcs_admin/showRegionDetails" }, method = RequestMethod.GET) - public void showRegionDetails(HttpServletRequest request, HttpServletResponse response) throws Exception { - String cacheName = (String) request.getParameter("cacheName"); - String details = null; - ObjectMapper mapper = new ObjectMapper(); - JSONObject j = null; - try { - details = getRegionStats(cacheName); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(details)); - j = new JSONObject(msg); - - } catch (Exception e) { - details = "There was an error retrieving the region details. Please try again."; - logger.error(EELFLoggerDelegate.errorLogger, "showRegionDetailed failed for cache name " + cacheName, e); - } - - response.setContentType("application/json"); - - PrintWriter out = response.getWriter(); - // out.write(details); - out.write(j.toString()); - } - - @SuppressWarnings("unchecked") - public JSONArray getRegions() { - LinkedList regions = null; - JSONArray ja = new JSONArray(); - try { - regions = getJcsAdminBean().buildCacheInfo(); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - for (CacheRegionInfo cri : regions) { - if (cri.getCache().getCacheName() != null && !cri.getCache().getCacheName().equals("[object Object]")) { - JSONObject jo = new JSONObject(); - jo.put("cacheName", cri.getCache().getCacheName()); - jo.put("size", cri.getCache().getSize()); - jo.put("byteCount", cri.getByteCount()); - jo.put("status", cri.getStatus()); - jo.put("hitCountRam", cri.getCache().getHitCountRam()); - jo.put("hitCountAux", cri.getCache().getHitCountAux()); - jo.put("missCountNotFound", cri.getCache().getMissCountNotFound()); - jo.put("missCountExpired", cri.getCache().getMissCountExpired()); - jo.put("items", - new JSONArray(mapper.writeValueAsString(getRegionItems(cri.getCache().getCacheName())))); - ja.put(jo); - } - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRegions failed", e); - } - - return ja; - } - - private String getRegionStats(String cacheName) throws Exception { - String stats = ""; - - JCS cache = JCS.getInstance(cacheName); - stats = cache.getStats(); - - return stats; - } - - private String getItemDetails(String cacheName, String keyName) throws Exception { - String details = ""; - - JCS cache = JCS.getInstance(cacheName); - ICacheElement element = cache.getCacheElement(keyName); - - if (element != null) { - ObjectMapper mapper = new ObjectMapper(); - mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - details = mapper.writeValueAsString(element); - } - - return details; - } - - @SuppressWarnings("rawtypes") - private List getRegionItems(String cacheName) { - List items = null; - - try { - items = getJcsAdminBean().buildElementInfo(cacheName); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRegionItems failed for cache name " + cacheName, e); - } - return items; - } - - private void clearAllRegions() { - try { - getJcsAdminBean().clearAllRegions(); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "clearAllRegions faield", e); - } - } - - private void clearCacheRegion(String cacheName) { - try { - getJcsAdminBean().clearRegion(cacheName); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "clearCacheRegion failed for cache name " + cacheName, e); - } - } - - private void clearCacheRegionItem(String cacheName, String keyName) { - try { - getJcsAdminBean().removeItem(cacheName, keyName); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "clearCacheRegionItem failed for key name " + keyName, e); - } - } - - public JCSAdminBean getJcsAdminBean() { - return jcsAdminBean; - } - - public void setJcsAdminBean(JCSAdminBean jcsAdminBean) { - this.jcsAdminBean = jcsAdminBean; - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java deleted file mode 100644 index 023f8d7b..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.App; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.aspect.AuditLog; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.rest.FavoritesClient; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.service.AppService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping("/") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@AuditLog -public class FavoritesController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FavoritesController.class); - - @Autowired - private AppService appService; - - /** - * Makes the REST API call to Portal Back-end and retrieves Favorite menu - * items for the currently logged in user. - * - * @param request - * @param response - */ - @RequestMapping(value = { "/get_favorites" }, method = RequestMethod.GET) - public void getFavorites(HttpServletRequest request, HttpServletResponse response) { - String appName = ""; - String requestId = ""; - String appUserName = ""; - String decryptedPwd = ""; - - try { - HttpSession session = request.getSession(); - User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); - if (user == null || user.getId() == null) { - logger.info(EELFLoggerDelegate.errorLogger, - ("Http request did not contain user info, cannot retrieve favorites.")); - - response.setContentType("application/json"); - JSONArray jsonResponse = new JSONArray(); - JSONObject error = new JSONObject(); - error.put("error", "Http request did not contain user info, cannot retrieve favorites."); - jsonResponse.put(error); - response.getWriter().write(jsonResponse.toString()); - } else { - logger.info(EELFLoggerDelegate.errorLogger, - "Retrieving Favorites for the user '" + MDC.get(SystemProperties.MDC_LOGIN_ID) + "'."); - - App app = appService.getDefaultApp(); - if (app!=null) { - appName = app.getName(); - appUserName = app.getUsername(); - try{ - decryptedPwd = CipherUtil.decrypt(app.getAppPassword(), SystemProperties.getProperty(SystemProperties.Decryption_Key)); - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in WebServiceCallServiceImpl.get while decrypting the password. Details: " + e.getMessage()); - } - } else { - logger.warn(EELFLoggerDelegate.errorLogger, "Unable to locate the app information from the database."); - appName = SystemProperties.SDK_NAME; - } - requestId = MDC.get(MDC_KEY_REQUEST_ID); - - String jsonResponse = FavoritesClient.getFavorites(MDC.get(SystemProperties.MDC_LOGIN_ID), appName, requestId, appUserName, decryptedPwd); - - logger.debug(EELFLoggerDelegate.debugLogger, "FavoritesMenu response: " + jsonResponse); - - response.setContentType("application/json"); - response.getWriter().write(jsonResponse); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, - "Exception occurred in FavoritesController.getFavorites while performing get_favorites. Details: " - + e.getMessage(), AlarmSeverityEnum.MINOR); - } - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java deleted file mode 100644 index 78c1440d..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java +++ /dev/null @@ -1,227 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Menu; -import org.openecomp.portalsdk.core.domain.MenuData; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.FnMenuService; -import org.openecomp.portalsdk.core.service.FunctionalMenuListService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * A controller for Admin to add/edit/delete menu items from FN_MENU. - */ - -@Controller -@RequestMapping("/") -public class FnMenuController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnMenuController.class); - - @Autowired - FnMenuService service; - - @Autowired - FunctionalMenuListService functionalMenuListService; - - private String viewName; - - @RequestMapping(value = { "/admin_fn_menu/get_parent_list" }, method = RequestMethod.GET) - public void getParentList(HttpServletRequest request, HttpServletResponse response) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - try { - response.getWriter().write(mapper.writeValueAsString(service.getParentList())); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getParentListFailed", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - } - } - - @RequestMapping(value = { "/admin_fn_menu/get_function_cd_list" }, method = RequestMethod.GET) - public void getFunctionCDList(HttpServletRequest request, HttpServletResponse response) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - try { - response.getWriter().write(mapper.writeValueAsString(functionalMenuListService.getFunctionCDList(request))); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getFunctionCDList", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - } - - } - - @RequestMapping(value = { "/admin_fn_menu" }, method = RequestMethod.GET) - public void getFnMenuList(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - List temp = null; - List> childItemList = new ArrayList>(); - List parentList = new ArrayList<>(); - - try { - temp = service.getFnMenuItems(); - for (MenuData menu : temp) { - MenuData parentData = new MenuData(); - parentData.setId(menu.getId()); - parentData.setLabel(menu.getLabel()); - if (menu.getParentMenu() != null) { - parentData.setParentId(menu.getParentMenu().getId()); - } - parentData.setAction(menu.getAction()); - parentData.setFunctionCd(menu.getFunctionCd()); - parentData.setImageSrc(menu.getImageSrc()); - parentData.setSortOrder(menu.getSortOrder()); - parentData.setActive(menu.isActive()); - parentData.setServlet(menu.getServlet()); - parentData.setQueryString(menu.getQueryString()); - parentData.setExternalUrl(menu.getExternalUrl()); - parentData.setTarget(menu.getTarget()); - parentData.setMenuSetCode(menu.getMenuSetCode()); - parentData.setSeparator(menu.isSeparator()); - parentData.setImageSrc(menu.getImageSrc()); - parentList.add(parentData); - List tempList = new ArrayList(); - // int countChildAction = 0; - /* - * for(Object o:menu.getChildMenus()){ Menu m = (Menu)o; Menu - * data = new Menu(); data.setId(m.getId()); - * data.setLabel(m.getLabel()); data.setAction(m.getAction()); - * data.setImageSrc(m.getImageSrc()); tempList.add(data); } - */ - childItemList.add(tempList); - } - model.put("fnMenuItems", parentList); - // JsonMessage msg = new - // JsonMessage(mapper.writeValueAsString(parentList),mapper.writeValueAsString(childItemList),"none"); - - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getFnMenuList failed", e); - } - - } - - @RequestMapping(value = { "/admin_fn_menu/updateFnMenu" }, method = RequestMethod.POST) - public ModelAndView updateFnMenu(HttpServletRequest request, HttpServletResponse response) throws Exception { - - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Menu fnMenuItem = mapper.readValue(root.get("availableFnMenuItem").toString(), Menu.class); - - service.saveFnMenu(fnMenuItem); - request.getSession() - .removeAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); - request.getSession().removeAttribute(SystemProperties.LEFT_MENU_CHILDREND); - request.getSession().removeAttribute(SystemProperties.LEFT_MENU_PARENT); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(service.getMenuItem(fnMenuItem.getId())); - - out.write(responseString); - - return null; - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "updateFnMenu failed", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - } - return null; - - } - - @RequestMapping(value = { "/admin_fn_menu/removeMenuItem" }, method = RequestMethod.POST) - public ModelAndView removeFnMenu(HttpServletRequest request, HttpServletResponse response) throws Exception { - - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Menu fnMenuItem = mapper.readValue(root.get("fnMenuItem").toString(), Menu.class); - Menu fnMenuItemRow = service.getMenuItemRow(fnMenuItem.getId()); - - service.removeMenuItem(fnMenuItemRow); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(service.getMenuItem(fnMenuItem.getId())); - out.write(responseString); - - return null; - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeFnMenu failed", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - } - return null; - - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java deleted file mode 100644 index 8e17eaae..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; - -import java.io.IOException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.App; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.aspect.AuditLog; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.rest.FunctionalMenuClient; -import org.openecomp.portalsdk.core.onboarding.ueb.UebException; -import org.openecomp.portalsdk.core.onboarding.ueb.UebManager; -import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg; -import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; -import org.openecomp.portalsdk.core.service.AppService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping("/") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -public class FuncMenuController extends RestrictedBaseController{ - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FuncMenuController.class); - - @Autowired - AppService appService; - - @AuditLog - @RequestMapping(value = {"/get_functional_menu" }, method = RequestMethod.GET) - public void functionalMenu(HttpServletRequest request, HttpServletResponse response) { - - User user = UserUtils.getUserSession(request); - //JSONArray validMenu = new JSONArray("[{\"menuId\":140,\"column\":1,\"text\":\"RT SDK Menu\",\"parentMenuId\":139,\"url\":\"http://www.cnn.com\"},{\"menuId\":139,\"column\":1,\"text\":\"RT Menu\",\"parentMenuId\":11,\"url\":\"\"},{\"menuId\":11,\"column\":1,\"text\":\"Product Design\",\"parentMenuId\":1,\"url\":\"\"},{\"menuId\":1,\"column\":1,\"text\":\"Design\",\"url\":\"\"}]"); - - try { - if ( user != null ) { - String useRestForFunctionalMenu = PortalApiProperties.getProperty(PortalApiConstants.USE_REST_FOR_FUNCTIONAL_MENU); - String funcMenuJsonString = ""; - if (useRestForFunctionalMenu==null || useRestForFunctionalMenu=="" || useRestForFunctionalMenu.equalsIgnoreCase("false")) { - logger.info(EELFLoggerDelegate.errorLogger, "Making use of UEB communication and Requesting functional menu for user " + user.getOrgUserId()); - funcMenuJsonString = getFunctionalMenu(user.getOrgUserId()); - } else { - funcMenuJsonString = getFunctionalMenuViaREST(user.getOrgUserId()); - } - response.setContentType("application/json"); - response.getWriter().write(funcMenuJsonString); - } else { - logger.info(EELFLoggerDelegate.errorLogger, "Http request did not contain user info, cannot retrieve functional menu"); - response.setContentType("application/json"); - JSONArray jsonResponse = new JSONArray(); - JSONObject error = new JSONObject(); - error.put("error","Http request did not contain user info, cannot retrieve functional menu"); - jsonResponse.put(error); - response.getWriter().write(jsonResponse.toString()); - } - } catch (Exception e) { - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - JSONArray jsonResponse = new JSONArray(); - JSONObject error = new JSONObject(); - try { - if ( null == e.getMessage() ) { - error.put("error","No menu data"); - } else { - error.put("error",e.getMessage()); - } - jsonResponse.put(error); - response.getWriter().write(jsonResponse.toString()); - logger.error(EELFLoggerDelegate.errorLogger, "Error getting functional_menu: " + e.getMessage(),AlarmSeverityEnum.MAJOR); - } catch (IOException e1) { - e1.printStackTrace(); - } - } - - } - - //-------------------------------------------------------------------------- - // Makes a synchronous call to ECOMP Portal to get the JSON file that - // contains the contents of the functional menu. The JSON file will be - // in the payload of the returned UEB message. - //-------------------------------------------------------------------------- - private String getFunctionalMenu(String userId) throws UebException - { - String returnString = null; - UebMsg funcMenuUebMsg = null; - UebMsg msg = new UebMsg(); - msg.putMsgType(UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU); - msg.putUserId(userId); - funcMenuUebMsg = UebManager.getInstance().requestReply(msg); - if (funcMenuUebMsg != null) { - if (funcMenuUebMsg.getPayload().startsWith("Error:")) { - logger.error(EELFLoggerDelegate.errorLogger, "getFunctionalMenu received an error in UEB msg = " + funcMenuUebMsg.getPayload()); - } else { - returnString = funcMenuUebMsg.getPayload(); - } - } - - logger.debug(EELFLoggerDelegate.debugLogger, "FunctionalMenu response: " + returnString); - - return returnString; - } - - private String getFunctionalMenuViaREST(String userId) { - String appName = ""; - String requestId = ""; - String appUserName = ""; - String decryptedPwd = ""; - - logger.info(EELFLoggerDelegate.debugLogger, "Making use of REST API communication and Requesting functional menu for user " + userId); - - App app = appService.getDefaultApp(); - if (app!=null) { - appName = app.getName(); - appUserName = app.getUsername(); - try{ - decryptedPwd = CipherUtil.decrypt(app.getAppPassword(), SystemProperties.getProperty(SystemProperties.Decryption_Key)); - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred in WebServiceCallServiceImpl.get while decrypting the password. Details: " + e.toString()); - } - } else { - logger.warn(EELFLoggerDelegate.errorLogger, "Unable to locate the app information from the database."); - appName = SystemProperties.SDK_NAME; - } - requestId = MDC.get(MDC_KEY_REQUEST_ID); - - String fnMenu = null; - try { - fnMenu = FunctionalMenuClient.getFunctionalMenu(userId, appName, requestId, appUserName, decryptedPwd); - }catch(Exception ex) { - fnMenu = "Failed to get functional menu: " + ex.toString(); - } - - logger.debug(EELFLoggerDelegate.debugLogger, "FunctionalMenu response: {}", fnMenu); - - return fnMenu; - } -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java deleted file mode 100644 index 467bd3c9..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class LogoutController extends UnRestrictedBaseController{ - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LogoutController.class); - - private User user; - - /** - * @param request - * @param response - * @return modelView - * - * globalLogout will invalid the current application session, then redirects to portal logout - */ - @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET) - public ModelAndView globalLogout(HttpServletRequest request, HttpServletResponse response) { - ModelAndView modelView = null; - try{ - chatRoomLogout(request); - request.getSession().invalidate(); - String portalUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); - String portalDomain = portalUrl.substring(0, portalUrl.lastIndexOf('/')); - String redirectUrl = portalDomain+"/logout.htm"; - modelView = new ModelAndView("redirect:"+redirectUrl); - }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, "Logout Error: " + e.getMessage(),AlarmSeverityEnum.MAJOR); - } - return modelView; - } - - /** - * @param request - * @param response - * @return modelView - * - * appLogout is a function that will invalid the current session (application logout) and redirects user to Portal. - */ - @RequestMapping(value = {"/app_logout.htm" }, method = RequestMethod.GET) - public ModelAndView appLogout(HttpServletRequest request, HttpServletResponse response) { - ModelAndView modelView = null; - try{ - chatRoomLogout(request); - modelView = new ModelAndView("redirect:"+PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)); - UserUtils.clearUserSession(request); - request.getSession().invalidate(); - }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, "Application Logout Error: " + e.getMessage(),AlarmSeverityEnum.MAJOR); - } - return modelView; - } - - - public void chatRoomLogout(HttpServletRequest request){ - request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); - setUser(UserUtils.getUserSession(request)); - // if(getUser()!=null){ - // Long login_IdLong = getUser().getId(); - // String name = getUser().getFirstName(); - // String login_IdStr = Long.toString(login_IdLong); - // } - //UserListName.getInstance().delUserName(name); - //UserListID.getInstance().delUserName(login_IdStr); - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java deleted file mode 100644 index ae212b50..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * This controller responds to a request for the web application manifest, - * returning a JSON with the information that was created at build time. - * - * Manifest entries have names with hyphens, which means Javascript code can't - * simply use the shorthand object.key; instead use object['key']. - */ -@RestController -@RequestMapping("/") -public class ManifestController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ManifestController.class); - - /** - * Required to obtain the webapp manifest. - */ - @Autowired - private ServletContext context; - - /** Path to resource on classpath */ - private final String MANIFEST_RESOURCE_PATH = "/META-INF/MANIFEST.MF"; - - /** - * Gets the content of the webapp manifest file META-INF/MANIFEST.MF. - * - * @return Attributes object with key-value pairs from the manifest - * @throws IOException - */ - private Attributes getWebappManifest() throws IOException { - // Manifest is formatted as Java-style properties - InputStream inputStream = context.getResourceAsStream(MANIFEST_RESOURCE_PATH); - if (inputStream == null) - throw new IOException("getWebappManifest: failed to get resource at path " + MANIFEST_RESOURCE_PATH); - Manifest manifest = new Manifest(inputStream); - inputStream.close(); - return manifest.getMainAttributes(); - } - - /** - * Gets the webapp manifest contents as a JSON object. - * - * @param request - * @return A map of key-value pairs. On success: - * - *
-	 * { 
-	 * 	 "key1": "value1", 
-	 *   "key2": "value2" 
-	 * }
-	 *         
- * - * On failure: - * - *
-	 * { "error": "message" }
-	 *         
- */ - @RequestMapping(value = { "/manifest" }, method = RequestMethod.GET, produces = "application/json") - @ResponseBody - public Map getManifest(HttpServletRequest request) { - try { - Attributes attributes = getWebappManifest(); - return attributes; - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "getManifest failed", ex); - Map response = new HashMap(); - response.put("error", "failed to get manifest: " + ex.toString()); - return response; - } - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java deleted file mode 100644 index ce5ec975..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.MenuData; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; -import org.openecomp.portalsdk.core.restful.client.SharedContextRestClient; -import org.openecomp.portalsdk.core.restful.domain.SharedContext; -import org.openecomp.portalsdk.core.service.FnMenuService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class MenuListController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MenuListController.class); - - @Autowired - private FnMenuService fnMenuService; - @Autowired - private SharedContextRestClient sharedContextRestClient; - - /** - * - * Gets Menu items and stores into session. - * - * @param request - * @param response - */ - @SuppressWarnings("unchecked") - @RequestMapping(value = { "/get_menu" }, method = RequestMethod.GET) - public void getMenu(HttpServletRequest request, HttpServletResponse response) { - logger.debug(EELFLoggerDelegate.debugLogger, "getMenu begins"); - try { - ObjectMapper mapper = new ObjectMapper(); - Set menuResult = null; - HttpSession session = request.getSession(); - List> childItemList = (List>) session - .getAttribute(SystemProperties.LEFT_MENU_CHILDREND); - List parentList = (List) session.getAttribute(SystemProperties.LEFT_MENU_PARENT); - if (parentList == null || childItemList == null || parentList.size() == 0 || childItemList.size() == 0) { - childItemList = new ArrayList>(); - parentList = new ArrayList(); - menuResult = (Set) session - .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); - fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); - logger.debug(EELFLoggerDelegate.debugLogger, "storing leftmenu items into session"); - session.setAttribute(SystemProperties.LEFT_MENU_PARENT, parentList); - session.setAttribute(SystemProperties.LEFT_MENU_CHILDREND, childItemList); - } - String userName = (String) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_NAME)); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(parentList), - mapper.writeValueAsString(childItemList), userName); - JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, "getMenu ends"); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getMenu failed", e); - } - } - - /** - * - * Gets app name from system.properties file. - * - * @param request - * @param response - */ - @RequestMapping(value = { "/get_app_name" }, method = RequestMethod.GET) - public void getAppName(HttpServletRequest request, HttpServletResponse response) { - logger.debug(EELFLoggerDelegate.debugLogger, "getAppName begins"); - HttpSession session = request.getSession(true); - try { - String appName = (String) session - .getAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); - if (appName != null && appName.equals("app_display_name")) { - appName = ""; - } - JsonMessage msg = new JsonMessage(appName); - JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - logger.debug(EELFLoggerDelegate.debugLogger, "getAppName ends"); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getAppName failed", e); - } - } - - /** - * Apparently unused? - * - * @param request - * @return Map with childItemList and parentList keys, associated values. - */ - @SuppressWarnings("unchecked") - @ModelAttribute("menu") - public Map getLeftMenuJSP(HttpServletRequest request) { - logger.debug(EELFLoggerDelegate.debugLogger, "getLeftMenuJSP begins"); - ObjectMapper mapper = new ObjectMapper(); - Map model = new HashMap(); - try { - HttpSession session = request.getSession(); - List> childItemList = (List>) session - .getAttribute(SystemProperties.LEFT_MENU_CHILDREND); - List parentList = (List) session.getAttribute(SystemProperties.LEFT_MENU_PARENT); - if (parentList == null || childItemList == null) { - childItemList = new ArrayList>(); - parentList = new ArrayList(); - Set menuResult = (Set) session - .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); - fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); - session.setAttribute(SystemProperties.LEFT_MENU_PARENT, parentList); - session.setAttribute(SystemProperties.LEFT_MENU_CHILDREND, childItemList); - } - model.put("childItemList", mapper.writeValueAsString(childItemList)); - model.put("parentList", mapper.writeValueAsString(parentList)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getLeftMenuJSP failed", e); - } - logger.debug(EELFLoggerDelegate.debugLogger, "getLeftMenuJSP ends"); - return model; - } - - /** - * Answers requests for user information, which is fetched from the shared - * context at Portal. - * - * @param request - * @param response - */ - @RequestMapping(value = { "/get_userinfo" }, method = RequestMethod.GET) - public void getUserInfo(HttpServletRequest request, HttpServletResponse response) { - logger.debug(EELFLoggerDelegate.debugLogger, "getUserInfo begins"); - try { - String contextId = null; - if (request.getCookies() != null) { - for (Cookie ck : request.getCookies()) { - if (ck.getName().equalsIgnoreCase("EPService")) - contextId = ck.getValue(); - } - } - logger.debug(EELFLoggerDelegate.debugLogger, "getUserInfo: ContextId is : " + contextId); - List sharedContextRes = sharedContextRestClient.getUserContext(contextId); - logger.debug(EELFLoggerDelegate.debugLogger, "getUserInfo: Shared Context Response is {}", - sharedContextRes); - Map model = new HashMap(); - for (SharedContext sharedContext : sharedContextRes) { - model.put(sharedContext.getCkey(), sharedContext.getCvalue()); - } - JSONObject j = new JSONObject(model); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUserInfo failed", e); - } - } - - /** - * Get User information from app sessions - * - * @param request - * @param response - */ - @RequestMapping(value = { "/get_topMenuInfo" }, method = RequestMethod.GET) - public void getTopMenu(HttpServletRequest request, HttpServletResponse response) { - - HttpSession session = request.getSession(); - try { - String userName = (String) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_NAME)); - String firstName = (String) session.getAttribute(SystemProperties.FIRST_NAME); - String lastName = (String) session.getAttribute(SystemProperties.LAST_NAME); - User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)); - Map map = new HashMap(); - String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); - String portalDomain = redirectUrl.substring(0, redirectUrl.lastIndexOf('/')); - String portalUrl = portalDomain + "/process_csp"; - String getAccessUrl = portalDomain + "/get_access"; - String contactUsLink = SystemProperties.getProperty(SystemProperties.CONTACT_US_LINK); - map.put("portalUrl", portalUrl); - map.put("contactUsLink", contactUsLink); - map.put("userName", userName); - map.put("firstName", firstName); - map.put("lastName", lastName); - map.put("userid", user.getOrgUserId()); - map.put("email", user.getEmail()); - map.put("getAccessUrl", getAccessUrl); - JSONObject j = new JSONObject(map); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to serialize JSON", e); - } - - } - - @RequestMapping(value = { "/page_redirect" }, method = RequestMethod.GET) - public void pageRedirect(HttpServletRequest request, HttpServletResponse response) { - String pageToURL = null; - try { - String pageTo = request.getParameter("page"); - if (pageTo.equals("contact")) - pageToURL = SystemProperties.getProperty(SystemProperties.CONTACT_US_LINK); - else if (pageTo.equals("access")) { - String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); - String portalDomain = redirectUrl.substring(0, redirectUrl.lastIndexOf('/')); - pageToURL = portalDomain + "/get_access"; - } - response.getWriter().write(pageToURL); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "pageRedirect failed", e); - } - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java deleted file mode 100644 index 39fae4f5..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.command.PostSearchBean; -import org.openecomp.portalsdk.core.command.support.SearchResult; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Lookup; -import org.openecomp.portalsdk.core.domain.Profile; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.LdapService; -import org.openecomp.portalsdk.core.service.PostSearchService; -import org.openecomp.portalsdk.core.service.ProfileService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class PostSearchController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PostSearchController.class); - - @SuppressWarnings("rawtypes") - private static List sortByList = null; - - @Autowired - private PostSearchService postSearchService; - - @Autowired - private LdapService ldapService; - - @Autowired - private ProfileService profileService; - - @RequestMapping(value = { "/post_search" }, method = RequestMethod.GET) - public ModelAndView welcome(HttpServletRequest request, - @ModelAttribute("postSearchBean") PostSearchBean postSearchBean) { - Map model = new HashMap(); - - ObjectMapper mapper = new ObjectMapper(); - try { - postSearchBean = new PostSearchBean(); - model.put("profileList", mapper.writeValueAsString(postSearchBean.getSearchResult())); - model.put("postSearchBean", mapper.writeValueAsString(postSearchBean)); - model.put("existingUsers", mapper.writeValueAsString(getExistingUsers())); - model.put("sortByList", mapper.writeValueAsString(getSortByList())); - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "welcome: failed to write JSON" + ex.getMessage()); - } - - return new ModelAndView(getViewName(), model); - } - - @RequestMapping(value = { "/post_search_sample" }, method = RequestMethod.GET) - public void getPostSearchProfile(HttpServletRequest request, HttpServletResponse response, - @ModelAttribute("postSearchBean") PostSearchBean postSearchBean) { - Map model = new HashMap(); - - ObjectMapper mapper = new ObjectMapper(); - try { - postSearchBean = new PostSearchBean(); - model.put("profileList", mapper.writeValueAsString(postSearchBean.getSearchResult())); - model.put("postSearchBean", mapper.writeValueAsString(postSearchBean)); - model.put("existingUsers", mapper.writeValueAsString(getExistingUsers())); - model.put("sortByList", mapper.writeValueAsString(getSortByList())); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "getPostSearchProfile: failed to write JSON" + ex.getMessage()); - } - - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private HashMap getExistingUsers() throws Exception { - HashMap existingUsers = new HashMap(); - - // get the list of user ids in the system - List list = profileService.findAll(); - - if (list != null) { - Iterator i = list.iterator(); - while (i.hasNext()) { - Profile user = i.next(); - String orgUserId = user.getOrgUserId(); // userid scalar - Long id = user.getId(); // id scalar - if (orgUserId != null) - existingUsers.put(orgUserId, id); - } - } - return existingUsers; - } - - @RequestMapping(value = { "/post_search/search" }, method = RequestMethod.POST) - public ModelAndView search(HttpServletRequest request, HttpServletResponse response) throws Exception { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - PostSearchBean postSearchBean = mapper.readValue(root.get("postSearchBean").toString(), - PostSearchBean.class); - - postSearchBean.setSearchResult(loadSearchResultData(request, postSearchBean)); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(postSearchBean); - JSONObject j = new JSONObject("{postSearchBean: " + responseString + "}"); - - out.write(j.toString()); - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "search: failed to send search result" + ex.getMessage()); - } - - return null; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public static List getSortByList() { - if (sortByList == null) { - sortByList = new ArrayList(); - sortByList.add(new Lookup("Last Name", "last_name")); - sortByList.add(new Lookup("First Name", "first_name")); - sortByList.add(new Lookup("HRID", "hrid")); - sortByList.add(new Lookup("SBCID", "sbcid")); - sortByList.add(new Lookup("Organization", "org_code")); - sortByList.add(new Lookup("Email", "email")); - } // if - - return sortByList; - } // getSortByList - - private SearchResult loadSearchResultData(HttpServletRequest request, PostSearchBean searchCriteria) - throws Exception { - return ldapService.searchPost(searchCriteria.getUser(), searchCriteria.getSortBy1(), - searchCriteria.getSortBy2(), searchCriteria.getSortBy3(), searchCriteria.getPageNo(), - searchCriteria.getNewDataSize(), UserUtils.getUserSession(request).getId().intValue()); - } - - @RequestMapping(value = { "/post_search/process" }, method = RequestMethod.POST) - public ModelAndView process(HttpServletRequest request, HttpServletResponse response) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); - JsonNode root = mapper.readTree(request.getReader()); - PostSearchBean postSearch = mapper.readValue(root.get("postSearchBean").toString(), PostSearchBean.class); - String errorMsg = "{}"; - try{ - postSearchService.process(request, postSearch); - postSearch.setSearchResult(loadSearchResultData(request, postSearch)); - }catch(Exception e){ - errorMsg=e.getMessage(); - logger.error(EELFLoggerDelegate.errorLogger,"Exception occurred while performing PostSearchController.process. Details:", e); - } - logger.info(EELFLoggerDelegate.auditLogger, "Import new user from webphone "); - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String postSearchString = mapper.writeValueAsString(postSearch); - JSONObject j = new JSONObject("{postSearchBean: " + postSearchString + ",existingUsers: " - + mapper.writeValueAsString(getExistingUsers()) + ",errorMsg:"+errorMsg+"}"); - - out.write(j.toString()); - - return null; - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java deleted file mode 100644 index 2f17ac68..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java +++ /dev/null @@ -1,362 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.service.UserProfileService; -import org.openecomp.portalsdk.core.service.UserService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class ProfileController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ProfileController.class); - - @Autowired - UserProfileService service; - - @Autowired - UserService userService; - - @Autowired - RoleService roleService; - - private String viewName; - - @RequestMapping(value = { "/profile" }, method = RequestMethod.GET) - public ModelAndView profile(HttpServletRequest request, HttpServletResponse response) throws Exception{ - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - User profile = null; - Long profileId = null; - - if (request.getRequestURI().indexOf("self_profile.htm") > -1) { - profile = UserUtils.getUserSession(request); - profileId = profile.getId(); - } else { - profileId = Long.parseLong(request.getParameter("profile_id")); - profile = (User) userService.getUser(String.valueOf(profileId)); - } - - try { - model.put("stateList", mapper.writeValueAsString(getStates())); - model.put("countries", mapper.writeValueAsString(getCountries())); - model.put("timeZones", mapper.writeValueAsString(getTimeZones())); - model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId()))); - model.put("profile", mapper.writeValueAsString(profile)); - model.put("profileId", mapper.writeValueAsString(profileId)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "profile: failed to write JSON", e); - } - return new ModelAndView("profile", "model", model); - } - - @RequestMapping(value = { "/self_profile" }, method = RequestMethod.GET) - public ModelAndView self_profile(HttpServletRequest request) throws Exception{ - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - - User profile = null; - Long profileId = null; - User user = UserUtils.getUserSession(request); - - profile = UserUtils.getUserSession(request); - try { - model.put("stateList", mapper.writeValueAsString(getStates())); - model.put("countries", mapper.writeValueAsString(getCountries())); - model.put("timeZones", mapper.writeValueAsString(getTimeZones())); - model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId()))); - model.put("profile", mapper.writeValueAsString(profile)); - model.put("profileId", mapper.writeValueAsString(profileId)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "self_profile: failed to write JSON" + e.getMessage()); - } - return new ModelAndView("profile", "model", model); - } - - @RequestMapping(value = { "/get_self_profile" }, method = RequestMethod.GET) - public void getSelfProfile(HttpServletRequest request, HttpServletResponse response) throws Exception{ - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - User profile = null; - Long profileId = null; - - profile = (User) UserUtils.getUserSession(request); - try { - model.put("stateList", mapper.writeValueAsString(getStates())); - model.put("countries", mapper.writeValueAsString(getCountries())); - model.put("timeZones", mapper.writeValueAsString(getTimeZones())); - model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId()))); - model.put("profile", mapper.writeValueAsString(profile)); - model.put("profileId", mapper.writeValueAsString(profileId)); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getSelfProfile: failed to write JSON" + e.getMessage()); - } - - } - - @RequestMapping(value = { "/get_profile" }, method = RequestMethod.GET) - public void GetUser(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - User user = UserUtils.getUserSession(request); - ObjectMapper mapper = new ObjectMapper(); - try { - User profile = null; - Long profileId = null; - if (request.getRequestURI().indexOf("self_profile.htm") > -1) { - profile = UserUtils.getUserSession(request); - profileId = profile.getId(); - } else { - profileId = Long.parseLong(request.getParameter("profile_id")); - profile = (User) userService.getUser(String.valueOf(profileId)); - - } - model.put("stateList", mapper.writeValueAsString(getStates())); - model.put("countries", mapper.writeValueAsString(getCountries())); - model.put("timeZones", mapper.writeValueAsString(getTimeZones())); - model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles(user.getOrgUserId()))); - model.put("profile", mapper.writeValueAsString(profile)); - model.put("profileId", mapper.writeValueAsString(profileId)); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "GetUser: failed to write JSON" + e.getMessage()); - } - } - - @RequestMapping(value = { "/profile/saveProfile" }, method = RequestMethod.POST) - public ModelAndView saveProfile(HttpServletRequest request, HttpServletResponse response) { - logger.info(EELFLoggerDelegate.debugLogger, "ProfileController.save"); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - User user = mapper.readValue(root.get("profile").toString(), User.class); - - String selectedCountry = mapper.readValue(root.get("selectedCountry").toString(), String.class); - String selectedState = mapper.readValue(root.get("selectedState").toString(), String.class); - String selectedTimeZone = mapper.readValue(root.get("selectedTimeZone").toString(), String.class); - - Long profileId = Long.parseLong(request.getParameter("profile_id")); - - User domainUser = (User) userService.getUser(String.valueOf(profileId)); - // user.setRoles(domainUser.getRoles()); - user.setPseudoRoles(domainUser.getPseudoRoles()); - user.setUserApps(domainUser.getUserApps()); - if (!selectedCountry.equals("")) { - user.setCountry(selectedCountry); - } - if (!selectedState.equals("")) { - user.setState(selectedState); - } - if (!selectedTimeZone.equals("")) { - user.setTimeZoneId(Long.parseLong(selectedTimeZone)); - } - service.saveUser(user); - logger.info(EELFLoggerDelegate.auditLogger, "Save user's profile for user " + profileId); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - out.write("" + profileId); - return null; - } catch (Exception e) { - response.setCharacterEncoding("UTF-8"); - try { - request.setCharacterEncoding("UTF-8"); - } catch (UnsupportedEncodingException e1) { - - e1.printStackTrace(); - - } - PrintWriter out = null; - try { - out = response.getWriter(); - } catch (IOException e1) { - logger.error(EELFLoggerDelegate.errorLogger, "saveProfile: failed to get writer" + e1.getMessage()); - } - out.write(e.getMessage()); - return null; - } - } - - @RequestMapping(value = { "/profile/removeRole" }, method = RequestMethod.POST) - public ModelAndView removeRole(HttpServletRequest request, HttpServletResponse response) throws Exception { - - logger.info(EELFLoggerDelegate.debugLogger, "ProfileController.save"); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role role = mapper.readValue(root.get("role").toString(), Role.class); - - String profileId = request.getParameter("profile_id"); - - User domainUser = (User) userService.getUser(profileId); - - domainUser.removeRole(role.getId()); - - service.saveUser(domainUser); - /*If adding new roles on the current logged in user, we need to update the user value in session*/ - if(UserUtils.getUserId(request)==Integer.valueOf(profileId)){ - HttpSession session = request.getSession(true); - session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), domainUser); - } - logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + role.getId() + " from user " + profileId); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - - Map model = new HashMap(); - model.put("profile", mapper.writeValueAsString(domainUser)); - JSONObject j = new JSONObject(mapper.writeValueAsString(domainUser)); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeRole" + e.getMessage()); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = { "/profile/addNewRole" }, method = RequestMethod.POST) - public ModelAndView addNewRole(HttpServletRequest request, HttpServletResponse response) throws Exception { - - logger.info(EELFLoggerDelegate.debugLogger, "ProfileController.save" ); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role role = mapper.readValue(root.get("role").toString(), Role.class); - String profileId = request.getParameter("profile_id"); - User domainUser = (User) userService.getUser(profileId); - domainUser.addRole(role); - service.saveUser(domainUser); - /*If removing roles on the current logged in user, we need to update the user value in session*/ - if(UserUtils.getUserId(request)==Integer.valueOf(profileId)){ - HttpSession session = request.getSession(true); - session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), domainUser); - } - logger.info(EELFLoggerDelegate.auditLogger, "Add new role " + role.getName() + " to user " + profileId); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - Map model = new HashMap(); - model.put("profile", mapper.writeValueAsString(domainUser)); - JSONObject j = new JSONObject(mapper.writeValueAsString(domainUser)); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "addNewRole" + e.getMessage()); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - - @SuppressWarnings("rawtypes") - public List getStates() { - return AppUtils.getLookupList("FN_LU_STATE", "STATE_CD", "STATE", null, "STATE_CD"); - } - - @SuppressWarnings("rawtypes") - public List getCountries() { - return AppUtils.getLookupList("FN_LU_COUNTRY", "COUNTRY_CD", "COUNTRY", null, "COUNTRY"); - } - - @SuppressWarnings("rawtypes") - public List getTimeZones() { - return AppUtils.getLookupList("FN_LU_TIMEZONE", "TIMEZONE_ID", "TIMEZONE_NAME", null, "TIMEZONE_NAME"); - } - - @SuppressWarnings("rawtypes") - public List getAvailableRoles(String requestedLoginId) throws Exception { - return roleService.getAvailableRoles(requestedLoginId); - } - -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java deleted file mode 100644 index 1e600a30..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.MenuData; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.FnMenuService; -import org.openecomp.portalsdk.core.service.UserProfileService; -import org.openecomp.portalsdk.core.service.UserService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class ProfileSearchController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ProfileSearchController.class); - - @Autowired - private UserProfileService service; - - @Autowired - UserService userService; - - @Autowired - private FnMenuService fnMenuService; - - @RequestMapping(value = { "/profile_search" }, method = RequestMethod.GET) - public ModelAndView profileSearch(HttpServletRequest request) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - List profileList = null; - logger.info(EELFLoggerDelegate.applicationLogger, "Initiating ProfileSearch in ProfileSearchController"); - try { - profileList = service.findAll(); - model.putAll(setDashboardData(request)); - model.put("profileList", mapper.writeValueAsString(profileList)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, "profileSearch failed", e); - } - return new ModelAndView(getViewName(), "model", model); - } - - @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET) - public void getUser(HttpServletRequest request, HttpServletResponse response) { - logger.info(EELFLoggerDelegate.applicationLogger, "Initiating get_user in ProfileSearchController"); - ObjectMapper mapper = new ObjectMapper(); - List profileList = null; - try { - profileList = service.findAll(); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(profileList)); - JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, "getUser failed", e); - } - } - - @RequestMapping(value = { "/get_user_pagination" }, method = RequestMethod.GET) - public void getUserPagination(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - logger.info(EELFLoggerDelegate.applicationLogger, "Initiating get_user_pagination in ProfileSearchController"); - int pageNum = Integer.parseInt(request.getParameter("pageNum")); - int viewPerPage = Integer.parseInt(request.getParameter("viewPerPage")); - List profileList = null; - try { - profileList = service.findAll(); - model.put("totalPage", (int) Math.ceil((double) profileList.size() / viewPerPage)); - profileList = profileList.subList( - viewPerPage * (pageNum - 1) < profileList.size() ? viewPerPage * (pageNum - 1) : profileList.size(), - viewPerPage * pageNum < profileList.size() ? viewPerPage * pageNum : profileList.size()); - model.put("profileList", mapper.writeValueAsString(profileList)); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, "getUserPagination failed", e); - } - } - - @SuppressWarnings("unchecked") - private Map setDashboardData(HttpServletRequest request) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - Map model = new HashMap(); - List> childItemList = new ArrayList>(); - List parentList = new ArrayList(); - logger.info(EELFLoggerDelegate.applicationLogger, "Initiating setDashboardData in ProfileSearchController"); - HttpSession session = request.getSession(); - try { - Set menuResult = (Set) session - .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); - fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, "setDashboardData failed", e); - } - model.put("childItemList", mapper.writeValueAsString(childItemList)); - model.put("parentList", mapper.writeValueAsString(parentList)); - return model; - } - - @RequestMapping(value = { "/profile/toggleProfileActive" }, method = RequestMethod.GET) - public void toggleProfileActive(HttpServletRequest request, HttpServletResponse response) throws IOException { - try { - logger.info(EELFLoggerDelegate.applicationLogger, - "Initiating toggleProfileActive in ProfileSearchController"); - String userId = request.getParameter("profile_id"); - User user = (User) userService.getUser(userId); - user.setActive(!user.getActive()); - service.saveUser(user); - logger.info(EELFLoggerDelegate.auditLogger, - "Change active status for user " + user.getId() + " to " + user.getActive()); - ObjectMapper mapper = new ObjectMapper(); - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(mapper.writeValueAsString(user.getActive())); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.applicationLogger, "toggleProfileActive failed", e); - } - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java deleted file mode 100644 index 5d12f4aa..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java +++ /dev/null @@ -1,354 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.RoleFunction; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.aspect.EELFLoggerAdvice; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.ServletRequestUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; - -@Controller -@RequestMapping("/") -public class RoleController extends RestrictedBaseController { - - @Autowired - RoleService roleService; - - private String viewName; - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleController.class); - - - @RequestMapping(value = { "/role" }, method = RequestMethod.GET) - public ModelAndView role(HttpServletRequest request) throws Exception { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - - Role role = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0))); - logger.info("role_id" + role.getId()); - try { - model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions(user.getOrgUserId()))); - model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(user.getOrgUserId(),role.getId()))); - model.put("role", mapper.writeValueAsString(role)); - } catch (Exception e) { - logger.error("role: failed", e); - logger.error(EELFLoggerDelegate.errorLogger, "role failed", e); - } - return new ModelAndView(getViewName(), model); - } - - @RequestMapping(value = { "/get_role" }, method = RequestMethod.GET) - public void getRole(HttpServletRequest request, HttpServletResponse response) throws Exception { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - Role role = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0))); - logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + role.getId()); - try { - model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions(user.getOrgUserId()))); - model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(user.getOrgUserId(),role.getId()))); - model.put("role", mapper.writeValueAsString(role)); - - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRole failed", e); - } - - } - - /** - * Creates a new role or updates an existing role. - * - * @param request - * @param response - * @return Always returns null. - * @throws IOException - * If the write to the result project fails - */ - @RequestMapping(value = { "/role/saveRole" }, method = RequestMethod.POST) - public ModelAndView saveRole(HttpServletRequest request, HttpServletResponse response) throws IOException { - JSONObject j = null; - User user = UserUtils.getUserSession(request); - logger.debug(EELFLoggerDelegate.debugLogger, "RoleController.save"); - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role role = mapper.readValue(root.get("role").toString(), Role.class); - - List childRoles = mapper.readValue(root.get("childRoles").toString(), - TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class)); - - List roleFunctions = mapper.readValue(root.get("roleFunctions").toString(), - TypeFactory.defaultInstance().constructCollectionType(List.class, RoleFunction.class)); - - Role domainRole = null; - if (role.getId() != null) { - doAuditLog("saveRole: updating existing role {}", role.getId()); - domainRole = roleService.getRole(user.getOrgUserId(),role.getId()); - - domainRole.setName(role.getName()); - domainRole.setPriority(role.getPriority()); - } else { - doAuditLog("saveRole: creating new role", role.getName()); - // check for existing role of same name - List roles = roleService.getAvailableRoles(user.getOrgUserId()); - for (Role existRole : roles) - if (existRole.getName().equalsIgnoreCase(role.getName())) - throw new Exception("role already exists: " + existRole.getName()); - - domainRole = new Role(); - domainRole.setName(role.getName()); - domainRole.setPriority(role.getPriority()); - if(role.getChildRoles() != null && role.getChildRoles().size() > 0 ){ -// if (role.getChildRoles().size() > 0 ) { - for (Object childRole : childRoles) { - domainRole.addChildRole((Role) childRole); - } -// } - } - if(role.getRoleFunctions() != null && role.getRoleFunctions().size() > 0){ -// if (role.getRoleFunctions().size() > 0) { - for (Object roleFunction : roleFunctions) { - domainRole.addRoleFunction((RoleFunction) roleFunction); - } -// } - } - } - - roleService.saveRole(user.getOrgUserId(),domainRole); - - String responseString = mapper.writeValueAsString(domainRole); - j = new JSONObject("{role: " + responseString + "}"); - } catch (Exception e) { - // Produce JSON error message - logger.error(EELFLoggerDelegate.errorLogger, "saveRole failed", e); - j = new JSONObject("{error: '" + e.getMessage() + "'}"); - } - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - return null; - } - - @RequestMapping(value = { "/role/removeRoleFunction" }, method = RequestMethod.POST) - public ModelAndView removeRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeRoleFunction"); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - RoleFunction roleFunction = mapper.readValue(root.get("roleFunction").toString(), RoleFunction.class); - - Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0))); - doAuditLog("Remove role function {} from role {}", roleFunction.getCode(), - ServletRequestUtils.getIntParameter(request, "role_id", 0)); - - domainRole.removeRoleFunction(roleFunction.getCode()); - - roleService.saveRole(user.getOrgUserId(),domainRole); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - String responseString = mapper.writeValueAsString(domainRole); - JSONObject j = new JSONObject("{role: " + responseString + "}"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeRole failed", e); - response.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = { "/role/addRoleFunction" }, method = RequestMethod.POST) - public ModelAndView addRoleFunction(HttpServletRequest request, HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeRoleFunction"); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - RoleFunction roleFunction = mapper.readValue(root.get("roleFunction").toString(), RoleFunction.class); - - Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0))); - - domainRole.addRoleFunction(roleFunction); - - roleService.saveRole(user.getOrgUserId(),domainRole); - doAuditLog("Add role function {} to role {}", roleFunction.getCode(), - ServletRequestUtils.getIntParameter(request, "role_id", 0)); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - String responseString = mapper.writeValueAsString(domainRole); - JSONObject j = new JSONObject("{role: " + responseString + "}"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeRoleFunction failed", e); - response.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = { "/role/removeChildRole" }, method = RequestMethod.POST) - public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.removeChileRole"); - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role childRole = mapper.readValue(root.get("childRole").toString(), Role.class); - - Role domainRole = roleService.getRole(user.getOrgUserId(),new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0))); - - domainRole.removeChildRole(childRole.getId()); - doAuditLog("remove child role {} from role {}", childRole.getId(), - ServletRequestUtils.getIntParameter(request, "role_id", 0)); - - roleService.saveRole(user.getOrgUserId(),domainRole); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - String responseString = mapper.writeValueAsString(domainRole); - JSONObject j = new JSONObject("{role: " + responseString + "}"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeChildRole failed", e); - response.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = { "/role/addChildRole" }, method = RequestMethod.POST) - public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - logger.info(EELFLoggerDelegate.applicationLogger, "RoleController.addChileRole"); - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role childRole = mapper.readValue(root.get("childRole").toString(), Role.class); - long role_id = new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)); - - Role domainRole = roleService.getRole(user.getOrgUserId(),role_id ); - - domainRole.addChildRole(childRole); - - roleService.saveRole(user.getOrgUserId(),domainRole); - doAuditLog("Add child role {} to role {}", childRole.getId(), - ServletRequestUtils.getIntParameter(request, "role_id", 0)); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json"); - String responseString = mapper.writeValueAsString(domainRole); - JSONObject j = new JSONObject("{role: " + responseString + "}"); - PrintWriter out = response.getWriter(); - out.write(j.toString()); - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "addChildRole failed", e); - response.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - /** - * Sets context with begin and end timestamps at current date & time, writes - * the specified message and parameters to the audit log, then removes the - * timestamps from context. - * - * @param message - * @param parameters - */ - private void doAuditLog(String message, Object... parameters) { - final String currentDateTime = EELFLoggerAdvice.getCurrentDateTimeUTC(); - // Set the MDC with audit properties - MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, currentDateTime); - MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, currentDateTime); - logger.info(EELFLoggerDelegate.auditLogger, message, parameters); - MDC.remove(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP); - MDC.remove(SystemProperties.AUDITLOG_END_TIMESTAMP); - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java deleted file mode 100644 index 0b8fb8c8..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.RoleFunction; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class RoleFunctionListController extends RestrictedBaseController { - - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleFunctionListController.class); - - @Autowired - RoleService service; - - private String viewName; - - @RequestMapping(value = {"/role_function_list" }, method = RequestMethod.GET) - public ModelAndView welcome(HttpServletRequest request) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - - try { - model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions(user.getOrgUserId()))); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "welcome failed", e); - } - - return new ModelAndView(getViewName(),model); - } - - @RequestMapping(value = {"/get_role_functions" }, method = RequestMethod.GET) - public void getRoleFunctionList(HttpServletRequest request,HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - try { - model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions(user.getOrgUserId()))); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getROleFunctionList failed", e); - } - - } - - @RequestMapping(value = {"/role_function_list/saveRoleFunction" }, method = RequestMethod.POST) - public void saveRoleFunction(HttpServletRequest request, - HttpServletResponse response, @RequestBody String roleFunc) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - String restCallStatus = ""; - try { - String data = roleFunc; - RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class); - String code = availableRoleFunction.getCode(); - RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),code); - domainRoleFunction.setName(availableRoleFunction.getName()); - domainRoleFunction.setCode(code); - restCallStatus="success"; - service.saveRoleFunction(user.getOrgUserId(),domainRoleFunction); - } catch (Exception e) { - restCallStatus="fail"; - logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e); - throw new Exception("failed while Saving RoleFunction"); - } - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } - - @RequestMapping(value = {"/role_function_list/addRoleFunction" }, method = RequestMethod.POST) - public void addRoleFunction(HttpServletRequest request, - HttpServletResponse response, @RequestBody String roleFunc) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - String restCallStatus = ""; - boolean canSave=true; - try { - String data = roleFunc; - RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class); - String code = availableRoleFunction.getCode(); - List currentRoleFunction = service.getRoleFunctions(user.getOrgUserId()); - restCallStatus="success"; - for(RoleFunction roleF:currentRoleFunction){ - if(roleF.getCode().equals(code)){ - restCallStatus="code exists"; - canSave=false; - break; - } - } - if(canSave) - service.saveRoleFunction(user.getOrgUserId(),availableRoleFunction); - } catch (Exception e) { - restCallStatus="fail"; - logger.error(EELFLoggerDelegate.errorLogger, "addRoleFunction failed", e); - throw new Exception(e.getMessage()); - } - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } - - @RequestMapping(value = {"/role_function_list/removeRoleFunction" }, method = RequestMethod.POST) - public void removeRoleFunction(HttpServletRequest request, - HttpServletResponse response, @RequestBody String roleFunc) throws Exception { - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - String restCallStatus = ""; - try { - String data = roleFunc; - - RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class); - - RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(),availableRoleFunction.getCode()); - - service.deleteRoleFunction(user.getOrgUserId(),domainRoleFunction); - logger.info(EELFLoggerDelegate.auditLogger, "Remove role function " + domainRoleFunction.getName()); - restCallStatus="success"; - } catch (Exception e) { - restCallStatus="fail"; - logger.error(EELFLoggerDelegate.errorLogger, "removeRoleFunction failed", e); - throw new Exception(e.getMessage()); - } - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(restCallStatus)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } - - public String getViewName() { - return viewName; - } - public void setViewName(String viewName) { - this.viewName = viewName; - } - - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java deleted file mode 100644 index 9ccff764..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java +++ /dev/null @@ -1,180 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class RoleListController extends RestrictedBaseController { - - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleListController.class); - @Autowired - RoleService service; - - private String viewName; - - @RequestMapping(value = {"/role_list" }, method = RequestMethod.GET) - public ModelAndView getRoleList(HttpServletRequest request) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - - try { - model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId()))); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRoleList failed", e); - } - - return new ModelAndView(getViewName(),model); - } - - @RequestMapping(value = {"/get_roles" }, method = RequestMethod.GET) - public void getRoles(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - - try { - model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId()))); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRoles failed", e); - } - } - - - @RequestMapping(value = {"/role_list/toggleRole" }, method = RequestMethod.POST) - public ModelAndView toggleRole(HttpServletRequest request, - HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - - - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role role = mapper.readValue(root.get("role").toString(), Role.class); - - Role domainRole = service.getRole(user.getOrgUserId(),role.getId()); - //role. toggle active ind - boolean active = domainRole.getActive(); - domainRole.setActive(!active); - - service.saveRole(user.getOrgUserId(),domainRole); - logger.info(EELFLoggerDelegate.auditLogger, "Toggle active status for role " + domainRole.getId()); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId())); - JSONObject j = new JSONObject("{availableRoles: "+responseString+"}"); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "toggleRole failed", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = {"/role_list/removeRole" }, method = RequestMethod.POST) - public ModelAndView removeRole(HttpServletRequest request, - HttpServletResponse response) throws Exception { - User user = UserUtils.getUserSession(request); - - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - Role role = mapper.readValue(root.get("role").toString(), Role.class); - - Role domainRole = service.getRole(user.getOrgUserId(),role.getId()); - - service.deleteDependcyRoleRecord(user.getOrgUserId(),role.getId()); - service.deleteRole(user.getOrgUserId(),domainRole); - logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + domainRole.getId()); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - - String responseString = mapper.writeValueAsString(service.getAvailableRoles(user.getOrgUserId())); - JSONObject j = new JSONObject("{availableRoles: "+responseString+"}"); - out.write(j.toString()); - - return null; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeRole failed", e); - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - public String getViewName() { - return viewName; - } - public void setViewName(String viewName) { - this.viewName = viewName; - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java deleted file mode 100644 index 10d2b95a..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalsdk.core.auth.LoginStrategy; -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; -import org.openecomp.portalsdk.core.service.LoginService; -import org.openecomp.portalsdk.core.service.ProfileService; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class SDKLoginController extends UnRestrictedBaseController { - @Autowired - ProfileService service; - @Autowired - private LoginService loginService; - @Autowired - private LoginStrategy loginStrategy; - - private String viewName; - - @RequestMapping(value = { "/login.htm" }, method = RequestMethod.GET) - public ModelAndView login(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("login", "model", model); - } - - @RequestMapping(value = { "/login_external.htm" }, method = RequestMethod.GET) - public ModelAndView externalLogin(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("login_external", "model", model); - } - - @RequestMapping(value = { "/login_external" }, method = RequestMethod.POST) - public ModelAndView doexternalLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - return loginStrategy.doExternalLogin(request, response); - } - - @RequestMapping(value = { "/doLogin" }, method = RequestMethod.GET) - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - return loginStrategy.doLogin(request, response); - } - - public String getJessionId(HttpServletRequest request) { - return request.getSession().getId(); - } - - protected void initateSessionMgtHandler(HttpServletRequest request) { - String jSessionId = getJessionId(request); - PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request)); - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - - public LoginService getLoginService() { - return loginService; - } - - public void setLoginService(LoginService loginService) { - this.loginService = loginService; - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java deleted file mode 100644 index 766d9eb9..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -import org.openecomp.portalsdk.core.auth.LoginStrategy; -import org.openecomp.portalsdk.core.command.LoginBean; -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.domain.RoleFunction; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.menu.MenuProperties; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; -import org.openecomp.portalsdk.core.service.LoginService; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.util.WebUtils; - -@Controller -@RequestMapping("/") -public class SingleSignOnController extends UnRestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SingleSignOnController.class); - - @Autowired - private LoginService loginService; - - @Autowired - private LoginStrategy loginStrategy; - - private String viewName; - private String welcomeView; - - public String getWelcomeView() { - return welcomeView; - } - - public void setWelcomeView(String welcomeView) { - this.welcomeView = welcomeView; - } - - @Autowired - RoleService roleService; - - /** - * Handles requests directed to the single sign-on page by the session - * timeout interceptor. - * - * @param request - * @return Redirect to an appropriate address - * @throws Exception - */ - @RequestMapping(value = { "/single_signon.htm" }, method = RequestMethod.GET) - public ModelAndView singleSignOnLogin(HttpServletRequest request) throws Exception { - - Map model = new HashMap(); - HashMap additionalParamsMap = new HashMap(); - LoginBean commandBean = new LoginBean(); - - // SessionTimeoutInterceptor sets these parameters - String forwardURL = URLDecoder.decode(request.getParameter("forwardURL"), "UTF-8"); - String redirectToPortal = request.getParameter("redirectToPortal"); - - if (isLoginCookieExist(request) && redirectToPortal == null) { - HttpSession session = null; - session = AppUtils.getSession(request); - User user = UserUtils.getUserSession(request); - if (session == null || user == null) { - - final String authMech = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); - String userId = loginStrategy.getUserId(request); - commandBean.setUserid(userId); - commandBean = getLoginService().findUser(commandBean, - (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), - additionalParamsMap); - List roleFunctionList= roleService.getRoleFunctions(userId); - if (commandBean.getUser() == null) { - String loginErrorMessage = (commandBean.getLoginErrorMessage() != null) - ? commandBean.getLoginErrorMessage() - : SystemProperties.MESSAGE_KEY_LOGIN_ERROR_USER_NOT_FOUND; - model.put(LoginStrategy.ERROR_MESSAGE_KEY, SystemProperties.getProperty(loginErrorMessage)); - final String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL) - + "?noUserError=Yes"; - logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: user is null, redirect URL is {}", - redirectUrl); - return new ModelAndView("redirect:" + redirectUrl); - } else { - // store the user's information in the session - String loginMethod; - if (null == authMech || "".equals(authMech) || "BOTH".equals(authMech)) { - loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP); - } else if ("CSP".equals(authMech)) { - loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP); - } else { - loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_WEB_JUNCTION); - } - UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), - commandBean.getBusinessDirectMenu(), loginMethod, roleFunctionList); - initateSessionMgtHandler(request); - logger.debug(EELFLoggerDelegate.debugLogger, - "singleSignOnLogin: create new user session for expired user {}; user {} exists in the system", - userId, commandBean.getUser().getOrgUserId()); - return new ModelAndView("redirect:" + forwardURL); - } - } // user is null or session is null - else { - // both user and session are non-null. - logger.info(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: redirecting to the forwardURL {}", - forwardURL); - return new ModelAndView("redirect:" + forwardURL); - } - - } else { - /* - * Login cookie not found, or redirect-to-portal parameter was - * found. - * - * Redirect the user to the portal with a suitable return URL. The - * forwardURL parameter that arrives as a parameter is a partial - * (not absolute) request path for a page in the application. The - * challenge here is to compute the correct absolute path for the - * original request so the portal can redirect the user back to the - * right place. If the application sits behind WebJunction, or if - * separate FE-BE hosts are used, then the URL yielded by the - * request has a host name that is not reachable by the user. - */ - String returnToAppUrl = null; - if (SystemProperties.containsProperty(SystemProperties.APP_BASE_URL)) { - // New feature as of 1610, release 3.3.3: - // application can publish a base URL in system.properties - String appUrl = SystemProperties.getProperty(SystemProperties.APP_BASE_URL); - returnToAppUrl = appUrl + (appUrl.endsWith("/") ? "" : "/") + forwardURL; - logger.debug(EELFLoggerDelegate.debugLogger, - "singleSignOnLogin: using app base URL {} and redirectURL {}", appUrl, returnToAppUrl); - } else { - // Be backward compatible with applications that don't need this - // feature. - // This is the controller for the single_signon.htm page, so the - // replace - // should always find the specified token. - returnToAppUrl = ((HttpServletRequest) request).getRequestURL().toString().replace("single_signon.htm", - forwardURL); - logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: computed redirectURL {}", - returnToAppUrl); - } - final String encodedReturnToAppUrl = URLEncoder.encode(returnToAppUrl, "UTF-8"); - // Also send the application's UEB key so Portal can block URL - // reflection attacks. - final String uebAppKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); - final String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL); - final String portalUrl = url.substring(0, url.lastIndexOf('/')) + "/process_csp"; - final String redirectUrl = portalUrl + "?uebAppKey=" + uebAppKey + "&redirectUrl=" + encodedReturnToAppUrl; - logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: portal-bound redirect URL is {}", - redirectUrl); - return new ModelAndView("redirect:" + redirectUrl); - } - } - - protected void initateSessionMgtHandler(HttpServletRequest request) { - String portalJSessionId = getPortalJSessionId(request); - String jSessionId = getJessionId(request); - PortalTimeoutHandler.sessionCreated(portalJSessionId, jSessionId, AppUtils.getSession(request)); - } - - public boolean isLoginCookieExist(HttpServletRequest request) { - Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE); - return (ep != null); - } - - public String getPortalJSessionId(HttpServletRequest request) { - Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE); - return ep.getValue(); - } - - public String getJessionId(HttpServletRequest request) { - return request.getSession().getId(); - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - - public LoginService getLoginService() { - return loginService; - } - - public void setLoginService(LoginService loginService) { - this.loginService = loginService; - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java deleted file mode 100644 index d7dfbaa5..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.portalsdk.core.command.UserRowBean; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.UsageUtils; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class UsageListController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UsageListController.class); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @RequestMapping(value = { "/usage_list" }, method = RequestMethod.GET) - public ModelAndView usageList(HttpServletRequest request) { - Map model = new HashMap(); - - HttpSession httpSession = request.getSession(); - HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute("activeUsers"); - if (activeUsers.size() == 0) { - activeUsers.put(httpSession.getId(), httpSession); - httpSession.getServletContext().setAttribute("activeUsers", activeUsers); - } - ArrayList rows = UsageUtils.getActiveUsers(activeUsers); - JSONArray ja = new JSONArray(); - try { - for (UserRowBean userRowBean : rows) { - JSONObject jo = new JSONObject(); - jo.put("id", userRowBean.getId()); - jo.put("lastName", userRowBean.getLastName()); - jo.put("email", userRowBean.getEmail()); - jo.put("lastAccess", userRowBean.getLastAccess()); - jo.put("remaining", userRowBean.getRemaining()); - jo.put("sessionId", userRowBean.getSessionId()); - if (!(httpSession.getId().equals(userRowBean.getSessionId()))) { - jo.put("delete", "yes"); - } else { - jo.put("delete", "no"); - } - ja.put(jo); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "usageList failed", e); - } - - model.put("model", ja); - - return new ModelAndView(getViewName(), model); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @RequestMapping(value = { "/get_usage_list" }, method = RequestMethod.GET) - public void getUsageList(HttpServletRequest request, HttpServletResponse response) { - - HttpSession httpSession = request.getSession(); - HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute("activeUsers"); - if (activeUsers.size() == 0) { - activeUsers.put(httpSession.getId(), httpSession); - httpSession.getServletContext().setAttribute("activeUsers", activeUsers); - } - ArrayList rows = UsageUtils.getActiveUsers(activeUsers); - JSONArray ja = new JSONArray(); - try { - for (UserRowBean userRowBean : rows) { - JSONObject jo = new JSONObject(); - jo.put("id", userRowBean.getId()); - jo.put("lastName", userRowBean.getLastName()); - jo.put("email", userRowBean.getEmail()); - jo.put("lastAccess", userRowBean.getLastAccess()); - jo.put("remaining", userRowBean.getRemaining()); - jo.put("sessionId", userRowBean.getSessionId()); - if (!(httpSession.getId().equals(userRowBean.getSessionId()))) { - jo.put("delete", "yes"); - } else { - jo.put("delete", "no"); - } - ja.put(jo); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUsageList failed", e); - } - JsonMessage msg; - try { - msg = new JsonMessage(ja.toString()); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUsageList failed to serialize", e); - } - - } - - @SuppressWarnings("rawtypes") - @RequestMapping(value = { "/usage_list/removeSession" }, method = RequestMethod.GET) - public void removeSession(HttpServletRequest request, HttpServletResponse response) throws Exception { - HashMap activeUsers = (HashMap) request.getSession().getServletContext().getAttribute("activeUsers"); - UserRowBean data = new UserRowBean(); - data.setSessionId(request.getParameter("deleteSessionId")); - UsageUtils.getActiveUsersAfterDelete(activeUsers, data); - - HttpSession httpSession = request.getSession(); - ArrayList rows = UsageUtils.getActiveUsers(activeUsers); - JSONArray ja = new JSONArray(); - try { - for (UserRowBean userRowBean : rows) { - JSONObject jo = new JSONObject(); - jo.put("id", userRowBean.getId()); - jo.put("lastName", userRowBean.getLastName()); - jo.put("email", userRowBean.getEmail()); - jo.put("lastAccess", userRowBean.getLastAccess()); - jo.put("remaining", userRowBean.getRemaining()); - jo.put("sessionId", userRowBean.getSessionId()); - if (!(httpSession.getId().equals(userRowBean.getSessionId()))) { - jo.put("delete", "yes"); - } else { - jo.put("delete", "no"); - } - ja.put(jo); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeSession failed", e); - } - - response.setContentType("application/json"); - PrintWriter out = response.getWriter(); - out.write(ja.toString()); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java deleted file mode 100644 index cb67c93d..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.Profile; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.ProfileService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Controller for user profile view. The view is restricted to authenticated - * users. The view name resolves to page user_profile.jsp which uses Angular. - */ - -@Controller -@RequestMapping("/") -public class UserProfileController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserProfileController.class); - - @Autowired - ProfileService service; - - @RequestMapping(value = { "/user_profile" }, method = RequestMethod.GET) - public ModelAndView userProfile(HttpServletRequest request) throws Exception { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - List profileList = service.findAll(); - try { - model.put("customerInfo", mapper.writeValueAsString(profileList)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "userProfile failed", e); - } - - return new ModelAndView("user_profile", "model", model); - } - -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java deleted file mode 100644 index 5ebe907f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.core; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for welcome view. The view is restricted to authenticated users. - * The view name defaults to the request name with no suffix, "welcome", which - * resolves to page welcome.jsp. - */ -@Controller -@RequestMapping("/") -public class WelcomeController extends RestrictedBaseController { - @RequestMapping(value = { "/welcome" }, method = RequestMethod.GET) - public ModelAndView welcome(HttpServletRequest request) { - final String defaultViewName = null; - return new ModelAndView(defaultViewName); - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java deleted file mode 100644 index 0930ab3f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.openecomp.portalapp.controller.core; - -/** - * Provides controllers for EPSDK application core functionality such as logging - * in, managing roles, editing menus, etc. - */ diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java deleted file mode 100644 index efcd4291..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; - -/** - * Controller for a single-page application sample. The view is restricted to - * authenticated users. The named view resolves to page singlePageSample.html, - * which uses Angular. - */ -@Controller -@RequestMapping("/") -public class AngularSinglePageController extends RestrictedBaseController { - - @RequestMapping(value = { "/singlePageSample" }, method = RequestMethod.GET) - public ModelAndView view(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("single_page_sample", "model", model); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java deleted file mode 100644 index 9c04ce89..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.BroadcastMessage; -import org.openecomp.portalsdk.core.service.BroadcastService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class BroadcastController extends RestrictedBaseController { - - @Autowired - private BroadcastService broadcastService; - - @RequestMapping(value = { "/broadcast" }, method = RequestMethod.GET) - public ModelAndView broadcast(HttpServletRequest request) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - - try { - model.put("broadcastMessage", mapper.writeValueAsString(broadcastService.getBroadcastMessage(request))); - model.put("broadcastSites", mapper.writeValueAsString(referenceData(request).get("broadcastSites"))); - } catch (Exception e) { - e.printStackTrace(); - } - return new ModelAndView(getViewName(), model); - } - - @RequestMapping(value = { "/get_broadcast" }, method = RequestMethod.GET) - public void getBroadcast(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - - try { - - model.put("broadcastMessage", mapper.writeValueAsString(broadcastService.getBroadcastMessage(request))); - model.put("broadcastSites", mapper.writeValueAsString(referenceData(request).get("broadcastSites"))); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected Map referenceData(HttpServletRequest request) { - Map lookupData = new HashMap(); - - if ("true".equals(SystemProperties.getProperty(SystemProperties.CLUSTERED))) { - lookupData.put("broadcastSites", AppUtils.getLookupList("fn_lu_broadcast_site", "broadcast_site_cd", - "broadcast_site_descr", "", "broadcast_site_descr")); - } - - return lookupData; - } - - @RequestMapping(value = { "/broadcast/save" }, method = RequestMethod.POST) - public ModelAndView save(HttpServletRequest request, HttpServletResponse response) throws Exception { - - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - BroadcastMessage broadcastMessage = mapper.readValue(root.get("broadcastMessage").toString(), - BroadcastMessage.class); - - broadcastService.saveBroadcastMessage(broadcastMessage); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(broadcastMessage); - JSONObject j = new JSONObject("{broadcastMessage: " + responseString + "}"); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java deleted file mode 100644 index 41603460..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.BroadcastMessage; -import org.openecomp.portalsdk.core.service.BroadcastService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class BroadcastListController extends RestrictedBaseController { - - @Autowired - private BroadcastService broadcastService; - - @RequestMapping(value = { "/broadcast_list" }, method = RequestMethod.GET) - public ModelAndView broadcastList(HttpServletRequest request) { - Map model = new HashMap(); - - model.put("model", broadcastService.getBcModel(request)); - return new ModelAndView(getViewName(), model); - } - - @RequestMapping(value = { "/get_broadcast_list" }, method = RequestMethod.GET) - public void getBroadcast(HttpServletRequest request, HttpServletResponse response) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - try { - model.put("model", broadcastService.getBcModel(request)); - model.put("messagesList", broadcastService.getBcModel(request).get("messagesList")); - model.put("messageLocations", broadcastService.getBcModel(request).get("messageLocations")); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @RequestMapping(value = { "/broadcast_list/remove" }, method = RequestMethod.POST) - public ModelAndView remove(HttpServletRequest request, HttpServletResponse response) throws Exception { - - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - BroadcastMessage broadcastMessage = mapper.readValue(root.get("broadcastMessage").toString(), - BroadcastMessage.class); - - broadcastService.removeBroadcastMessage(broadcastMessage); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(broadcastMessage); - JSONObject j = new JSONObject("{broadcastMessage: " + responseString + "}"); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } - - @RequestMapping(value = { "/broadcast_list/toggleActive" }, method = RequestMethod.POST) - public ModelAndView toggleActive(HttpServletRequest request, HttpServletResponse response) throws Exception { - - try { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - BroadcastMessage broadcastMessage = mapper.readValue(root.get("broadcastMessage").toString(), - BroadcastMessage.class); - - broadcastService.saveBroadcastMessage(broadcastMessage); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - String responseString = mapper.writeValueAsString(broadcastMessage); - JSONObject j = new JSONObject("{broadcastMessage: " + responseString + "}"); - - out.write(j.toString()); - - return null; - } catch (Exception e) { - response.setCharacterEncoding("UTF-8"); - request.setCharacterEncoding("UTF-8"); - PrintWriter out = response.getWriter(); - out.write(e.getMessage()); - return null; - } - - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java deleted file mode 100644 index b25cbef4..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - - -/** - * Controller for a message sequence chart view. The view is restricted to - * authenticated users. The view name defaults to the request name with no - * suffix, "callflow", which resolves to page details.jsp. That page is an - * iframe around page details.html. - */ -@Controller -@RequestMapping("/") -public class CallflowController extends RestrictedBaseController { - - @RequestMapping(value = { "/callflow" }, method = RequestMethod.GET) - public ModelAndView plot() { - final String defaultViewName = null; - return new ModelAndView(defaultViewName); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java deleted file mode 100644 index e5cfb3f2..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - - - -/** - * @author chris zeng - * - */ - -@Controller -@RequestMapping("/") -public class CamundaCockpitController extends RestrictedBaseController { - @SuppressWarnings("rawtypes") - @RequestMapping(value = {"/get_camunda_cockpit_link" }, method = RequestMethod.GET, produces = "application/json") - @ResponseBody - public Map getCamundaCockpitLink(HttpServletRequest request,HttpServletResponse response) { - Map map = new HashMap(); - String camundaCockpitUrl = ""; - String camundaCockpitlinkDefined = "false"; - if (SystemProperties.containsProperty("camunda_cockpit_link")){ - camundaCockpitUrl = SystemProperties.getProperty("camunda_cockpit_link"); - camundaCockpitlinkDefined = "true"; - }; - map.put("link_defined", camundaCockpitlinkDefined); - map.put("camunda_cockpit_link", camundaCockpitUrl); - return map; - }; -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java deleted file mode 100644 index 03aaab5f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.UserProfileService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class CollaborateListController extends RestrictedBaseController{ - @Autowired - UserProfileService service; - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CollaborateListController.class); - - @RequestMapping(value = {"/collaborate_list" }, method = RequestMethod.GET) - public ModelAndView ProfileSearch(HttpServletRequest request) { - Map model = new HashMap(); - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - List profileList =null; - try { - profileList = service.findAllUserWithOnOffline(user.getOrgUserId()); - model.put("profileList", mapper.writeValueAsString(profileList)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Error happened during collaborate list search" + e.getMessage()); - - } - return new ModelAndView(getViewName(),"model", model); - } - - @RequestMapping(value = {"/get_collaborate_list" }, method = RequestMethod.GET) - public void getCollaborateList(HttpServletRequest request,HttpServletResponse response) { - - ObjectMapper mapper = new ObjectMapper(); - User user = UserUtils.getUserSession(request); - - List profileList =null; - try { - profileList = service.findAllUserWithOnOffline(user.getOrgUserId()); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(profileList)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Error happened during get collaborate list" + e.getMessage()); - - } - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java deleted file mode 100644 index 55920bb8..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class CollaborationController extends RestrictedBaseController{ - - @RequestMapping(value = {"/collaboration" }, method = RequestMethod.GET) - public ModelAndView view(HttpServletRequest request) { - Map model = new HashMap(); - User user = UserUtils.getUserSession(request); - - model.put("name",(user.getFirstName() + " " + (user.getLastName() != null? user.getLastName().substring(0,1): "" ))); - return new ModelAndView(getViewName(),"model", model); - } - @RequestMapping(value = {"/openCollaboration" }, method = RequestMethod.GET) - public ModelAndView openCollaboration(HttpServletRequest request) { - Map model = new HashMap(); - User user = UserUtils.getUserSession(request); - - model.put("name",(user.getFirstName() + " " + (user.getLastName() != null? user.getLastName().substring(0,1): "" ))); - return new ModelAndView("openCollaboration","model", model); - } -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java deleted file mode 100644 index 17f33c77..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.service.ProfileService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - - -/** - * Controller for user profile view. The view is restricted to authenticated - * users. The view name resolves to page user_profile.jsp which uses Angular. - */ - -@Controller -@RequestMapping("/") -public class DS2SampleController extends UnRestrictedBaseController { - - @Autowired - ProfileService service; - - @RequestMapping(value = { "/ds2_sample" }, method = RequestMethod.GET) - public ModelAndView ProfileSearch(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView("ds2_sample", "model", model); - } - -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java deleted file mode 100644 index 69e5051f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.io.IOException; - -import org.json.JSONObject; -import org.openecomp.portalapp.model.Result; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.ModelAndView; - -import io.searchbox.client.JestClient; -import io.searchbox.client.JestClientFactory; -import io.searchbox.client.config.HttpClientConfig; -import io.searchbox.core.Search; -import io.searchbox.core.SearchResult; -import io.searchbox.core.Suggest; -import io.searchbox.core.SuggestResult; -import io.searchbox.params.Parameters; - -/** - * Controller for views that demonstrate Elastic Search features. - */ -@RestController -public class ElasticSearchController extends RestrictedBaseController{ - - @RequestMapping(value = {"/es_search_demo" }, method = RequestMethod.GET) - public ModelAndView search() { - return new ModelAndView("es_search_demo"); - } - - @RequestMapping(value = {"/es_suggest_demo" }, method = RequestMethod.GET) - public ModelAndView suggest() { - return new ModelAndView("es_suggest_demo"); - } - - @RequestMapping(value="/es_suggest/{task}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity doSuggest(@PathVariable("task") String task) throws IOException { - JSONObject obj = new JSONObject(task); - String searchTerm = obj.getString("data"); - String searchSize = obj.getString("size"); - String searchFuzzy = obj.getString("fuzzy"); - String resultName = obj.getString("resultname"); - - JestClientFactory factory = new JestClientFactory(); - factory.setHttpClientConfig(new HttpClientConfig - .Builder("http://todo_elastic_search_server") - .multiThreaded(true) - .build()); - JestClient client = factory.getObject(); - - - Suggest suggest = new Suggest.Builder("{\n" - +"\"" + resultName +"\" : {\n" - +"\"text\" : \""+ searchTerm +"\",\n" - +"\"completion\" : {\n" - +"\"field\" : \"suggest\",\n" - +"\"size\" : " + searchSize + ",\n" - +"\"fuzzy\" : \"" + searchFuzzy + "\"\n" - +"}\n" - +"}\n" - +"}").addIndex("customer").build(); - - SuggestResult result = client.execute(suggest); - System.err.println(result.getJsonObject().toString()); - return new ResponseEntity(new Result(result.getJsonObject().toString()),HttpStatus.OK); - } - - @RequestMapping(value="/es_search/{task}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity doSearch(@PathVariable("task") String task) throws IOException { - JSONObject obj = new JSONObject(task); - String searchTerm = obj.getString("data"); - String searchSize = obj.getString("size"); - // String searchFuzzy = obj.getString("fuzzy"); - - JestClientFactory factory = new JestClientFactory(); - factory.setHttpClientConfig(new HttpClientConfig - .Builder("http://todo_elastic_search_server") - .multiThreaded(true) - .build()); - JestClient client = factory.getObject(); - - Search search = new Search.Builder("{\n" - +"\"query\" : {\n" - +"\"query_string\" : {\n" - +"\"query\" : \"name:"+ searchTerm +"\"\n" - +"}\n" - +"}\n" - +"}").addIndex("customer").setParameter(Parameters.SIZE,Integer.valueOf(searchSize)).build(); - - SearchResult result = client.execute(search); - System.err.println(result.getJsonObject().toString()); - return new ResponseEntity(new Result(result.getJsonObject().toString()),HttpStatus.OK); - } - - public ResponseEntity sendResult(Result result) { - return new ResponseEntity(result, HttpStatus.OK); - } - - @Override - public boolean isRESTfulCall() { - return true; - } -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java deleted file mode 100644 index e36458fd..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.ElementLinkService; -import org.openecomp.portalsdk.core.service.ElementMapService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class ElementModelController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ElementModelController.class); - - @RequestMapping(value = { "/elementMapLayout" }, method = RequestMethod.GET, produces = "text/plain") - public String layout(HttpServletRequest request, HttpServletResponse response) throws Exception { - - String collapseDomains = request.getParameter("collapsedDomains"); - String expandDomains = request.getParameter("expandedDomains"); - - String contentFileName = request.getParameter("contentFileName"); - String layoutFileName = request.getParameter("layoutFileName"); - - final String realPath = request.getServletContext().getRealPath("/"); - logger.debug(EELFLoggerDelegate.debugLogger, "layout: servlet context real path: {}", realPath); - - ElementMapService eltMapSvc = new ElementMapService(); - String yamlString = eltMapSvc.buildElementMapYaml( - new String[] { collapseDomains, expandDomains, realPath, contentFileName, layoutFileName }); - - return yamlString; - } - - @RequestMapping(value = { "/elementMapLink" }, method = RequestMethod.GET, produces = "text/plain") - public String callflow(HttpServletRequest request, HttpServletResponse response) throws Exception { - - String callFlowName = request.getParameter("callFlowName"); - String callFlowStep = request.getParameter("callFlowStep"); - - final String realPath = request.getServletContext().getRealPath("/"); - logger.debug(EELFLoggerDelegate.debugLogger, "callflow: servlet context real path: {}", realPath); - - ElementLinkService eltLinkSvc = new ElementLinkService(); - String yamlString = eltLinkSvc.buildElementLinkYaml(new String[] { realPath, callFlowName, callFlowStep }); - - return yamlString; - } - - /* - public ModelAndView callflowAdditional(HttpServletRequest request, HttpServletResponse response) throws Exception { - - Map model = new HashMap(); - String callFlowName = request.getParameter("callFlowName"); - String callFlowStep = request.getParameter("callFlowStep"); - - ElementLinkService main = new ElementLinkService(); - String yamlString = main.main2(new String[] { callFlowName, callFlowStep }); - model.put("output_string", yamlString); - return new ModelAndView("data_out", "model", model); - } - */ - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java deleted file mode 100644 index bda3c0aa..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for geographic map view. The view is restricted to authenticated - * users. The view name defaults to the request name with no suffix, - * "leafletMap", which resolves to page leafletMap.jsp. - */ -@Controller -@RequestMapping("/") -public class LeafletMapContoller extends RestrictedBaseController { - - @RequestMapping(value = { "/leafletMap" }, method = RequestMethod.GET) - public ModelAndView plot() { - final String defaultViewName = null; - return new ModelAndView(defaultViewName); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java deleted file mode 100644 index 1961edf8..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for a network map view that uses iframes. The view is restricted - * to authenticated users. - */ -@Controller -@RequestMapping("/") -public class NetMapController extends RestrictedBaseController { - - @RequestMapping(value = { "/net_map" }, method = RequestMethod.GET) - public ModelAndView plot(HttpServletRequest request) { - Map model = new HashMap(); - model.put("frame_int", "net_map_int"); - // This view resolves to page frame_insert.jsp - return new ModelAndView("frame_insert", model); - } - - @RequestMapping(value = { "/net_map_int" }, method = RequestMethod.GET) - public ModelAndView plot2() { - // The view name defaults to the request without any suffix. - final String defaultViewName = null; - // This view resolves to page net_map.jsp - return new ModelAndView(defaultViewName); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java deleted file mode 100644 index 5a0719ee..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.io.PrintWriter; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalsdk.core.command.PostDroolsBean; -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.PostDroolsService; -import org.openecomp.portalsdk.core.web.support.JsonMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class PostDroolsController extends RestrictedBaseController { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PostDroolsController.class); - - @Autowired - private PostDroolsService postDroolsService; - - @RequestMapping(value = { "/drools" }, method = RequestMethod.GET) - public ModelAndView drools(HttpServletRequest request) { - return new ModelAndView(getViewName()); - } - - @RequestMapping(value = { "/getDrools" }, method = RequestMethod.GET) - public void getDrools(HttpServletRequest request, HttpServletResponse response) { - // Map model = new HashMap(); - - ObjectMapper mapper = new ObjectMapper(); - try { - List beanList = postDroolsService.fetchDroolBeans(); - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(beanList)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getDrools failed", e); - } - } - - @RequestMapping(value = { "/getDroolDetails" }, method = RequestMethod.GET) - public void getDroolDetails(HttpServletRequest request, HttpServletResponse response) { - - ObjectMapper mapper = new ObjectMapper(); - try { - - PostDroolsBean postDroolsBean = new PostDroolsBean(); - String selectedFile = request.getParameter("selectedFile"); - postDroolsBean.setDroolsFile(selectedFile);// sample populated - // postDroolsBean.setSelectedRules("[\"NJ\",\"NY\",\"KY\"]"); - postDroolsBean.setClassName(postDroolsService.retrieveClass(selectedFile)); - - JsonMessage msg = new JsonMessage(mapper.writeValueAsString(postDroolsBean)); - JSONObject j = new JSONObject(msg); - response.getWriter().write(j.toString()); - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getDroolDetails failed", e); - } - } - - @RequestMapping(value = { "/post_drools/execute" }, method = RequestMethod.POST) - public ModelAndView search(HttpServletRequest request, HttpServletResponse response) throws Exception { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - PostDroolsBean postDroolsBean = mapper.readValue(root.get("postDroolsBean").toString(), - PostDroolsBean.class); - - String resultsString = postDroolsService.execute(postDroolsBean.getDroolsFile(), - postDroolsBean.getClassName(), postDroolsBean.getSelectedRules()); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); - - PrintWriter out = response.getWriter(); - // String responseString = mapper.writeValueAsString(resultsString); - JSONObject j = new JSONObject("{resultsString: " + resultsString + "}"); - - out.write(j.toString()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "search failed", e); - } - - return null; - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java deleted file mode 100644 index 9cc44c86..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Report dashboard - * - */ - -@Controller -@RequestMapping("/") -public class ReportDashboardController extends RestrictedBaseController { - @RequestMapping(value = {"/report_dashboard" }, method = RequestMethod.GET) - public ModelAndView adminView(HttpServletRequest request) { - Map model = new HashMap(); - return new ModelAndView(getViewName(),"model", model); - } -} \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java deleted file mode 100644 index e01bb8c3..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.controller.sample; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.controller.RestrictedBaseController; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -/** - * Controller for a network map view that uses iframes. The view is restricted - * to authenticated users. - */ -@Controller -@RequestMapping("/") -public class SamplePageController extends RestrictedBaseController { - - @RequestMapping(value = { "/samplePage" }, method = RequestMethod.GET) - public ModelAndView plot(HttpServletRequest request) { - Map model = new HashMap(); - /*model.put("frame_int", "net_map_int"); - // This view resolves to page frame_insert.jsp - return new ModelAndView("frame_insert", model);*/ - return new ModelAndView("samplePage", "model", model); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java deleted file mode 100644 index 8c04d60f..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.openecomp.portalapp.controller.sample; - -/** - * Provides controllers for EPSDK application sample pages such as call flow etc. - */ diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java deleted file mode 100644 index ba07bd32..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.model; - -public class Result { - private String result; - - public Result(String result) { - this.result = result; - } - - public String getResult() { - return result; - } - - public void setResult(String result) { - this.result = result; - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java deleted file mode 100644 index f6206187..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.scheduler; - -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.quartz.DisallowConcurrentExecution; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.PersistJobDataAfterExecution; -import org.springframework.scheduling.quartz.QuartzJobBean; - -@PersistJobDataAfterExecution -@DisallowConcurrentExecution -public class LogJob extends QuartzJobBean { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LogJob.class); - - @Override - protected void executeInternal(JobExecutionContext ctx) - throws JobExecutionException { - // JobDataMap dataMap = ctx.getJobDetail().getJobDataMap(); - //int cnt = dataMap.getInt(""); - // JobKey jobKey = ctx.getJobDetail().getKey(); - logger.info(EELFLoggerDelegate.debugLogger, (Runtime.getRuntime().maxMemory() + " " + Runtime.getRuntime().maxMemory())); - - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java deleted file mode 100644 index bffc3d00..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.scheduler; - -import java.text.ParseException; -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.portalsdk.core.scheduler.CronRegistry; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.context.annotation.DependsOn; -import org.springframework.scheduling.quartz.CronTriggerFactoryBean; -import org.springframework.scheduling.quartz.JobDetailFactoryBean; -import org.springframework.stereotype.Component; - -@Component -@DependsOn({ "systemProperties" }) -public class LogRegistry extends CronRegistry { - - private static final String groupName = "AppGroup"; - private static final String jobName = "LogJob"; - private static final String triggerName = "LogTrigger"; - - // @Autowired - // private SystemProperties systemProperties; - - // @Bean - public JobDetailFactoryBean jobDetailFactoryBean() { - Map map = new HashMap(); - map.put("units", "bytes"); - return jobDetailFactoryBean(groupName, jobName, LogJob.class, map); - } - - // @Bean - public CronTriggerFactoryBean cronTriggerFactoryBean() throws ParseException { - // "0 * * * * ? * - return cronTriggerFactoryBean(groupName, triggerName, SystemProperties.getProperty(SystemProperties.LOG_CRON)); - } - -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java deleted file mode 100644 index c670c2ba..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ - -package org.openecomp.portalapp.service; - -import java.util.Set; - -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.User; - -/** - * Defines methods that can be used to extend the features of the user/role - * provisioning class supplied in EPSDK-Common. - */ -public interface IAdminAuthExtension { - - /** - * Invoked from OnBoardingApiServiceImpl#pushUser after user was saved. App - * developers can provide a class with their own logic following this - * action; for example, updating app's related tables - * - * @param user - * User object sent by Portal - */ - public void saveUserExtension(User user); - - /** - * Invoked from OnBoardingApiServiceImpl#editUser after user was updated. - * App developers can provide a class with their own logic following this - * action; for example, updating app's related tables - * - * @param user - * User object sent by Portal - */ - public void editUserExtension(User user); - - /** - * Invoked from OnBoardingApiServiceImpl#pushUserRole after user's roles - * were updated. App developers can provide a class with their own logic - * following this action; for example, updating app's related tables - * - * @param roles - * Roles object sent by Portal - * @param user - * User object sent by Portal - */ - public void saveUserRoleExtension(Set roles, User user); -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java deleted file mode 100644 index 7303cfc4..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java +++ /dev/null @@ -1,361 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.service; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.core.auth.LoginStrategy; -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.domain.UserApp; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.client.AppContextManager; -import org.openecomp.portalsdk.core.onboarding.crossapi.IPortalRestAPIService; -import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; -import org.openecomp.portalsdk.core.restful.domain.EcompRole; -import org.openecomp.portalsdk.core.restful.domain.EcompUser; -import org.openecomp.portalsdk.core.service.RoleService; -import org.openecomp.portalsdk.core.service.UserProfileService; -import org.openecomp.portalsdk.core.service.WebServiceCallService; -import org.openecomp.portalsdk.core.util.JSONUtil; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.UserUtils; -import org.slf4j.MDC; -import org.springframework.context.ApplicationContext; - -/** - * Implements the REST API interface to answer requests made by Portal app about - * users and active sessions. - * - * Since an instance of this class will be instantiated by the OnBoarding - * servlet from the ecompFW library, we cannot use Spring injections here. This - * 'injection' is done indirectly using AppContextManager class. - * - * @author Ikram Ikramullah - * - */ -public class OnBoardingApiServiceImpl implements IPortalRestAPIService { - - private RoleService roleService; - private UserProfileService userProfileService; - private IAdminAuthExtension adminAuthExtensionServiceImpl; - - private LoginStrategy loginStrategy; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OnBoardingApiServiceImpl.class); - - public OnBoardingApiServiceImpl() { - // Defend against null-pointer exception during server startup - // that was caused by a spurious Spring annotation on this class. - ApplicationContext appContext = AppContextManager.getAppContext(); - if (appContext == null) - throw new RuntimeException("OnBoardingApiServiceImpl ctor failed to get appContext"); - roleService = appContext.getBean(RoleService.class); - userProfileService = appContext.getBean(UserProfileService.class); - loginStrategy = appContext.getBean(LoginStrategy.class); - // initialize the base class definition for Admin Auth Extension - adminAuthExtensionServiceImpl = appContext.getBean(IAdminAuthExtension.class); - } - - private void setCurrentAttributes(User user, EcompUser userJson) { - - user.setEmail(userJson.getEmail()); - user.setFirstName(userJson.getFirstName()); - user.setHrid(userJson.getHrid()); - user.setJobTitle(userJson.getJobTitle()); - user.setLastName(userJson.getLastName()); - user.setLoginId(userJson.getLoginId()); - user.setOrgManagerUserId(userJson.getOrgManagerUserId()); - user.setMiddleInitial(userJson.getMiddleInitial()); - user.setOrgCode(userJson.getOrgCode()); - user.setOrgId(userJson.getOrgId()); - user.setPhone(userJson.getPhone()); - user.setOrgUserId(userJson.getOrgUserId()); - user.setActive(userJson.isActive()); - // user.setRoles(new TreeSet(userJson.getRoles())); - } - - @Override - public void pushUser(EcompUser userJson) throws PortalAPIException { - - if (logger.isDebugEnabled()) - logger.debug(EELFLoggerDelegate.debugLogger, "pushUser was invoked: {}", userJson); - User user = new User(); - String response = ""; - try { - // Set input attributes to the object obout to be saved - setCurrentAttributes(user, userJson); - user.setRoles(new TreeSet()); - user.setUserApps(new TreeSet()); - user.setPseudoRoles(new TreeSet()); - userProfileService.saveUser(user); - logger.debug(EELFLoggerDelegate.debugLogger, "push user success."); - - // After successful creation, call admin auth extension - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.saveUserExtension(user); - } catch (Exception ex) { - logger.error("pushUser: saveUserExtension failed", ex); - } - } - - response = "push user success."; - response = JSONUtil.convertResponseToJSON(response); - } catch (Exception e) { - response = "OnboardingApiService.pushUser failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } finally { - MDC.remove(SystemProperties.MDC_TIMER); - } - } - - @Override - public void editUser(String loginId, EcompUser userJson) throws PortalAPIException { - - if (logger.isDebugEnabled()) - logger.debug(EELFLoggerDelegate.debugLogger, "OnboardingApi editUser was invoked with loginID {}, JSON {}", - loginId, userJson); - User editUser = new User(); - String response = ""; - try { - setCurrentAttributes(editUser, userJson); - if (editUser.getOrgUserId() != null) { - editUser.setLoginId(editUser.getOrgUserId()); - } - User domainUser = userProfileService.getUserByLoginId(loginId); - if (domainUser != null) - domainUser = JSONUtil.mapToDomainUser(domainUser, editUser); - else - domainUser = editUser; - userProfileService.saveUser(domainUser); - logger.debug(EELFLoggerDelegate.debugLogger, "edit user success."); - - // After successful edit, call the admin auth extension - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.editUserExtension(domainUser); - } catch (Exception ex) { - logger.error("editUser: editUserExtension failed", ex); - } - } - - response = "edit user success."; - response = JSONUtil.convertResponseToJSON(response); - } catch (Exception e) { - response = "OnboardingApiService.editUser failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } finally { - MDC.remove(SystemProperties.MDC_TIMER); - } - - // return response; - } - - @Override - public EcompUser getUser(String loginId) throws PortalAPIException { - try { - if (logger.isDebugEnabled()) - logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId); - User user = userProfileService.getUserByLoginId(loginId); - if (user == null) { - logger.info(EELFLoggerDelegate.debugLogger, "User + " + loginId + " doesn't exist"); - return null; - // Unfortunately, Portal is not ready to accept proper error - // response yet .. - // commenting throw clauses until portal is ready - // throw new PortalAPIException("User + " + loginId + " doesn't - // exist"); - } else - return UserUtils.convertToEcompUser(user); - } catch (Exception e) { - String response = "OnboardingApiService.getUser failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - return null; - // Unfortunately, Portal is not ready to accept proper error response - // yet .. commenting throw clauses until portal is ready - // throw new PortalAPIException(response, e); - } - - } - - @Override - public List getUsers() throws PortalAPIException { - try { - List users = userProfileService.findAllActive(); - List ecompUsers = new ArrayList(); - for (User user : users) - ecompUsers.add(UserUtils.convertToEcompUser(user)); - return ecompUsers; - } catch (Exception e) { - String response = "OnboardingApiService.getUsers failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } - } - - @Override - public List getAvailableRoles(String requestedLoginId) throws PortalAPIException { - try { - List roles = roleService.getActiveRoles(requestedLoginId); - List ecompRoles = new ArrayList(); - for (Role role : roles) - ecompRoles.add(UserUtils.convertToEcompRole(role)); - return ecompRoles; - } catch (Exception e) { - String response = "OnboardingApiService.getAvailableRoles failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } - } - - @Override - public void pushUserRole(String loginId, List rolesJson) throws PortalAPIException { - String response = ""; - try { - if (logger.isDebugEnabled()) - logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}, roles Json {}", loginId, - rolesJson); - User user = userProfileService.getUserByLoginId(loginId); - /* - * List ecompRoles = mapper.readValue(rolesJson, - * TypeFactory.defaultInstance().constructCollectionType(List.class, - * EcompRole.class)); - */ - SortedSet roles = new TreeSet(); - for (EcompRole role : rolesJson) { - roles.add(roleService.getRole(loginId,role.getId())); - } - // Replace existing roles with new ones - replaceExistingRoles(roles, user); - - logger.debug(EELFLoggerDelegate.debugLogger, "push user role success."); - - // After successful creation, call admin auth extension - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.saveUserRoleExtension(roles, user); - } catch (Exception ex) { - logger.error("pushUserRole: saveUserRoleExtension failed", ex); - } - } - response = "push user role success."; - response = JSONUtil.convertResponseToJSON(response); - - } catch (Exception e) { - response = "OnboardingApiService.pushUserRole failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } finally { - MDC.remove(SystemProperties.MDC_TIMER); - } - - } - - @Override - public List getUserRoles(String loginId) throws PortalAPIException { - if (logger.isDebugEnabled()) - logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId); - List ecompRoles = new ArrayList(); - try { - User user = userProfileService.getUserByLoginId(loginId); - SortedSet currentRoles = null; - if (user != null) { - currentRoles = user.getRoles(); - if (currentRoles != null) - for (Role role : currentRoles) - ecompRoles.add(UserUtils.convertToEcompRole(role)); - } - return ecompRoles; - } catch (Exception e) { - String response = "OnboardingApiService.getUserRoles failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } - } - - @SuppressWarnings("unchecked") - private void replaceExistingRoles(SortedSet roles, User user) { - // 1. remove existing roles - Set userApps = user.getUserApps(); - Iterator appsItr = userApps.iterator(); - while (appsItr.hasNext()) { - UserApp tempUserApp = appsItr.next(); - boolean roleFound = false; - for (Role role : roles) { - if (tempUserApp.getRole().getId().equals(role.getId())) { - roleFound = true; - break; - } - } - if (!roleFound) - appsItr.remove(); - } - user.setUserApps(userApps); - userProfileService.saveUser(user); - - // 2. add new roles - user.setRoles(roles); - userProfileService.saveUser(user); - } - - @Override - public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException { - WebServiceCallService securityService = AppContextManager.getAppContext().getBean(WebServiceCallService.class); - try { - String appUser = request.getHeader("username"); - String password = request.getHeader("password"); - // System.out.println("username = " + appUser); - // System.out.println("password = " + password); - boolean flag = securityService.verifyRESTCredential(null, appUser, password); - // System.out.println("username = " + appUser); - // System.out.println("password = " + password); - return flag; - - } catch (Exception e) { - String response = "OnboardingApiService.isAppAuthenticated failed"; - logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); - } - } - - public String getSessionTimeOuts() throws Exception { - return PortalTimeoutHandler.gatherSessionExtensions(); - } - - public void updateSessionTimeOuts(String sessionMap) throws Exception { - PortalTimeoutHandler.updateSessionExtensions(sessionMap); - } - - @Override - public String getUserId(HttpServletRequest request) throws PortalAPIException { - return loginStrategy.getUserId(request); - } -} diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java deleted file mode 100644 index 00c1d869..00000000 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ================================================================================ - * ECOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalapp.util; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.spi.FilterReply; - -/** - * Custom Filter class bind with logback.xml - * configuration file to strip out certain log messages - * coming out of special packages or classes. - * - */ -public class CustomLoggingFilter extends Filter { - - /** - * Custom Filter is added to strip out the continuous U-EB logging messages - * But make sure we log the ERROR & WARNING Level messages. - */ - @Override - public FilterReply decide(ILoggingEvent event) { - try { - if ((event.getLevel() != Level.ERROR || event.getLevel() != Level.WARN) && - (event.getThreadName().equalsIgnoreCase("UEBConsumerThread")) && - (event.getLoggerName().contains("org.openecomp.nsa") || event.getLoggerName().contains("org.apache.http")) - ) { - return FilterReply.DENY; - } else { - return FilterReply.NEUTRAL; - } - } catch(Exception e) { - return FilterReply.NEUTRAL; - } - } -} -- cgit 1.2.3-korg