Exemplo n.º 1
0
  protected void updateActive(ActionRequest actionRequest, String cmd) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    if ((groupId == themeDisplay.getDoAsGroupId())
        || (groupId == themeDisplay.getScopeGroupId())
        || (groupId == getRefererGroupId(themeDisplay))) {

      throw new RequiredGroupException(
          String.valueOf(groupId), RequiredGroupException.CURRENT_GROUP);
    }

    Group group = GroupServiceUtil.getGroup(groupId);

    boolean active = false;

    if (cmd.equals(Constants.RESTORE)) {
      active = true;
    }

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(Group.class.getName(), actionRequest);

    GroupServiceUtil.updateGroup(
        groupId,
        group.getParentGroupId(),
        group.getName(),
        group.getDescription(),
        group.getType(),
        group.getFriendlyURL(),
        active,
        serviceContext);
  }
  protected int[] getRoleTypes(long companyId, Group group, String modelResource) {

    int[] types = RoleConstants.TYPES_REGULAR_AND_SITE;

    if (isPortalModelResource(modelResource)) {
      if (modelResource.equals(Organization.class.getName())
          || modelResource.equals(User.class.getName())) {

        types = RoleConstants.TYPES_ORGANIZATION_AND_REGULAR;
      } else {
        types = RoleConstants.TYPES_REGULAR;
      }
    } else {
      if (group != null) {
        if (group.isLayout()) {
          try {
            group = GroupServiceUtil.getGroup(group.getParentGroupId());
          } catch (Exception e) {
          }
        }

        if (group.isOrganization()) {
          types = RoleConstants.TYPES_ORGANIZATION_AND_REGULAR_AND_SITE;
        } else if (group.isUser()) {
          types = RoleConstants.TYPES_REGULAR;
        }
      }
    }

    return types;
  }
  public static com.liferay.portal.model.GroupSoap getGroup(long groupId) throws RemoteException {
    try {
      com.liferay.portal.model.Group returnValue = GroupServiceUtil.getGroup(groupId);

      return com.liferay.portal.model.GroupSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  public static com.liferay.portal.model.GroupSoap getGroup(long companyId, java.lang.String name)
      throws RemoteException {
    try {
      com.liferay.portal.model.Group returnValue = GroupServiceUtil.getGroup(companyId, name);

      return com.liferay.portal.model.GroupSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
Exemplo n.º 5
0
  public static List<Group> getFavoriteSitesGroups(long userId, String name, int start, int end)
      throws Exception {

    List<Object[]> favoriteSites =
        FavoriteSiteLocalServiceUtil.getFavoriteSites(userId, name, start, end);

    List<Group> groups = new ArrayList<Group>(favoriteSites.size());

    for (Object[] favoriteSite : favoriteSites) {
      long curUserId = (Long) favoriteSite[0];
      long groupId = (Long) favoriteSite[1];

      try {
        groups.add(GroupServiceUtil.getGroup(groupId));
      } catch (Exception e) {
        FavoriteSiteLocalServiceUtil.deleteFavoriteSite(curUserId, groupId);
      }
    }

    return groups;
  }
  protected String getResults(HttpServletRequest request) throws Exception {

    String xml = StringUtil.read(request.getInputStream());

    String documentName = null;

    int beginPos = xml.lastIndexOf("<document>");
    int endPos = xml.lastIndexOf("</document>");

    if (beginPos != -1) {
      documentName = xml.substring(beginPos + 10, endPos);

      documentName = HttpUtil.decodeURL(documentName);
    }

    String path = documentName;

    int pos = documentName.lastIndexOf("sharepoint/");

    if (pos != -1) {
      path = path.substring(pos + 11);
    }

    Group group = GroupServiceUtil.getGroup(SharepointUtil.getGroupId(path));

    boolean minimal = false;

    beginPos = xml.lastIndexOf("<minimal>");
    endPos = xml.lastIndexOf("</minimal>");

    if (beginPos != -1) {
      minimal = GetterUtil.getBoolean(xml.substring(beginPos + 9, endPos));
    }

    Document doc = SAXReaderUtil.createDocument();

    Element root = doc.addElement("Results");

    String url = "http://" + request.getLocalAddr() + ":" + request.getServerPort() + "/sharepoint";

    root.addElement("SubscribeUrl").setText(url);
    root.addElement("MtgInstance");
    root.addElement("SettingUrl").setText(url);
    root.addElement("PermsUrl").setText(url);
    root.addElement("UserInfoUrl").setText(url);

    Element rolesEl = root.addElement("Roles");

    List<Role> roles = RoleLocalServiceUtil.getRoles(PortalUtil.getCompanyId(request));

    for (Role role : roles) {
      ResponseElement responseElement = new RoleResponseElement(role);

      responseElement.addElement(rolesEl);
    }

    if (!minimal) {
      Element schemaEl = root.addElement("Schema");

      schemaEl.addAttribute("Name", "Documents");
      schemaEl.addAttribute("Url", group.getName());

      Element fieldEl = schemaEl.addElement("Field");

      fieldEl.addAttribute("Name", "FileLeafRef");
      fieldEl.addAttribute("Required", "true");
      fieldEl.addAttribute("Type", "Invalid");

      fieldEl.addElement("Choices");

      fieldEl = schemaEl.addElement("Field");

      fieldEl.addAttribute("Name", "_SourceUrl");
      fieldEl.addAttribute("Required", "false");
      fieldEl.addAttribute("Type", "Text");

      fieldEl.addElement("Choices");

      fieldEl = schemaEl.addElement("Field");

      fieldEl.addAttribute("Name", "_SharedFileIndex");
      fieldEl.addAttribute("Required", "false");
      fieldEl.addAttribute("Type", "Text");

      fieldEl.addElement("Choices");

      fieldEl = schemaEl.addElement("Field");

      fieldEl.addAttribute("Name", "Order");
      fieldEl.addAttribute("Required", "false");
      fieldEl.addAttribute("Type", "Number");

      fieldEl.addElement("Choices");

      fieldEl = schemaEl.addElement("Field");

      fieldEl.addAttribute("Name", "Title");
      fieldEl.addAttribute("Required", "false");
      fieldEl.addAttribute("Type", "Text");

      fieldEl.addElement("Choices");

      Element listInfoEl = root.addElement("ListInfo");

      listInfoEl.addAttribute("Name", "Links");

      listInfoEl.addElement("Moderated").setText(String.valueOf(false));

      Element listPermissionsEl = listInfoEl.addElement("ListPermissions");

      listPermissionsEl.addElement("DeleteListItems");
      listPermissionsEl.addElement("EditListItems");
      listPermissionsEl.addElement("InsertListItems");
      listPermissionsEl.addElement("ManageRoles");
      listPermissionsEl.addElement("ManageWeb");
    }

    Element permissionsEl = root.addElement("Permissions");

    if (!minimal) {
      permissionsEl.addElement("DeleteListItems");
      permissionsEl.addElement("EditListItems");
      permissionsEl.addElement("InsertListItems");
      permissionsEl.addElement("ManageRoles");
      permissionsEl.addElement("ManageWeb");
    }

    root.addElement("HasUniquePerm").setText(String.valueOf(true));
    root.addElement("WorkspaceType").setText("DWS");
    root.addElement("IsADMode").setText(String.valueOf(false));
    root.addElement("DocUrl").setText(documentName);
    root.addElement("Minimal").setText(String.valueOf(true));

    Element resultsEl = root.addElement("Results");

    resultsEl.addElement("Title").setText(group.getName());
    resultsEl.addElement("LastUpdate");

    User user = (User) request.getSession().getAttribute(WebKeys.USER);

    ResponseElement responseElement = new MemberResponseElement(user, false);

    responseElement.addElement(resultsEl);

    Element membersEl = resultsEl.addElement("Members");

    List<User> users = UserLocalServiceUtil.getGroupUsers(group.getGroupId());

    for (User member : users) {
      responseElement = new MemberResponseElement(member, true);

      responseElement.addElement(membersEl);
    }

    if (!minimal) {
      Element assigneesEl = resultsEl.addElement("Assignees");

      for (User member : users) {
        responseElement = new MemberResponseElement(member, true);

        responseElement.addElement(assigneesEl);
      }

      Element listEl = resultsEl.addElement("List");

      listEl.addAttribute("Name", "Documents");

      listEl.addElement("ID");

      String parentFolderPath = path;

      pos = parentFolderPath.lastIndexOf("/");

      if (pos != -1) {
        parentFolderPath = parentFolderPath.substring(0, pos);
      }

      SharepointStorage storage = SharepointUtil.getStorage(parentFolderPath);

      SharepointRequest sharepointRequest = new SharepointRequest(parentFolderPath);

      storage.addDocumentElements(sharepointRequest, listEl);
    }

    return doc.asXML();
  }