/**
   * Updates the role with the primary key.
   *
   * @param roleId the primary key of the role
   * @param name the role's new name
   * @param titleMap the new localized titles (optionally <code>null</code>) to replace those
   *     existing for the role
   * @param descriptionMap the new localized descriptions (optionally <code>null</code>) to replace
   *     those existing for the role
   * @param subtype the role's new subtype (optionally <code>null</code>)
   * @return the role with the primary key
   * @throws PortalException if a role with the primary could not be found or if the role's name was
   *     invalid
   * @throws SystemException if a system exception occurred
   */
  public Role updateRole(
      long roleId,
      String name,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String subtype)
      throws PortalException, SystemException {

    Role role = rolePersistence.findByPrimaryKey(roleId);

    validate(roleId, role.getCompanyId(), role.getClassNameId(), name);

    if (PortalUtil.isSystemRole(role.getName())) {
      name = role.getName();
      subtype = null;
    }

    role.setName(name);
    role.setTitleMap(titleMap);
    role.setDescriptionMap(descriptionMap);
    role.setSubtype(subtype);

    rolePersistence.update(role, false);

    return role;
  }
Ejemplo n.º 2
0
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static Role toModel(RoleSoap soapModel) {
    Role model = new RoleImpl();

    model.setRoleId(soapModel.getRoleId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setClassNameId(soapModel.getClassNameId());
    model.setClassPK(soapModel.getClassPK());
    model.setName(soapModel.getName());
    model.setTitle(soapModel.getTitle());
    model.setDescription(soapModel.getDescription());
    model.setType(soapModel.getType());
    model.setSubtype(soapModel.getSubtype());

    return model;
  }