summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Lott (cl778h) <clott@research.att.com>2017-10-04 14:14:36 -0400
committerChristopher Lott (cl778h) <clott@research.att.com>2017-10-04 15:53:41 -0400
commitb6079b39fc1193a32223933f7d93c08a63809689 (patch)
tree679384195495dfa64953d6f6aea253b58bfe78c9
parent88c674e9f243ee7bfacfca847383ea01b482c1c1 (diff)
Repair widget-ms problem; adjust sonar in poms
Using OParent again; override some Sonar configuration and tasks. Repair display & fetch of users from remote apps. Use EPSDK version 1710 database scripts. Issue: PORTAL-50, PORTAL-59, PORTAL-86 Change-Id: I05eaea3680b0422236cc86cdd0ad5847c2731e54 Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
-rw-r--r--deliveries/Dockerfile.mariadb8
-rw-r--r--ecomp-portal-BE-common/pom.xml39
-rw-r--r--ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java16
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java757
-rw-r--r--ecomp-portal-BE-os/README.md2
-rw-r--r--ecomp-portal-BE-os/pom.xml8
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java46
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java303
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java26
-rw-r--r--ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/raptor_pdf.properties4
-rw-r--r--ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html2
-rw-r--r--ecomp-portal-FE-common/client/app/views/users/users.controller.spec.js141
-rw-r--r--ecomp-portal-widget-ms/widget-ms/pom.xml50
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/StorageServiceImpl.java8
-rw-r--r--pom.xml98
15 files changed, 612 insertions, 896 deletions
diff --git a/deliveries/Dockerfile.mariadb b/deliveries/Dockerfile.mariadb
index 5b0abd51..9f8eb868 100644
--- a/deliveries/Dockerfile.mariadb
+++ b/deliveries/Dockerfile.mariadb
@@ -19,10 +19,10 @@ COPY ${PORTAL_SCRIPT_DIR}/EcompPortalDMLMySql_1710_OS.sql /docker-entrypoint
COPY Apps_Users_OnBoarding_Script.sql /docker-entrypoint-initdb.d/EcompPortalDMLMySql_1710_z_apps_users.sql
# SDK App DDL and DML unchanged since 1707
-COPY ${SDK_SCRIPT_DIR}/EcompSdkDDLMySql_1707_Common.sql /docker-entrypoint-initdb.d/
-COPY ${SDK_SCRIPT_DIR}/EcompSdkDDLMySql_1707_OS.sql /docker-entrypoint-initdb.d/
-COPY ${SDK_SCRIPT_DIR}/EcompSdkDMLMySql_1707_Common.sql /docker-entrypoint-initdb.d/
-COPY ${SDK_SCRIPT_DIR}/EcompSdkDMLMySql_1707_OS.sql /docker-entrypoint-initdb.d/
+COPY ${SDK_SCRIPT_DIR}/EcompSdkDDLMySql_1710_Common.sql /docker-entrypoint-initdb.d/
+COPY ${SDK_SCRIPT_DIR}/EcompSdkDDLMySql_1710_OS.sql /docker-entrypoint-initdb.d/
+COPY ${SDK_SCRIPT_DIR}/EcompSdkDMLMySql_1710_Common.sql /docker-entrypoint-initdb.d/
+COPY ${SDK_SCRIPT_DIR}/EcompSdkDMLMySql_1710_OS.sql /docker-entrypoint-initdb.d/
# DBC App combined DDL/DML, built by script
COPY ${DBC_SCRIPT_DIR}/dbca-complete-mysql-1707-os.sql /docker-entrypoint-initdb.d/
diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml
index 894bb7f8..3d1db4db 100644
--- a/ecomp-portal-BE-common/pom.xml
+++ b/ecomp-portal-BE-common/pom.xml
@@ -113,7 +113,6 @@
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>
-
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
@@ -165,7 +164,6 @@
</exclusion>
</exclusions>
</dependency>
-
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
@@ -177,7 +175,6 @@
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
-
<!-- hibernate-core depends on dom4j, which has optional dependencies.
On jenkins, contrary to doc, mvn 3.0.5 packages the optional dependencies
in the war. Workaround: exclude them explicitly. -->
@@ -216,7 +213,6 @@
</exclusion>
</exclusions>
</dependency>
-
<!-- Servlet+JSP+JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
@@ -233,10 +229,6 @@
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
-
- <!-- Oracle JDBC driver -->
- <!-- <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId>
- <version>11.2.0.4</version> </dependency> -->
<!-- Apache Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
@@ -253,7 +245,6 @@
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.0-milestone1</version>
</dependency>
-
<!-- Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -270,13 +261,11 @@
<artifactId>jackson-databind</artifactId>
<version>${fasterxml.version}</version>
</dependency>
-
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
-
<!-- Elastic Search -->
<dependency>
<groupId>org.elasticsearch</groupId>
@@ -288,7 +277,6 @@
<artifactId>jest</artifactId>
<version>2.0.0</version>
</dependency>
-
<dependency>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
@@ -299,16 +287,13 @@
<artifactId>*</artifactId>
</exclusion>
</exclusions>
- <!-- -->
</dependency>
-
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-websocket</artifactId>
<version>8.0.28</version>
<scope>provided</scope>
</dependency>
-
<dependency>
<groupId>concurrent</groupId>
<artifactId>concurrent</artifactId>
@@ -320,8 +305,6 @@
</exclusion>
</exclusions>
</dependency>
-
-
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
@@ -388,7 +371,6 @@
</exclusion>
</exclusions>
</dependency>
-
<!-- for generating PDF -->
<dependency>
<groupId>com.lowagie</groupId>
@@ -408,19 +390,16 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.45</version>
</dependency>
-
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
-
<dependency>
<groupId>com.att.nsa</groupId>
<artifactId>cambriaClient</artifactId>
@@ -444,7 +423,6 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-fw</artifactId>
@@ -489,7 +467,6 @@
<artifactId>epsdk-workflow</artifactId>
<version>${epsdk.version}</version>
</dependency>
-
<!-- Raptor required Libraries -->
<!-- for static charts -->
<dependency>
@@ -497,7 +474,6 @@
<artifactId>epsdk-analytics</artifactId>
<version>${epsdk.version}</version>
</dependency>
-
<!-- Referenced by some poms and needed for testing; do NOT use "test"
scope here. -->
<dependency>
@@ -505,7 +481,6 @@
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
-
<!-- for testing -->
<dependency>
<groupId>junit</groupId>
@@ -533,31 +508,26 @@
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
</dependency>
-
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>
-
<dependency>
<groupId>com.ecwid.consul</groupId>
<artifactId>consul-api</artifactId>
<version>1.2.1</version>
</dependency>
-
<dependency>
<groupId>com.orbitz.consul</groupId>
<artifactId>consul-client</artifactId>
<version>0.13.8</version>
</dependency>
-
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
-
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
@@ -568,9 +538,7 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
-
<!-- Schedulers required Libraries -->
-
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
@@ -591,6 +559,13 @@
<artifactId>jersey-jetty-connector</artifactId>
<version>2.23.1</version>
</dependency>
+ <!-- Jacoco for offline instrumentation -->
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <version>${jacocoVersion}</version>
+ <classifier>runtime</classifier>
+ </dependency>
</dependencies>
<!-- No deployment descriptor. -->
diff --git a/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java b/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java
index 9721a904..4e069214 100644
--- a/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java
+++ b/ecomp-portal-BE-common/src/main/java/jarutil/ExtractJar.java
@@ -64,22 +64,6 @@ public class ExtractJar {
}
}
- public static void readJar(File jarFile) throws Exception {
- JarInputStream in = new JarInputStream(new FileInputStream(jarFile));
- JarEntry je;
- while ((je = in.getNextJarEntry()) != null) {
- if (je.isDirectory() == false) {
- if (je.getName().startsWith("att/raptor/config/")) {
- // while((je=in.getNextJarEntry( ))!=null) {
- System.out.println(je.getName() + " " + je.getTime());
- // }
-
- }
- }
- }
- in.close();
- }
-
public static void extractFilesFromJar(String directory) throws IOException {
// JarFile jar = new JarFile(jarFile);
Class clazz = ExtractJar.class;
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java
index 683bca30..110bf2ec 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java
@@ -38,6 +38,7 @@
package org.openecomp.portalapp.portal.service;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -48,6 +49,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
@@ -86,6 +88,7 @@ import org.openecomp.portalapp.portal.transport.ExternalRoleDescription;
import org.openecomp.portalapp.portal.transport.FieldsValidator;
import org.openecomp.portalapp.portal.transport.FunctionalMenuItem;
import org.openecomp.portalapp.portal.transport.FunctionalMenuRole;
+import org.openecomp.portalapp.portal.transport.RemoteRole;
import org.openecomp.portalapp.portal.transport.RemoteUserWithRoles;
import org.openecomp.portalapp.portal.transport.RoleInAppForUser;
import org.openecomp.portalapp.portal.transport.RolesInAppForUser;
@@ -111,14 +114,14 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@EPMetricsLog
-public class UserRolesCommonServiceImpl {
+public class UserRolesCommonServiceImpl {
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserRolesCommonServiceImpl.class);
private static final Object syncRests = new Object();
-
+
@Autowired
- private DataAccessService dataAccessService;
+ private DataAccessService dataAccessService;
@Autowired
private SessionFactory sessionFactory;
@Autowired
@@ -130,17 +133,17 @@ public class UserRolesCommonServiceImpl {
@Autowired
private EPRoleService epRoleService;
@Autowired
- private RoleService roleService;
-
+ private RoleService roleService;
+
@Autowired
private ExternalAccessRolesService externalAccessRolesService;
-
+
RestTemplate template = new RestTemplate();
-
+
/**
*
* @param ecompRoles
- * @return HashMap<Long, EcompRole>
+ * @return HashMap<Long, EcompRole>
*/
private static HashMap<Long, EcompRole> hashMapFromEcompRoles(EcompRole[] ecompRoles) {
HashMap<Long, EcompRole> result = new HashMap<Long, EcompRole>();
@@ -153,7 +156,7 @@ public class UserRolesCommonServiceImpl {
}
return result;
}
-
+
/**
*
* @param userId
@@ -191,16 +194,19 @@ public class UserRolesCommonServiceImpl {
EcompPortalUtils.closeLocalSession(localSession, "searchOrCreateUser");
}
}
-
+
/**
- * This method return nothing and remove roles before adding any roles for an app
+ * This method return nothing and remove roles before adding any roles for an
+ * app
+ *
* @param userRole
* @param appId
* @param localSession
* @param userAppRoles
* @param newUserAppRolesMap
*/
- private static void syncUserRolesExtension(EPUserApp userRole, Long appId, Session localSession, EcompRole[] userAppRoles, HashMap<Long, EcompRole> newUserAppRolesMap) {
+ private static void syncUserRolesExtension(EPUserApp userRole, Long appId, Session localSession,
+ EcompRole[] userAppRoles, HashMap<Long, EcompRole> newUserAppRolesMap) {
Long userAppRoleId = 0L;
if (appId == PortalConstants.PORTAL_APP_ID) { // local app
@@ -215,32 +221,32 @@ public class UserRolesCommonServiceImpl {
newUserAppRolesMap.remove(userAppRoleId);
}
}
-
+
/**
* Checks whether the role is inactive
- *
+ *
* @param epRole
* @throws Exception
- * if role is inactive, throws exception
+ * if role is inactive, throws exception
*/
- private void checkIfRoleInactive(EPRole epRole) throws Exception{
- if(!epRole.getActive()){
- throw new Exception(epRole.getName()+ " role is unavailable");
+ private void checkIfRoleInactive(EPRole epRole) throws Exception {
+ if (!epRole.getActive()) {
+ throw new Exception(epRole.getName() + " role is unavailable");
}
}
-
+
/**
*
* @param sessionFactory
* @param userId
* @param appId
* @param userAppRoles
- * @param extRequestValue
- * set to false if request is from users page otherwise true
+ * @param extRequestValue
+ * set to false if request is from users page otherwise true
* @throws Exception
*/
- protected void syncUserRoles(SessionFactory sessionFactory, String userId, Long appId,
- EcompRole[] userAppRoles, Boolean extRequestValue, String reqType) throws Exception {
+ protected void syncUserRoles(SessionFactory sessionFactory, String userId, Long appId, EcompRole[] userAppRoles,
+ Boolean extRequestValue, String reqType) throws Exception {
boolean result = false;
Session localSession = null;
Transaction transaction = null;
@@ -261,28 +267,33 @@ public class UserRolesCommonServiceImpl {
@SuppressWarnings("unchecked")
List<EPUserApp> userRoles = localSession.createQuery("from " + EPUserApp.class.getName()
+ " where app.id=" + appId + roleActive + " and userId=" + client.getId()).list();
-
+
if ("DELETE".equals(reqType)) {
for (EPUserApp userAppRoleList : userRoles) {
userAppParams.put("roleName", String.valueOf(userAppRoleList.getRole().getName()));
- userAppParams.put("appId", String.valueOf(appId));
+ userAppParams.put("appId", String.valueOf(appId));
appParams.put("appRoleName", userAppRoleList.getRole().getName());
@SuppressWarnings("unchecked")
- List<EPRole> rolesList = (!userAppRoleList.getRole().getName().equals(PortalConstants.ADMIN_ROLE)) ? (List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", userAppParams, null) : (List<EPRole>) dataAccessService.executeNamedQuery("getPortalAppRoles", appParams, null);
- if(rolesList.size() > 0 || !rolesList.isEmpty()){
- checkIfRoleInactive(rolesList.get(0));
+ List<EPRole> rolesList = (!userAppRoleList.getRole().getName()
+ .equals(PortalConstants.ADMIN_ROLE))
+ ? (List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles",
+ userAppParams, null)
+ : (List<EPRole>) dataAccessService.executeNamedQuery("getPortalAppRoles",
+ appParams, null);
+ if (rolesList.size() > 0 || !rolesList.isEmpty()) {
+ checkIfRoleInactive(rolesList.get(0));
}
}
}
for (EPUserApp userRole : userRoles) {
- if (!userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID) && userRole.getRoleId() != PortalConstants.SYS_ADMIN_ROLE_ID && !extRequestValue){
+ if (!userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)
+ && userRole.getRoleId() != PortalConstants.SYS_ADMIN_ROLE_ID && !extRequestValue) {
syncUserRolesExtension(userRole, appId, localSession, userAppRoles, newUserAppRolesMap);
- }
- else if (extRequestValue && ("PUT".equals(reqType) || "POST".equals(reqType) || "DELETE".equals(reqType))){
+ } else if (extRequestValue
+ && ("PUT".equals(reqType) || "POST".equals(reqType) || "DELETE".equals(reqType))) {
syncUserRolesExtension(userRole, appId, localSession, userAppRoles, newUserAppRolesMap);
- }
- else if (extRequestValue && !userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)){
+ } else if (extRequestValue && !userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)) {
syncUserRolesExtension(userRole, appId, localSession, userAppRoles, newUserAppRolesMap);
}
}
@@ -293,12 +304,13 @@ public class UserRolesCommonServiceImpl {
HashMap<Long, EPRole> rolesMap = new HashMap<Long, EPRole>();
if (appId.equals(PortalConstants.PORTAL_APP_ID)) { // local app
String appIdValue = "";
- if(!extRequestValue){
- appIdValue = "and id != " + PortalConstants.SYS_ADMIN_ROLE_ID;
+ if (!extRequestValue) {
+ appIdValue = "and id != " + PortalConstants.SYS_ADMIN_ROLE_ID;
}
@SuppressWarnings("unchecked")
List<EPRole> roles = localSession
- .createQuery("from " + EPRole.class.getName() + " where appId is null " + appIdValue).list();
+ .createQuery("from " + EPRole.class.getName() + " where appId is null " + appIdValue)
+ .list();
for (EPRole role : roles) {
role.setAppId(1L);
rolesMap.put(role.getId(), role);
@@ -319,15 +331,18 @@ public class UserRolesCommonServiceImpl {
EPRole role = null;
for (EcompRole userRole : newRolesToAdd) {
EPUserApp userApp = new EPUserApp();
- if (("PUT".equals(reqType) || "POST".equals(reqType)) && userRole.getName().equals(PortalConstants.ADMIN_ROLE)) {
- role = (EPRole) localSession.get(EPRole.class, new Long(PortalConstants.ACCOUNT_ADMIN_ROLE_ID));
+ if (("PUT".equals(reqType) || "POST".equals(reqType))
+ && userRole.getName().equals(PortalConstants.ADMIN_ROLE)) {
+ role = (EPRole) localSession.get(EPRole.class,
+ new Long(PortalConstants.ACCOUNT_ADMIN_ROLE_ID));
userApp.setRole(role);
- } else if ((userRole.getId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)) && !extRequestValue){
- continue;
- }else if((userRole.getId().equals(PortalConstants.SYS_ADMIN_ROLE_ID)) && app.getId().equals(PortalConstants.PORTAL_APP_ID) && !extRequestValue){
+ } else if ((userRole.getId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID))
+ && !extRequestValue) {
continue;
- }
- else {
+ } else if ((userRole.getId().equals(PortalConstants.SYS_ADMIN_ROLE_ID))
+ && app.getId().equals(PortalConstants.PORTAL_APP_ID) && !extRequestValue) {
+ continue;
+ } else {
userApp.setRole(rolesMap.get(userRole.getId()));
}
@@ -339,19 +354,17 @@ public class UserRolesCommonServiceImpl {
if (appId == PortalConstants.PORTAL_APP_ID) {
/*
- * for local app -- hack - always make sure fn_role
- * table's app_id is null and not 1 for primary app in
- * this case being ecomp portal app; reason: hibernate
- * is rightly setting this to 1 while persisting to
- * fn_role as per the mapping but SDK role management
- * code expects the app_id to be null as there is no
+ * for local app -- hack - always make sure fn_role table's app_id is null and
+ * not 1 for primary app in this case being ecomp portal app; reason: hibernate
+ * is rightly setting this to 1 while persisting to fn_role as per the mapping
+ * but SDK role management code expects the app_id to be null as there is no
* concept of App_id in SDK
*/
localSession.flush();
SQLQuery sqlQuery = localSession
.createSQLQuery("update fn_role set app_id = null where app_id = 1 ");
sqlQuery.executeUpdate();
-
+
}
}
}
@@ -362,7 +375,7 @@ public class UserRolesCommonServiceImpl {
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
EcompPortalUtils.rollbackTransaction(transaction,
"Exception occurred in syncUserRoles, Details: " + e.toString());
- if("DELETE".equals(reqType)){
+ if ("DELETE".equals(reqType)) {
throw new Exception(e.getMessage());
}
} finally {
@@ -373,13 +386,13 @@ public class UserRolesCommonServiceImpl {
}
}
}
-
+
/**
* Called when getting the list of roles for the user
*
* @param appRoles
* @param userAppRoles
- * @return List<RoleInAppForUser>
+ * @return List<RoleInAppForUser>
*/
protected List<RoleInAppForUser> constructRolesInAppForUserGet(EcompRole[] appRoles, EcompRole[] userAppRoles) {
List<RoleInAppForUser> rolesInAppForUser = new ArrayList<RoleInAppForUser>();
@@ -411,11 +424,12 @@ public class UserRolesCommonServiceImpl {
*
* @param appRoles
* @param userAppRoles
- * @param extRequestValue
- * set to false if request is from users page otherwise true
+ * @param extRequestValue
+ * set to false if request is from users page otherwise true
* @return List<RoleInAppForUser>
*/
- protected List<RoleInAppForUser> constructRolesInAppForUserGet(List<Role> appRoles, EPRole[] userAppRoles, Boolean extRequestValue) {
+ protected List<RoleInAppForUser> constructRolesInAppForUserGet(List<Role> appRoles, EPRole[] userAppRoles,
+ Boolean extRequestValue) {
List<RoleInAppForUser> rolesInAppForUser = new ArrayList<RoleInAppForUser>();
Set<Long> userAppRolesMap = new HashSet<Long>();
@@ -443,7 +457,6 @@ public class UserRolesCommonServiceImpl {
return rolesInAppForUser;
}
-
/**
* copies of methods in GetAppsWithUserRoleState
*
@@ -505,7 +518,8 @@ public class UserRolesCommonServiceImpl {
"from " + EPUserApp.class.getName() + " where app.id=" + appId + " and role_id=" + roleId)
.list();
- logger.debug(EELFLoggerDelegate.debugLogger, "syncAppRoles: number of userRoles to delete: " + userRoles.size());
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "syncAppRoles: number of userRoles to delete: " + userRoles.size());
for (EPUserApp userRole : userRoles) {
logger.debug(EELFLoggerDelegate.debugLogger,
"syncAppRoles: about to delete userRole: " + userRole.toString());
@@ -555,14 +569,16 @@ public class UserRolesCommonServiceImpl {
}
}
externalAccessRolesService.deleteRoleDependencyRecords(localSession, roleId, appId);
- logger.debug(EELFLoggerDelegate.debugLogger, "syncAppRoles: about to delete the role: " + role.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "syncAppRoles: about to delete the role: " + role.toString());
localSession.delete(role);
localSession.flush();
logger.debug(EELFLoggerDelegate.debugLogger, "syncAppRoles: deleted the role");
}
}
for (EcompRole role : newRolesToAdd) {
- logger.debug(EELFLoggerDelegate.debugLogger, "syncAppRoles: about to add missing role: " + role.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "syncAppRoles: about to add missing role: " + role.toString());
EPRole newRole = new EPRole();
// Attention! All roles from remote application supposed to be
// active!
@@ -585,11 +601,7 @@ public class UserRolesCommonServiceImpl {
localSession.close();
}
}
-
-
-
-
-
+
/**
* Called when updating the list of roles for the user
*
@@ -613,7 +625,7 @@ public class UserRolesCommonServiceImpl {
}
return result;
}
-
+
/**
*
* @param roleInAppForUserList
@@ -627,7 +639,7 @@ public class UserRolesCommonServiceImpl {
}
return false;
}
-
+
/**
* Builds JSON and posts it to a remote application to update user roles.
*
@@ -653,11 +665,11 @@ public class UserRolesCommonServiceImpl {
// even when it fails!
return updateUserRolesInEcomp;
}
-
+
/**
*
* @param roleInAppForUserList
- * @return Set<EcompRole>
+ * @return Set<EcompRole>
*/
protected Set<EcompRole> constructUsersEcompRoles(List<RoleInAppForUser> roleInAppForUserList) {
Set<EcompRole> existingUserRoles = new TreeSet<EcompRole>();
@@ -671,18 +683,18 @@ public class UserRolesCommonServiceImpl {
}
return existingUserRoles;
}
-
+
/**
* Constructs user app roles excluding Account Administrator role
*
* @param roleInAppForUserList
- * @return
- * List of roles with Role name, Role Id
+ * @return List of roles with Role name, Role Id
*/
protected Set<EcompRole> constructUsersRemoteAppRoles(List<RoleInAppForUser> roleInAppForUserList) {
Set<EcompRole> existingUserRoles = new TreeSet<EcompRole>();
for (RoleInAppForUser roleInAppForUser : roleInAppForUserList) {
- if (roleInAppForUser.isApplied && !roleInAppForUser.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)) {
+ if (roleInAppForUser.isApplied
+ && !roleInAppForUser.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)) {
EcompRole ecompRole = new EcompRole();
ecompRole.setId(roleInAppForUser.roleId);
ecompRole.setName(roleInAppForUser.roleName);
@@ -691,16 +703,17 @@ public class UserRolesCommonServiceImpl {
}
return existingUserRoles;
}
-
+
/**
* This is for a single app
*
* @param rolesInAppForUser
- * @param externalSystemRequest
- * set to false if requests from Users page otherwise true
+ * @param externalSystemRequest
+ * set to false if requests from Users page otherwise true
* @return true on success, false otherwise
*/
- protected boolean applyChangesInUserRolesForAppToEcompDB(RolesInAppForUser rolesInAppForUser, boolean externalSystemRequest, String reqType) throws Exception {
+ protected boolean applyChangesInUserRolesForAppToEcompDB(RolesInAppForUser rolesInAppForUser,
+ boolean externalSystemRequest, String reqType) throws Exception {
boolean result = false;
String userId = rolesInAppForUser.orgUserId;
Long appId = rolesInAppForUser.appId;
@@ -710,8 +723,10 @@ public class UserRolesCommonServiceImpl {
}
if (rolesInAppForUser != null) {
- EcompRole[] userAppRoles = new EcompRole[rolesInAppForUser.roles.stream().distinct().collect(Collectors.toList()).size()];
- for (int i = 0; i < rolesInAppForUser.roles.stream().distinct().collect(Collectors.toList()).size(); i++) {
+ EcompRole[] userAppRoles = new EcompRole[rolesInAppForUser.roles.stream().distinct()
+ .collect(Collectors.toList()).size()];
+ for (int i = 0; i < rolesInAppForUser.roles.stream().distinct().collect(Collectors.toList())
+ .size(); i++) {
RoleInAppForUser roleInAppForUser = rolesInAppForUser.roles.get(i);
EcompRole role = new EcompRole();
role.setId(roleInAppForUser.roleId);
@@ -723,8 +738,9 @@ public class UserRolesCommonServiceImpl {
result = true;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,
- "applyChangesInUserRolesForAppToEcompDB: failed to syncUserRoles for orgUserId " + userId, e);
- if("DELETE".equals(reqType)){
+ "applyChangesInUserRolesForAppToEcompDB: failed to syncUserRoles for orgUserId " + userId,
+ e);
+ if ("DELETE".equals(reqType)) {
throw new Exception(e.getMessage());
}
}
@@ -732,7 +748,7 @@ public class UserRolesCommonServiceImpl {
}
return result;
}
-
+
/**
*
* @param appId
@@ -748,7 +764,7 @@ public class UserRolesCommonServiceImpl {
userWithRemoteAppRoles.setRoles(remoteUser.getRoles());
return userWithRemoteAppRoles;
}
-
+
/*
* (non-Javadoc)
*
@@ -777,7 +793,7 @@ public class UserRolesCommonServiceImpl {
return rolesList;
}
-
+
/**
* It adds new user for remote application
*
@@ -788,14 +804,17 @@ public class UserRolesCommonServiceImpl {
* @param mapper
* @param searchService
* @param applicationsRestClientService
- * @return
+ * @return
* @throws Exception
*/
- private EPUser addRemoteUser(List<RoleInAppForUser> roleInAppForUserList, String userId, EPApp app, ObjectMapper mapper, SearchService searchService, ApplicationsRestClientService applicationsRestClientService) throws Exception{
+ private EPUser addRemoteUser(List<RoleInAppForUser> roleInAppForUserList, String userId, EPApp app,
+ ObjectMapper mapper, SearchService searchService,
+ ApplicationsRestClientService applicationsRestClientService) throws Exception {
EPUser addRemoteUser = null;
if (remoteUserShouldBeCreated(roleInAppForUserList)) {
-
- createNewUserOnRemoteApp(userId, app, applicationsRestClientService, searchService, mapper, isAppUpgradeVersion(app));
+
+ createNewUserOnRemoteApp(userId, app, applicationsRestClientService, searchService, mapper,
+ isAppUpgradeVersion(app));
// If we succeed, we know that the new user was
// persisted on remote app.
addRemoteUser = getUserFromApp(userId, app, applicationsRestClientService);
@@ -807,10 +826,10 @@ public class UserRolesCommonServiceImpl {
}
return addRemoteUser;
}
-
+
/**
- * It checks whether the remote user exists or not
- * if exits returns user object else null
+ * It checks whether the remote user exists or not if exits returns user object
+ * else null
*
* @param userId
* @param app
@@ -818,7 +837,8 @@ public class UserRolesCommonServiceImpl {
* @return
* @throws HTTPException
*/
- private EPUser checkIfRemoteUserExits(String userId, EPApp app, ApplicationsRestClientService applicationsRestClientService) throws HTTPException{
+ private EPUser checkIfRemoteUserExits(String userId, EPApp app,
+ ApplicationsRestClientService applicationsRestClientService) throws HTTPException {
EPUser checkRemoteUser = null;
try {
checkRemoteUser = getUserFromApp(userId, app, applicationsRestClientService);
@@ -828,7 +848,7 @@ public class UserRolesCommonServiceImpl {
logger.debug(EELFLoggerDelegate.debugLogger,
"setAppWithUserRoleStateForUser: getuserFromApp threw exception with response code 400; continuing",
e);
- } else if(e.getResponseCode() == 404) {
+ } else if (e.getResponseCode() == 404) {
logger.debug(EELFLoggerDelegate.debugLogger,
"setAppWithUserRoleStateForUser: getuserFromApp threw exception with response code 404; continuing",
e);
@@ -839,14 +859,13 @@ public class UserRolesCommonServiceImpl {
}
return checkRemoteUser;
}
-
-
+
/*
* (non-Javadoc)
*
* @see org.openecomp.portalapp.portal.service.UserRolesService#
- * setAppWithUserRoleStateForUser(org.openecomp.portalapp.portal.domain.
- * EPUser, org.openecomp.portalapp.portal.transport.AppWithRolesForUser)
+ * setAppWithUserRoleStateForUser(org.openecomp.portalapp.portal.domain. EPUser,
+ * org.openecomp.portalapp.portal.transport.AppWithRolesForUser)
*/
public boolean setAppWithUserRoleStateForUser(EPUser user, AppWithRolesForUser newAppRolesForUser) {
boolean result = false;
@@ -877,7 +896,7 @@ public class UserRolesCommonServiceImpl {
applicationsRestClientService);
}
}
-
+
Set<EcompRole> userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper,
applicationsRestClientService, appId, userId);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId,
@@ -886,26 +905,27 @@ public class UserRolesCommonServiceImpl {
// Apply changes in external Access system
updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, epRequestValue);
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal");
- }
+ }
// In case if portal is not centralized then follow existing approach
- else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){
+ else if (!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
Set<EcompRole> userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper,
- applicationsRestClientService, appId, userId);
+ applicationsRestClientService, appId, userId);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId,
userRolesInLocalApp);
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal");
- } else{// remote app
+ } else {// remote app
EPUser remoteAppUser = null;
- if(!app.getCentralAuth() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)){
-
+ if (!app.getCentralAuth() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
+
remoteAppUser = checkIfRemoteUserExits(userId, app, applicationsRestClientService);
-
+
if (remoteAppUser == null) {
- remoteAppUser = addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService, applicationsRestClientService);
+ remoteAppUser = addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService,
+ applicationsRestClientService);
}
if (remoteAppUser != null) {
- Set<EcompRole> userRolesInRemoteApp = postUsersRolesToRemoteApp(roleInAppForUserList, mapper,
- applicationsRestClientService, appId, userId);
+ Set<EcompRole> userRolesInRemoteApp = postUsersRolesToRemoteApp(roleInAppForUserList,
+ mapper, applicationsRestClientService, appId, userId);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId,
userRolesInRemoteApp);
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, null);
@@ -913,8 +933,8 @@ public class UserRolesCommonServiceImpl {
// If no roles remain, request app to set user inactive.
if (userRolesInRemoteApp.size() == 0) {
logger.debug(EELFLoggerDelegate.debugLogger,
- "setAppWithUserRoleStateForUser: no roles in app {}, set user {} to inactive", app,
- userId);
+ "setAppWithUserRoleStateForUser: no roles in app {}, set user {} to inactive",
+ app, userId);
remoteAppUser.setActive(false);
postUserToRemoteApp(userId, user, app, applicationsRestClientService);
}
@@ -922,8 +942,7 @@ public class UserRolesCommonServiceImpl {
}
}
} catch (Exception e) {
- String message = String.format(
- "Failed to create user or update user roles for User %s, AppId %s",
+ String message = String.format("Failed to create user or update user roles for User %s, AppId %s",
userId, Long.toString(appId));
logger.error(EELFLoggerDelegate.errorLogger, message, e);
result = false;
@@ -932,16 +951,20 @@ public class UserRolesCommonServiceImpl {
}
return result;
}
+
/**
- * It adds user roles in External system and also make data consistent in both local and in External System
+ * It adds user roles in External system and also make data consistent in both
+ * local and in External System
*
- * @param app details
+ * @param app
+ * details
* @param orgUserId
- * @param roleInAppUser Contains list of active roles
+ * @param roleInAppUser
+ * Contains list of active roles
*/
@SuppressWarnings("unchecked")
- private void updateUserRolesInExternalSystem(EPApp app, String orgUserId, List<RoleInAppForUser> roleInAppUser, boolean isPortalRequest)
- {
+ private void updateUserRolesInExternalSystem(EPApp app, String orgUserId, List<RoleInAppForUser> roleInAppUser,
+ boolean isPortalRequest) {
try {
// check if user exists
final Map<String, String> userParams = new HashMap<>();
@@ -964,7 +987,8 @@ public class UserRolesCommonServiceImpl {
.exchange(SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL)
+ "roles/user/" + name, HttpMethod.GET, getUserRolesEntity, String.class);
if (getResponse.getStatusCode().value() == 200) {
- logger.debug(EELFLoggerDelegate.debugLogger, "updateUserRolesInExternalSystem: Finished GET user roles from external system and received user roles {}",
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "updateUserRolesInExternalSystem: Finished GET user roles from external system and received user roles {}",
getResponse.getBody());
}
@@ -998,8 +1022,9 @@ public class UserRolesCommonServiceImpl {
}
}
}
- // If request coming from portal not from external role approval system then we have to check if user already
- // have account admin or system admin as GUI will not send these roles
+ // If request coming from portal not from external role approval system then we
+ // have to check if user already
+ // have account admin or system admin as GUI will not send these roles
if (!isPortalRequest) {
final Map<String, String> loginIdParams = new HashMap<>();
loginIdParams.put("orgUserIdValue", orgUserId);
@@ -1032,7 +1057,8 @@ public class UserRolesCommonServiceImpl {
for (ExternalAccessUserRoleDetail extAccessUserRole : userRoleDetailList) {
currentUserRolesInExternalSystem.put(extAccessUserRole.getName(), extAccessUserRole);
}
- // Check if roles does not exists in local but still there in External Central Auth System delete them all
+ // Check if roles does not exists in local but still there in External Central
+ // Auth System delete them all
for (ExternalAccessUserRoleDetail userRole : userRoleDetailList) {
if (!(currentUserRolesToUpdate
.containsKey(userRole.getName().substring(app.getNameSpace().length() + 1).replaceAll("_", " "))
@@ -1051,7 +1077,8 @@ public class UserRolesCommonServiceImpl {
userRole, deleteResponse.getBody());
}
}
- // Check if user roles does not exists in External Central Auth System add them all
+ // Check if user roles does not exists in External Central Auth System add them
+ // all
for (RoleInAppForUser addUserRole : roleInAppUserNonDupls) {
if (!(currentUserRolesInExternalSystem
.containsKey(app.getNameSpace() + "." + addUserRole.getRoleName().replaceAll(" ", "_")))) {
@@ -1059,7 +1086,8 @@ public class UserRolesCommonServiceImpl {
app.getNameSpace() + "." + addUserRole.getRoleName().replaceAll(" ", "_"));
String formattedUserRole = mapper.writeValueAsString(extUser);
HttpEntity<String> entity = new HttpEntity<>(formattedUserRole, headers);
- logger.debug(EELFLoggerDelegate.debugLogger, "updateUserRolesInExternalSystem: Connecting to external system and adding user role",
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "updateUserRolesInExternalSystem: Connecting to external system and adding user role",
addUserRole.getRoleName());
ResponseEntity<String> addResponse = template
.exchange(SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL)
@@ -1069,14 +1097,16 @@ public class UserRolesCommonServiceImpl {
getResponse.getBody(), addUserRole.getRoleName());
if (addResponse.getStatusCode().value() != 201 && addResponse.getStatusCode().value() != 404) {
logger.debug(EELFLoggerDelegate.debugLogger,
- "Finished POST operation in external system but unable to save user role", getResponse.getBody(),
- addUserRole.getRoleName());
+ "Finished POST operation in external system but unable to save user role",
+ getResponse.getBody(), addUserRole.getRoleName());
throw new Exception(addResponse.getBody());
}
}
}
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "updateUserRolesInExternalSystem: Failed to add user role for application {} due to {}", app.getId(), e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "updateUserRolesInExternalSystem: Failed to add user role for application {} due to {}",
+ app.getId(), e);
}
}
@@ -1094,30 +1124,30 @@ public class UserRolesCommonServiceImpl {
ApplicationsRestClientService applicationsRestClientService, SearchService searchService,
ObjectMapper mapper, boolean postOpenSource) throws Exception {
-
- EPUser client = searchService.searchUserByUserId(userId);
-
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- if (client == null) {
- String msg = "cannot create user " + userId + ", because he/she cannot be found in phonebook.";
- logger.error(EELFLoggerDelegate.errorLogger, msg);
- throw new Exception(msg);
- }
+ EPUser client = searchService.searchUserByUserId(userId);
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ if (client == null) {
+ String msg = "cannot create user " + userId + ", because he/she cannot be found in phonebook.";
+ logger.error(EELFLoggerDelegate.errorLogger, msg);
+ throw new Exception(msg);
+ }
- client.setLoginId(userId);
- client.setActive(true);
+ client.setLoginId(userId);
+ client.setActive(true);
- String userInString = null;
- userInString = mapper.writerFor(EPUser.class).writeValueAsString(client);
- logger.debug(EELFLoggerDelegate.debugLogger,
- "about to post new client to remote application, users json = " + userInString);
- applicationsRestClientService.post(EPUser.class, app.getId(), userInString, String.format("/user", userId));
+ String userInString = null;
+ userInString = mapper.writerFor(EPUser.class).writeValueAsString(client);
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "about to post new client to remote application, users json = " + userInString);
+ applicationsRestClientService.post(EPUser.class, app.getId(), userInString, String.format("/user", userId));
}
-
+
@SuppressWarnings("unchecked")
- protected void applyChangesToAppRolesRequest(Long appId, Long userId, String updateStatus, EPUserAppRolesRequest epUserAppRolesRequest) {
+ protected void applyChangesToAppRolesRequest(Long appId, Long userId, String updateStatus,
+ EPUserAppRolesRequest epUserAppRolesRequest) {
final Map<String, Long> epRequestParams = new HashMap<>();
try {
EPUserAppRolesRequest epAppRolesRequestData = epUserAppRolesRequest;
@@ -1146,7 +1176,7 @@ public class UserRolesCommonServiceImpl {
logger.error(EELFLoggerDelegate.errorLogger, "applyChangesToAppRolesRequest failed", e);
}
}
-
+
@SuppressWarnings("unchecked")
public void applyChangesToUserAppRolesForMyLoginsRequest(EPUser user, Long appId) {
final Map<String, Long> params = new HashMap<>();
@@ -1185,7 +1215,7 @@ public class UserRolesCommonServiceImpl {
logger.error(EELFLoggerDelegate.errorLogger, "applyChangesToUserAppRolesRequest failed", e);
}
}
-
+
/**
* Pushes specified user details to the specified remote app.
*
@@ -1200,30 +1230,29 @@ public class UserRolesCommonServiceImpl {
*/
protected void postUserToRemoteApp(String userId, EPUser user, EPApp app,
ApplicationsRestClientService applicationsRestClientService) throws HTTPException {
-
- getUser(userId, app, applicationsRestClientService);
-
+
+ getUser(userId, app, applicationsRestClientService);
+
}
-
+
/**
* It returns user details for single org user id
*
* @param userParams
- * @return
- * if user exists it returns list of user details otherwise empty value
+ * @return if user exists it returns list of user details otherwise empty value
*/
@SuppressWarnings("unchecked")
- private List<EPUser> checkIfUserExists(Map<String, String> userParams){
- return (List<EPUser>)dataAccessService.executeNamedQuery("epUserAppId", userParams, null);
+ private List<EPUser> checkIfUserExists(Map<String, String> userParams) {
+ return (List<EPUser>) dataAccessService.executeNamedQuery("epUserAppId", userParams, null);
}
-
+
/**
* It checks whether the new user is valid or not otherwise throws exception
*
* @param orgUserId
* @param app
- * @return
- * Checks if user is valid and returns message otherwise throws exception
+ * @return Checks if user is valid and returns message otherwise throws
+ * exception
* @throws Exception
*/
private String validateNewUser(String orgUserId, EPApp app) throws Exception {
@@ -1237,29 +1266,30 @@ public class UserRolesCommonServiceImpl {
}
return "Saved Successfully";
}
-
+
/**
- * Checks if the fields exists or not
- *
+ * Checks if the fields exists or not
+ *
* @param userList
- * contains user information
+ * contains user information
* @param app
- * contains app name
+ * contains app name
* @throws Exception
- * throws exception if the field is not valid
+ * throws exception if the field is not valid
*/
- private void validateExternalRequestFields(List<EPUser> userList, EPApp app) throws Exception{
- if (userList.size() == 0 || userList.isEmpty() ) {
+ private void validateExternalRequestFields(List<EPUser> userList, EPApp app) throws Exception {
+ if (userList.size() == 0 || userList.isEmpty()) {
throw new Exception("User does not exist");
- } else if(app == null) {
+ } else if (app == null) {
throw new Exception("Application does not exist");
- } else if(!app.getEnabled() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
- throw new Exception(app.getMlAppName()+" application is unavailable");
+ } else if (!app.getEnabled() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
+ throw new Exception(app.getMlAppName() + " application is unavailable");
}
}
-
+
@SuppressWarnings("unchecked")
- public ExternalRequestFieldsValidator setExternalRequestUserAppRole(ExternalSystemUser newAppRolesForUser, String reqType) {
+ public ExternalRequestFieldsValidator setExternalRequestUserAppRole(ExternalSystemUser newAppRolesForUser,
+ String reqType) {
boolean result = false;
boolean externalSystemRequest = true;
final Map<String, Long> params = new HashMap<>();
@@ -1275,7 +1305,7 @@ public class UserRolesCommonServiceImpl {
orgUserId = newAppRolesForUser.getLoginId().trim();
}
String appName = newAppRolesForUser.getApplicationName();
- String logMessage = ("DELETE").equals(reqType) ? "Deleting": "Assigning/Updating" ;
+ String logMessage = ("DELETE").equals(reqType) ? "Deleting" : "Assigning/Updating";
if (orgUserId.length() > 0) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -1297,24 +1327,24 @@ public class UserRolesCommonServiceImpl {
.executeNamedQuery("userAppRolesRequestList", params, null);
epRequestIdSize = epRequestId.size();
}
-
- //If Non-Centralized app make sure you sync app roles before assigning to user
- if(!app.getId().equals(PortalConstants.PORTAL_APP_ID) && !app.getCentralAuth()){
- EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, app.getId(), "/roles");
- syncAppRoles(sessionFactory, app.getId(), appRoles);
+
+ // If Non-Centralized app make sure you sync app roles before assigning to user
+ if (!app.getId().equals(PortalConstants.PORTAL_APP_ID) && !app.getCentralAuth()) {
+ EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, app.getId(), "/roles");
+ syncAppRoles(sessionFactory, app.getId(), appRoles);
}
List<RoleInAppForUser> roleInAppForUserList = roleInAppForUserList(newAppRolesForUser.getRoles(),
app.getId(), app.getMlAppName());
List<EcompUserAppRoles> userRoleList = null;
- if(!userInfo.isEmpty()){
- final Map<String, Long> appParams = new HashMap<>();
- appParams.put("userId", userId.getId());
- appParams.put("appId", app.getId());
- userRoleList = dataAccessService.executeNamedQuery("getUserAppExistingRoles", appParams, null);
+ if (!userInfo.isEmpty()) {
+ final Map<String, Long> appParams = new HashMap<>();
+ appParams.put("userId", userId.getId());
+ appParams.put("appId", app.getId());
+ userRoleList = dataAccessService.executeNamedQuery("getUserAppExistingRoles", appParams, null);
}
// Check if list contains just account admin role
boolean checkIfAdminRoleExists = false;
- if (reqType.equals("DELETE") && userRoleList!=null) {
+ if (reqType.equals("DELETE") && userRoleList != null) {
checkIfAdminRoleExists = userRoleList.stream()
.anyMatch(userRole -> userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID));
} else {
@@ -1326,11 +1356,11 @@ public class UserRolesCommonServiceImpl {
// We should add If user does not exist in remote application
try {
// If adding just account admin role dont make remote application user call
- if (!app.getId().equals(PortalConstants.PORTAL_APP_ID) && !(checkIfAdminRoleExists
- && reqType.equals("DELETE")) && roleInAppForUserList.size() > 1) {
+ if (!app.getId().equals(PortalConstants.PORTAL_APP_ID)
+ && !(checkIfAdminRoleExists && reqType.equals("DELETE"))
+ && roleInAppForUserList.size() > 1) {
EPUser remoteAppUser = null;
- remoteAppUser = checkIfRemoteUserExits(orgUserId, app,
- applicationsRestClientService);
+ remoteAppUser = checkIfRemoteUserExits(orgUserId, app, applicationsRestClientService);
if (remoteAppUser == null) {
addRemoteUser(roleInAppForUserList, orgUserId, app, mapper, searchService,
applicationsRestClientService);
@@ -1339,7 +1369,8 @@ public class UserRolesCommonServiceImpl {
}
} catch (Exception e) {
reqMessage = e.getMessage();
- logger.error(EELFLoggerDelegate.errorLogger, "setExternalRequestUserAppRole: Failed to added remote user", e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "setExternalRequestUserAppRole: Failed to added remote user", e);
throw new Exception(reqMessage);
}
Set<EcompRole> userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper,
@@ -1348,63 +1379,68 @@ public class UserRolesCommonServiceImpl {
userRolesInLocalApp);
List<RoleInAppForUser> roleAppUserList = rolesInAppForUser.roles;
// Apply changes in external Access system
- updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, externalSystemRequest);
- logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage,
+ updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList,
+ externalSystemRequest);
+ logger.info(EELFLoggerDelegate.debugLogger,
+ "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage,
newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId());
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType);
- }
- // If local application is not centralized
- else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){
+ }
+ // If local application is not centralized
+ else if (!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
Set<EcompRole> userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper,
- applicationsRestClientService, app.getId(), orgUserId);
+ applicationsRestClientService, app.getId(), orgUserId);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId, app.getId(),
userRolesInLocalApp);
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType);
} else {// remote app
// If adding just account admin role don't do remote application user call
- if(!((roleInAppForUserList.size() == 1 || reqType.equals("DELETE")) && checkIfAdminRoleExists)){
- EPUser remoteAppUser = null;
+ if (!((roleInAppForUserList.size() == 1 || reqType.equals("DELETE")) && checkIfAdminRoleExists)) {
+ EPUser remoteAppUser = null;
remoteAppUser = checkIfRemoteUserExits(orgUserId, app, applicationsRestClientService);
- if (remoteAppUser == null) {
- remoteAppUser = addRemoteUser(roleInAppForUserList, orgUserId, app, mapper, searchService, applicationsRestClientService);
- reqMessage = "Saved Successfully";
- }
+ if (remoteAppUser == null) {
+ remoteAppUser = addRemoteUser(roleInAppForUserList, orgUserId, app, mapper, searchService,
+ applicationsRestClientService);
+ reqMessage = "Saved Successfully";
+ }
if (remoteAppUser != null) {
Set<EcompRole> userRolesInRemoteApp = postUsersRolesToRemoteApp(roleInAppForUserList,
mapper, applicationsRestClientService, app.getId(), orgUserId);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId,
app.getId(), userRolesInRemoteApp);
- logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}",
- logMessage, newAppRolesForUser.getApplicationName(),
- newAppRolesForUser.getLoginId());
+ logger.info(EELFLoggerDelegate.debugLogger,
+ "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage,
+ newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId());
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest,
reqType);
// If no roles remain, request app to set user inactive.
- /*if (userRolesInRemoteApp.size() == 0) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "setAppWithUserRoleStateForUser: no roles in app {}, set user {} to inactive", app,
- orgUserId);
- //TODO Need to fix the logged in user is not set to inactive
- remoteAppUser.setActive(false);
- postUserToRemoteApp(orgUserId, user, app, applicationsRestClientService);
- }*/
+ /*
+ * if (userRolesInRemoteApp.size() == 0) {
+ * logger.debug(EELFLoggerDelegate.debugLogger,
+ * "setAppWithUserRoleStateForUser: no roles in app {}, set user {} to inactive"
+ * , app, orgUserId); //TODO Need to fix the logged in user is not set to
+ * inactive remoteAppUser.setActive(false); postUserToRemoteApp(orgUserId, user,
+ * app, applicationsRestClientService); }
+ */
}
} else {
- // Here we are adding only we have single account admin in roleInAppForUserList and this should not add in remote
- if(!(reqType.equals("DELETE")) && userInfo.isEmpty()){
+ // Here we are adding only we have single account admin in roleInAppForUserList
+ // and this should not add in remote
+ if (!(reqType.equals("DELETE")) && userInfo.isEmpty()) {
reqMessage = "Saved Successfully";
}
Set<EcompRole> userRolesInRemoteApp = constructUsersEcompRoles(roleInAppForUserList);
RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId, app.getId(),
userRolesInRemoteApp);
- logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}",
- logMessage, newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId());
+ logger.info(EELFLoggerDelegate.debugLogger,
+ "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage,
+ newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId());
result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest,
reqType);
}
- if(!result){
+ if (!result) {
reqMessage = "Failed to save the user app role(s)";
}
if (epRequestIdSize > 0 && !userInfo.isEmpty()) {
@@ -1413,22 +1449,22 @@ public class UserRolesCommonServiceImpl {
}
}
} catch (Exception e) {
- String message = String.format("setExternalRequestUserAppRole: Failed to create user or update user roles for User %s, AppId %s",
+ String message = String.format(
+ "setExternalRequestUserAppRole: Failed to create user or update user roles for User %s, AppId %s",
orgUserId, appName);
logger.error(EELFLoggerDelegate.errorLogger, message, e);
result = false;
reqMessage = e.getMessage();
- if(epRequestIdSize > 0 && userInfo!=null && !userInfo.isEmpty()){
- updateStatus = "F";
- applyChangesToAppRolesRequest(app.getId(), userId.getId(),
- updateStatus, epRequestId.get(0));
- }
+ if (epRequestIdSize > 0 && userInfo != null && !userInfo.isEmpty()) {
+ updateStatus = "F";
+ applyChangesToAppRolesRequest(app.getId(), userId.getId(), updateStatus, epRequestId.get(0));
+ }
}
}
return new ExternalRequestFieldsValidator(result, reqMessage);
}
-
+
/**
*
* @param roleInAppForUserList
@@ -1436,7 +1472,7 @@ public class UserRolesCommonServiceImpl {
* @param applicationsRestClientService
* @param appId
* @param userId
- * @return Set<EcompRole>
+ * @return Set<EcompRole>
* @throws JsonProcessingException
* @throws HTTPException
*/
@@ -1446,16 +1482,16 @@ public class UserRolesCommonServiceImpl {
Set<EcompRole> updatedUserRoles = constructUsersEcompRoles(roleInAppForUserList);
return updatedUserRoles;
}
-
+
/**
- * It constructs and returns list of user app roles when the external API role approval system calls
- * this method
+ * It constructs and returns list of user app roles when the external API role
+ * approval system calls this method
*
* @param roleInAppForUserList
* @param appId
* @return list of user app roles
* @throws Exception
- * throws exceptions if role id does not exits
+ * throws exceptions if role id does not exits
*/
private List<RoleInAppForUser> roleInAppForUserList(List<ExternalSystemRoleApproval> roleInAppForUserList,
Long appId, String appName) throws Exception {
@@ -1467,14 +1503,18 @@ public class UserRolesCommonServiceImpl {
if (existingAppRole == null) {
logger.error(EELFLoggerDelegate.errorLogger, "roleInAppForUserList failed for the roles {}",
roleInAppForUserList);
- throw new Exception("'" +roleInAppForUser.getRoleName() + "'" +" role does not exist for " + appName + " application");
+ throw new Exception("'" + roleInAppForUser.getRoleName() + "'" + " role does not exist for " + appName
+ + " application");
}
if (!existingAppRole.getActive()) {
logger.error(EELFLoggerDelegate.errorLogger, "roleInAppForUserList failed for the roles {}",
roleInAppForUserList);
- throw new Exception(roleInAppForUser.getRoleName() + " role is unavailable for "+ appName + " application");
+ throw new Exception(
+ roleInAppForUser.getRoleName() + " role is unavailable for " + appName + " application");
} else {
- ecompRole.roleId = (appId == 1 || roleInAppForUser.getRoleName().equals(PortalConstants.ADMIN_ROLE)) ? existingAppRole.getId() : existingAppRole.getAppRoleId();
+ ecompRole.roleId = (appId == 1 || roleInAppForUser.getRoleName().equals(PortalConstants.ADMIN_ROLE))
+ ? existingAppRole.getId()
+ : existingAppRole.getAppRoleId();
ecompRole.roleName = roleInAppForUser.getRoleName();
ecompRole.isApplied = true;
existingUserRoles.add(ecompRole);
@@ -1482,8 +1522,6 @@ public class UserRolesCommonServiceImpl {
}
return existingUserRoles;
}
-
-
/**
*
@@ -1493,8 +1531,8 @@ public class UserRolesCommonServiceImpl {
* @return EPUser
* @throws HTTPException
*/
- protected EPUser getUserFromApp(String userId, EPApp app, ApplicationsRestClientService applicationsRestClientService)
- throws HTTPException {
+ protected EPUser getUserFromApp(String userId, EPApp app,
+ ApplicationsRestClientService applicationsRestClientService) throws HTTPException {
// local app
if (app.getId() == PortalConstants.PORTAL_APP_ID) {
// Map<String,String> params = new HashMap<String,String>();
@@ -1508,32 +1546,31 @@ public class UserRolesCommonServiceImpl {
return null;
}
// remote app
-
+
return getUser(userId, app, applicationsRestClientService);
}
-
+
protected EPUser getUser(String userId, EPApp app, ApplicationsRestClientService applicationsRestClientService)
throws HTTPException {
return applicationsRestClientService.get(EPUser.class, app.getId(), String.format("/user/%s", userId));
}
-
- protected boolean isAppUpgradeVersion(EPApp app){
+
+ protected boolean isAppUpgradeVersion(EPApp app) {
return true;
}
-
-
- public ExternalSystemAccess getExternalRequestAccess(){
- ExternalSystemAccess res = null;
+
+ public ExternalSystemAccess getExternalRequestAccess() {
+ ExternalSystemAccess res = null;
try {
- res = new ExternalSystemAccess(EPCommonSystemProperties.EXTERNAL_ACCESS_ENABLE,
- Boolean.parseBoolean(SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_ACCESS_ENABLE)));
+ res = new ExternalSystemAccess(EPCommonSystemProperties.EXTERNAL_ACCESS_ENABLE, Boolean
+ .parseBoolean(SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_ACCESS_ENABLE)));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getExternalRequestAccess failed" + e.getMessage());
}
- return res;
+ return res;
}
-
+
/*
* (non-Javadoc)
*
@@ -1548,10 +1585,10 @@ public class UserRolesCommonServiceImpl {
try {
// for ecomp portal app, no need to make a remote call
List<Role> roleList = new ArrayList<>();
- if (appId == PortalConstants.PORTAL_APP_ID) {
- if(app.getCentralAuth()){
+ if (appId == PortalConstants.PORTAL_APP_ID) {
+ if (app.getCentralAuth()) {
List<CentralRole> cenRoleList = externalAccessRolesService.getRolesForApp(app.getUebKey());
- for(CentralRole cenRole : cenRoleList){
+ for (CentralRole cenRole : cenRoleList) {
Role role = new Role();
role.setActive(cenRole.isActive());
role.setId(cenRole.getId());
@@ -1559,46 +1596,48 @@ public class UserRolesCommonServiceImpl {
role.setPriority(cenRole.getPriority());
roleList.add(role);
}
- }else{
+ } else {
roleList = roleService.getAvailableRoles(userId);
}
List<Role> activeRoleList = new ArrayList<Role>();
- for(Role role: roleList) {
- if(role.getActive()) {
- if(role.getId() != 1){ // prevent portal admin from being added
+ for (Role role : roleList) {
+ if (role.getActive()) {
+ if (role.getId() != 1) { // prevent portal admin from being added
activeRoleList.add(role);
- } else if(extRequestValue){
+ } else if (extRequestValue) {
activeRoleList.add(role);
}
}
-
+
}
- EPUser localUser = getUserFromApp(userId, app, applicationsRestClientService);
+ EPUser localUser = getUserFromApp(userId, app, applicationsRestClientService);
// If localUser does not exists return roles
Set<EPRole> roleSet = null;
EPRole[] roleSetList = null;
- if(localUser != null){
+ if (localUser != null) {
roleSet = localUser.getAppEPRoles(app);
roleSetList = roleSet.toArray(new EPRole[0]);
}
rolesInAppForUser = constructRolesInAppForUserGet(activeRoleList, roleSetList, extRequestValue);
return rolesInAppForUser;
}
-
+
EcompRole[] appRoles = null;
List<EcompRole> roles = new ArrayList<>();
- if(app.getCentralAuth()){
- //Sync application functions from External Access System
+ if (app.getCentralAuth()) {
+ // Sync application functions from External Access System
externalAccessRolesService.syncRoleFunctionFromExternalAccessSystem(app);
- List<EPRole> applicationRoles = dataAccessService.getList(EPRole.class, " where app_id = "+app.getId()+ " and active_yn = 'Y'", null, null);;
- for(EPRole role : applicationRoles){
+ List<EPRole> applicationRoles = dataAccessService.getList(EPRole.class,
+ " where app_id = " + app.getId() + " and active_yn = 'Y'", null, null);
+ ;
+ for (EPRole role : applicationRoles) {
EcompRole ecompRole = new EcompRole();
ecompRole.setId(role.getId());
ecompRole.setName(role.getName());
roles.add(ecompRole);
}
appRoles = roles.toArray(new EcompRole[roles.size()]);
- } else{
+ } else {
appRoles = applicationsRestClientService.get(EcompRole[].class, appId, "/roles");
}
// Test this error case, for generating an internal Ecomp Portal
@@ -1607,31 +1646,32 @@ public class UserRolesCommonServiceImpl {
// If there is an exception in the rest client api, then null will
// be returned.
if (appRoles != null) {
- if(!app.getCentralAuth()) {
- syncAppRoles(sessionFactory, appId, appRoles);
+ if (!app.getCentralAuth()) {
+ syncAppRoles(sessionFactory, appId, appRoles);
}
EcompRole[] userAppRoles = null;
try {
try {
- if(app.getCentralAuth()){
+ if (app.getCentralAuth()) {
final Map<String, String> params = new HashMap<>();
final Map<String, Long> userParams = new HashMap<>();
params.put("orgUserIdValue", userId);
List<EPUser> user = dataAccessService.executeNamedQuery("epUserAppId", params, null);
userParams.put("appId", app.getId());
- userParams.put("userId", user.get(0).getId());
- List<EPUserAppCurrentRoles> userAppsRolesList = dataAccessService.executeNamedQuery("getUserAppCurrentRoles", userParams, null);
- List<EcompRole> setUserRoles = new ArrayList<>();
- for(EPUserAppCurrentRoles role : userAppsRolesList){
- EcompRole ecompRole = new EcompRole();
- ecompRole.setId(role.getRoleId());
- ecompRole.setName(role.getRoleName());
- setUserRoles.add(ecompRole);
- }
- userAppRoles = setUserRoles.toArray(new EcompRole[setUserRoles.size()]);
- rolesInAppForUser = constructRolesInAppForUserGet(appRoles, userAppRoles);
- return rolesInAppForUser;
- }else{
+ userParams.put("userId", user.get(0).getId());
+ List<EPUserAppCurrentRoles> userAppsRolesList = dataAccessService
+ .executeNamedQuery("getUserAppCurrentRoles", userParams, null);
+ List<EcompRole> setUserRoles = new ArrayList<>();
+ for (EPUserAppCurrentRoles role : userAppsRolesList) {
+ EcompRole ecompRole = new EcompRole();
+ ecompRole.setId(role.getRoleId());
+ ecompRole.setName(role.getRoleName());
+ setUserRoles.add(ecompRole);
+ }
+ userAppRoles = setUserRoles.toArray(new EcompRole[setUserRoles.size()]);
+ rolesInAppForUser = constructRolesInAppForUserGet(appRoles, userAppRoles);
+ return rolesInAppForUser;
+ } else {
userAppRoles = applicationsRestClientService.get(EcompRole[].class, appId,
String.format("/user/%s/roles", userId));
}
@@ -1656,21 +1696,21 @@ public class UserRolesCommonServiceImpl {
logger.warn(EELFLoggerDelegate.applicationLogger, message);
}
}
-
- HashMap<Long, EcompRole> appRolesActiveMap =hashMapFromEcompRoles(appRoles);
- ArrayList<EcompRole> activeRoles = new ArrayList<EcompRole>();
- if(userAppRoles != null){
- for (int i = 0; i < userAppRoles.length; i++) {
- if (appRolesActiveMap.containsKey(userAppRoles[i].getId())) {
- EcompRole role = new EcompRole();
- role.setId(userAppRoles[i].getId());
- role.setName(userAppRoles[i].getName());
- activeRoles.add(role);
- }
+
+ HashMap<Long, EcompRole> appRolesActiveMap = hashMapFromEcompRoles(appRoles);
+ ArrayList<EcompRole> activeRoles = new ArrayList<EcompRole>();
+ if (userAppRoles != null) {
+ for (int i = 0; i < userAppRoles.length; i++) {
+ if (appRolesActiveMap.containsKey(userAppRoles[i].getId())) {
+ EcompRole role = new EcompRole();
+ role.setId(userAppRoles[i].getId());
+ role.setName(userAppRoles[i].getName());
+ activeRoles.add(role);
}
}
- EcompRole[] userAppRolesActive = activeRoles.toArray(new EcompRole[activeRoles.size()]);
-
+ }
+ EcompRole[] userAppRolesActive = activeRoles.toArray(new EcompRole[activeRoles.size()]);
+
// If the remote application isn't down we MUST sync user
// roles here in case we have this user here!
syncUserRoles(sessionFactory, userId, appId, userAppRolesActive, extRequestValue, null);
@@ -1693,7 +1733,7 @@ public class UserRolesCommonServiceImpl {
return rolesInAppForUser;
}
-
+
private boolean postUserRolesToMylogins(AppWithRolesForUser userAppRolesData,
ApplicationsRestClientService applicationsRestClientService, Long appId, Long userId)
throws JsonProcessingException, HTTPException {
@@ -1701,20 +1741,24 @@ public class UserRolesCommonServiceImpl {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String userRolesAsString = mapper.writeValueAsString(userAppRolesData);
- logger.error(EELFLoggerDelegate.errorLogger,"Should not be reached here, as the endpoint is not defined yet from the Mylogins");
- applicationsRestClientService.post(AppWithRolesForUser.class, appId, userRolesAsString, String.format("/user/%s/myLoginroles", userId));
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Should not be reached here, as the endpoint is not defined yet from the Mylogins");
+ applicationsRestClientService.post(AppWithRolesForUser.class, appId, userRolesAsString,
+ String.format("/user/%s/myLoginroles", userId));
return result;
}
public FieldsValidator putUserAppRolesRequest(AppWithRolesForUser userAppRolesData, EPUser user) {
FieldsValidator fieldsValidator = new FieldsValidator();
final Map<String, Long> params = new HashMap<>();
- EPUserAppRoles appRole= new EPUserAppRoles();
+ EPUserAppRoles appRole = new EPUserAppRoles();
try {
- logger.error(EELFLoggerDelegate.errorLogger,"Should not be reached here, still the endpoint is yet to be defined");
- boolean result = postUserRolesToMylogins(userAppRolesData, applicationsRestClientService, userAppRolesData.appId, user.getId());
- logger.debug(EELFLoggerDelegate.debugLogger,"putUserAppRolesRequest: result {}", result);
-
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Should not be reached here, still the endpoint is yet to be defined");
+ boolean result = postUserRolesToMylogins(userAppRolesData, applicationsRestClientService,
+ userAppRolesData.appId, user.getId());
+ logger.debug(EELFLoggerDelegate.debugLogger, "putUserAppRolesRequest: result {}", result);
+
params.put("appId", userAppRolesData.appId);
EPUserAppRolesRequest epAppRolesRequestData = new EPUserAppRolesRequest();
epAppRolesRequestData.setCreatedDate(new Date());
@@ -1727,7 +1771,7 @@ public class UserRolesCommonServiceImpl {
dataAccessService.saveDomainObject(epAppRolesRequestData, null);
for (RoleInAppForUser userAppRoles : appRoleIdList) {
Boolean isAppliedVal = userAppRoles.isApplied;
- params.put("appRoleId", userAppRoles.roleId);
+ params.put("appRoleId", userAppRoles.roleId);
if (isAppliedVal) {
appRole = (EPUserAppRoles) dataAccessService.executeNamedQuery("appRoles", params, null).get(0);
EPUserAppRolesRequestDetail epAppRoleDetail = new EPUserAppRolesRequestDetail();
@@ -1735,7 +1779,7 @@ public class UserRolesCommonServiceImpl {
epAppRoleDetail.setReqType("P");
epAppRoleDetail.setEpRequestIdData(epAppRolesRequestData);
dataAccessService.saveDomainObject(epAppRoleDetail, null);
- }
+ }
}
epAppRolesRequestData.setEpRequestIdDetail(appRoleDetails);
fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_OK);
@@ -1747,18 +1791,18 @@ public class UserRolesCommonServiceImpl {
return fieldsValidator;
}
- public List<EPUserAppCatalogRoles> getUserAppCatalogRoles(EPUser userid, String appName) {
+ public List<EPUserAppCatalogRoles> getUserAppCatalogRoles(EPUser userid, String appName) {
Map<String, String> params = new HashMap<>();
params.put("userid", userid.getId().toString());
- //params.put("appid", appid);
+ // params.put("appid", appid);
params.put("appName", appName);
-
+
@SuppressWarnings("unchecked")
List<EPUserAppCatalogRoles> userAppRoles = (List<EPUserAppCatalogRoles>) dataAccessService
.executeNamedQuery("userAppCatalogRoles", params, null);
- return userAppRoles;
+ return userAppRoles;
}
-
+
public String updateRemoteUserProfile(String orgUserId, Long appId) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -1794,7 +1838,6 @@ public class UserRolesCommonServiceImpl {
return "success";
}
-
/*
* (non-Javadoc)
*
@@ -1810,4 +1853,100 @@ public class UserRolesCommonServiceImpl {
return roleList;
}
+ /**
+ * Retrieves and returns a list of user app roles for local and remote
+ * applications based on the app id.
+ *
+ * @param appId
+ * @return list of user app roles
+ * @throws HTTPException
+ */
+ public List<UserApplicationRoles> getUsersFromAppEndpoint(Long appId) throws HTTPException {
+ ArrayList<UserApplicationRoles> userApplicationRoles = new ArrayList<UserApplicationRoles>();
+
+ EPApp app = appsService.getApp(appId);
+ // If local or centralized application
+ if (appId == PortalConstants.PORTAL_APP_ID || app.getCentralAuth()) {
+ @SuppressWarnings("unchecked")
+ List<EPUser> userList = (List<EPUser>) dataAccessService.executeNamedQuery("getActiveUsers", null, null);
+ for (EPUser user : userList) {
+ UserApplicationRoles userWithAppRoles = convertToUserApplicationRoles(appId, user, app);
+ if (userWithAppRoles.getRoles() != null && userWithAppRoles.getRoles().size() > 0)
+ userApplicationRoles.add(userWithAppRoles);
+ }
+ }
+ // remote app
+ else {
+ RemoteUserWithRoles[] remoteUsers = null;
+ String remoteUsersString = applicationsRestClientService.getIncomingJsonString(appId, "/users");
+ remoteUsers = doGetUsers(isAppUpgradeVersion(app), remoteUsersString);
+ userApplicationRoles = new ArrayList<UserApplicationRoles>();
+ for (RemoteUserWithRoles remoteUser : remoteUsers) {
+ UserApplicationRoles userWithRemoteAppRoles = convertToUserApplicationRoles(appId, remoteUser);
+ if (userWithRemoteAppRoles.getRoles() != null && userWithRemoteAppRoles.getRoles().size() > 0) {
+ userApplicationRoles.add(userWithRemoteAppRoles);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, "User " + userWithRemoteAppRoles.getOrgUserId()
+ + " doesn't have any roles assigned to any app.");
+ }
+ }
+ }
+ return userApplicationRoles;
+ }
+
+ /**
+ *
+ * @param appId
+ * @param user
+ * @param appgetUsersFromAppEndpoint
+ * @return
+ */
+ private UserApplicationRoles convertToUserApplicationRoles(Long appId, EPUser user, EPApp app) {
+ UserApplicationRoles userWithRemoteAppRoles = new UserApplicationRoles();
+ userWithRemoteAppRoles.setAppId(appId);
+ userWithRemoteAppRoles.setOrgUserId(user.getOrgUserId());
+ userWithRemoteAppRoles.setFirstName(user.getFirstName());
+ userWithRemoteAppRoles.setLastName(user.getLastName());
+ userWithRemoteAppRoles.setRoles(convertToRemoteRoleList(user, app));
+ return userWithRemoteAppRoles;
+ }
+
+ /**
+ *
+ * @param user
+ * @param app
+ * @return
+ */
+ private List<RemoteRole> convertToRemoteRoleList(EPUser user, EPApp app) {
+ List<RemoteRole> roleList = new ArrayList<RemoteRole>();
+ SortedSet<EPRole> roleSet = user.getAppEPRoles(app);
+ for (EPRole role : roleSet) {
+ RemoteRole rRole = new RemoteRole();
+ rRole.setId(role.getId());
+ rRole.setName(role.getName());
+ roleList.add(rRole);
+ }
+ return roleList;
+ }
+
+ /**
+ *
+ * Returns RemoteUserWithRoles reading the value from remote application user in the form a string from an ObjectMapper
+ * @param postOpenSource
+ * @param remoteUsersString
+ * @return RemoteUserWithRoles
+ */
+ public RemoteUserWithRoles[] doGetUsers(boolean postOpenSource, String remoteUsersString) {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.readValue(remoteUsersString, RemoteUserWithRoles[].class);
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "doGetUsers : Failed : Unexpected property in incoming JSON",
+ e);
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "doGetUsers : Incoming JSON that caused it --> " + remoteUsersString);
+ }
+
+ return new RemoteUserWithRoles[0];
+ }
}
diff --git a/ecomp-portal-BE-os/README.md b/ecomp-portal-BE-os/README.md
index 45b0a791..33d968ab 100644
--- a/ecomp-portal-BE-os/README.md
+++ b/ecomp-portal-BE-os/README.md
@@ -42,6 +42,8 @@ Version 1.1.0 (Amsterdam), November 2017
- [Portal-86] Remove internal att.com usages from tests and other files
- [Portal-102] Fixed the page refresh issue on App Account Management page
- [Portal-104] replace mysql DB connector with mariaDB connector
+- [Portal-116] Empty Widgets on Home page - widget uploaded with a wrong format in db
+- [Portal-59] Fix to to display Portal users on User page
Version 1.0.0, February 2017
- Initial release
diff --git a/ecomp-portal-BE-os/pom.xml b/ecomp-portal-BE-os/pom.xml
index 901f6841..473d0eeb 100644
--- a/ecomp-portal-BE-os/pom.xml
+++ b/ecomp-portal-BE-os/pom.xml
@@ -287,7 +287,6 @@
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
-
<!-- Apache Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
@@ -608,6 +607,13 @@
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
+ <!-- Jacoco for offline instrumentation -->
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <version>${jacocoVersion}</version>
+ <classifier>runtime</classifier>
+ </dependency>
</dependencies>
<reporting>
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java
deleted file mode 100644
index fd0974b0..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
- * you may not use this software 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.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
- *
- * ============LICENSE_END============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.portal.service;
-
-import org.apache.cxf.transport.http.HTTPException;
-
-public interface ApplicationsRestClientService {
- public <T> T get(Class<T> clazz, long app, String restPath) throws HTTPException;
- public <T> T post(Class<T> clazz, long appId, Object payload, String restPath) throws HTTPException ;
- public <T> T put(Class<T> clazz, long appId, Object payload, String restPath) throws HTTPException ;
-}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
deleted file mode 100644
index 55479a20..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
- * you may not use this software 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.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
- *
- * ============LICENSE_END============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.portal.service;
-
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-
-import java.lang.reflect.Type;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Date;
-
-import javax.annotation.PostConstruct;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.transport.http.HTTPException;
-import org.openecomp.portalapp.portal.domain.EPApp;
-import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
-import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
-import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum;
-import org.openecomp.portalapp.portal.logging.logic.EPLogUtil;
-import org.openecomp.portalapp.portal.utils.EPSystemProperties;
-import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
-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.Service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-@Service("applicationsRestClientService")
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-@EPAuditLog
-public class ApplicationsRestClientServiceImpl implements ApplicationsRestClientService {
-
- private static final String PASSWORD_HEADER = "password";
-
- private static final String APP_USERNAME_HEADER = "username";
-
- private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ApplicationsRestClientServiceImpl.class);
-
- @Autowired
- private AppsCacheService appsCacheService;
- Gson gson = null;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @PostConstruct
- private void init() {
- logger.debug(EELFLoggerDelegate.debugLogger, "initializing");
- GsonBuilder builder = new GsonBuilder();
-
- // Register an adapter to manage the date types as long values
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
- public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- return new Date(json.getAsJsonPrimitive().getAsLong());
- }
- });
-
- gson = builder.create();
- }
-
- // TODO: do we need to do additional logging for remote API calls?
- private static WebClient createClientForPath(String baseUri, String path) {
- logger.info(EELFLoggerDelegate.debugLogger, "Creating web client for " + baseUri + " + " + path);
- WebClient client = WebClient.create(baseUri);
- client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);
- client.path(path);
- return client;
- }
-
- @EPMetricsLog
- private void verifyResponse(Response response) throws HTTPException {
- int status = response.getStatus();
- logger.debug(EELFLoggerDelegate.debugLogger, "http response status=" + status);
- MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE, Integer.toString(status));
- if (!isHttpSuccess(status)) {
- String errMsg = "Failed. Status=" + status + "; [" + response.getStatusInfo().getReasonPhrase().toString()
- + "]";
- URL url = null;
- try {
- // must not be null to avoid NPE in HTTPException constructor
- url = new URL("http://null");
- if (response.getLocation() != null)
- url = response.getLocation().toURL();
- } catch (MalformedURLException e) {
- // never mind. it is only for the debug message.
- logger.warn(EELFLoggerDelegate.errorLogger, "Failed to build URL", e);
- }
- logger.error(EELFLoggerDelegate.errorLogger, "http response failed. " + errMsg + "; url=" + url);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeIncorrectHttpStatusError);
- throw new HTTPException(status, errMsg, url);
- }
- }
-
- private static boolean isHttpSuccess(int status) {
- return status / 100 == 2;
- }
-
- @EPMetricsLog
- private WebClient createClientForApp(long appId, String restPath) {
- logger.debug(EELFLoggerDelegate.debugLogger, "creating client for appId=" + appId + "; restPath=" + restPath);
- EPApp externalApp = appsCacheService.getApp(appId);
- if (externalApp != null) {
- String appBaseUri = externalApp.getAppRestEndpoint();
- String username = externalApp.getUsername();
- String encriptedPwd = externalApp.getAppPassword();
- String decreptedAppPwd = "";
-
- // Set local context
- MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTP);
- if (appBaseUri != null && appBaseUri.contains("https")) {
- MDC.put(EPSystemProperties.PROTOCOL, EPSystemProperties.HTTPS);
- }
- MDC.put(EPSystemProperties.FULL_URL, appBaseUri + restPath);
- MDC.put(EPSystemProperties.TARGET_ENTITY, externalApp.getName());
- MDC.put(EPSystemProperties.TARGET_SERVICE_NAME, restPath);
-
- try {
- decreptedAppPwd = CipherUtil.decrypt(encriptedPwd,
- SystemProperties.getProperty(SystemProperties.Decryption_Key));
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "createClientForApp failed to decrypt", e);
- }
- logger.debug(EELFLoggerDelegate.debugLogger,
- String.format("App %d found, baseUri=[%s], Headers: [%s=%s, %s=%s]", appId, appBaseUri,
- APP_USERNAME_HEADER, username, PASSWORD_HEADER, encriptedPwd));
- WebClient client = createClientForPath(appBaseUri, restPath);
- client.header(APP_USERNAME_HEADER, username);
- client.header(PASSWORD_HEADER, decreptedAppPwd);
- client.header(SystemProperties.ECOMP_REQUEST_ID, MDC.get(MDC_KEY_REQUEST_ID));
- client.header(SystemProperties.USERAGENT_NAME, EPSystemProperties.ECOMP_PORTAL_BE);
-
- return client;
- }
- return null;
- }
-
- @Override
- public <T> T get(Class<T> clazz, long appId, String restPath) throws HTTPException {
-
- WebClient webClient = null;
- Response response = null;
- T t = null;
-
- webClient = createClientForApp(appId, restPath);
- EcompPortalUtils.logAndSerializeObject(restPath, "GET request =", "no-payload");
-
- try {
- if (webClient != null) {
- response = webClient.get();
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "Unable to create the Webclient to make the '" + restPath + "' API call.");
- }
- } catch (Exception e) {
- MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE,
- Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError);
- logger.error(EELFLoggerDelegate.errorLogger, "get 1 failed", e);
- }
-
- if (response != null) {
- verifyResponse(response);
- String str = response.readEntity(String.class);
- EcompPortalUtils.logAndSerializeObject(restPath, "GET result =", str);
- try {
- t = mapper.readValue(str, clazz);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "get 2 failed", e);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput);
- }
- }
-
- return t;
- }
-
- @Override
- public <T> T post(Class<T> clazz, long appId, Object payload, String restPath) throws HTTPException {
- WebClient client = null;
- Response response = null;
- T t = null;
-
- client = createClientForApp(appId, restPath);
- EcompPortalUtils.logAndSerializeObject(restPath, "POST request =", payload);
-
- try {
- if (client != null) {
- response = client.post(payload);
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "Unable to create the Webclient to make the {} API call", restPath);
- }
- } catch (Exception e) {
- MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE,
- Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError);
- logger.error(EELFLoggerDelegate.errorLogger, "post 1 failed", e);
- }
-
- if (response != null) {
- verifyResponse(response);
-
- // String contentType = response.getHeaderString("Content-Type");
- if (clazz != null) {
- String str = response.readEntity(String.class);
- EcompPortalUtils.logAndSerializeObject(restPath, "POST result =", str);
- try {
- t = gson.fromJson(str, clazz);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "post 2 failed", e);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput);
- }
- }
- }
- return t;
- }
-
- @Override
- public <T> T put(Class<T> clazz, long appId, Object payload, String restPath) throws HTTPException {
- WebClient client = null;
- Response response = null;
- T t = null;
-
- client = createClientForApp(appId, restPath);
- EcompPortalUtils.logAndSerializeObject(restPath, "PUT request =", payload);
-
- try {
- if (client != null) {
- response = client.put(payload);
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "Unable to create the Webclient to make the '" + restPath + "' API call.");
- }
- } catch (Exception e) {
- MDC.put(EPSystemProperties.EXTERNAL_API_RESPONSE_CODE,
- Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeRestApiGeneralError);
- logger.error(EELFLoggerDelegate.errorLogger, "put 1 failed", e);
- }
-
- if (response != null) {
- verifyResponse(response);
- String str = response.readEntity(String.class);
- EcompPortalUtils.logAndSerializeObject(restPath, "PUT result =", str);
- try {
- t = gson.fromJson(str, clazz);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "put 2 failed", e);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeInvalidJsonInput);
- }
- }
- return t;
- }
-}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java
index c38fc6ae..41b320c2 100644
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java
+++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java
@@ -37,7 +37,6 @@
*/
package org.openecomp.portalapp.portal.service;
-import java.util.ArrayList;
import java.util.List;
import org.apache.cxf.transport.http.HTTPException;
@@ -46,8 +45,6 @@ import org.openecomp.portalapp.portal.domain.EPRole;
import org.openecomp.portalapp.portal.domain.EPUser;
import org.openecomp.portalapp.portal.domain.EPUserApp;
import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
-import org.openecomp.portalapp.portal.transport.RemoteUserWithRoles;
-import org.openecomp.portalapp.portal.transport.UserApplicationRoles;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.service.DataAccessService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -69,9 +66,7 @@ public class UserRolesServiceImpl extends UserRolesCommonServiceImpl implements
@Autowired
private DataAccessService dataAccessService;
- @Autowired
- private ApplicationsRestClientService applicationsRestClientService;
-
+
private EPUser getUserFromRemoteApp(String orgUserId, EPApp app,
ApplicationsRestClientService applicationsRestClientService) throws HTTPException {
EPUser user = applicationsRestClientService.get(EPUser.class, app.getId(),
@@ -100,25 +95,6 @@ public class UserRolesServiceImpl extends UserRolesCommonServiceImpl implements
applicationsRestClientService.post(EPUser.class, app.getId(), userAsString, String.format("/user", orgUserId));
}
- @Override
- public List<UserApplicationRoles> getUsersFromAppEndpoint(Long appId) throws HTTPException {
- RemoteUserWithRoles[] remoteUsers = applicationsRestClientService.get(RemoteUserWithRoles[].class, appId,
- "/users");
- ArrayList<UserApplicationRoles> userApplicationRoles = new ArrayList<UserApplicationRoles>();
- for (RemoteUserWithRoles remoteUser : remoteUsers) {
- UserApplicationRoles userWithRemoteAppRoles = convertToUserApplicationRoles(appId, remoteUser);
- if (userWithRemoteAppRoles.getRoles() != null && userWithRemoteAppRoles.getRoles().size() > 0) {
- userApplicationRoles.add(userWithRemoteAppRoles);
- } else {
- logger.debug(EELFLoggerDelegate.debugLogger, "User " + userWithRemoteAppRoles.getOrgUserId()
- + " doesn't have any roles assigned to any app.");
-
- }
- }
-
- return userApplicationRoles;
- }
-
public static void persistExternalRoleInEcompDb(EPRole externalAppRole, Long appId, EPRoleService roleService) {
externalAppRole.setAppId(appId);
externalAppRole.setAppRoleId(externalAppRole.getId());
diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/raptor_pdf.properties b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/raptor_pdf.properties
index 38e05235..484f205c 100644
--- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/raptor_pdf.properties
+++ b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/raptor_pdf.properties
@@ -50,8 +50,8 @@ pdf_data_table_header_background_hex_code=#8A9BB3
#footer header
pdf_footer_font_size=9
pdf_footer_font_family=Arial
-pdf_att_proprietary=xxxx
-pdf_att_proprierary_font_size=7
+pdf_proprietary=xxxx
+pdf_proprierary_font_size=7
pdf_date_timezone=GMT
pdf_date_pattern=MM/dd/yyyy hh:mm:ss a
##page number position at 1 - footer middle, 0 -- header right, 2 - both
diff --git a/ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html b/ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html
index a19826f5..fbe255a9 100644
--- a/ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html
+++ b/ecomp-portal-FE-common/client/app/views/dashboard/dashboard-widget-parameter-manage.html
@@ -50,7 +50,7 @@
<div class="widgets-popup-margin">
<div class="get-access-table">
<div class="table-control manage-widget-parameters-table">
- <div class="c-ecomp-att-abs-table manage-widget-parameters-table-details">
+ <div class="manage-widget-parameters-table-details">
<table b2b-table id="table-main" table-data="ignoredTableData"
current-page="ignoredCurrentPage" ng-show="isLoadingTable">
<thead b2b-table-row type="header">
diff --git a/ecomp-portal-FE-common/client/app/views/users/users.controller.spec.js b/ecomp-portal-FE-common/client/app/views/users/users.controller.spec.js
deleted file mode 100644
index 0b3c0110..00000000
--- a/ecomp-portal-FE-common/client/app/views/users/users.controller.spec.js
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * 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.
- * ================================================================================
- */
-// /**
-// * Created by nnaffar on 12/17/15.
-// */
-// 'use strict';
-//
-// describe('Controller: UsersCtrl ', () => {
-// beforeEach(module('ecompApp'));
-//
-// //destroy $http default cache before starting to prevent the error 'default cache already exists'
-// beforeEach(inject((_CacheFactory_)=> {
-// _CacheFactory_.destroyAll();
-// }));
-//
-// let users, $controller, $q, $rootScope, $log, $scope;
-//
-// beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
-// [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
-// }));
-//
-// let applicationsServiceMock, usersServiceMock;
-// let deferredAdminApps, deferredUsersAccounts;
-// beforeEach(()=> {
-// [deferredAdminApps, deferredUsersAccounts] = [$q.defer(), $q.defer()];
-//
-// applicationsServiceMock = {
-// getAdminApps: () => {
-// var promise = () => {return deferredAdminApps.promise};
-// var cancel = jasmine.createSpy();
-// return {
-// promise: promise,
-// cancel: cancel
-// }
-// }
-// };
-//
-// usersServiceMock = jasmine.createSpyObj('usersServiceMock', ['getAccountUsers']);
-//
-// //applicationsServiceMock.getAdminApps().promise().and.returnValue(deferredAdminApps.promise);
-// usersServiceMock.getAccountUsers.and.returnValue(deferredUsersAccounts.promise);
-//
-// $scope = $rootScope.$new();
-// users = $controller('UsersCtrl', {
-// $log: $log,
-// applicationsService: applicationsServiceMock,
-// usersService: usersServiceMock,
-// $scope: $scope
-// });
-// $scope.users = users;
-// });
-//
-// //MOCKS
-// let appsListMock = [
-// {value: 'SSP', title: 'SSP', id: 3},
-// {value: 'ASDC', title: 'ASDC', id: 23},
-// {value: 'Formation', title: 'Formation', id: 223}
-// ];
-//
-// let usersListMock = [
-// {
-// "orgUserId": "nn605g",
-// "firstName": "Nabil",
-// "lastName": "Naffar",
-// "roles": [
-// {
-// "roleId": 1,
-// "roleName": "Standard user"
-// },
-// {
-// "roleId": 9,
-// "roleName": "Super standard user"
-// },
-// {
-// "roleId": 2,
-// "roleName": "Super duper standard user"
-// }
-// ]
-// }];
-// let secondUsersListMock = [
-// {
-// "orgUserId": "sadf7",
-// "firstName": "John",
-// "lastName": "Hall",
-// "roles": [
-// {
-// "roleId": 1,
-// "roleName": "Standard user"
-// },
-// {
-// "roleId": 2,
-// "roleName": "Super duper standard user"
-// }
-// ]
-// }];
-//
-// it('should get all user\'s administrated applications when initializing the view', ()=> {
-// deferredAdminApps.resolve(appsListMock);
-// deferredUsersAccounts.resolve(usersListMock);
-// $scope.$apply();
-// expect(users.adminApps).toEqual(appsListMock);
-// expect(users.selectedApp).toEqual(appsListMock[0]);
-// });
-//
-// it('should get first application users by default when initializing the view', () => {
-// $scope.$apply();
-// deferredAdminApps.resolve(appsListMock);
-// deferredUsersAccounts.resolve(usersListMock);
-// $scope.$apply();
-// expect(users.accountUsers).toEqual(usersListMock);
-// });
-//
-// it('should get application users when changing application', () => {
-// $scope.$apply();
-// deferredAdminApps.resolve(appsListMock);
-// $scope.$apply();
-//
-// users.selectedApp = appsListMock[1];
-// deferredUsersAccounts.resolve(secondUsersListMock);
-// $scope.$apply('users');//change app
-//
-// expect(users.accountUsers).toEqual(secondUsersListMock);
-// });
-// });
diff --git a/ecomp-portal-widget-ms/widget-ms/pom.xml b/ecomp-portal-widget-ms/widget-ms/pom.xml
index 08659cc7..67350d28 100644
--- a/ecomp-portal-widget-ms/widget-ms/pom.xml
+++ b/ecomp-portal-widget-ms/widget-ms/pom.xml
@@ -24,6 +24,8 @@
<java.version>1.8</java.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<skipTests>true</skipTests>
+ <!-- Replicate this from OParent -->
+ <jacocoVersion>0.7.6.201602180812</jacocoVersion>
</properties>
<dependencies>
@@ -128,6 +130,13 @@
</exclusion>
</exclusions>
</dependency>
+ <!-- Jacoco offline instrumentation agent -->
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <version>${jacocoVersion}</version>
+ <classifier>runtime</classifier>
+ </dependency>
</dependencies>
<build>
@@ -150,6 +159,7 @@
<pluginManagement>
<plugins>
+ <!-- replicated from OParent -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
@@ -184,10 +194,28 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.6.201602180812</version>
+ <version>${jacocoVersion}</version>
<executions>
+ <!-- disable jacoco executions from oparent -->
+ <execution>
+ <id>pre-unit-test</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>post-unit-test</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>pre-integration-test</id>
+ <phase>none</phase>
+ </execution>
<execution>
- <id>prepare-agent</id>
+ <id>post-integration-test</id>
+ <phase>none</phase>
+ </execution>
+ <!-- Order matters -->
+ <execution>
+ <id>portal-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
@@ -195,21 +223,22 @@
<destFile>${sonar.jacoco.reportPath}</destFile>
</configuration>
</execution>
+ <!-- offline instrumentation for PowerMock -->
<execution>
- <id>default-instrument</id>
+ <id>portal-offline-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
- <id>default-restore-instrumented-classes</id>
+ <id>portal-restore-instrumented-classes</id>
<phase>test</phase>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
- <id>post-unit-test</id>
+ <id>portal-post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
@@ -219,9 +248,18 @@
<outputDirectory>${project.basedir}/target/site/jacoco</outputDirectory>
</configuration>
</execution>
-
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <jacoco-agent.destfile>${project.build.directory}/code-coverage/jacoco-ut.exec</jacoco-agent.destfile>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/StorageServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/StorageServiceImpl.java
index 8c5e0778..2f7206ea 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/StorageServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/service/impl/StorageServiceImpl.java
@@ -244,8 +244,8 @@ public class StorageServiceImpl implements StorageService {
String controllerName = "Portal" + widgetId + "Ctrl";
String cssName = "portal" + widgetId + "-css-ready";
String colorArg1 = "color: #fff";
- String framework = sb.replaceAll("ARUGMENT1", namespace).replaceAll("ARUGMENT2", controllerName)
- .replaceAll("ARUGMENT3", cssName).replaceAll("CSS_ARG1", colorArg1)
+ String framework = sb.replaceAll("ARGUMENT1", namespace).replaceAll("ARGUMENT2", controllerName)
+ .replaceAll("ARGUMENT3", cssName).replaceAll("CSS_ARG1", colorArg1)
.replaceAll("MICROSERVICE_ID", newWidget.getServiceId().toString())
.replaceAll("WIDGET_ID", Long.toString(widgetId));
@@ -350,8 +350,8 @@ public class StorageServiceImpl implements StorageService {
String controllerName = "Portal" + widgetId + "Ctrl";
String cssName = "portal" + widgetId + "-css-ready";
String colorArg1 = "color: #fff";
- String framework = sb.replaceAll("ARUGMENT1", namespace).replaceAll("ARUGMENT2", controllerName)
- .replaceAll("ARUGMENT3", cssName).replaceAll("CSS_ARG1", colorArg1)
+ String framework = sb.replaceAll("ARGUMENT1", namespace).replaceAll("ARGUMENT2", controllerName)
+ .replaceAll("ARGUMENT3", cssName).replaceAll("CSS_ARG1", colorArg1)
.replaceAll("MICROSERVICE_ID", newWidget.getServiceId().toString())
.replaceAll("WIDGET_ID", Long.toString(widgetId));
widgetFile.setFramework(framework.getBytes());
diff --git a/pom.xml b/pom.xml
index 74567657..cfd733c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
@@ -10,6 +11,7 @@
<relativePath />
</parent>
+
<groupId>org.onap.portal</groupId>
<artifactId>onap-portal-parent</artifactId>
<version>1.3.0</version>
@@ -32,15 +34,16 @@
<hibernate.version>4.3.11.Final</hibernate.version>
<fasterxml.version>2.7.4</fasterxml.version>
<eelf.version>1.0.0</eelf.version>
+ <!-- NOT provided by OParent, unfortunately -->
+ <jacocoVersion>0.7.6.201602180812</jacocoVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<encoding>UTF-8</encoding>
- <sonar.exclusions>**/scripts/**/*,**.js</sonar.exclusions>
- <sonar.test.exclusions>**/test/**/*,**/tests/**/*</sonar.test.exclusions>
+ <sonar.exclusions>**/scripts/**/*,**.js</sonar.exclusions>
+ <sonar.test.exclusions>**/test/**/*,**/tests/**/*</sonar.test.exclusions>
</properties>
<!-- Specify the repositories here to avoid coordination of ~/.m2/settings.xml
- files among all developers. Also use values (not properties) so oparent can
- be resolved. -->
+ files among developers. Use values (not properties) so oparent can be resolved. -->
<repositories>
<repository>
<id>onap-releases</id>
@@ -100,7 +103,6 @@
</plugins>
</build>
</profile>
-
</profiles>
<build>
@@ -139,14 +141,98 @@
<target>1.8</target>
</configuration>
</plugin>
+ <!-- maven-site-plugin config is provided by OParent -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>
+ <!-- Jacoco -->
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <!-- Override OParent version -->
+ <version>${jacocoVersion}</version>
+ <executions>
+ <!-- disable jacoco executions from oparent -->
+ <execution>
+ <id>pre-unit-test</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>post-unit-test</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>pre-integration-test</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>post-integration-test</id>
+ <phase>none</phase>
+ </execution>
+ <!-- Order matters -->
+ <execution>
+ <id>portal-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ </configuration>
+ </execution>
+ <!-- offline instrumentation for PowerMock -->
+ <execution>
+ <id>portal-offline-instrument</id>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>portal-restore-instrumented-classes</id>
+ <phase>test</phase>
+ <goals>
+ <goal>restore-instrumented-classes</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>portal-post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${sonar.jacoco.reportPath}</dataFile>
+ <outputDirectory>${project.basedir}/target/site/jacoco</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <jacoco-agent.destfile>${project.build.directory}/code-coverage/jacoco-ut.exec</jacoco-agent.destfile>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
<!-- No deployment step for this project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>2.8</version>
+ <!-- version managed by oparent <version>2.8</version> -->
<configuration>
<skip>true</skip>
</configuration>