/** Gets all roles available. */
  public List<InfoGlueRoleBean> getRoles() {
    if (!ServerNodeController.getController().getIsIPAllowed(getRequest())) {
      logger.error(
          "A client with IP "
              + getRequest().getRemoteAddr()
              + " was denied access to the webservice. Could be a hack attempt or you have just not configured the allowed IP-addresses correct.");
      return null;
    }

    List<InfoGlueRoleBean> roles = new ArrayList<InfoGlueRoleBean>();

    logger.info("***************************************");
    logger.info("Getting all roles through webservice...");
    logger.info("***************************************");

    try {
      List rolesList = RoleControllerProxy.getController().getAllRoles();

      Iterator rolesListIterator = rolesList.iterator();
      while (rolesListIterator.hasNext()) {
        InfoGlueRole role = (InfoGlueRole) rolesListIterator.next();
        InfoGlueRoleBean bean = new InfoGlueRoleBean();
        bean.setName(role.getName());
        bean.setDisplayName(role.getDisplayName());
        bean.setDescription(role.getDescription());
        roles.add(bean);
      }
    } catch (Exception e) {
      logger.error(
          "En error occurred when we tried to create a new contentVersion:" + e.getMessage(), e);
    }

    return roles;
  }
Esempio n. 2
0
  /**
   * This method initializes the view by populating all the entities. It fetches the role itself,
   * the type of authorization update support and all the assigned principals. It then populates a
   * list of unassigned principals.
   */
  protected void initialize(String roleName) throws Exception {
    this.infoGlueRole = RoleControllerProxy.getController().getRole(roleName);
    this.supportsUpdate = this.infoGlueRole.getAutorizationModule().getSupportUpdate();
    this.availableSystemUserCount =
        UserControllerProxy.getTableCount("cmSystemUser", "userName").getCount();
    if (this.supportsUpdate) {
      this.assignedInfoGluePrincipals =
          this.infoGlueRole.getAutorizationModule().getRoleUsers(roleName);
      if (availableSystemUserCount < 10000) {
        this.infoGluePrincipals = this.infoGlueRole.getAutorizationModule().getUsers();
        // this.supportsUpdate				= RoleControllerProxy.getController().getSupportUpdate();
        if (this.supportsUpdate) // Only fetch if the user can edit.
        {
          List newInfogluePrincipals = new ArrayList();
          newInfogluePrincipals.addAll(this.infoGluePrincipals);
          newInfogluePrincipals.removeAll(assignedInfoGluePrincipals);
          this.unassignedInfoGluePrincipals = newInfogluePrincipals;
        }
      }
    }

    this.contentTypeDefinitionVOList =
        ContentTypeDefinitionController.getController()
            .getContentTypeDefinitionVOList(ContentTypeDefinitionVO.EXTRANET_ROLE_PROPERTIES);
    this.assignedContentTypeDefinitionVOList =
        RolePropertiesController.getController().getContentTypeDefinitionVOList(roleName);
  }
  protected String doExecute() throws Exception {
    ceb.add(this.roleVO.validate());
    ceb.throwIfNotEmpty();

    String[] userNames = getRequest().getParameterValues("userName");
    String[] contentTypeDefinitionIds = getRequest().getParameterValues("contentTypeDefinitionId");

    RoleControllerProxy.getController().createRole(this.roleVO);
    if (userNames != null) {
      RoleControllerProxy.getController().updateRole(this.roleVO, userNames);
    }

    if (contentTypeDefinitionIds != null
        && contentTypeDefinitionIds.length > 0
        && !contentTypeDefinitionIds[0].equals(""))
      RolePropertiesController.getController()
          .updateContentTypeDefinitions(this.getRoleName(), contentTypeDefinitionIds);

    return "success";
  }
  /** Gets all roles available. */
  public List<InfoGluePrincipalBean> getPrincipalsWithRole(String roleName) {
    if (!ServerNodeController.getController().getIsIPAllowed(getRequest())) {
      logger.error(
          "A client with IP "
              + getRequest().getRemoteAddr()
              + " was denied access to the webservice. Could be a hack attempt or you have just not configured the allowed IP-addresses correct.");
      return null;
    }

    List<InfoGluePrincipalBean> users = new ArrayList<InfoGluePrincipalBean>();

    logger.info("***************************************");
    logger.info("Getting all principals through webservice..");
    logger.info("***************************************");

    try {
      List principalList = RoleControllerProxy.getController().getInfoGluePrincipals(roleName);

      Iterator principalListIterator = principalList.iterator();
      while (principalListIterator.hasNext()) {
        InfoGluePrincipal principal = (InfoGluePrincipal) principalListIterator.next();
        InfoGluePrincipalBean bean = new InfoGluePrincipalBean();
        bean.setName(principal.getName());
        bean.setDisplayName(principal.getDisplayName());
        bean.setEmail(principal.getEmail());
        bean.setFirstName(principal.getFirstName());
        bean.setLastName(principal.getLastName());
        bean.setAdministrator(false);
        bean.setMetaInformation(principal.getMetaInformation());

        List groups = new ArrayList();
        Iterator groupsListIterator = principal.getGroups().iterator();
        while (groupsListIterator.hasNext()) {
          InfoGlueGroup group = (InfoGlueGroup) groupsListIterator.next();
          InfoGlueGroupBean groupBean = new InfoGlueGroupBean();
          groupBean.setName(group.getName());
          groupBean.setDisplayName(group.getDisplayName());
          groupBean.setDescription(group.getDescription());
          groups.add(groupBean);
        }
        bean.setGroups(groups);

        List roles = new ArrayList();
        Iterator rolesListIterator = principal.getRoles().iterator();
        while (rolesListIterator.hasNext()) {
          InfoGlueRole role = (InfoGlueRole) rolesListIterator.next();
          InfoGlueRoleBean roleBean = new InfoGlueRoleBean();
          roleBean.setName(role.getName());
          roleBean.setDisplayName(role.getDisplayName());
          roleBean.setDescription(role.getDescription());
          roles.add(roleBean);
        }
        bean.setRoles(roles);

        users.add(bean);
      }
    } catch (Exception e) {
      logger.error(
          "En error occurred when we tried to create a new contentVersion:" + e.getMessage(), e);
    }

    return users;
  }
  public List getRoles() throws Exception {
    List roles = RoleControllerProxy.getController().getAllRoles();

    return roles;
  }