diff options
author | 2017-07-14 14:19:22 -0400 | |
---|---|---|
committer | 2017-07-14 14:29:49 -0400 | |
commit | 3aec9d2ab7f373a12e052d5e2c1c59b2a19770dc (patch) | |
tree | fd13e4b474891a3efa1320524026d7ddad757297 /ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java | |
parent | 30b8e1fd4328ea37fc5599f8a9723ea79ae0e369 (diff) |
[Portal 21] Role management
This push includes continuation of the changes required to handle
cetralized roles,user management
Change-Id: I38e9dc946ff53ac61dd3b580c335f4ad52b372f7
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java deleted file mode 100644 index 3e7b2b14..00000000 --- a/ecomp-sdk/epsdk-core/src/main/java/org/openecomp/portalsdk/core/service/UserProfileServiceCentalizedImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.openecomp.portalsdk.core.service; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.SortedSet; - -import org.openecomp.portalsdk.core.domain.Role; -import org.openecomp.portalsdk.core.domain.User; -import org.openecomp.portalsdk.core.domain.support.CollaborateList; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; - - -@Transactional -public class UserProfileServiceCentalizedImpl implements UserProfileService { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserProfileServiceCentalizedImpl.class); - - @Autowired - AppService appService; - - @Autowired - RestApiRequestBuilder restApiRequestBuilder; - - @Autowired - private DataAccessService dataAccessService; - - public DataAccessService getDataAccessService() { - return dataAccessService; - } - - public void setDataAccessService(DataAccessService dataAccessService) { - this.dataAccessService = dataAccessService; - } - - @Override - public List<User> findAll() { - List<User> roles = new ArrayList<>(); - ObjectMapper mapper = new ObjectMapper(); - - String user = restApiRequestBuilder.getViaREST("/findAll", true,null); - try { - roles = mapper.readValue(user, - TypeFactory.defaultInstance().constructCollectionType(List.class, User.class)); - } catch (JsonParseException e) { - logger.error(EELFLoggerDelegate.errorLogger, "Json parsing failed", e); - } catch (JsonMappingException e) { - logger.error(EELFLoggerDelegate.errorLogger, "Json mapping failed", e); - } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, "IO exception", e); - } - - return roles; - } - - @Override - public User getUser(String id) { - ObjectMapper mapper = new ObjectMapper(); - User user = new User(); - String responseString = restApiRequestBuilder.getViaREST("/getUser/" + id, true,id); - try { - - user = mapper.readValue(responseString, User.class); - } catch (JsonParseException e) { - logger.error(EELFLoggerDelegate.errorLogger, "Json parsing failed", e); - } catch (JsonMappingException e) { - logger.error(EELFLoggerDelegate.errorLogger, "Json mapping failed", e); - } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, "IO exception", e); - } - - return user; - } - - @Override - public User getUserByLoginId(String loginId) { - return getUser(loginId); - } - - @Override - public void saveUser(User user) { - try { - getDataAccessService().saveDomainObject(user, null); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "saveUser Failed", e); - } - } - - @Override - public List<User> findAllUserWithOnOffline(String originOrgUserId) { - HashSet<String> onlineUser = CollaborateList.getInstance().getAllUserName(); - List<User> users = findAll(); - for (User u : users) { - if (onlineUser.contains(u.getOrgUserId())) - u.setOnline(true); - if (u.getOrgUserId() != null) { - if (originOrgUserId.compareTo(u.getOrgUserId()) > 0) { - u.setChatId(originOrgUserId + "-" + u.getOrgUserId()); - } else - u.setChatId(u.getOrgUserId() + "-" + originOrgUserId); - } - } - return users; - } - - @Override - public List<User> findAllActive() { - List<User> users = findAll(); - Iterator<User> itr = users.iterator(); - while (itr.hasNext()) { - User u = (User) itr.next(); - if (!u.getActive()) - itr.remove();// if not active remove user from list - else { - SortedSet<Role> roles = u.getRoles(); - Iterator<Role> itrRoles = roles.iterator(); - while (itrRoles.hasNext()) { - Role role = (Role) itrRoles.next(); - if (!role.getActive()) - u.removeRole(role.getId());// if not active remove role - // from list - } - } - } - return users; - } - -} |