summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java68
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java (renamed from ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java)18
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java66
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java51
-rw-r--r--ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java108
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java (renamed from ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java)28
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java68
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java19
-rw-r--r--ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java42
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java20
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java6
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java4
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java73
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ManifestController.java1
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileController.java4
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/AngularSinglePageController.java2
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java4
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElementModelController.java12
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java4
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java8
-rw-r--r--ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java13
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java23
-rw-r--r--ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java25
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java4
-rw-r--r--ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java20
25 files changed, 249 insertions, 442 deletions
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
index 8c191181..2c6f3ff7 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRole.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,23 +38,25 @@
package org.onap.portalsdk.external.authorization.domain;
import java.io.Serializable;
+import java.util.List;
public class ExternalAccessRole implements Serializable {
- /**
- *
- */
private static final long serialVersionUID = 3439986826362436339L;
+
public String name;
- public String description;
+ private List<ExternalAccessPerms> perms;
+ public ExternalAccessRoleDescription description;
- public ExternalAccessRole() {
+ public ExternalAccessRole() {
+ super();
}
-
- public ExternalAccessRole(String name, String description) {
+
+ public ExternalAccessRole(String name, List<ExternalAccessPerms> ecPerms, ExternalAccessRoleDescription description) {
super();
this.name = name;
+ this.perms = ecPerms;
this.description = description;
}
@@ -65,12 +67,58 @@ public class ExternalAccessRole implements Serializable {
public void setName(String name) {
this.name = name;
}
+
+ public List<ExternalAccessPerms> getPerms() {
+ return perms;
+ }
- public String getDescription() {
+ public void setPerms(List<ExternalAccessPerms> perms) {
+ this.perms = perms;
+ }
+
+ public ExternalAccessRoleDescription getDescription() {
return description;
}
- public void setDescription(String description) {
+ public void setDescription(ExternalAccessRoleDescription description) {
this.description = description;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((perms == null) ? 0 : perms.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ExternalAccessRole other = (ExternalAccessRole) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (perms == null) {
+ if (other.perms != null)
+ return false;
+ } else if (!perms.equals(other.perms))
+ return false;
+ return true;
+ }
+
}
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java
index 68effb0c..e7e18749 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescription.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescription.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -37,9 +37,7 @@
*/
package org.onap.portalsdk.external.authorization.domain;
-import java.util.List;
-
-public class ExternalRoleDescription {
+public class ExternalAccessRoleDescription {
private String id;
private String name;
@@ -47,7 +45,6 @@ public class ExternalRoleDescription {
private String priority;
private String appId;
private String appRoleId;
- private List<ExternalAccessPerms> permissions;
public String getId() {
return id;
@@ -85,13 +82,6 @@ public class ExternalRoleDescription {
public void setAppRoleId(String appRoleId) {
this.appRoleId = appRoleId;
}
-
- public List<ExternalAccessPerms> getPermissions() {
- return permissions;
- }
- public void setPermissions(List<ExternalAccessPerms> permissions) {
- this.permissions = permissions;
- }
@Override
public int hashCode() {
final int prime = 31;
@@ -112,7 +102,7 @@ public class ExternalRoleDescription {
return false;
if (getClass() != obj.getClass())
return false;
- ExternalRoleDescription other = (ExternalRoleDescription) obj;
+ ExternalAccessRoleDescription other = (ExternalAccessRoleDescription) obj;
if (active == null) {
if (other.active != null)
return false;
@@ -146,5 +136,7 @@ public class ExternalRoleDescription {
return true;
}
+
+
}
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java
deleted file mode 100644
index 95b4f0c4..00000000
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePerms.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal SDK
- * ===================================================================
- * Copyright (C) 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============================================
- *
- *
- */
-package org.onap.portalsdk.external.authorization.domain;
-
-public class ExternalAccessRolePerms {
-
- private ExternalAccessPerms perm;
- private String role;
-
-
- public ExternalAccessRolePerms(ExternalAccessPerms perm, String role) {
- super();
- this.perm = perm;
- this.role = role;
- }
-
- public ExternalAccessPerms getPerm() {
- return perm;
- }
- public void setPerm(ExternalAccessPerms perm) {
- this.perm = perm;
- }
- public String getRole() {
- return role;
- }
- public void setRole(String role) {
- this.role = role;
- }
-
-
-}
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
index 929bd351..5e189e5c 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetail.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -39,42 +39,30 @@ package org.onap.portalsdk.external.authorization.domain;
public class ExternalAccessUserRoleDetail {
- private String name;
- private ExternalRoleDescription description;
-
+ private ExternalAccessRole role;
+
+ public ExternalAccessRole getRole() {
+ return role;
+ }
+
+ public void setRole(ExternalAccessRole role) {
+ this.role = role;
+ }
- /**
- *
- */
public ExternalAccessUserRoleDetail() {
super();
- }
+ }
- public ExternalAccessUserRoleDetail(String name, ExternalRoleDescription description) {
+ public ExternalAccessUserRoleDetail(ExternalAccessRole role) {
super();
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public ExternalRoleDescription getDescription() {
- return description;
- }
- public void setDescription(ExternalRoleDescription description) {
- this.description = description;
+ this.role = role;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((role == null) ? 0 : role.hashCode());
return result;
}
@@ -87,15 +75,10 @@ public class ExternalAccessUserRoleDetail {
if (getClass() != obj.getClass())
return false;
ExternalAccessUserRoleDetail other = (ExternalAccessUserRoleDetail) obj;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (name == null) {
- if (other.name != null)
+ if (role == null) {
+ if (other.role != null)
return false;
- } else if (!name.equals(other.name))
+ } else if (!role.equals(other.role))
return false;
return true;
}
diff --git a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
index 3eac97b5..14d8a5e2 100644
--- a/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-aaf/src/main/java/org/onap/portalsdk/external/authorization/service/UserApiServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -61,8 +61,9 @@ import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.service.LdapService;
import org.onap.portalsdk.core.service.PostSearchService;
import org.onap.portalsdk.external.authorization.domain.ExternalAccessPerms;
+import org.onap.portalsdk.external.authorization.domain.ExternalAccessRole;
+import org.onap.portalsdk.external.authorization.domain.ExternalAccessRoleDescription;
import org.onap.portalsdk.external.authorization.domain.ExternalAccessUserRoleDetail;
-import org.onap.portalsdk.external.authorization.domain.ExternalRoleDescription;
import org.onap.portalsdk.external.authorization.exception.UserNotFoundException;
import org.onap.portalsdk.external.authorization.util.EcompExternalAuthProperties;
import org.onap.portalsdk.external.authorization.util.EcompExternalAuthUtils;
@@ -133,7 +134,7 @@ public class UserApiServiceImpl implements UserApiService {
}
String userRoles = getResponse.getBody();
ObjectMapper mapper = new ObjectMapper();
- List<ExternalAccessUserRoleDetail> userRoleDetailList = setExterbalAccessUserRoles(namespace, userRoles,
+ List<ExternalAccessUserRoleDetail> userRoleDetailList = setExternalAccessUserRoles(namespace, userRoles,
mapper);
if (userRoleDetailList.isEmpty()) {
@@ -148,7 +149,7 @@ public class UserApiServiceImpl implements UserApiService {
}
- private List<ExternalAccessUserRoleDetail> setExterbalAccessUserRoles(String namespace, String userRoles,
+ private List<ExternalAccessUserRoleDetail> setExternalAccessUserRoles(String namespace, String userRoles,
ObjectMapper mapper) throws IOException, JsonParseException, JsonMappingException, UserNotFoundException {
JSONObject userJsonObj;
JSONArray userJsonArray;
@@ -163,20 +164,21 @@ public class UserApiServiceImpl implements UserApiService {
.endsWith(EcompExternalAuthUtils.EXT_ROLE_FIELD_ADMIN)
&& !role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME)
.endsWith(EcompExternalAuthUtils.EXT_ROLE_FIELD_OWNER)) {
- ExternalRoleDescription desc = new ExternalRoleDescription();
+ ExternalAccessRoleDescription ecDesc = new ExternalAccessRoleDescription();
if (role.has(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION) && EcompExternalAuthUtils
.isJSONValid(role.getString(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION))) {
- desc = mapper.readValue(role.getString(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION),
- ExternalRoleDescription.class);
+ ecDesc = mapper.readValue(role.getString(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION),
+ ExternalAccessRoleDescription.class);
}
+ List<ExternalAccessPerms> ecPerms = new ArrayList<>();
if (role.has(EcompExternalAuthUtils.EXT_FIELD_PERMS)) {
JSONArray perms = role.getJSONArray(EcompExternalAuthUtils.EXT_FIELD_PERMS);
- List<ExternalAccessPerms> permsList = mapper.readValue(perms.toString(), TypeFactory
- .defaultInstance().constructCollectionType(List.class, ExternalAccessPerms.class));
- desc.setPermissions(permsList);
+ ecPerms = mapper.readValue(perms.toString(), TypeFactory.defaultInstance()
+ .constructCollectionType(List.class, ExternalAccessPerms.class));
}
- userRoleDetail = new ExternalAccessUserRoleDetail(
- role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME), desc);
+ ExternalAccessRole ecRole = new ExternalAccessRole(
+ role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME), ecPerms, ecDesc);
+ userRoleDetail = new ExternalAccessUserRoleDetail(ecRole);
userRoleDetailList.add(userRoleDetail);
}
}
@@ -216,47 +218,31 @@ public class UserApiServiceImpl implements UserApiService {
App app) {
Set userApps = new TreeSet();
for (ExternalAccessUserRoleDetail userRoleDetail : userRoleDetailList) {
- ExternalRoleDescription roleDesc = userRoleDetail.getDescription();
+ ExternalAccessRole ecRole = userRoleDetail.getRole();
+ ExternalAccessRoleDescription roleDesc = ecRole.getDescription();
UserApp userApp = new UserApp();
Role role = new Role();
Set roleFunctions = new TreeSet<>();
- if (roleDesc != null) {
- if (roleDesc.getName() == null) {
- role.setActive(true);
- role.setName(userRoleDetail.getName());
- } else {
- role.setActive(Boolean.valueOf(roleDesc.getActive()));
- role.setId(Long.valueOf(roleDesc.getAppRoleId()));
- role.setName(roleDesc.getName());
- if (!roleDesc.getPriority().equals(EcompExternalAuthUtils.EXT_NULL_VALUE)) {
- role.setPriority(Integer.valueOf(roleDesc.getPriority()));
- }
+ if (roleDesc.getName() == null) {
+ role.setActive(true);
+ role.setName(ecRole.getName());
+ } else {
+ role.setActive(Boolean.valueOf(roleDesc.getActive()));
+ role.setId(Long.valueOf(roleDesc.getAppRoleId()));
+ role.setName(roleDesc.getName());
+ if (!roleDesc.getPriority().equals(EcompExternalAuthUtils.EXT_NULL_VALUE)) {
+ role.setPriority(Integer.valueOf(roleDesc.getPriority()));
}
- if (roleDesc.getPermissions() != null) {
- for (ExternalAccessPerms extPerm : roleDesc.getPermissions()) {
- RoleFunction roleFunction = new RoleFunction();
- roleFunction.setCode(extPerm.getInstance());
- roleFunction.setAction(extPerm.getAction());
- if (extPerm.getDescription() != null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getDescription());
- } else if (extPerm.getDescription() == null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|"
- + extPerm.getInstance() + "|" + extPerm.getAction());
- } else if (extPerm.getDescription() == null
- && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(
- extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction());
- }
- if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setType(extPerm.getType().substring(namespace.length() + 1));
- } else {
- roleFunction.setType(extPerm.getType());
- }
- roleFunctions.add(roleFunction);
- }
+ }
+ for (ExternalAccessPerms extPerm : ecRole.getPerms()) {
+ RoleFunction roleFunction = new RoleFunction();
+ roleFunction.setCode(extPerm.getInstance());
+ roleFunction.setAction(extPerm.getAction());
+ if (extPerm.getDescription() != null) {
+ roleFunction.setName(extPerm.getDescription());
}
+ roleFunction.setType(extPerm.getType());
+ roleFunctions.add(roleFunction);
}
role.setRoleFunctions(roleFunctions);
userApp.setApp(app);
@@ -336,22 +322,10 @@ public class UserApiServiceImpl implements UserApiService {
RoleFunction roleFunction = new RoleFunction();
roleFunction.setCode(extPerm.getInstance());
roleFunction.setAction(extPerm.getAction());
- if (extPerm.getDescription() != null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
+ if (extPerm.getDescription() != null) {
roleFunction.setName(extPerm.getDescription());
- } else if (extPerm.getDescription() == null
- && EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getType().substring(namespace.length() + 1) + "|" + extPerm.getInstance()
- + "|" + extPerm.getAction());
- } else if (extPerm.getDescription() == null
- && !EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setName(extPerm.getType() + "|" + extPerm.getInstance() + "|" + extPerm.getAction());
- }
- if (EcompExternalAuthUtils.checkNameSpaceMatching(extPerm.getType(), namespace)) {
- roleFunction.setType(extPerm.getType().substring(namespace.length() + 1));
- } else {
- roleFunction.setType(extPerm.getType());
}
+ roleFunction.setType(extPerm.getType());
roleFunctions.add(roleFunction);
}
return roleFunctions;
@@ -377,9 +351,9 @@ public class UserApiServiceImpl implements UserApiService {
HttpEntity<String> entity = new HttpEntity<>(credentials.toString(), headers);
logger.debug(EELFLoggerDelegate.debugLogger, "checkUserExists: Connecting to external auth system for user {}",
username);
- ResponseEntity<String> getResponse = template.exchange(EcompExternalAuthProperties
- .getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_URL)
- + EXTERNAL_AUTH_POST_CREDENTIALS_ENDPOINT, HttpMethod.POST, entity, String.class);
+ ResponseEntity<String> getResponse = template
+ .exchange(EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_URL)
+ + EXTERNAL_AUTH_POST_CREDENTIALS_ENDPOINT, HttpMethod.POST, entity, String.class);
if (getResponse.getStatusCode().value() == 200) {
logger.debug(EELFLoggerDelegate.debugLogger,
"checkUserExists: Finished POST from external auth system to validate credentials and status: {}",
@@ -390,8 +364,8 @@ public class UserApiServiceImpl implements UserApiService {
private String changeIfUserDomainNotAppended(String username) {
if (!EcompExternalAuthUtils.validate(username)) {
- username = username + EcompExternalAuthProperties
- .getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_DOMAIN);
+ username = username
+ + EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_USER_DOMAIN);
}
return username;
}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java
index 251f8303..9e7970b2 100644
--- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalRoleDescriptionTest.java
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleDescriptionTest.java
@@ -39,48 +39,29 @@ package org.onap.portalsdk.external.authorization.domain;
import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.List;
-
import org.junit.Test;
-public class ExternalRoleDescriptionTest {
+public class ExternalAccessRoleDescriptionTest {
- public ExternalRoleDescription mockExternalRoleDescriptionTest() {
- List<ExternalAccessPerms> mockPerms = new ArrayList<>();
- ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
- mockExtPermsTest.setAction("*");
- mockExtPermsTest.setDescription("test_name");
- mockExtPermsTest.setType("test_type");
- mockExtPermsTest.setInstance("test_instance");
- mockPerms.add(mockExtPermsTest);
- ExternalRoleDescription mockExtRoleDesc = new ExternalRoleDescription();
+ public ExternalAccessRoleDescription mockExternalRoleDescriptionTest() {
+ ExternalAccessRoleDescription mockExtRoleDesc = new ExternalAccessRoleDescription();
mockExtRoleDesc.setActive("true");
mockExtRoleDesc.setAppRoleId("1");
mockExtRoleDesc.setAppId("1");
mockExtRoleDesc.setId("1");
mockExtRoleDesc.setName("test");
- mockExtRoleDesc.setPermissions(mockPerms);
mockExtRoleDesc.setPriority("1");
return mockExtRoleDesc;
}
@Test
public void externalRoleDescriptionTest() {
- List<ExternalAccessPerms> perms = new ArrayList<>();
- ExternalAccessPerms extPermsTest = new ExternalAccessPerms();
- extPermsTest.setAction("*");
- extPermsTest.setDescription("test_name");
- extPermsTest.setType("test_type");
- extPermsTest.setInstance("test_instance");
- perms.add(extPermsTest);
- ExternalRoleDescription extRoleDesc = new ExternalRoleDescription();
+ ExternalAccessRoleDescription extRoleDesc = new ExternalAccessRoleDescription();
extRoleDesc.setActive("true");
extRoleDesc.setAppRoleId("1");
extRoleDesc.setAppId("1");
extRoleDesc.setId("1");
extRoleDesc.setName("test");
- extRoleDesc.setPermissions(perms);
extRoleDesc.setPriority("1");
assertEquals(extRoleDesc.getActive(), mockExternalRoleDescriptionTest().getActive());
assertEquals(extRoleDesc.getAppId(), mockExternalRoleDescriptionTest().getAppId());
@@ -88,7 +69,6 @@ public class ExternalRoleDescriptionTest {
assertEquals(extRoleDesc.getId(), mockExternalRoleDescriptionTest().getId());
assertEquals(extRoleDesc.getName(), mockExternalRoleDescriptionTest().getName());
assertEquals(extRoleDesc.getPriority(), mockExternalRoleDescriptionTest().getPriority());
- assertEquals(extRoleDesc.getPermissions(), mockExternalRoleDescriptionTest().getPermissions());
assertEquals(true, extRoleDesc.equals(mockExternalRoleDescriptionTest()));
}
}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java
deleted file mode 100644
index acb14c65..00000000
--- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRolePermsTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal SDK
- * ===================================================================
- * Copyright (C) 2018 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============================================
- *
- *
- */
-package org.onap.portalsdk.external.authorization.domain;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class ExternalAccessRolePermsTest {
-
- public ExternalAccessRolePerms mockExternalAccessRolePermsTest() {
- ExternalAccessPerms mockPerm = new ExternalAccessPerms();
- mockPerm.setAction("*");
- mockPerm.setDescription("test_name");
- mockPerm.setType("test_type");
- mockPerm.setInstance("test_instance");
- ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(mockPerm, "test_role");
- return mockExtRolePermsTest;
- }
-
- @Test
- public void externalAccessRolePermsTest() {
- ExternalAccessPerms perm = new ExternalAccessPerms();
- perm.setAction("*");
- perm.setDescription("test_name");
- perm.setType("test_type");
- perm.setInstance("test_instance");
- ExternalAccessRolePerms mockExtRolePermsTest = new ExternalAccessRolePerms(perm, "test_role");
- assertEquals(mockExtRolePermsTest.getRole(), mockExternalAccessRolePermsTest().getRole());
- assertEquals(mockExtRolePermsTest.getPerm(), mockExternalAccessRolePermsTest().getPerm());
- }
-
-}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java
index aa498aa0..3fc5ae86 100644
--- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessRoleTest.java
@@ -39,21 +39,36 @@ package org.onap.portalsdk.external.authorization.domain;
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Test;
public class ExternalAccessRoleTest {
public ExternalAccessRole mockExternalAccessRoleTest() {
ExternalAccessRole mockRole = new ExternalAccessRole();
+ ExternalAccessRoleDescription roleDesc = new ExternalAccessRoleDescription();
+ ExternalAccessPerms ecPerm = new ExternalAccessPerms();
+ List<ExternalAccessPerms> ecPerms = new ArrayList<>();
+ ecPerm.setAction("test_action");
+ ecPerm.setType("test_type");
+ ecPerm.setInstance("test_instance");
+ ecPerm.setDescription("test_description");
+ roleDesc.setActive("true");
+ roleDesc.setAppId("1");
mockRole.setName("test_role");
- mockRole.setDescription("test_role_description");
+ mockRole.setPerms(ecPerms);
+ mockRole.setDescription(roleDesc);
return mockRole;
}
@Test
public void externalAccessRolePermsTest() {
- ExternalAccessRole role = new ExternalAccessRole("test_role", "test_role_description");
+ ExternalAccessRole mockRole = mockExternalAccessRoleTest();
+ ExternalAccessRole role = new ExternalAccessRole(mockRole.getName(), mockRole.getPerms(), mockRole.getDescription());
assertEquals(role.getName(), mockExternalAccessRoleTest().getName());
+ assertEquals(role.getPerms(), mockExternalAccessRoleTest().getPerms());
assertEquals(role.getDescription(), mockExternalAccessRoleTest().getDescription());
}
}
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java
index 5e750543..9d20e02c 100644
--- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java
+++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessUserRoleDetailTest.java
@@ -47,6 +47,7 @@ import org.junit.Test;
public class ExternalAccessUserRoleDetailTest {
public ExternalAccessUserRoleDetail mockExternalAccessUserRoleDetailTest() {
+ ExternalAccessRole role = new ExternalAccessRole();
List<ExternalAccessPerms> mockPerms = new ArrayList<>();
ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms();
mockExtPermsTest.setAction("*");
@@ -54,46 +55,27 @@ public class ExternalAccessUserRoleDetailTest {
mockExtPermsTest.setType("test_type");
mockExtPermsTest.setInstance("test_instance");
mockPerms.add(mockExtPermsTest);
- ExternalRoleDescription mockRoleDesc = new ExternalRoleDescription();
+ ExternalAccessRoleDescription mockRoleDesc = new ExternalAccessRoleDescription();
mockRoleDesc.setActive("true");
mockRoleDesc.setAppId("1");
mockRoleDesc.setAppRoleId("1");
mockRoleDesc.setId("1");
mockRoleDesc.setPriority("1");
mockRoleDesc.setName("test");
- mockRoleDesc.setPermissions(mockPerms);
- ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail();
- mockExtUserRoleDetailTest.setName("test");
- mockExtUserRoleDetailTest.setDescription(mockRoleDesc);
+ mockRoleDesc.setName("com.test.app.rolename");
+ role.setPerms(mockPerms);
+ role.setDescription(mockRoleDesc);
+ ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail(role);
return mockExtUserRoleDetailTest;
}
@Test
public void externalAccessPermsTest() {
- List<ExternalAccessPerms> perms = new ArrayList<>();
- ExternalAccessPerms extPermsTest = new ExternalAccessPerms();
- extPermsTest.setAction("*");
- extPermsTest.setDescription("test_name");
- extPermsTest.setType("test_type");
- extPermsTest.setInstance("test_instance");
- perms.add(extPermsTest);
- ExternalRoleDescription roleDesc = new ExternalRoleDescription();
- roleDesc.setActive("true");
- roleDesc.setAppId("1");
- roleDesc.setAppRoleId("1");
- roleDesc.setId("1");
- roleDesc.setPriority("1");
- roleDesc.setName("test");
- roleDesc.setPermissions(perms);
- ExternalAccessUserRoleDetail extUserRoleDetailTest = new ExternalAccessUserRoleDetail();
- extUserRoleDetailTest.setName("test");
- extUserRoleDetailTest.setDescription(roleDesc);
- ExternalAccessUserRoleDetail extUserRoleDetailTest2 = new ExternalAccessUserRoleDetail("test", roleDesc);
- assertEquals(extUserRoleDetailTest.getName(), mockExternalAccessUserRoleDetailTest().getName());
- assertEquals(extUserRoleDetailTest.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
- assertEquals(extUserRoleDetailTest2.getName(), mockExternalAccessUserRoleDetailTest().getName());
- assertEquals(extUserRoleDetailTest2.getDescription(), mockExternalAccessUserRoleDetailTest().getDescription());
- assertEquals(true, new ExternalAccessUserRoleDetail("test",roleDesc)
- .equals(new ExternalAccessUserRoleDetail("test",roleDesc)));
+ ExternalAccessUserRoleDetail extUserRoleDetailTest2 = mockExternalAccessUserRoleDetailTest();
+ ExternalAccessRole role = extUserRoleDetailTest2.getRole();
+ assertEquals(role.getName(), mockExternalAccessUserRoleDetailTest().getRole().getName());
+ assertEquals(role.getPerms(), mockExternalAccessUserRoleDetailTest().getRole().getPerms());
+ assertEquals(role.getDescription(), mockExternalAccessUserRoleDetailTest().getRole().getDescription());
+
}
}
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
index d87a5b13..e976f144 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java
@@ -1995,11 +1995,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
String insertQry = Globals.getDownloadAllInsert();
- Connection connection = null;
- PreparedStatement pst = null;
- try {
- connection = DbUtils.getConnection();
- pst = connection.prepareStatement(insertQry);
+ try(Connection connection = DbUtils.getConnection();
+ PreparedStatement pst = connection.prepareStatement(insertQry)){
if(nvl(emailId).length()>0){
pst.setInt(1, Integer.parseInt(userId));
pst.setInt(2, Integer.parseInt(rr.getReportID()));
@@ -2019,8 +2016,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
connection.commit();
}
}
- pst.close();
- connection.close();
logger.debug(EELFLoggerDelegate.debugLogger, ("Data inserted"));
} catch (SQLException ex) {
throw new RaptorException(ex);
@@ -2028,16 +2023,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject {
throw new RaptorException(ex);
} catch (Exception ex) {
throw new RaptorException (ex);
- } finally {
- try {
- if(connection!=null)
- connection.close();
- if(pst!=null)
- pst.close();
- } catch (SQLException ex) {
- throw new RaptorException(ex);
- }
- }
+ }
//DbUtils.commitTransaction(connection);
//DbUtils.clearConnection(connection);
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java
index d68c9855..eee04045 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/gmap/line/LineCollection.java
@@ -47,8 +47,8 @@ public class LineCollection {
private ArrayList<LineInfo> lineCollection;
public LineCollection() {
- lineCollection = new ArrayList<LineInfo>(20000);
- selectedLine = new HashSet<String>();
+ lineCollection = new ArrayList<>(20000);
+ selectedLine = new HashSet<>();
}
public void addSelectedLine(String lineID) {
@@ -157,7 +157,7 @@ public class LineCollection {
}
public String[] getWildCardLine(String lineID) {
- ArrayList<String> list = new ArrayList<String>();
+ ArrayList<String> list = new ArrayList<>();
for (LineInfo lineInfo : lineCollection) {
if (lineInfo.getLineID().toLowerCase().indexOf(lineID.toLowerCase()) != -1) {
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java
index ec83ffbf..60c45b4f 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java
@@ -3179,10 +3179,8 @@ public class ChartD3Helper {
}
}
- try {
- BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"));
+ try(BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"))) {
out.write(wholeScript.toString());
- out.close();
} catch (IOException e) {
e.printStackTrace();
System.out.println("Exception ");
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java
index 12355573..b5390c92 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java
@@ -73,17 +73,18 @@ public class ExtractJar {
* @throws Exception
*/
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("org/onap/portalsdk/analytics/config/")) {
- System.out.println(je.getName() + " " + je.getTime());
-
+ try(JarInputStream in = new JarInputStream(new FileInputStream(jarFile)))
+ {
+ JarEntry je;
+ while ((je = in.getNextJarEntry()) != null) {
+ if (je.isDirectory() == false) {
+ if (je.getName().startsWith("org/onap/portalsdk/analytics/config/")) {
+ System.out.println(je.getName() + " " + je.getTime());
+
+ }
}
}
}
- in.close();
}
/**
@@ -95,37 +96,37 @@ public class ExtractJar {
Class clazz = ExtractJar.class;
URL jarUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
- JarInputStream entryStream = new JarInputStream(jarUrl.openStream());
- JarEntry entry;
-
- while (true) {
- entry = entryStream.getNextJarEntry();
- if (entry == null)
- break;
- if (entry.getName().indexOf("jarutil") < 0) {
- System.out.println(entry.getName());
- File file = new File(directory, entry.getName());
- if (entry.isDirectory()) {
- if (!file.exists())
- file.mkdirs();
- } else {
- File dir = new File(file.getParent());
- if (!dir.exists())
- dir.mkdirs();
- if (file.exists())
- file.delete();
- FileOutputStream fout = new FileOutputStream(file);
- copy(entryStream, fout);
- fout.close();
-
- if (entry.getTime() >= 0)
- file.setLastModified(entry.getTime());
+ try(JarInputStream entryStream = new JarInputStream(jarUrl.openStream())){
+ JarEntry entry;
+
+ while (true) {
+ entry = entryStream.getNextJarEntry();
+ if (entry == null)
+ break;
+ if (entry.getName().indexOf("jarutil") < 0) {
+ System.out.println(entry.getName());
+ File file = new File(directory, entry.getName());
+ if (entry.isDirectory()) {
+ if (!file.exists())
+ file.mkdirs();
+ } else {
+ File dir = new File(file.getParent());
+ if (!dir.exists())
+ dir.mkdirs();
+ if (file.exists())
+ file.delete();
+ try(FileOutputStream fout = new FileOutputStream(file)){
+ copy(entryStream, fout);
+ }
+
+ if (entry.getTime() >= 0)
+ file.setLastModified(entry.getTime());
+ }
+
}
-
+ entryStream.closeEntry();
}
- entryStream.closeEntry();
}
- entryStream.close();
System.out.println("/WEB-INF/classes/org/onap/portalsdk/analytics");
System.out.println("Delete .... ");
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ManifestController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ManifestController.java
index 65964fe5..0fd3cfbb 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ManifestController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ManifestController.java
@@ -45,7 +45,6 @@ import java.util.jar.Attributes;
import java.util.jar.Manifest;
import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileController.java
index 74c18850..c7edfb81 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileController.java
@@ -88,7 +88,7 @@ public class ProfileController extends RestrictedBaseController {
@RequestMapping(value = { "/profile" }, method = RequestMethod.GET)
public ModelAndView profile(HttpServletRequest request) throws IOException {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
User user = UserUtils.getUserSession(request);
@@ -138,7 +138,7 @@ public class ProfileController extends RestrictedBaseController {
@RequestMapping(value = { "/get_self_profile" }, method = RequestMethod.GET)
public void getSelfProfile(HttpServletRequest request, HttpServletResponse response) {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
User user = UserUtils.getUserSession(request);
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/AngularSinglePageController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/AngularSinglePageController.java
index b5d78768..96b602c3 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/AngularSinglePageController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/AngularSinglePageController.java
@@ -59,7 +59,7 @@ public class AngularSinglePageController extends RestrictedBaseController {
@RequestMapping(value = { "/singlePageSample" }, method = RequestMethod.GET)
public ModelAndView view(HttpServletRequest request) {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
return new ModelAndView("single_page_sample", "model", model);
}
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
index ec300780..ba90f46f 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
@@ -73,7 +73,7 @@ public class BroadcastController extends RestrictedBaseController {
@RequestMapping(value = { "/broadcast" }, method = RequestMethod.GET)
public ModelAndView broadcast(HttpServletRequest request) {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
try {
@@ -87,7 +87,7 @@ public class BroadcastController extends RestrictedBaseController {
@RequestMapping(value = { "/get_broadcast" }, method = RequestMethod.GET)
public void getBroadcast(HttpServletRequest request, HttpServletResponse response) {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
try {
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElementModelController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElementModelController.java
index 361a4187..9588a7e4 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElementModelController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElementModelController.java
@@ -89,18 +89,6 @@ public class ElementModelController extends RestrictedBaseController {
return yamlString;
}
- /*
- public ModelAndView callflowAdditional(HttpServletRequest request, HttpServletResponse response) throws Exception {
- Map<String, Object> model = new HashMap<String, Object>();
- String callFlowName = request.getParameter("callFlowName");
- String callFlowStep = request.getParameter("callFlowStep");
-
- ElementLinkService main = new ElementLinkService();
- String yamlString = main.main2(new String[] { callFlowName, callFlowStep });
- model.put("output_string", yamlString);
- return new ModelAndView("data_out", "model", model);
- }
- */
}
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java
index fb0338ea..43d548f9 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java
@@ -75,7 +75,7 @@ public class PostDroolsController extends RestrictedBaseController {
@RequestMapping(value = { "/getDrools" }, method = RequestMethod.GET)
public void getDrools(HttpServletRequest request, HttpServletResponse response) {
- // Map<String, Object> model = new HashMap<String, Object>();
+
ObjectMapper mapper = new ObjectMapper();
try {
@@ -97,7 +97,6 @@ public class PostDroolsController extends RestrictedBaseController {
PostDroolsBean postDroolsBean = new PostDroolsBean();
String selectedFile = request.getParameter("selectedFile");
postDroolsBean.setDroolsFile(selectedFile);// sample populated
- // postDroolsBean.setSelectedRules("[\"NJ\",\"NY\",\"KY\"]");
postDroolsBean.setClassName(postDroolsService.retrieveClass(selectedFile));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(postDroolsBean));
@@ -126,7 +125,6 @@ public class PostDroolsController extends RestrictedBaseController {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- // String responseString = mapper.writeValueAsString(resultsString);
JSONObject j = new JSONObject("{resultsString: " + resultsString + "}");
out.write(j.toString());
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
index 871a3750..966eb8f2 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java
@@ -279,7 +279,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
}
else {
List<User> users = userProfileService.findAllActive();
- List<EcompUser> ecompUsers = new ArrayList<EcompUser>();
+ List<EcompUser> ecompUsers = new ArrayList<>();
for (User user : users)
ecompUsers.add(UserUtils.convertToEcompUser(user));
return ecompUsers;
@@ -299,7 +299,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException {
try {
List<Role> roles = roleService.getActiveRoles(requestedLoginId);
- List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
+ List<EcompRole> ecompRoles = new ArrayList<>();
for (Role role : roles)
ecompRoles.add(UserUtils.convertToEcompRole(role));
return ecompRoles;
@@ -323,7 +323,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
* TypeFactory.defaultInstance().constructCollectionType(List.class,
* EcompRole.class));
*/
- SortedSet<Role> roles = new TreeSet<Role>();
+ SortedSet<Role> roles = new TreeSet<>();
for (EcompRole role : rolesJson) {
roles.add(roleService.getRole(loginId,role.getId()));
}
@@ -357,7 +357,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR
public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException {
if (logger.isDebugEnabled())
logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId);
- List<EcompRole> ecompRoles = new ArrayList<EcompRole>();
+ List<EcompRole> ecompRoles = new ArrayList<>();
try {
if (isCentralized.equals(isAccessCentralized)) {
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
index 6ddcbcfb..989394d6 100644
--- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
+++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -264,6 +264,8 @@ public class OnBoardingApiServiceImplTest {
@Test
public void pushUserRoleTest() throws Exception {
String loginId = "123";
+ App app = new App();
+ app.setId(1l);
List<EcompRole> rolesJson = new ArrayList<>();
EcompRole role1 = new EcompRole();
role1.setId(123L);
@@ -274,12 +276,13 @@ public class OnBoardingApiServiceImplTest {
Role role = new Role();
role.setId(123L);
userApp.setRole(role);
+ userApp.setApp(app);
UserApp userApp2 = new UserApp();
Role role2 = new Role();
role2.setId(124L);
userApp2.setRole(role2);
-
+ userApp2.setApp(app);
userApps.add(userApp);
userApps.add(userApp2);
User user = new User();
@@ -292,9 +295,10 @@ public class OnBoardingApiServiceImplTest {
Assert.assertTrue(true);
}
- @Test(expected = PortalAPIException.class)
+ @Test
public void pushUserRoleExceptionTest() throws Exception {
String loginId = "123";
+ App app = new App();
List<EcompRole> rolesJson = new ArrayList<>();
EcompRole role1 = new EcompRole();
role1.setId(123L);
@@ -304,7 +308,8 @@ public class OnBoardingApiServiceImplTest {
UserApp userApp = new UserApp();
Role role = new Role();
role.setId(123L);
-
+ userApp.setApp(app);
+ userApp.setRole(role);
userApps.add(userApp);
User user = new User();
user.setUserApps(userApps);
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
index 43cac076..d2d35ef5 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RoleServiceImpl.java
@@ -38,6 +38,7 @@
package org.onap.portalsdk.core.service;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Iterator;
@@ -166,24 +167,14 @@ public class RoleServiceImpl implements RoleService {
@Override
public void deleteDependcyRoleRecord(String loginId, Long id) {
- Connection conn = null;
- Statement stmt = null;
- try {
- conn = getDataSource().getConnection();
- stmt = conn.createStatement();
- String sql = "delete from fn_user_role where role_id = '" + id + "'";
- stmt.executeUpdate(sql);
+
+ String sql = "delete from fn_user_role where role_id =?";
+ try( Connection conn = getDataSource().getConnection();PreparedStatement pstmt = conn.prepareStatement(sql)) {
+ pstmt.setLong(1, id);
+ pstmt.executeUpdate(sql);
+
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord failed", e);
- } finally {
- try {
- if (stmt != null)
- stmt.close();
- if (conn != null)
- conn.close();
- } catch (SQLException se) {
- logger.error(EELFLoggerDelegate.errorLogger, "deleteDependcyRoleRecord failed to close", se);
- }
}
}
diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
index 4eebb02f..aff5b1f1 100644
--- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
+++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/UserApp.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -91,33 +91,26 @@ public class UserApp implements java.io.Serializable, Comparable {
return (this.getUserId().equals(castOther.getUserId()))
&& (this.getApp().getId().equals(castOther.getApp().getId()))
- && (this.getRole().getId().equals(castOther.getRole().getId()))
+ && (this.getRole().getId() != null ? this.getRole().getId().equals(castOther.getRole().getId()) : this.getRole().getName().equals(castOther.getRole().getName()))
&& ((this.priority == null && castOther.getPriority() == null)
|| this.getPriority().equals(castOther.getPriority()));
}
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + (int) (this.getUserId() == null ? 0 : this.getUserId().intValue());
- result = 37 * result + (int) (this.getApp().getId() == null ? 0 : this.getApp().getId().intValue());
- result = 37 * result + (int) (this.getRole().getId() == null ? 0 : this.getRole().getId().intValue());
+ Long result = 17l;
+ result = 37 * result + (int) (this.getUserId() == null ? 0 : this.getUserId().hashCode());
+ result = 37 * result + (int) (this.getApp().getId() == null ? 0 : this.getApp().getId().hashCode());
+ result = 37 * result + (int) (this.getRole().getId() == null ? (this.getRole().getName() == null ? 0 : this.getRole().getName().hashCode() ) : this.getRole().getId().hashCode());
result = 37 * result + (int) (this.priority == null ? 0 : this.priority);
- return result;
+ return Long.hashCode(result);
}
@Override
public int compareTo(Object other) {
UserApp castOther = (UserApp) other;
- Long c1 = (this.getUserId() == null ? 0 : this.getUserId())
- + (this.getApp() == null || this.getApp().getId() == null ? 0 : this.getApp().getId())
- + (this.getRole() == null || this.getRole().getId() == null ? 0 : this.getRole().getId())
- + (this.priority == null ? 0 : this.priority);
- Long c2 = (castOther.getUserId() == null ? 0 : castOther.getUserId())
- + (castOther.getApp() == null || castOther.getApp().getId() == null ? 0 : castOther.getApp().getId())
- + (castOther.getRole() == null || castOther.getRole().getId() == null ? 0 : castOther.getRole().getId())
- + (castOther.priority == null ? 0 : castOther.priority);
- return c1.compareTo(c2);
+ int c1 = this.hashCode() - castOther.hashCode();
+ return c1;
}
}
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
index 2433d93b..288b5a21 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserAppTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -66,7 +66,7 @@ public class UserAppTest {
UserApp userapp2 = mockUserApp();
userapp2.setUserId((long) 2);
assertNull(userapp1.getPriority());
- assertEquals(userapp2.compareTo(userapp1), 1);
+ assertEquals(userapp2.compareTo(userapp1), 50653);
assertNotNull(userapp1.hashCode());
userapp2.setUserId((long) 1);
assertTrue(userapp1.equals(userapp2));
diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
index 598ee900..b4fb2ced 100644
--- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
+++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/UserTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal SDK
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -37,17 +37,15 @@
*/
package org.onap.portalsdk.core.domain;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.junit.Test;
-import org.onap.portalsdk.core.domain.App;
-import org.onap.portalsdk.core.domain.Role;
-import org.onap.portalsdk.core.domain.User;
-import org.onap.portalsdk.core.domain.UserApp;
public class UserTest {
@@ -165,8 +163,14 @@ public class UserTest {
public void addAppRolesIfRolesNullTest()
{
User user = mockUser();
+ App appTest = new App();
+ appTest.setId(1l);
+ SortedSet<Role> roles = new TreeSet<>();
Set userApps = new TreeSet();
UserApp userapp = new UserApp();
+ userapp.setApp(appTest);
+ userapp.setRole(new Role());
+ user.setRoles(roles);
userApps.add(userapp);
user.setUserApps(userApps);
user.setUserApps(userApps);
@@ -195,11 +199,15 @@ public class UserTest {
User user = mockUser();
Set userApps = new TreeSet();
UserApp userapp = new UserApp();
+ App app = new App();
+ app.setId(1l);
SortedSet<Role> roles = new TreeSet();
Role role = new Role();
role.setId((long) 1);
+ role.setName("test");
roles.add(role);
userapp.setRole(role);
+ userapp.setApp(app);
userApps.add(userapp);
user.setUserApps(userApps);
user.removeRole((long) 1);