示例#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;
  }
示例#2
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));
  }
示例#3
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);
  }
示例#4
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);
  }
示例#5
0
  @Transactional(readOnly = true)
  public List<UserAttribute> getUserAsAttributeList(
      String principalName, List<String> attributeList) {

    List<UserAttribute> attrList = new ArrayList<UserAttribute>();

    User u =
        getUserByPrincipal(
            sysConfiguration.getDefaultSecurityDomain(),
            principalName,
            sysConfiguration.getDefaultManagedSysId(),
            false);
    if (u == null) {
      return null;
    }
    UserAttribute atr = new UserAttribute("EMAIL", u.getEmail());
    attrList.add(atr);

    return attrList;
  }
示例#6
0
  private void validateEmailAddress(User user, Set<EmailAddress> emailSet) {

    if (emailSet == null || emailSet.isEmpty()) return;

    Iterator<EmailAddress> it = emailSet.iterator();

    while (it.hasNext()) {
      EmailAddress emailAdr = it.next();
      if (StringUtils.isEmpty(emailAdr.getParentId())) {
        emailAdr.setParentId(user.getUserId());
        emailAdr.setParentType(ContactConstants.PARENT_TYPE_USER);
      }
    }
  }
示例#7
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");

  }
示例#8
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#getUserAsMap(java.lang
   * .String)
   */
  @Transactional(readOnly = true)
  public Map<String, UserAttribute> getUserAsMap(String userId) {
    User usr = getUser(userId);
    if (usr == null) {
      return null;
    }

    Map<String, UserAttribute> attrMap = getAllAttributes(userId);
    if (attrMap == null) {
      attrMap = new HashMap<String, UserAttribute>();
    }
    // assign the predefined properties

    attrMap.put("USER_ID", new UserAttribute(null, userId, null, "USER_ID", userId));
    attrMap.put(
        "FIRST_NAME", new UserAttribute(null, userId, null, "FIRST_NAME", usr.getFirstName()));
    attrMap.put("LAST_NAME", new UserAttribute(null, userId, null, "LAST_NAME", usr.getLastName()));
    attrMap.put(
        "MIDDLE_INIT",
        new UserAttribute(null, userId, null, "MIDDLE_INIT", String.valueOf(usr.getMiddleInit())));
    attrMap.put("TITLE", new UserAttribute(null, userId, null, "TITLE", usr.getTitle()));
    attrMap.put("DEPT", new UserAttribute(null, userId, null, "DEPT", usr.getDeptCd()));
    attrMap.put(
        "STATUS", new UserAttribute(null, userId, null, "STATUS", usr.getStatus().toString()));
    if (usr.getBirthdate() != null) {
      attrMap.put(
          "BIRTHDATE",
          new UserAttribute(null, userId, null, "BIRTHDATE", usr.getBirthdate().toString()));
    } else {
      attrMap.put("BIRTHDATE", new UserAttribute(null, userId, null, "BIRTHDATE", null));
    }
    attrMap.put("SEX", new UserAttribute(null, userId, null, "SEX", String.valueOf(usr.getSex())));
    if (usr.getCreateDate() != null) {
      attrMap.put(
          "CREATE_DATE",
          new UserAttribute(null, userId, null, "CREATE_DATE", usr.getCreateDate().toString()));
    } else {
      attrMap.put("CREATE_DATE", new UserAttribute(null, userId, null, "CREATE_DATE", null));
    }
    attrMap.put(
        "CREATED_BY", new UserAttribute(null, userId, null, "CREATED_BY", usr.getCreatedBy()));
    if (usr.getLastUpdate() != null) {
      attrMap.put(
          "LAST_UPDATE",
          new UserAttribute(null, userId, null, "LAST_UPDATE", usr.getLastUpdate().toString()));
    } else {
      attrMap.put("LAST_UPDATE", new UserAttribute(null, userId, null, "LAST_UPDATE", null));
    }
    attrMap.put(
        "LAST_UPDATEDBY",
        new UserAttribute(null, userId, null, "LAST_UPDATEDBY", usr.getLastUpdatedBy()));
    attrMap.put("PREFIX", new UserAttribute(null, userId, null, "PREFIX", usr.getPrefix()));
    attrMap.put("SUFFIX", new UserAttribute(null, userId, null, "SUFFIX", usr.getSuffix()));
    attrMap.put(
        "USER_TYPE_IND",
        new UserAttribute(null, userId, null, "USER_TYPE_IND", usr.getUserTypeInd()));
    attrMap.put(
        "EMPLOYEE_ID", new UserAttribute(null, userId, null, "EMPLOYEE_ID", usr.getEmployeeId()));
    attrMap.put(
        "EMPLOYEE_TYPE",
        new UserAttribute(null, userId, null, "EMPLOYEE_TYPE", usr.getEmployeeType()));
    attrMap.put(
        "LOCATION_ID", new UserAttribute(null, userId, null, "LOCATION_ID", usr.getLocationCd()));
    attrMap.put(
        "ORGANIZATION_ID",
        new UserAttribute(null, userId, null, "ORGANIZATION_ID", usr.getCompanyId()));
    attrMap.put(
        "COMPANY_OWNER_ID",
        new UserAttribute(null, userId, null, "COMPANY_OWNER_ID", usr.getCompanyOwnerId()));

    attrMap.put(
        "MANAGER_ID", new UserAttribute(null, userId, null, "MANAGER_ID", usr.getManagerId()));
    attrMap.put("JOB_CODE", new UserAttribute(null, userId, null, "JOB_CODE", usr.getJobCode()));

    return attrMap;
  }