Example #1
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;
  }
Example #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#getAttribute(java.lang
   * .String)
   */
  @Transactional(readOnly = true)
  public UserAttribute getAttribute(String attrId) {
    if (attrId == null) {
      throw new NullPointerException("attrId is null");
    }
    UserAttributeEntity attributeEntity = userAttributeDao.findById(attrId);

    return attributeEntity != null ? new UserAttribute(attributeEntity) : null;
  }
Example #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#removeAllAttributes
   * (java.lang.String)
   */
  @Transactional
  public void removeAllAttributes(String userId) {
    if (userId == null) {
      throw new NullPointerException("userId is null");
    }
    userAttributeDao.deleteUserAttributes(userId);

    // this.userMsgProducer.sendMessage(userId,"DELETE");

  }
Example #4
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");

  }
Example #5
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");

  }
Example #6
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#addAttribute(org.openiam
   * .idm.srvc.user.dto.UserAttribute)
   */
  @Transactional
  public UserAttribute addAttribute(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.");
    }

    UserAttributeEntity attributeEntity =
        userAttributeDozerConverter.convertToEntity(attribute, true);
    userAttributeDao.add(attributeEntity);

    // this.userMsgProducer.sendMessage(attribute.getUserId(),"ADD");

    return userAttributeDozerConverter.convertToDTO(attributeEntity, true);
  }