aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-06-24 12:14:57 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-07-05 09:56:53 +0000
commit00875f083ffd56b2b861c147c5ef0fe928b77202 (patch)
tree432c067c6a38c644f02c4f85618d432bb3cfea09 /catalog-be/src
parent6d95c7cfb45cebed0de5e31fae5874ffaa0fb577 (diff)
Fix sonar issues
Fix sonar/checkstyle issues in sdc code Issue-ID: SDC-3158 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: I004b0f579ff1f273f39a155217972f5efcdcf5cb
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImpl.java (renamed from catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImpl.java)91
-rw-r--r--catalog-be/src/main/resources/portal.properties2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImplTest.java (renamed from catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java)6
3 files changed, 56 insertions, 43 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImpl.java
index 5b9c83fb98..757eeb83ce 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,6 +21,9 @@
package org.openecomp.sdc.be.ecomp;
import fj.data.Either;
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
@@ -40,11 +43,7 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.Map;
-
-public final class PortalRestAPICentralServiceImpl implements IPortalRestCentralService {
+public final class PortalRestApiCentralServiceImpl implements IPortalRestCentralService {
private static final String FAILED_TO_UPDATE_USER_CREDENTIALS = "Failed to update user credentials";
private static final String FAILED_TO_DEACTIVATE_USER = "Failed to deactivate user {}";
private static final String FAILED_TO_EDIT_USER = "Failed to edit user";
@@ -59,25 +58,26 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
private static final String JH0003 = "jh0003";
private static final String PUSH_USER = "PushUser";
private static final String RECEIVED_NULL_FOR_ARGUMENT_USER = "Received null for argument user";
- private static final Logger log = Logger.getLogger(PortalRestAPICentralServiceImpl.class);
+ private static final Logger log = Logger.getLogger(PortalRestApiCentralServiceImpl.class);
private UserBusinessLogic userBusinessLogic;
private UserBusinessLogicExt userBusinessLogicExt;
- public PortalRestAPICentralServiceImpl() throws PortalAPIException {
+ public PortalRestApiCentralServiceImpl() throws PortalAPIException {
try {
ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext();
userBusinessLogic = (UserBusinessLogic) ctx.getBean("userBusinessLogic");
userBusinessLogicExt = (UserBusinessLogicExt) ctx.getBean("userBusinessLogicExt");
} catch (Exception e) {
log.debug("Failed to get user UserBusinessLogic", e);
- BeEcompErrorManager.getInstance().logInvalidInputError("constructor", "Exception thrown" + e.getMessage(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance().logInvalidInputError("constructor", "Exception thrown" + e.getMessage(),
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException("SDC Internal server error");
}
- log.debug("PortalRestAPICentralServiceImpl Class Instantiated");
+ log.debug("PortalRestApiCentralServiceImpl Class Instantiated");
}
//For testing purposes
- PortalRestAPICentralServiceImpl(UserBusinessLogic ubl, UserBusinessLogicExt uble) {
+ PortalRestApiCentralServiceImpl(UserBusinessLogic ubl, UserBusinessLogicExt uble) {
this.userBusinessLogic = ubl;
this.userBusinessLogicExt = uble;
}
@@ -85,11 +85,11 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
@Override
public Map<String, String> getAppCredentials() throws PortalAPIException {
Map<String, String> credMap = new HashMap<>();
- String portal_user = PortalApiProperties.getProperty(PortalPropertiesEnum.USER.value());
+ String portalUser = PortalApiProperties.getProperty(PortalPropertiesEnum.USER.value());
String password = PortalApiProperties.getProperty(PortalPropertiesEnum.PASSWORD.value());
String appName = PortalApiProperties.getProperty(PortalPropertiesEnum.APP_NAME.value());
try {
- credMap.put("username", CipherUtil.decryptPKC(portal_user));
+ credMap.put("username", CipherUtil.decryptPKC(portalUser));
credMap.put("password", CipherUtil.decryptPKC(password));
credMap.put("appName", CipherUtil.decryptPKC(appName));
} catch (CipherUtilException e) {
@@ -105,7 +105,8 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
log.debug("Start handle request of ECOMP pushUser");
if (user == null) {
- BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, RECEIVED_NULL_FOR_ARGUMENT_USER, BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, RECEIVED_NULL_FOR_ARGUMENT_USER,
+ BeEcompErrorManager.ErrorSeverity.INFO);
log.debug(RECEIVED_NULL_FOR_ARGUMENT_USER);
throw new PortalAPIException(RECEIVED_NULL_FOR_ARGUMENT_USER);
}
@@ -116,12 +117,13 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
User convertedAsdcUser = EcompUserConverter.convertEcompUserToUser(user);
- try{
+ try {
log.debug("Before creating ecomp user {} sdc user {}", user, convertedAsdcUser);
userBusinessLogic.createUser(modifierAttId, convertedAsdcUser);
- }catch (Exception e) {
+ } catch (Exception e) {
log.debug(FAILED_TO_CREATE_USER, user, e);
- BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CREATE_USER, BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance()
+ .logInvalidInputError(PUSH_USER, FAILED_TO_CREATE_USER, BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException(FAILED_TO_CREATE_USER + e.getMessage());
}
@@ -132,38 +134,42 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
public void editUser(String loginId, EcompUser user) throws PortalAPIException {
if (user == null) {
log.debug(RECEIVED_NULL_FOR_ARGUMENT_USER);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, RECEIVED_NULL_FOR_ARGUMENT_USER, BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, RECEIVED_NULL_FOR_ARGUMENT_USER,
+ BeEcompErrorManager.ErrorSeverity.INFO);
throw new PortalAPIException(RECEIVED_NULL_FOR_ARGUMENT_USER);
} else if (loginId == null) {
log.debug(RECEIVED_NULL_FOR_ARGUMENT_LOGIN_ID);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, RECEIVED_NULL_FOR_ARGUMENT_LOGIN_ID, BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, RECEIVED_NULL_FOR_ARGUMENT_LOGIN_ID,
+ BeEcompErrorManager.ErrorSeverity.INFO);
throw new PortalAPIException(RECEIVED_NULL_FOR_ARGUMENT_LOGIN_ID);
}
- log.debug("Start handle request of ECOMP editUser {} with loginId {} with follopwing roles {}", user, loginId, user.getRoles());
+ log.debug("Start handle request of ECOMP editUser {} with loginId {} with follopwing roles {}", user, loginId,
+ user.getRoles());
final String modifierAttId = JH0003;
log.debug("modifier id is {}", modifierAttId);
if (user.getLoginId() != null && !user.getLoginId().equals(loginId)) {
log.debug("loginId and user loginId not equal");
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, "loginId and user loginId not equal", BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, "loginId and user loginId not equal",
+ BeEcompErrorManager.ErrorSeverity.INFO);
throw new PortalAPIException("loginId not equals to the user loginId field");
} else if (user.getLoginId() == null) {
user.setLoginId(loginId);
}
Either<User, ActionStatus> verifyNewUser;
- try{
+ try {
verifyNewUser = userBusinessLogic.verifyNewUserForPortal(user.getLoginId());
- } catch (ComponentException e){
+ } catch (ComponentException e) {
log.debug("Failed to verify new user", e);
throw new PortalAPIException(e.getCause());
}
- if(verifyNewUser.isRight() &&
- (ActionStatus.USER_NOT_FOUND.equals(verifyNewUser.right().value()) ||
- ActionStatus.USER_INACTIVE.equals(verifyNewUser.right().value()))){
+ if (verifyNewUser.isRight()
+ && (ActionStatus.USER_NOT_FOUND.equals(verifyNewUser.right().value())
+ || ActionStatus.USER_INACTIVE.equals(verifyNewUser.right().value()))) {
log.debug("Edit user for user that not exist in DB, executing push user flow {}", user);
pushUser(user);
return;
@@ -175,18 +181,20 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
if (updateUserCredentialsResponse.isRight()) {
log.debug(FAILED_TO_UPDATE_USER_CREDENTIALS);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, FAILED_TO_UPDATE_USER_CREDENTIALS, BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, FAILED_TO_UPDATE_USER_CREDENTIALS,
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException(FAILED_TO_EDIT_USER + updateUserCredentialsResponse.right().value());
}
- if(user.getRoles() == null || user.getRoles().isEmpty()){
+ if (user.getRoles() == null || user.getRoles().isEmpty()) {
try {
log.debug("Before deactivating ecomp user {} sdc user {}", user, asdcUser);
userBusinessLogicExt.deActivateUser(modifierAttId, loginId);
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.debug("Error: Failed to deactivate user {}", loginId);
- BeEcompErrorManager.getInstance().logInvalidInputError(FAILED_TO_DEACTIVATE_USER, "Failed to deactivate user", BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance()
+ .logInvalidInputError(FAILED_TO_DEACTIVATE_USER, "Failed to deactivate user",
+ BeEcompErrorManager.ErrorSeverity.INFO);
throw new PortalAPIException("Error: Failed to deactivate user" + e);
}
} else {
@@ -194,9 +202,11 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
try {
log.debug("Before updating ecomp user {} sdc user {}", user, asdcUser);
userBusinessLogic.updateUserRole(modifierAttId, loginId, asdcUser.getRole());
- }catch (Exception e) {
+ } catch (Exception e) {
log.debug("Error: Failed to update user role {}", loginId);
- BeEcompErrorManager.getInstance().logInvalidInputError(FAILED_TO_EDIT_USER, "Failed to update user role", BeEcompErrorManager.ErrorSeverity.INFO);
+ BeEcompErrorManager.getInstance()
+ .logInvalidInputError(FAILED_TO_EDIT_USER, "Failed to update user role",
+ BeEcompErrorManager.ErrorSeverity.INFO);
throw new PortalAPIException("Error: Failed to update user role" + e);
}
}
@@ -208,7 +218,8 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
String header = request.getHeader(Constants.USER_ID_HEADER);
if (header == null) {
log.debug(FAILED_TO_GET_USER_ID_HEADER);
- BeEcompErrorManager.getInstance().logInvalidInputError("getUserId", FAILED_TO_GET_USER_ID_HEADER, BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance().logInvalidInputError("getUserId", FAILED_TO_GET_USER_ID_HEADER,
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException(FAILED_TO_GET_USER_ID_HEADER);
}
return header;
@@ -216,13 +227,15 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
public static void checkIfSingleRoleProvided(EcompUser user) throws PortalAPIException {
- if(user.getRoles() == null) {
+ if (user.getRoles() == null) {
log.debug(RECEIVED_NULL_ROLES, user);
- BeEcompErrorManager.getInstance().logInvalidInputError(CHECK_ROLES, RECEIVED_NULL_ROLES, BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance()
+ .logInvalidInputError(CHECK_ROLES, RECEIVED_NULL_ROLES, BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException(RECEIVED_NULL_ROLES + user);
- }else if(user.getRoles().size() > 1) {
+ } else if (user.getRoles().size() > 1) {
log.debug(RECEIVED_MULTIPLE_ROLES, user);
- BeEcompErrorManager.getInstance().logInvalidInputError(CHECK_ROLES, RECEIVED_MULTIPLE_ROLES2, BeEcompErrorManager.ErrorSeverity.ERROR);
+ BeEcompErrorManager.getInstance().logInvalidInputError(CHECK_ROLES, RECEIVED_MULTIPLE_ROLES2,
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new PortalAPIException(RECEIVED_MULTIPLE_ROLES2 + user);
}
}
diff --git a/catalog-be/src/main/resources/portal.properties b/catalog-be/src/main/resources/portal.properties
index a182e80972..8c31b4c281 100644
--- a/catalog-be/src/main/resources/portal.properties
+++ b/catalog-be/src/main/resources/portal.properties
@@ -53,7 +53,7 @@ use_rest_for_functional_menu=true
##########################################################################
# Name of java class that implements the OnBoardingApiService interface.
-portal.api.impl.class = org.openecomp.sdc.be.ecomp.PortalRestAPICentralServiceImpl
+portal.api.impl.class = org.openecomp.sdc.be.ecomp.PortalRestApiCentralServiceImpl
# Use this tag if the app is centralized remote/local
role_access_centralized = remote
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImplTest.java
index 964e6258df..d09ec17fd3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/PortalRestApiCentralServiceImplTest.java
@@ -38,9 +38,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-public class PortalRestAPICentralServiceImplTest {
+public class PortalRestApiCentralServiceImplTest {
- private PortalRestAPICentralServiceImpl testSubject;
+ private PortalRestApiCentralServiceImpl testSubject;
private UserBusinessLogic ubl;
private UserBusinessLogicExt uble;
@@ -48,7 +48,7 @@ public class PortalRestAPICentralServiceImplTest {
public void createTestSubject() {
ubl = Mockito.mock(UserBusinessLogic.class);
uble = Mockito.mock(UserBusinessLogicExt.class);
- testSubject = new PortalRestAPICentralServiceImpl(ubl, uble);
+ testSubject = new PortalRestApiCentralServiceImpl(ubl, uble);
}