From fb81b5b97b8375ed406e191039a95be9df43445f Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Sun, 2 Dec 2018 16:14:43 +0200 Subject: update sdc portal integration Issue-ID: SDC-1749 Change-Id: Ia6a143bfc0a1511909bc83cb5ea1c1b3f8789b08 Signed-off-by: Tal Gitelman --- .../org/openecomp/sdc/be/ecomp/EcompIntImpl.java | 27 ++++++----------- .../be/ecomp/PortalRestAPICentralServiceImpl.java | 34 ++++++++-------------- .../be/ecomp/converters/EcompUserConverter.java | 6 ++-- 3 files changed, 24 insertions(+), 43 deletions(-) (limited to 'catalog-be/src/main/java/org') 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 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 createUserResponse = userBusinessLogic.createUser(modifier, convertedAsdcUser); // ALREADY EXIST ResponseFormat @@ -158,18 +153,14 @@ public class EcompIntImpl implements IPortalRestAPIService { user.setLoginId(loginId); } - Either 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 updateUserCredentialsResponse = userBusinessLogic.updateUserCredentials(asdcUser.left().value()); + Either 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 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 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 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 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 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 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 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 -- cgit 1.2.3-korg