Esempio n. 1
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#getUser(java.lang.String
   * , boolean)
   */
  @Transactional(readOnly = true)
  public User getUserWithDependent(String id, boolean dependants) {

    UserEntity usr = userDao.findById(id);
    if (usr == null) {
      return null;
    }

    if (!dependants) {
      return userDozerConverter.convertToDTO(usr, true);
    }

    // assemble the various dependant objects
    org.hibernate.Hibernate.initialize(usr.getPhones());
    org.hibernate.Hibernate.initialize(usr.getEmailAddresses());
    org.hibernate.Hibernate.initialize(usr.getAddresses());
    org.hibernate.Hibernate.initialize(usr.getUserAttributes());
    User user = userDozerConverter.convertToDTO(usr, true);
    List<Login> principalList = loginDao.findUser(id);
    if (principalList != null) {
      user.setPrincipalList(principalList);
    }

    return user;
  }
Esempio n. 2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#getAllAttributes(java
   * .lang.String)
   */
  @Transactional(readOnly = true)
  public Map<String, UserAttribute> getAllAttributes(String userId) {
    Map<String, UserAttribute> attrMap = new HashMap<String, UserAttribute>();

    if (userId == null) {
      throw new NullPointerException("userId is null");
    }

    UserEntity usrEntity = userDao.findById(userId);

    if (usrEntity == null) return null;

    List<UserAttributeEntity> attrList = userAttributeDao.findUserAttributes(userId);

    if (attrList == null || attrList.size() == 0) return null;

    // migrate to a Map for the User object
    if (attrList != null && !attrList.isEmpty()) {
      int size = attrList.size();
      for (int i = 0; i < size; i++) {
        UserAttributeEntity attr = attrList.get(i);
        attrMap.put(attr.getName(), new UserAttribute(attr));
      }
    }

    return attrMap;
  }
Esempio n. 3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.openiam.idm.srvc.user.service.UserDataService#removePhone(org.openiam
  * .idm.srvc.continfo.dto.Phone)
  */
 @Transactional
 public void removePhone(Phone val) {
   if (val == null) throw new NullPointerException("val is null");
   if (val.getPhoneId() == null) throw new NullPointerException("PhoneId is null");
   UserEntity parent = userDao.findById(val.getParentId());
   phoneDao.remove(phoneDozerConverter.convertToEntity(val, true));
 }
Esempio n. 4
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#updateUser(org.openiam
   * .idm.srvc.user.dto.User)
   */
  @Transactional
  public void updateUser(User user) {
    if (user == null) throw new NullPointerException("user object is null");
    if (user.getUserId() == null) throw new NullPointerException("user id is null");

    user.setLastUpdate(new Date(System.currentTimeMillis()));

    userDao.update(userDozerConverter.convertToEntity(user, true));
  }
Esempio n. 5
0
 @Override
 public List<User> getAllUsers() {
   List<ReconcileUserEntity> uL = userDao.findAllUsers();
   if (uL == null) return null;
   List<User> result = new ArrayList<User>();
   for (ReconcileUserEntity uWE : uL) {
     result.add(new User(uWE));
   }
   return result;
 }
Esempio n. 6
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#updateAttribute(org
   * .openiam.idm.srvc.user.dto.UserAttribute)
   */
  @Transactional
  public void updateAttribute(UserAttribute attribute) {
    if (attribute == null) throw new NullPointerException("Attribute can not be null");

    if (StringUtils.isEmpty(attribute.getUserId())) {
      throw new NullPointerException("User has not been associated with this attribute.");
    }
    UserEntity userEntity = userDao.findById(attribute.getUserId());
    userAttributeDao.update(userAttributeDozerConverter.convertToEntity(attribute, true));
    // this.userMsgProducer.sendMessage(attribute.getUserId(),"UPDATE");

  }
Esempio n. 7
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#addUser(org.openiam
   * .idm.srvc.user.dto.User, boolean)
   */
  @Transactional
  public User addUserWithDependent(User user, boolean dependency) {
    if (user == null) throw new NullPointerException("user object is null");

    if (user.getCreateDate() == null) {
      user.setCreateDate(new Date(System.currentTimeMillis()));
    }
    if (user.getLastUpdate() == null) {
      user.setLastUpdate(new Date(System.currentTimeMillis()));
    }

    // if there are dependants, then make user that the parentId has been
    // set

    validateEmailAddress(user, user.getEmailAddresses());

    log.debug("User Object before addUser: "******"ADD");

    return userDozerConverter.convertToDTO(entity, true);
  }
Esempio n. 8
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#removeAttribute(org
   * .openiam.idm.srvc.user.dto.UserAttribute)
   */
  @Transactional
  public void removeAttribute(UserAttribute attr) {
    if (attr == null) {
      throw new NullPointerException("attr is null");
    }
    if (StringUtils.isEmpty(attr.getId())) {
      throw new NullPointerException("attrId is null");
    }
    UserEntity userEntity = userDao.findById(attr.getUserId());
    userAttributeDao.remove(userAttributeDozerConverter.convertToEntity(attr, true));

    // this.userMsgProducer.sendMessage(attr.getUserId(),"DELETE");

  }
Esempio n. 9
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#addUser(org.openiam
   * .idm.srvc.user.dto.User)
   */
  @Transactional
  public User addUser(User user) {
    if (user == null) throw new NullPointerException("user object is null");

    if (user.getCreateDate() == null) {
      user.setCreateDate(new Date(System.currentTimeMillis()));
    }
    if (user.getLastUpdate() == null) {
      user.setLastUpdate(new Date(System.currentTimeMillis()));
    }

    validateEmailAddress(user, user.getEmailAddresses());
    UserEntity userEntity = userDozerConverter.convertToEntity(user, true);
    userDao.add(userEntity);

    return userDozerConverter.convertToDTO(userEntity, true);
  }
Esempio n. 10
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#removeUser(java.lang
   * .String)
   */
  @Transactional
  public void removeUser(String id) {
    if (id == null) throw new NullPointerException("user id is null");

    User user = new User(id);

    // removes all the dependant objects.
    removeAllAttributes(id);
    removeAllPhones(id);
    removeAllAddresses(id);
    removeAllNotes(id);
    removeAllEmailAddresses(id);

    userDao.remove(userDozerConverter.convertToEntity(user, true));

    // / this.userMsgProducer.sendMessage(user.getUserId(),"DELETE");

  }
Esempio n. 11
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#updateNote(org.openiam
   * .idm.srvc.user.dto.UserNote)
   */
  @Transactional
  public void updateNote(UserNote note) {
    if (note == null) throw new NullPointerException("Note cannot be null");
    if (StringUtils.isEmpty(note.getUserNoteId())) {
      throw new NullPointerException("noteId is null");
    }
    if (StringUtils.isEmpty(note.getUserId())) {
      throw new NullPointerException("User is not associated with this note.");
    }

    UserEntity usr = userDao.findById(note.getUserId());

    UserNoteEntity userNoteEntity = userNoteDozerConverter.convertToEntity(note, true);
    if (userNoteEntity.getUser() == null) {
      userNoteEntity.setUser(usr);
    }

    userNoteDao.merge(userNoteEntity);
  }
Esempio n. 12
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#addNote(org.openiam
   * .idm.srvc.user.dto.UserNote)
   */
  @Transactional
  public UserNote addNote(UserNote note) {
    if (note == null) throw new NullPointerException("Note cannot be null");

    if (note.getUserId() == null) {
      throw new NullPointerException("User is not associated with this note.");
    }

    UserEntity usr = userDao.findById(note.getUserId());

    UserNoteEntity userNoteEntity = userNoteDozerConverter.convertToEntity(note, true);

    if (userNoteEntity.getUser() == null) {
      userNoteEntity.setUser(usr);
    }

    userNoteDao.persist(userNoteEntity);

    return userNoteDozerConverter.convertToDTO(userNoteEntity, true);
  }
Esempio n. 13
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#updateUser(org.openiam
   * .idm.srvc.user.dto.User, boolean)
   */
  @Transactional
  public void updateUserWithDependent(User user, boolean dependency) {
    if (user == null) throw new NullPointerException("user object is null");
    if (user.getUserId() == null) throw new NullPointerException("user id is null");

    user.setLastUpdate(new Date(System.currentTimeMillis()));

    validateEmailAddress(user, user.getEmailAddresses());

    userDao.update(userDozerConverter.convertToEntity(user, true));

    if (!dependency) return;

    // address
    /*
     * Map<Address> adrMap = user.getAddresses(); if (adrMap != null &&
     * adrMap.size() > 0 ) {
     * this.addressDao.saveAddressMap(user.getUserId(),
     * ContactConstants.PARENT_TYPE_USER , adrMap); }
     */
    // email
    /*
     * Map<String, EmailAddress> emailMap = user.getEmailAddresses(); if
     * (emailMap != null && emailMap.size() > 0 ) {
     * this.emailAddressDao.saveEmailAddressMap(user.getUserId(),
     * ContactConstants.PARENT_TYPE_USER , emailMap); }
     */
    // phone
    /*
     * Map<String, Phone> phoneMap = user.getPhones(); if (phoneMap != null
     * && phoneMap.size() > 0 ) {
     * this.phoneDao.savePhoneMap(user.getUserId(),
     * ContactConstants.PARENT_TYPE_USER , phoneMap); }
     */
    // this.userMsgProducer.sendMessage(user,"UPDATE");

  }
Esempio n. 14
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#search(org.openiam.
   * util.db.Search)
   */
  @Transactional(readOnly = true)
  public List<User> search(UserSearch search) {
    List<UserEntity> entityList = userDao.search(search);

    return userDozerConverter.convertToDTOList(entityList, false);
  }
Esempio n. 15
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.openiam.idm.srvc.user.service.UserDataService#getUser(java.lang.String
  * )
  */
 @Transactional(readOnly = true)
 public User getUser(String id) {
   UserEntity entity = userDao.findById(id);
   return userDozerConverter.convertToDTO(entity, true);
 }
Esempio n. 16
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#findUsersByLastUpdateRange
   * (java.util.Date, java.util.Date)
   */
  @Transactional(readOnly = true)
  public List findUsersByLastUpdateRange(Date startDate, Date endDate) {

    return userDao.findByLastUpdateRange(startDate, endDate);
  }
Esempio n. 17
0
 @Transactional(readOnly = true)
 public User getUserByName(String firstName, String lastName) {
   UserEntity userEntity = userDao.findByName(firstName, lastName);
   return userDozerConverter.convertToDTO(userEntity, true);
 }
Esempio n. 18
0
  @Transactional(readOnly = true)
  public List<User> searchByDelegationProperties(DelegationFilterSearch search) {
    List<UserEntity> entityList = userDao.findByDelegationProperties(search);

    return userDozerConverter.convertToDTOList(entityList, false);
  }
Esempio n. 19
0
 @Override
 @Transactional(readOnly = true)
 public Integer searchCount(UserSearch search) {
   return userDao.searchCount(search);
 }
Esempio n. 20
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#findUserByOrganization
   * (java.lang.String)
   */
  @Transactional(readOnly = true)
  public List<User> findUserByOrganization(String orgId) {
    List<UserEntity> entityList = userDao.findByOrganization(orgId);

    return userDozerConverter.convertToDTOList(entityList, false);
  }
Esempio n. 21
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.openiam.idm.srvc.user.service.UserDataService#findUsersByStatus(java
  * .lang.String)
  */
 @Transactional(readOnly = true)
 public List findUsersByStatus(UserStatusEnum status) {
   return userDao.findByStatus(status);
 }