@Override
  protected void doExportStagedModel(PortletDataContext portletDataContext, Repository repository)
      throws Exception {

    Element repositoryElement = portletDataContext.getExportDataElement(repository);

    Folder folder = DLAppLocalServiceUtil.getFolder(repository.getDlFolderId());

    if (folder.getModel() instanceof DLFolder) {
      DLFolder dlFolder = (DLFolder) folder.getModel();

      repositoryElement.addAttribute("hidden", String.valueOf(dlFolder.isHidden()));
    }

    portletDataContext.addClassedModel(
        repositoryElement, ExportImportPathUtil.getModelPath(repository), repository);

    List<RepositoryEntry> repositoryEntries =
        RepositoryEntryLocalServiceUtil.getRepositoryEntries(repository.getRepositoryId());

    for (RepositoryEntry repositoryEntry : repositoryEntries) {
      StagedModelDataHandlerUtil.exportReferenceStagedModel(
          portletDataContext, repository, repositoryEntry, PortletDataContext.REFERENCE_TYPE_CHILD);
    }
  }
Esempio n. 2
0
  @Override
  public String getAbsolutePath(PortletRequest portletRequest, long folderId)
      throws PortalException, SystemException {

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

    if (folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return themeDisplay.translate("home");
    }

    Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

    List<Folder> folders = folder.getAncestors();

    Collections.reverse(folders);

    StringBundler sb = new StringBundler((folders.size() * 3) + 5);

    sb.append(themeDisplay.translate("home"));
    sb.append(StringPool.SPACE);

    for (Folder curFolder : folders) {
      sb.append(StringPool.RAQUO);
      sb.append(StringPool.SPACE);
      sb.append(curFolder.getName());
    }

    sb.append(StringPool.RAQUO);
    sb.append(StringPool.SPACE);
    sb.append(folder.getName());

    return sb.toString();
  }
Esempio n. 3
0
  @Override
  public boolean isSubscribedToFolder(
      long companyId, long groupId, long userId, long folderId, boolean recursive)
      throws PortalException, SystemException {

    List<Long> ancestorFolderIds = new ArrayList<Long>();

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

      if (recursive) {
        ancestorFolderIds = folder.getAncestorFolderIds();

        ancestorFolderIds.add(groupId);
      }

      ancestorFolderIds.add(0, folderId);
    } else {
      ancestorFolderIds.add(groupId);
    }

    long[] folderIdsArray = ArrayUtil.toLongArray(ancestorFolderIds);

    return SubscriptionLocalServiceUtil.isSubscribed(
        companyId, userId, Folder.class.getName(), folderIdsArray);
  }
 @Override
 public Folder getFolder() {
   try {
     return DLAppLocalServiceUtil.getFolder(_folderId);
   } catch (PortalException pe) {
     return null;
   }
 }
Esempio n. 5
0
  public static void addPortletBreadcrumbEntries(
      long folderId, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    if (folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return;
    }

    Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

    addPortletBreadcrumbEntries(folder, request, renderResponse);
  }
  public static boolean contains(
      PermissionChecker permissionChecker, long groupId, long folderId, String actionId)
      throws PortalException, SystemException {

    if (folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return DLPermission.contains(permissionChecker, groupId, actionId);
    } else {
      Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

      return folder.containsPermission(permissionChecker, actionId);
    }
  }
  /** @see com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter */
  public static boolean hasFiles(HttpServletRequest request) {
    try {

      // Do not use permission checking since this may be called from
      // other contexts that are also managing the principal

      User user = _getUser(request);

      String path = HttpUtil.fixPath(request.getPathInfo());

      String[] pathArray = StringUtil.split(path, CharPool.SLASH);

      if (pathArray.length == 0) {
        return true;
      } else if (_PATH_DDM.equals(pathArray[0])) {
        _checkDDMRecord(pathArray);
      } else if (Validator.isNumber(pathArray[0])) {
        _checkFileEntry(pathArray);
      } else {
        long groupId = _getGroupId(user.getCompanyId(), pathArray[0]);
        long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

        for (int i = 1; i < pathArray.length; i++) {
          try {
            Folder folder = DLAppLocalServiceUtil.getFolder(groupId, folderId, pathArray[i]);

            folderId = folder.getFolderId();
          } catch (NoSuchFolderException nsfe) {
            if (i != (pathArray.length - 1)) {
              return false;
            }

            pathArray =
                new String[] {String.valueOf(groupId), String.valueOf(folderId), pathArray[i]};

            _checkFileEntry(pathArray);
          }
        }
      }
    } catch (Exception e) {
      return false;
    }

    return true;
  }
  @Override
  public Folder addPortletFolder(
      long userId,
      long repositoryId,
      long parentFolderId,
      String folderName,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    boolean dlAppHelperEnabled = DLAppHelperThreadLocal.isEnabled();

    try {
      DLAppHelperThreadLocal.setEnabled(false);

      return DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
    } catch (NoSuchFolderException nsfe) {
      return DLAppLocalServiceUtil.addFolder(
          userId, repositoryId, parentFolderId, folderName, StringPool.BLANK, serviceContext);
    } finally {
      DLAppHelperThreadLocal.setEnabled(dlAppHelperEnabled);
    }
  }
  protected Folder addFolder(long parentFolderId, String name, boolean deleteExisting)
      throws Exception {

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    if (deleteExisting) {
      try {
        Folder folder = DLAppLocalServiceUtil.getFolder(_group.getGroupId(), parentFolderId, name);

        DLAppLocalServiceUtil.deleteFolder(folder.getFolderId());
      } catch (NoSuchFolderException nsfe) {
      }
    }

    return DLAppLocalServiceUtil.addFolder(
        TestPropsValues.getUserId(),
        _group.getGroupId(),
        parentFolderId,
        name,
        StringPool.BLANK,
        serviceContext);
  }
  @Override
  public Folder getPortletFolder(long repositoryId, long parentFolderId, String folderName)
      throws PortalException, SystemException {

    return DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
  }
  @Override
  public Folder getPortletFolder(long folderId) throws PortalException, SystemException {

    return DLAppLocalServiceUtil.getFolder(folderId);
  }
Esempio n. 12
0
  @Override
  public String getWebDavURL(
      ThemeDisplay themeDisplay,
      Folder folder,
      FileEntry fileEntry,
      boolean manualCheckInRequired,
      boolean openDocumentUrl)
      throws PortalException, SystemException {

    StringBundler webDavURL = new StringBundler(8);

    boolean secure = false;

    if (themeDisplay.isSecure() || PropsValues.WEBDAV_SERVLET_HTTPS_REQUIRED) {

      secure = true;
    }

    String portalURL =
        PortalUtil.getPortalURL(themeDisplay.getServerName(), themeDisplay.getServerPort(), secure);

    webDavURL.append(portalURL);

    webDavURL.append(themeDisplay.getPathContext());
    webDavURL.append("/webdav");

    if (manualCheckInRequired) {
      webDavURL.append(MANUAL_CHECK_IN_REQUIRED_PATH);
    }

    String fileEntryTitle = null;

    if (fileEntry != null) {
      String extension = fileEntry.getExtension();

      fileEntryTitle = HtmlUtil.unescape(fileEntry.getTitle());

      if (openDocumentUrl
          && isOfficeExtension(extension)
          && !fileEntryTitle.endsWith(StringPool.PERIOD + extension)) {

        webDavURL.append(OFFICE_EXTENSION_PATH);

        fileEntryTitle += StringPool.PERIOD + extension;
      }
    }

    Group group = themeDisplay.getScopeGroup();

    webDavURL.append(group.getFriendlyURL());
    webDavURL.append("/document_library");

    StringBuilder sb = new StringBuilder();

    if ((folder != null) && (folder.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID)) {

      Folder curFolder = folder;

      while (true) {
        sb.insert(0, HttpUtil.encodeURL(curFolder.getName(), true));
        sb.insert(0, StringPool.SLASH);

        if (curFolder.getParentFolderId() == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

          break;
        }

        curFolder = DLAppLocalServiceUtil.getFolder(curFolder.getParentFolderId());
      }
    }

    if (fileEntry != null) {
      sb.append(StringPool.SLASH);
      sb.append(HttpUtil.encodeURL(fileEntryTitle, true));
    }

    webDavURL.append(sb.toString());

    return webDavURL.toString();
  }