コード例 #1
0
  protected void getRootFolders(CommandArgument argument, Document doc, Element foldersEl)
      throws Exception {

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();

    groupParams.put("usersGroups", new Long(argument.getUserId()));

    List<Group> groups =
        GroupLocalServiceUtil.search(
            argument.getCompanyId(), null, null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    List<Organization> userOrgs =
        OrganizationLocalServiceUtil.getUserOrganizations(argument.getUserId(), true);

    for (Organization organization : userOrgs) {
      groups.add(0, organization.getGroup());
    }

    if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED
        || PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) {

      Group userGroup =
          GroupLocalServiceUtil.getUserGroup(argument.getCompanyId(), argument.getUserId());

      groups.add(0, userGroup);
    }

    ThemeDisplay themeDisplay = argument.getThemeDisplay();

    long scopeGroupId = themeDisplay.getScopeGroupId();

    for (Group group : groups) {
      Element folderEl = doc.createElement("Folder");

      foldersEl.appendChild(folderEl);

      boolean setNameAttribute = false;

      if (group.hasStagingGroup()) {
        Group stagingGroup = group.getStagingGroup();

        if (stagingGroup.getGroupId() == scopeGroupId) {
          folderEl.setAttribute(
              "name",
              stagingGroup.getGroupId()
                  + " - "
                  + HtmlUtil.escape(stagingGroup.getDescriptiveName()));

          setNameAttribute = true;
        }
      }

      if (!setNameAttribute) {
        folderEl.setAttribute(
            "name", group.getGroupId() + " - " + HtmlUtil.escape(group.getDescriptiveName()));
      }
    }
  }
コード例 #2
0
  private void _getFiles(CommandArgument commandArgument, Document document, Node rootNode)
      throws Exception {

    Element filesElement = document.createElement("Files");

    rootNode.appendChild(filesElement);

    if (Validator.isNull(commandArgument.getCurrentGroupName())) {
      return;
    }

    Group group = commandArgument.getCurrentGroup();

    Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder());

    List<FileEntry> fileEntries =
        DLAppServiceUtil.getFileEntries(group.getGroupId(), folder.getFolderId());

    for (FileEntry fileEntry : fileEntries) {
      Element fileElement = document.createElement("File");

      filesElement.appendChild(fileElement);

      fileElement.setAttribute("name", fileEntry.getTitle());
      fileElement.setAttribute("desc", fileEntry.getTitle());
      fileElement.setAttribute("size", getSize(fileEntry.getSize()));

      StringBundler url = new StringBundler(5);

      ThemeDisplay themeDisplay = commandArgument.getThemeDisplay();

      url.append(themeDisplay.getPathMain());
      url.append("/document_library/get_file?uuid=");
      url.append(fileEntry.getUuid());
      url.append("&groupId=");
      url.append(group.getGroupId());

      fileElement.setAttribute("url", url.toString());
    }
  }
コード例 #3
0
  private void _getFiles(CommandArgument commandArgument, Document document, Node rootNode)
      throws Exception {

    if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) {
      return;
    }

    Element filesElement = document.createElement("Files");

    rootNode.appendChild(filesElement);

    Group group = commandArgument.getCurrentGroup();

    List<Layout> layouts =
        LayoutLocalServiceUtil.getLayouts(
            group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

    if (("/" + commandArgument.getCurrentGroupName() + "/")
        .equals(commandArgument.getCurrentFolder())) {

      for (Layout layout : layouts) {
        Element fileElement = document.createElement("File");

        filesElement.appendChild(fileElement);

        fileElement.setAttribute("name", _getLayoutName(layout));
        fileElement.setAttribute("desc", _getLayoutName(layout));
        fileElement.setAttribute("size", StringPool.BLANK);
        fileElement.setAttribute(
            "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false));
      }
    } else {
      String layoutName = _getLayoutName(commandArgument.getCurrentFolder());

      Layout layout = null;

      for (int i = 0; i < layouts.size(); i++) {
        layout = _getLayout(layoutName, layouts.get(i));

        if (layout != null) {
          break;
        }
      }

      if (layout == null) {
        return;
      }

      List<Layout> layoutChildren = layout.getChildren();

      for (int i = 0; i < layoutChildren.size(); i++) {
        layout = layoutChildren.get(i);

        Element fileElement = document.createElement("File");

        filesElement.appendChild(fileElement);

        fileElement.setAttribute("name", _getLayoutName(layout));
        fileElement.setAttribute("desc", _getLayoutName(layout));
        fileElement.setAttribute("size", getSize());
        fileElement.setAttribute(
            "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false));
      }
    }
  }