aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorTal Gitelman <tal.gitelman@att.com>2018-12-02 16:14:43 +0200
committerTal Gitelman <tal.gitelman@att.com>2018-12-02 15:41:44 +0000
commitfb81b5b97b8375ed406e191039a95be9df43445f (patch)
treee4cf61ada1804a8ac21f9fbd4dc643417e3fe0e7 /catalog-be/src/main/java
parent4a99e32a55f5b9210625274310cb8d68dd4095e7 (diff)
update sdc portal integration
Issue-ID: SDC-1749 Change-Id: Ia6a143bfc0a1511909bc83cb5ea1c1b3f8789b08 Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/PortalRestAPICentralServiceImpl.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java6
3 files changed, 24 insertions, 43 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
index 27f214568e..c84558dbd0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
@@ -93,18 +93,13 @@ public class EcompIntImpl implements IPortalRestAPIService {
modifier.setUserId(modifierAttId);
log.debug("modifier id is {}", modifierAttId);
- Either<User, String> newASDCUser = EcompUserConverter.convertEcompUserToUser(user);
- if (newASDCUser.isRight()) {
+ User convertedAsdcUser = EcompUserConverter.convertEcompUserToUser(user);
+ if (convertedAsdcUser == null) {
BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CONVERT_USER, ErrorSeverity.INFO);
log.debug(FAILED_TO_CREATE_USER, user);
- throw new PortalAPIException("Failed to create user " + newASDCUser.right().value());
- } else if (newASDCUser.left().value() == null) {
- BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, NULL_POINTER_RETURNED_FROM_USER_CONVERTER, ErrorSeverity.INFO);
- log.debug(FAILED_TO_CREATE_USER, user);
- throw new PortalAPIException("Failed to create user " + newASDCUser.right().value());
+ throw new PortalAPIException("Failed to convert user " + user);
}
- User convertedAsdcUser = newASDCUser.left().value();
Either<User, ResponseFormat> createUserResponse = userBusinessLogic.createUser(modifier, convertedAsdcUser);
// ALREADY EXIST ResponseFormat
@@ -158,18 +153,14 @@ public class EcompIntImpl implements IPortalRestAPIService {
user.setLoginId(loginId);
}
- Either<User, String> asdcUser = EcompUserConverter.convertEcompUserToUser(user);
- if (asdcUser.isRight()) {
- log.debug(FAILED_TO_CONVERT_USER);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, FAILED_TO_CONVERT_USER, ErrorSeverity.INFO);
- throw new PortalAPIException(asdcUser.right().value());
- } else if (asdcUser.left().value() == null) {
- log.debug(NULL_POINTER_RETURNED_FROM_USER_CONVERTER);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, NULL_POINTER_RETURNED_FROM_USER_CONVERTER, ErrorSeverity.INFO);
- throw new PortalAPIException(FAILED_TO_EDIT_USER);
+ User convertedAsdcUser = EcompUserConverter.convertEcompUserToUser(user);
+ if (convertedAsdcUser == null) {
+ BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CONVERT_USER, ErrorSeverity.INFO);
+ log.debug(FAILED_TO_CREATE_USER, user);
+ throw new PortalAPIException("Failed to convert user " + user);
}
- Either<User, ResponseFormat> updateUserCredentialsResponse = userBusinessLogic.updateUserCredentials(asdcUser.left().value());
+ Either<User, ResponseFormat> updateUserCredentialsResponse = userBusinessLogic.updateUserCredentials(convertedAsdcUser);
if (updateUserCredentialsResponse.isRight()) {
log.debug(FAILED_TO_UPDATE_USER_CREDENTIALS);
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 36f51da3d0..4df659ddd2 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
@@ -54,7 +54,7 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
log.debug("PortalRestAPICentralServiceImpl Class Instantiated");
}
- public PortalRestAPICentralServiceImpl(UserBusinessLogic ubl) {
+ PortalRestAPICentralServiceImpl(UserBusinessLogic ubl) {
this.userBusinessLogic = ubl;
}
@@ -92,18 +92,13 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
modifier.setUserId(modifierAttId);
log.debug("modifier id is {}", modifierAttId);
- Either<User, String> newASDCUser = EcompUserConverter.convertEcompUserToUser(user);
- if (newASDCUser.isRight()) {
+ User convertedAsdcUser = EcompUserConverter.convertEcompUserToUser(user);
+ if (convertedAsdcUser == null) {
BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CONVERT_USER, BeEcompErrorManager.ErrorSeverity.INFO);
log.debug(FAILED_TO_CREATE_USER, user);
- throw new PortalAPIException("Failed to create user " + newASDCUser.right().value());
- } else if (newASDCUser.left().value() == null) {
- BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, NULL_POINTER_RETURNED_FROM_USER_CONVERTER, BeEcompErrorManager.ErrorSeverity.INFO);
- log.debug(FAILED_TO_CREATE_USER, user);
- throw new PortalAPIException("Failed to create user " + newASDCUser.right().value());
+ throw new PortalAPIException("Failed to convert user " + user);
}
- User convertedAsdcUser = newASDCUser.left().value();
Either<User, ResponseFormat> createUserResponse = userBusinessLogic.createUser(modifier, convertedAsdcUser);
// ALREADY EXIST ResponseFormat
@@ -113,20 +108,20 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
if (!createUserResponse.right().value().getMessageId().equals(ALREADY_EXISTS_RESPONSE_ID)) {
log.debug(FAILED_TO_CREATE_USER, user);
BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CREATE_USER, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new PortalAPIException(FAILED_TO_CREATE_USER + createUserResponse.right());
+ throw new PortalAPIException(FAILED_TO_CREATE_USER + createUserResponse.right().value());
} else {
log.debug("User already exist and will be updated and reactivated {}", user);
Either<User, ResponseFormat> updateUserResp = userBusinessLogic.updateUserCredentials(convertedAsdcUser);
if(updateUserResp.isRight()){
log.debug(FAILED_TO_UPDATE_USER_CREDENTIALS, user);
BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_UPDATE_USER_CREDENTIALS, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new PortalAPIException(FAILED_TO_UPDATE_USER_CREDENTIALS + createUserResponse.right());
+ throw new PortalAPIException(FAILED_TO_UPDATE_USER_CREDENTIALS + createUserResponse.right().value());
}
Either<User, ResponseFormat> updateUserRoleResp = userBusinessLogic.updateUserRole(modifier, convertedAsdcUser.getUserId(), convertedAsdcUser.getRole());
if(updateUserRoleResp.isRight()){
log.debug(FAILED_TO_UPDATE_USER_ROLE, user);
BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_UPDATE_USER_ROLE, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new PortalAPIException(FAILED_TO_UPDATE_USER_ROLE + createUserResponse.right());
+ throw new PortalAPIException(FAILED_TO_UPDATE_USER_ROLE + createUserResponse.right().value());
}
}
@@ -163,18 +158,13 @@ public final class PortalRestAPICentralServiceImpl implements IPortalRestCentral
user.setLoginId(loginId);
}
- Either<User, String> convertorResp = EcompUserConverter.convertEcompUserToUser(user);
- if (convertorResp.isRight()) {
- log.debug(FAILED_TO_CONVERT_USER);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, FAILED_TO_CONVERT_USER, BeEcompErrorManager.ErrorSeverity.INFO);
- throw new PortalAPIException(convertorResp.right().value());
- } else if (convertorResp.left().value() == null) {
- log.debug(NULL_POINTER_RETURNED_FROM_USER_CONVERTER);
- BeEcompErrorManager.getInstance().logInvalidInputError(EDIT_USER, NULL_POINTER_RETURNED_FROM_USER_CONVERTER, BeEcompErrorManager.ErrorSeverity.INFO);
- throw new PortalAPIException(FAILED_TO_EDIT_USER);
+ User asdcUser = EcompUserConverter.convertEcompUserToUser(user);
+ if (asdcUser == null) {
+ BeEcompErrorManager.getInstance().logInvalidInputError(PUSH_USER, FAILED_TO_CONVERT_USER, BeEcompErrorManager.ErrorSeverity.INFO);
+ log.debug(FAILED_TO_CREATE_USER, user);
+ throw new PortalAPIException("Failed to convert user " + user);
}
- User asdcUser = convertorResp.left().value();
Either<User, ResponseFormat> updateUserCredentialsResponse = userBusinessLogic.updateUserCredentials(asdcUser);
if (updateUserCredentialsResponse.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
index 61b29a3986..4e06c4ea41 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
@@ -72,11 +72,11 @@ public final class EcompUserConverter {
return Either.left(convertedUser);
}
- public static Either<User, String> convertEcompUserToUser(EcompUser ecompUser) {
+ public static User convertEcompUserToUser(EcompUser ecompUser) {
User convertedUser = new User();
if (ecompUser == null) {
- return Either.right("EcompUser is null");
+ return convertedUser;
}
convertedUser.setFirstName(ecompUser.getFirstName());
@@ -105,6 +105,6 @@ public final class EcompUserConverter {
convertedUser.setStatus(UserStatusEnum.INACTIVE);
}
- return Either.left(convertedUser);
+ return convertedUser;
}
} \ No newline at end of file