/**
   * Returns the WebDAV URL to access the structure.
   *
   * @param themeDisplay the theme display needed to build the URL. It can set HTTPS access, the
   *     server name, the server port, the path context, and the scope group.
   * @param webDAVToken the WebDAV token for the URL
   * @return the WebDAV URL
   */
  @Override
  public String getWebDavURL(ThemeDisplay themeDisplay, String webDAVToken) {
    StringBundler sb = new StringBundler(11);

    boolean secure = false;

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

      secure = true;
    }

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

    sb.append(portalURL);

    sb.append(themeDisplay.getPathContext());
    sb.append(StringPool.SLASH);
    sb.append("webdav");

    Group group = themeDisplay.getScopeGroup();

    sb.append(group.getFriendlyURL());

    sb.append(StringPool.SLASH);
    sb.append(webDAVToken);
    sb.append(StringPool.SLASH);
    sb.append("Structures");
    sb.append(StringPool.SLASH);
    sb.append(getStructureId());

    return sb.toString();
  }
  @Override
  public JournalArticleDisplay getDisplay(
      long groupId,
      String articleId,
      double version,
      String ddmTemplateKey,
      String viewMode,
      String languageId,
      int page,
      PortletRequestModel portletRequestModel,
      ThemeDisplay themeDisplay) {

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();

    articleId = StringUtil.toUpperCase(GetterUtil.getString(articleId));
    ddmTemplateKey = StringUtil.toUpperCase(GetterUtil.getString(ddmTemplateKey));

    long layoutSetId = 0;
    boolean secure = false;

    if (themeDisplay != null) {
      try {
        if (!JournalArticlePermission.contains(
            themeDisplay.getPermissionChecker(), groupId, articleId, ActionKeys.VIEW)) {

          return null;
        }
      } catch (Exception e) {
      }

      LayoutSet layoutSet = themeDisplay.getLayoutSet();

      layoutSetId = layoutSet.getLayoutSetId();

      secure = themeDisplay.isSecure();
    }

    JournalContentKey journalContentKey =
        new JournalContentKey(
            groupId,
            articleId,
            version,
            ddmTemplateKey,
            layoutSetId,
            viewMode,
            languageId,
            page,
            secure);

    JournalArticleDisplay articleDisplay = _getPortalCache().get(journalContentKey);

    boolean lifecycleRender = false;

    if (portletRequestModel != null) {
      lifecycleRender = RenderRequest.RENDER_PHASE.equals(portletRequestModel.getLifecycle());
    }

    if ((articleDisplay == null) || !lifecycleRender) {
      articleDisplay =
          getArticleDisplay(
              groupId,
              articleId,
              ddmTemplateKey,
              viewMode,
              languageId,
              page,
              portletRequestModel,
              themeDisplay);

      if ((articleDisplay != null) && articleDisplay.isCacheable() && lifecycleRender) {

        _getPortalCache().put(journalContentKey, articleDisplay);
      }
    }

    if (_log.isDebugEnabled()) {
      _log.debug(
          "getDisplay for {"
              + groupId
              + ", "
              + articleId
              + ", "
              + ddmTemplateKey
              + ", "
              + viewMode
              + ", "
              + languageId
              + ", "
              + page
              + "} takes "
              + stopWatch.getTime()
              + " ms");
    }

    return articleDisplay;
  }
예제 #3
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();
  }