summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src/main/java
diff options
context:
space:
mode:
authorTATTAVARADA <statta@research.att.com>2017-04-27 07:53:18 -0400
committerst782s <statta@research.att.com>2017-04-27 08:31:27 -0400
commit6beb446925c967aca92f5513adf36c5db77c00d6 (patch)
tree9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/epsdk-app-common/src/main/java
parent246b225194e3e8dc1926294de591a94fd9787fa7 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/main/java')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java52
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java51
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java248
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java118
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java223
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java175
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java113
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java111
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java255
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java211
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java352
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java163
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java342
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java172
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java170
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java99
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java223
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java165
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java68
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java43
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java6
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java49
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java131
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java143
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java45
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java60
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java85
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java55
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java54
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java128
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java87
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java43
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java57
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java122
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java46
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java50
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java5
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java37
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java45
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java57
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java65
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java361
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java54
43 files changed, 5139 insertions, 0 deletions
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
new file mode 100644
index 00000000..c0904704
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AdminController.java
@@ -0,0 +1,52 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ return new ModelAndView("admin", "model", model);
+ }
+
+ @RequestMapping(value = { "/admin2" }, method = RequestMethod.GET)
+ public ModelAndView adminView(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..7441106f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/AngularAdminController.java
@@ -0,0 +1,51 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ return new ModelAndView("user_profile_list","model", model);
+ }
+
+ @RequestMapping(value = {"/admin" }, method = RequestMethod.GET)
+ public ModelAndView adminView(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+
+ 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/CacheAdminController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java
new file mode 100644
index 00000000..81d35f3d
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/CacheAdminController.java
@@ -0,0 +1,248 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ 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<CacheRegionInfo> 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
new file mode 100644
index 00000000..023f8d7b
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FavoritesController.java
@@ -0,0 +1,118 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..2c589991
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FnMenuController.java
@@ -0,0 +1,223 @@
+/*-
+ * ================================================================================
+ * 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.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;
+
+ 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(service.getFunctionCDList()));
+ } 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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+ List<MenuData> temp = null;
+ List<List<MenuData>> childItemList = new ArrayList<List<MenuData>>();
+ List<MenuData> 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<MenuData> tempList = new ArrayList<MenuData>();
+ // 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
new file mode 100644
index 00000000..8e17eaae
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/FuncMenuController.java
@@ -0,0 +1,175 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..467bd3c9
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/LogoutController.java
@@ -0,0 +1,113 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..ae212b50
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ManifestController.java
@@ -0,0 +1,111 @@
+/*-
+ * ================================================================================
+ * 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:
+ *
+ * <pre>
+ * {
+ * "key1": "value1",
+ * "key2": "value2"
+ * }
+ * </pre>
+ *
+ * On failure:
+ *
+ * <pre>
+ * { "error": "message" }
+ * </pre>
+ */
+ @RequestMapping(value = { "/manifest" }, method = RequestMethod.GET, produces = "application/json")
+ @ResponseBody
+ public Map<Object, Object> getManifest(HttpServletRequest request) {
+ try {
+ Attributes attributes = getWebappManifest();
+ return attributes;
+ } catch (Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getManifest failed", ex);
+ Map<Object, Object> response = new HashMap<Object, Object>();
+ 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
new file mode 100644
index 00000000..ce5ec975
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/MenuListController.java
@@ -0,0 +1,255 @@
+/*-
+ * ================================================================================
+ * 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<MenuData> menuResult = null;
+ HttpSession session = request.getSession();
+ List<List<MenuData>> childItemList = (List<List<MenuData>>) session
+ .getAttribute(SystemProperties.LEFT_MENU_CHILDREND);
+ List<MenuData> parentList = (List<MenuData>) session.getAttribute(SystemProperties.LEFT_MENU_PARENT);
+ if (parentList == null || childItemList == null || parentList.size() == 0 || childItemList.size() == 0) {
+ childItemList = new ArrayList<List<MenuData>>();
+ parentList = new ArrayList<MenuData>();
+ menuResult = (Set<MenuData>) 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<String, Object> getLeftMenuJSP(HttpServletRequest request) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getLeftMenuJSP begins");
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, Object> model = new HashMap<String, Object>();
+ try {
+ HttpSession session = request.getSession();
+ List<List<MenuData>> childItemList = (List<List<MenuData>>) session
+ .getAttribute(SystemProperties.LEFT_MENU_CHILDREND);
+ List<MenuData> parentList = (List<MenuData>) session.getAttribute(SystemProperties.LEFT_MENU_PARENT);
+ if (parentList == null || childItemList == null) {
+ childItemList = new ArrayList<List<MenuData>>();
+ parentList = new ArrayList<MenuData>();
+ Set<MenuData> menuResult = (Set<MenuData>) 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<SharedContext> sharedContextRes = sharedContextRestClient.getUserContext(contextId);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getUserInfo: Shared Context Response is {}",
+ sharedContextRes);
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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<String, String> map = new HashMap<String, String>();
+ 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
new file mode 100644
index 00000000..2da1e6a6
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/PostSearchController.java
@@ -0,0 +1,211 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ 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<String, Object> model = new HashMap<String, Object>();
+
+ 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() {
+ HashMap existingUsers = new HashMap();
+
+ // get the list of user ids in the system
+ List<Profile> list = profileService.findAll();
+
+ if (list != null) {
+ Iterator<Profile> 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
new file mode 100644
index 00000000..a774274c
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileController.java
@@ -0,0 +1,352 @@
+/*-
+ * ================================================================================
+ * 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 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.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
+ RoleService roleService;
+
+ private String viewName;
+
+ @RequestMapping(value = { "/profile" }, method = RequestMethod.GET)
+ public ModelAndView profile(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ 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) service.getUser(request.getParameter("profile_id"));
+ }
+
+ 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()));
+ 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) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ User profile = null;
+ Long profileId = null;
+
+ profile = UserUtils.getUserSession(request);
+ profileId = profile.getId();
+ profile = (User) service.getUser(profileId.toString());
+
+ 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()));
+ 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) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ User profile = null;
+ Long profileId = null;
+
+ profile = UserUtils.getUserSession(request);
+ profileId = profile.getId();
+ profile = (User) service.getUser(profileId.toString());
+
+ 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()));
+ 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<String, Object> model = new HashMap<String, Object>();
+ 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) service.getUser(request.getParameter("profile_id"));
+ }
+ model.put("stateList", mapper.writeValueAsString(getStates()));
+ model.put("countries", mapper.writeValueAsString(getCountries()));
+ model.put("timeZones", mapper.writeValueAsString(getTimeZones()));
+ model.put("availableRoles", mapper.writeValueAsString(getAvailableRoles()));
+ 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) service.getUser(request.getParameter("profile_id"));
+ // 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);
+
+ // Long profileId = Long.parseLong(request.getParameter("profile_id"));
+
+ User domainUser = (User) service.getUser(request.getParameter("profile_id"));
+
+ domainUser.removeRole(role.getId());
+
+ service.saveUser(domainUser);
+ logger.info(EELFLoggerDelegate.auditLogger, "Remove role " + role.getId() + " from user " + request.getParameter("profile_id"));
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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);
+
+ // Long profileId = Long.parseLong(request.getParameter("profile_id"));
+
+ User domainUser = (User) service.getUser(request.getParameter("profile_id"));
+
+ domainUser.addRole(role);
+
+ service.saveUser(domainUser);
+ logger.info(EELFLoggerDelegate.auditLogger, "Add new role " + role.getName() + " to user " + request.getParameter("profile_id"));
+
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application / json");
+ request.setCharacterEncoding("UTF-8");
+
+ PrintWriter out = response.getWriter();
+
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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() {
+ return roleService.getAvailableRoles();
+ }
+
+} \ 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
new file mode 100644
index 00000000..c5614f80
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/ProfileSearchController.java
@@ -0,0 +1,163 @@
+/*-
+ * ================================================================================
+ * 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.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
+ UserProfileService service;
+
+ @Autowired
+ FnMenuService fnMenuService;
+
+ @RequestMapping(value = { "/profile_search" }, method = RequestMethod.GET)
+ public ModelAndView ProfileSearch(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+ List<User> 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,
+ "error while profile_search process in ProfileSearchController" + e.getMessage());
+ }
+ 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<User> profileList = null;
+ try {
+ profileList = service.findAll();
+ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(profileList));
+ JSONObject j = new JSONObject(msg);
+ response.getWriter().write(j.toString());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.applicationLogger,
+ "error while get_user process in ProfileSearchController" + e.getMessage());
+ }
+ }
+
+ @RequestMapping(value = { "/get_user_pagination" }, method = RequestMethod.GET)
+ public void getUserPagination(HttpServletRequest request, HttpServletResponse response) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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<User> 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.getWriter().write(j.toString());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.applicationLogger,
+ "error while get_user_pagination process in ProfileSearchController" + e.getMessage());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<String, Object> setDashboardData(HttpServletRequest request) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, Object> model = new HashMap<String, Object>();
+ List<List<MenuData>> childItemList = new ArrayList<List<MenuData>>();
+ List<MenuData> parentList = new ArrayList<MenuData>();
+ logger.info(EELFLoggerDelegate.applicationLogger, "Initiating setDashboardData in ProfileSearchController");
+ HttpSession session = request.getSession();
+ try {
+ Set<MenuData> menuResult = (Set<MenuData>) session
+ .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME));
+ fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.applicationLogger,
+ "error while setDashboardData process in ProfileSearchController" + e.getMessage());
+ }
+ 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) service.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,
+ "error while toggleProfileActive process in ProfileSearchController" + e.getMessage());
+ }
+ }
+}
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
new file mode 100644
index 00000000..ca902c49
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleController.java
@@ -0,0 +1,342 @@
+/*-
+ * ================================================================================
+ * 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.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.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 {
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleController.class);
+
+ @Autowired
+ RoleService roleService;
+
+ private String viewName;
+
+ @RequestMapping(value = { "/role" }, method = RequestMethod.GET)
+ public ModelAndView role(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ Role role = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ logger.info("role_id" + role.getId());
+ try {
+ model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions()));
+ model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(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) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ Role role = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+ logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + role.getId());
+ try {
+ model.put("availableRoleFunctions", mapper.writeValueAsString(roleService.getRoleFunctions()));
+ model.put("availableRoles", mapper.writeValueAsString(roleService.getAvailableChildRoles(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;
+ 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<Role> childRoles = mapper.readValue(root.get("childRoles").toString(),
+ TypeFactory.defaultInstance().constructCollectionType(List.class, Role.class));
+
+ List<RoleFunction> 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(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<Role> roles = roleService.getAvailableRoles();
+ 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().size() > 0) {
+ for (Object childRole : childRoles) {
+ domainRole.addChildRole((Role) childRole);
+ }
+ }
+ if (role.getRoleFunctions().size() > 0) {
+ for (Object roleFunction : roleFunctions) {
+ domainRole.addRoleFunction((RoleFunction) roleFunction);
+ }
+ }
+ }
+
+ roleService.saveRole(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 {
+
+ 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(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(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 {
+
+ 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(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+
+ domainRole.addRoleFunction(roleFunction);
+
+ roleService.saveRole(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 {
+
+ 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(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(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 {
+
+ 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);
+
+ Role domainRole = roleService.getRole(new Long(ServletRequestUtils.getIntParameter(request, "role_id", 0)));
+
+ domainRole.addChildRole(childRole);
+
+ roleService.saveRole(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
new file mode 100644
index 00000000..13b3a7c8
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleFunctionListController.java
@@ -0,0 +1,172 @@
+/*-
+ * ================================================================================
+ * 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.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.service.RoleService;
+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.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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions()));
+ } 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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ model.put("availableRoleFunctions", mapper.writeValueAsString(service.getRoleFunctions()));
+ 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();
+ String restCallStatus = "";
+ try {
+ String data = roleFunc;
+ RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
+ String code = availableRoleFunction.getCode();
+ RoleFunction domainRoleFunction = service.getRoleFunction(code);
+ domainRoleFunction.setName(availableRoleFunction.getName());
+ domainRoleFunction.setCode(code);
+ restCallStatus="success";
+ service.saveRoleFunction(domainRoleFunction);
+ } catch (Exception e) {
+ restCallStatus="fail";
+ logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e);
+ }
+ 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();
+ String restCallStatus = "";
+ boolean canSave=true;
+ try {
+ String data = roleFunc;
+ RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
+ String code = availableRoleFunction.getCode();
+ RoleFunction domainRoleFunction = service.getRoleFunction(code);
+ domainRoleFunction.setName(availableRoleFunction.getName());
+ domainRoleFunction.setCode(code);
+ List<RoleFunction> currentRoleFunction = service.getRoleFunctions();
+ restCallStatus="success";
+ for(RoleFunction roleF:currentRoleFunction){
+ if(roleF.getCode().equals(code)){
+ restCallStatus="code exists";
+ canSave=false;
+ break;
+ }
+ }
+ if(canSave)
+ service.saveRoleFunction(domainRoleFunction);
+ } catch (Exception e) {
+ restCallStatus="fail";
+ logger.error(EELFLoggerDelegate.errorLogger, "addRoleFunction failed", e);
+ }
+ 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();
+ String restCallStatus = "";
+ try {
+ String data = roleFunc;
+
+ RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class);
+
+ RoleFunction domainRoleFunction = service.getRoleFunction(availableRoleFunction.getCode());
+
+ service.deleteRoleFunction(domainRoleFunction);
+ logger.info(EELFLoggerDelegate.auditLogger, "Remove role function " + domainRoleFunction.getName());
+ restCallStatus="success";
+ } catch (Exception e) {
+ restCallStatus="fail";
+ logger.error(EELFLoggerDelegate.errorLogger, "removeRoleFunction failed", e);
+ }
+ 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
new file mode 100644
index 00000000..be08d4e9
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/RoleListController.java
@@ -0,0 +1,170 @@
+/*-
+ * ================================================================================
+ * 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.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.service.RoleService;
+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 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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles()));
+ } 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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+
+ try {
+ model.put("availableRoles", mapper.writeValueAsString(service.getAvailableRoles()));
+ 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 {
+
+ 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(role.getId());
+ //role. toggle active ind
+ boolean active = domainRole.getActive();
+ domainRole.setActive(!active);
+
+ service.saveRole(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());
+ 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 {
+
+ 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(role.getId());
+
+ service.deleteDependcyRoleRecord(role.getId());
+ service.deleteRole(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());
+ 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
new file mode 100644
index 00000000..10d2b95a
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SDKLoginController.java
@@ -0,0 +1,99 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ return new ModelAndView("login", "model", model);
+ }
+
+ @RequestMapping(value = { "/login_external.htm" }, method = RequestMethod.GET)
+ public ModelAndView externalLogin(HttpServletRequest request) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..9ffa1d1d
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/SingleSignOnController.java
@@ -0,0 +1,223 @@
+/*-
+ * ================================================================================
+ * 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.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.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.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;
+ }
+
+ /**
+ * 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<String, String> model = new HashMap<String, String>();
+ HashMap<String, String> additionalParamsMap = new HashMap<String, String>();
+ 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);
+ 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);
+ 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
new file mode 100644
index 00000000..d7dfbaa5
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UsageListController.java
@@ -0,0 +1,165 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ 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<UserRowBean> 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<UserRowBean> 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<UserRowBean> 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
new file mode 100644
index 00000000..cee60e48
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/UserProfileController.java
@@ -0,0 +1,68 @@
+/*-
+ * ================================================================================
+ * 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) {
+ Map<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+ List<Profile> 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
new file mode 100644
index 00000000..5ebe907f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/WelcomeController.java
@@ -0,0 +1,43 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..0930ab3f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/core/package-info.java
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 00000000..efcd4291
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/AngularSinglePageController.java
@@ -0,0 +1,49 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..9c04ce89
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastController.java
@@ -0,0 +1,131 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..41603460
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/BroadcastListController.java
@@ -0,0 +1,143 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..b25cbef4
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CallflowController.java
@@ -0,0 +1,45 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..e5cfb3f2
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CamundaCockpitController.java
@@ -0,0 +1,60 @@
+/*-
+ * ================================================================================
+ * 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<String,String> map = new HashMap<String,String>();
+ 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
new file mode 100644
index 00000000..03aaab5f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborateListController.java
@@ -0,0 +1,85 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ ObjectMapper mapper = new ObjectMapper();
+ User user = UserUtils.getUserSession(request);
+
+ List<User> 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<User> 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
new file mode 100644
index 00000000..55920bb8
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/CollaborationController.java
@@ -0,0 +1,55 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..17f33c77
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/DS2SampleController.java
@@ -0,0 +1,54 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..69e5051f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElasticSearchController.java
@@ -0,0 +1,128 @@
+/*-
+ * ================================================================================
+ * 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<Result> 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<Result>(new Result(result.getJsonObject().toString()),HttpStatus.OK);
+ }
+
+ @RequestMapping(value="/es_search/{task}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<Result> 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<Result>(new Result(result.getJsonObject().toString()),HttpStatus.OK);
+ }
+
+ public ResponseEntity<Result> sendResult(Result result) {
+ return new ResponseEntity<Result>(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
new file mode 100644
index 00000000..e36458fd
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ElementModelController.java
@@ -0,0 +1,87 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..bda3c0aa
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/LeafletMapContoller.java
@@ -0,0 +1,43 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..1961edf8
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/NetMapController.java
@@ -0,0 +1,57 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..5a0719ee
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/PostDroolsController.java
@@ -0,0 +1,122 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ List<PostDroolsBean> 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
new file mode 100644
index 00000000..9cc44c86
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/ReportDashboardController.java
@@ -0,0 +1,46 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..e01bb8c3
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/SamplePageController.java
@@ -0,0 +1,50 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> model = new HashMap<String, Object>();
+ /*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
new file mode 100644
index 00000000..8c04d60f
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/controller/sample/package-info.java
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 00000000..ba07bd32
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/model/Result.java
@@ -0,0 +1,37 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..f6206187
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java
@@ -0,0 +1,45 @@
+/*-
+ * ================================================================================
+ * 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
new file mode 100644
index 00000000..bffc3d00
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java
@@ -0,0 +1,57 @@
+/*-
+ * ================================================================================
+ * 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<String, Object> map = new HashMap<String, Object>();
+ 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
new file mode 100644
index 00000000..c670c2ba
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/IAdminAuthExtension.java
@@ -0,0 +1,65 @@
+/*-
+ * ================================================================================
+ * 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<Role> 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
new file mode 100644
index 00000000..cb822494
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/service/OnBoardingApiServiceImpl.java
@@ -0,0 +1,361 @@
+/*-
+ * ================================================================================
+ * 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<Role>());
+ user.setUserApps(new TreeSet<UserApp>());
+ user.setPseudoRoles(new TreeSet<Role>());
+ 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<EcompUser> getUsers() throws PortalAPIException {
+ try {
+ List<User> users = userProfileService.findAllActive();
+ List<EcompUser> ecompUsers = new ArrayList<EcompUser>();
+ 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<EcompRole> getAvailableRoles() throws PortalAPIException {
+ try {
+ List<Role> roles = roleService.getActiveRoles();
+ List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
+ 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<EcompRole> 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<EcompRole> ecompRoles = mapper.readValue(rolesJson,
+ * TypeFactory.defaultInstance().constructCollectionType(List.class,
+ * EcompRole.class));
+ */
+ SortedSet<Role> roles = new TreeSet<Role>();
+ for (EcompRole role : rolesJson) {
+ roles.add(roleService.getRole(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<EcompRole> getUserRoles(String loginId) throws PortalAPIException {
+ if (logger.isDebugEnabled())
+ logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId);
+ List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
+ try {
+ User user = userProfileService.getUserByLoginId(loginId);
+ SortedSet<Role> 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<Role> roles, User user) {
+ // 1. remove existing roles
+ Set<UserApp> userApps = user.getUserApps();
+ Iterator<UserApp> 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
new file mode 100644
index 00000000..00c1d869
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/openecomp/portalapp/util/CustomLoggingFilter.java
@@ -0,0 +1,54 @@
+/*-
+ * ================================================================================
+ * 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<ILoggingEvent> {
+
+ /**
+ * 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;
+ }
+ }
+}