@Override public String getPortalURL(long groupId) throws PortalException, SystemException { String portalURL = PortalUtil.getPortalURL(getVirtualHostname(), Http.HTTP_PORT, false); if (groupId <= 0) { return portalURL; } Group group = GroupLocalServiceUtil.getGroup(groupId); if (group.hasPublicLayouts()) { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, false); if (Validator.isNotNull(layoutSet.getVirtualHostname())) { portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false); } } else if (group.hasPrivateLayouts()) { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, true); if (Validator.isNotNull(layoutSet.getVirtualHostname())) { portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false); } } return portalURL; }
/** * 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 ActionForward render( ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try { ActionUtil.getEntry(renderRequest); if (PropsValues.BLOGS_PINGBACK_ENABLED) { BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY); if ((entry != null) && entry.isAllowPingbacks()) { HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse); response.addHeader( "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback"); } } } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.blogs.error"); } else { throw e; } } return mapping.findForward(getForward(renderRequest, "portlet.blogs.edit_entry")); }
public String getCDNBaseURL() { if (_cdnBaseURL != null) { return _cdnBaseURL; } String host = getCDNHost(); String portalURL = getPortalURL(); if (getServerName() != null) { try { portalURL = PortalUtil.getPortalURL(getLayout(), this); } catch (Exception e) { _log.error(e, e); } } if (Validator.isNull(host)) { host = portalURL; } _cdnBaseURL = host; return _cdnBaseURL; }
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(request, Constants.CMD); String redirectUri = PortalUtil.getPortalURL(request) + _REDIRECT_URI; if (cmd.equals("login")) { GoogleAuthorizationCodeFlow flow = getFlow(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); GoogleAuthorizationCodeRequestUrl googleAuthorizationCodeRequestUrl = flow.newAuthorizationUrl(); googleAuthorizationCodeRequestUrl.setRedirectUri(redirectUri); String url = googleAuthorizationCodeRequestUrl.build(); response.sendRedirect(url); } else if (cmd.equals("token")) { HttpSession session = request.getSession(); String code = ParamUtil.getString(request, "code"); if (Validator.isNotNull(code)) { Credential credential = exchangeCode( themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), code, redirectUri); User user = setGoogleCredentials(session, themeDisplay.getCompanyId(), credential); if ((user != null) && (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) { redirectUpdateAccount(request, response, user); return null; } sendLoginRedirect(request, response); return null; } String error = ParamUtil.getString(request, "error"); if (error.equals("access_denied")) { sendLoginRedirect(request, response); return null; } } return null; }
protected String getCompleteRedirectURL(HttpServletRequest request, String redirect) { HttpSession session = request.getSession(); Boolean httpsInitial = (Boolean) session.getAttribute(WebKeys.HTTPS_INITIAL); String portalURL = null; if (PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS && !PropsValues.SESSION_ENABLE_PHISHING_PROTECTION && (httpsInitial != null) && !httpsInitial.booleanValue()) { portalURL = PortalUtil.getPortalURL(request, false); } else { portalURL = PortalUtil.getPortalURL(request); } return portalURL.concat(redirect); }
/** * Returns the full, absolute URL (including the portal's URL) of the navigation item's layout. * * @return the full, absolute URL of the navigation item's layout * @throws Exception if an exception occurred */ public String getRegularFullURL() throws Exception { String portalURL = PortalUtil.getPortalURL(_request); String regularURL = getRegularURL(); if (StringUtil.startsWith(regularURL, portalURL) || Validator.isUrl(regularURL)) { return regularURL; } else { return portalURL.concat(regularURL); } }
@Override public void sendRedirect(String redirect) throws IOException { String portalURL = PortalUtil.getPortalURL(_request); if (redirect.charAt(0) == CharPool.SLASH) { if (Validator.isNotNull(portalURL)) { redirect = portalURL.concat(redirect); } } if (!CookieKeys.hasSessionId(_request) && redirect.startsWith(portalURL)) { redirect = PortalUtil.getURLWithSessionId(redirect, _request.getSession().getId()); } _request.setAttribute(AbsoluteRedirectsResponse.class.getName(), redirect); super.sendRedirect(redirect); }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { try { ActionUtil.getEntry(renderRequest); if (PropsValues.BLOGS_PINGBACK_ENABLED) { BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY); if ((entry != null) && entry.isAllowPingbacks()) { HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse); response.addHeader( "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback"); } } } catch (Exception e) { if (e instanceof NoSuchEntryException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/html/portlet/blogs/error.jsp"; } else { throw new PortletException(e); } } long assetCategoryId = ParamUtil.getLong(renderRequest, "categoryId"); String assetCategoryName = ParamUtil.getString(renderRequest, "tag"); if ((assetCategoryId > 0) || Validator.isNotNull(assetCategoryName)) { return "/html/portlet/blogs/view.jsp"; } return getPath(); }
public void setLookAndFeel(Theme theme, ColorScheme colorScheme) { _theme = theme; _colorScheme = colorScheme; if ((theme != null) && (colorScheme != null)) { String themeStaticResourcePath = theme.getStaticResourcePath(); String cdnBaseURL = getCDNBaseURL(); setPathColorSchemeImages( cdnBaseURL + themeStaticResourcePath + colorScheme.getColorSchemeImagesPath()); String dynamicResourcesHost = getCDNDynamicResourcesHost(); if (Validator.isNull(dynamicResourcesHost)) { String portalURL = getPortalURL(); if (getServerName() != null) { try { portalURL = PortalUtil.getPortalURL(getLayout(), this); } catch (Exception e) { _log.error(e, e); } } dynamicResourcesHost = portalURL; } setPathThemeCss(dynamicResourcesHost + themeStaticResourcePath + theme.getCssPath()); setPathThemeImages(cdnBaseURL + themeStaticResourcePath + theme.getImagesPath()); setPathThemeJavaScript(cdnBaseURL + themeStaticResourcePath + theme.getJavaScriptPath()); setPathThemeRoot(themeStaticResourcePath + theme.getRootPath()); setPathThemeTemplates(cdnBaseURL + themeStaticResourcePath + theme.getTemplatesPath()); } }
private void _doServeResource( HttpServletRequest request, HttpServletResponse response, Portlet portlet) throws Exception { HttpServletRequest ownerLayoutRequest = getOwnerLayoutRequestWrapper(request, portlet); Layout ownerLayout = (Layout) ownerLayoutRequest.getAttribute(WebKeys.LAYOUT); boolean allowAddPortletDefaultResource = PortalUtil.isAllowAddPortletDefaultResource(ownerLayoutRequest, portlet); if (!allowAddPortletDefaultResource) { String url = null; LastPath lastPath = (LastPath) request.getAttribute(WebKeys.LAST_PATH); if (lastPath != null) { StringBundler sb = new StringBundler(3); sb.append(PortalUtil.getPortalURL(request)); sb.append(lastPath.getContextPath()); sb.append(lastPath.getPath()); url = sb.toString(); } else { url = String.valueOf(request.getRequestURI()); } response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); _log.error("Reject serveResource for " + url + " on " + portlet.getPortletId()); return; } WindowState windowState = (WindowState) request.getAttribute(WebKeys.WINDOW_STATE); PortletMode portletMode = PortletModeFactory.getPortletMode(ParamUtil.getString(request, "p_p_mode")); PortletPreferencesIds portletPreferencesIds = PortletPreferencesFactoryUtil.getPortletPreferencesIds(request, portlet.getPortletId()); PortletPreferences portletPreferences = PortletPreferencesLocalServiceUtil.getPreferences(portletPreferencesIds); ServletContext servletContext = (ServletContext) request.getAttribute(WebKeys.CTX); InvokerPortlet invokerPortlet = PortletInstanceFactoryUtil.create(portlet, servletContext); PortletConfig portletConfig = PortletConfigFactoryUtil.create(portlet, servletContext); PortletContext portletContext = portletConfig.getPortletContext(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT); String portletPrimaryKey = PortletPermissionUtil.getPrimaryKey(layout.getPlid(), portlet.getPortletId()); portletDisplay.setId(portlet.getPortletId()); portletDisplay.setRootPortletId(portlet.getRootPortletId()); portletDisplay.setInstanceId(portlet.getInstanceId()); portletDisplay.setResourcePK(portletPrimaryKey); portletDisplay.setPortletName(portletConfig.getPortletName()); portletDisplay.setNamespace(PortalUtil.getPortletNamespace(portlet.getPortletId())); WebDAVStorage webDAVStorage = portlet.getWebDAVStorageInstance(); if (webDAVStorage != null) { portletDisplay.setWebDAVEnabled(true); } else { portletDisplay.setWebDAVEnabled(false); } ResourceRequestImpl resourceRequestImpl = ResourceRequestFactory.create( request, portlet, invokerPortlet, portletContext, windowState, portletMode, portletPreferences, layout.getPlid()); long companyId = PortalUtil.getCompanyId(request); ResourceResponseImpl resourceResponseImpl = ResourceResponseFactory.create( resourceRequestImpl, response, portlet.getPortletId(), companyId); resourceRequestImpl.defineObjects(portletConfig, resourceResponseImpl); try { ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequestImpl); ServiceContextThreadLocal.pushServiceContext(serviceContext); PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); long scopeGroupId = themeDisplay.getScopeGroupId(); boolean access = PortletPermissionUtil.hasAccessPermission( permissionChecker, scopeGroupId, ownerLayout, portlet, portletMode); if (access) { invokerPortlet.serveResource(resourceRequestImpl, resourceResponseImpl); resourceResponseImpl.transferHeaders(response); } } finally { ServiceContextThreadLocal.popServiceContext(); } }
private ActionResult _doProcessAction( HttpServletRequest request, HttpServletResponse response, Portlet portlet) throws Exception { HttpServletRequest ownerLayoutRequest = getOwnerLayoutRequestWrapper(request, portlet); Layout ownerLayout = (Layout) ownerLayoutRequest.getAttribute(WebKeys.LAYOUT); boolean allowAddPortletDefaultResource = PortalUtil.isAllowAddPortletDefaultResource(ownerLayoutRequest, portlet); if (!allowAddPortletDefaultResource) { String url = null; LastPath lastPath = (LastPath) request.getAttribute(WebKeys.LAST_PATH); if (lastPath != null) { StringBundler sb = new StringBundler(3); sb.append(PortalUtil.getPortalURL(request)); sb.append(lastPath.getContextPath()); sb.append(lastPath.getPath()); url = sb.toString(); } else { url = String.valueOf(request.getRequestURI()); } _log.error("Reject processAction for " + url + " on " + portlet.getPortletId()); return ActionResult.EMPTY_ACTION_RESULT; } Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT); WindowState windowState = WindowStateFactory.getWindowState(ParamUtil.getString(request, "p_p_state")); if (layout.isTypeControlPanel() && ((windowState == null) || windowState.equals(WindowState.NORMAL) || Validator.isNull(windowState.toString()))) { windowState = WindowState.MAXIMIZED; } PortletMode portletMode = PortletModeFactory.getPortletMode(ParamUtil.getString(request, "p_p_mode")); PortletPreferencesIds portletPreferencesIds = PortletPreferencesFactoryUtil.getPortletPreferencesIds(request, portlet.getPortletId()); PortletPreferences portletPreferences = PortletPreferencesLocalServiceUtil.getPreferences(portletPreferencesIds); ServletContext servletContext = (ServletContext) request.getAttribute(WebKeys.CTX); InvokerPortlet invokerPortlet = PortletInstanceFactoryUtil.create(portlet, servletContext); PortletConfig portletConfig = PortletConfigFactoryUtil.create(portlet, servletContext); PortletContext portletContext = portletConfig.getPortletContext(); String contentType = request.getHeader(HttpHeaders.CONTENT_TYPE); if (_log.isDebugEnabled()) { _log.debug("Content type " + contentType); } UploadServletRequest uploadServletRequest = null; try { if ((contentType != null) && contentType.startsWith(ContentTypes.MULTIPART_FORM_DATA)) { PortletConfigImpl invokerPortletConfigImpl = (PortletConfigImpl) invokerPortlet.getPortletConfig(); if (invokerPortlet.isStrutsPortlet() || invokerPortletConfigImpl.isCopyRequestParameters() || !invokerPortletConfigImpl.isWARFile()) { uploadServletRequest = new UploadServletRequestImpl(request); request = uploadServletRequest; } } if (PropsValues.AUTH_TOKEN_CHECK_ENABLED && invokerPortlet.isCheckAuthToken()) { AuthTokenUtil.check(request); } ActionRequestImpl actionRequestImpl = ActionRequestFactory.create( request, portlet, invokerPortlet, portletContext, windowState, portletMode, portletPreferences, layout.getPlid()); User user = PortalUtil.getUser(request); ActionResponseImpl actionResponseImpl = ActionResponseFactory.create( actionRequestImpl, response, portlet.getPortletId(), user, layout, windowState, portletMode); actionRequestImpl.defineObjects(portletConfig, actionResponseImpl); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequestImpl); ServiceContextThreadLocal.pushServiceContext(serviceContext); PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long scopeGroupId = themeDisplay.getScopeGroupId(); boolean access = PortletPermissionUtil.hasAccessPermission( permissionChecker, scopeGroupId, ownerLayout, portlet, portletMode); if (access) { invokerPortlet.processAction(actionRequestImpl, actionResponseImpl); actionResponseImpl.transferHeaders(response); } RenderParametersPool.put( request, layout.getPlid(), portlet.getPortletId(), actionResponseImpl.getRenderParameterMap()); List<Event> events = actionResponseImpl.getEvents(); String redirectLocation = actionResponseImpl.getRedirectLocation(); if (Validator.isNull(redirectLocation) && portlet.isActionURLRedirect()) { PortletURL portletURL = new PortletURLImpl( actionRequestImpl, actionRequestImpl.getPortletName(), layout.getPlid(), PortletRequest.RENDER_PHASE); Map<String, String[]> renderParameters = actionResponseImpl.getRenderParameterMap(); for (Map.Entry<String, String[]> entry : renderParameters.entrySet()) { String key = entry.getKey(); String[] value = entry.getValue(); portletURL.setParameter(key, value); } redirectLocation = portletURL.toString(); } return new ActionResult(events, redirectLocation); } finally { if (uploadServletRequest != null) { uploadServletRequest.cleanUp(); } ServiceContextThreadLocal.popServiceContext(); } }
protected void visitArticles(Element element, Layout layout, ThemeDisplay themeDisplay) throws PortalException, SystemException { List<JournalArticle> journalArticles = JournalArticleServiceUtil.getArticlesByLayoutUuid(layout.getGroupId(), layout.getUuid()); if (journalArticles.isEmpty()) { return; } Set<String> processedArticleIds = new HashSet<String>(); for (JournalArticle journalArticle : journalArticles) { if (processedArticleIds.contains(journalArticle.getArticleId()) || (journalArticle.getStatus() != WorkflowConstants.STATUS_APPROVED)) { continue; } String portalURL = PortalUtil.getPortalURL(layout, themeDisplay); String groupFriendlyURL = PortalUtil.getGroupFriendlyURL( GroupLocalServiceUtil.getGroup(journalArticle.getGroupId()), false, themeDisplay); StringBundler sb = new StringBundler(4); if (!groupFriendlyURL.startsWith(portalURL)) { sb.append(portalURL); } sb.append(groupFriendlyURL); sb.append(JournalArticleConstants.CANONICAL_URL_SEPARATOR); sb.append(journalArticle.getUrlTitle()); String articleURL = PortalUtil.getCanonicalURL(sb.toString(), themeDisplay, layout); addURLElement( element, articleURL, null, journalArticle.getModifiedDate(), articleURL, getAlternateURLs(articleURL, themeDisplay, layout)); Locale[] availableLocales = LanguageUtil.getAvailableLocales(layout.getGroupId()); if (availableLocales.length > 1) { Locale defaultLocale = LocaleUtil.getSiteDefault(); for (Locale availableLocale : availableLocales) { if (!availableLocale.equals(defaultLocale)) { String alternateURL = PortalUtil.getAlternateURL(articleURL, themeDisplay, availableLocale, layout); addURLElement( element, alternateURL, null, journalArticle.getModifiedDate(), articleURL, getAlternateURLs(articleURL, themeDisplay, layout)); } } } processedArticleIds.add(journalArticle.getArticleId()); } }
private String _getURL( HttpServletRequest request, boolean resetMaxState, boolean resetRenderParameters) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (resetMaxState) { Layout layout = themeDisplay.getLayout(); LayoutTypePortlet layoutTypePortlet = null; if (layout.equals(this)) { layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); } else { try { layoutTypePortlet = _getLayoutTypePortletClone(request); } catch (IOException ioe) { _log.error("Unable to clone layout settings", ioe); layoutTypePortlet = (LayoutTypePortlet) getLayoutType(); } } if (layoutTypePortlet.hasStateMax()) { String portletId = StringUtil.split(layoutTypePortlet.getStateMax())[0]; PortletURLImpl portletURLImpl = new PortletURLImpl(request, portletId, getPlid(), PortletRequest.ACTION_PHASE); try { portletURLImpl.setWindowState(WindowState.NORMAL); portletURLImpl.setPortletMode(PortletMode.VIEW); } catch (PortletException pe) { throw new SystemException(pe); } portletURLImpl.setAnchor(false); if (PropsValues.LAYOUT_DEFAULT_P_L_RESET && !resetRenderParameters) { portletURLImpl.setParameter("p_l_reset", "0"); } else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET && resetRenderParameters) { portletURLImpl.setParameter("p_l_reset", "1"); } return portletURLImpl.toString(); } } String portalURL = PortalUtil.getPortalURL(request); String url = PortalUtil.getLayoutURL(this, themeDisplay); if (!CookieKeys.hasSessionId(request) && (url.startsWith(portalURL) || url.startsWith(StringPool.SLASH))) { url = PortalUtil.getURLWithSessionId(url, request.getSession().getId()); } if (!resetMaxState) { return url; } if (PropsValues.LAYOUT_DEFAULT_P_L_RESET && !resetRenderParameters) { url = HttpUtil.addParameter(url, "p_l_reset", 0); } else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET && resetRenderParameters) { url = HttpUtil.addParameter(url, "p_l_reset", 1); } return url; }
protected void sendEmail(WallEntry wallEntry, ThemeDisplay themeDisplay) throws Exception { long companyId = wallEntry.getCompanyId(); String portalURL = PortalUtil.getPortalURL(themeDisplay); String layoutURL = PortalUtil.getLayoutURL(themeDisplay); String wallEntryURL = portalURL + layoutURL; Group group = GroupLocalServiceUtil.getGroup(wallEntry.getGroupId()); User user = userLocalService.getUserById(group.getClassPK()); User wallEntryUser = userLocalService.getUserById(wallEntry.getUserId()); String fromName = PrefsPropsUtil.getString(companyId, "admin.email.from.name"); String fromAddress = PrefsPropsUtil.getString(companyId, "admin.email.from.address"); String toName = user.getFullName(); String toAddress = user.getEmailAddress(); ClassLoader classLoader = getClass().getClassLoader(); String subject = StringUtil.read( classLoader, "com/liferay/socialnetworking/wall/dependencies/" + "wall_entry_added_subject.tmpl"); String body = StringUtil.read( classLoader, "com/liferay/socialnetworking/wall/dependencies/" + "wall_entry_added_body.tmpl"); subject = StringUtil.replace( subject, new String[] { "[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$TO_ADDRESS$]", "[$TO_NAME$]", "[$WALL_ENTRY_URL$]", "[$WALL_ENTRY_USER_ADDRESS$]", "[$WALL_ENTRY_USER_NAME$]" }, new String[] { fromAddress, fromName, toAddress, toName, wallEntryURL, wallEntryUser.getEmailAddress(), wallEntryUser.getFullName() }); body = StringUtil.replace( body, new String[] { "[$FROM_ADDRESS$]", "[$FROM_NAME$]", "[$TO_ADDRESS$]", "[$TO_NAME$]", "[$WALL_ENTRY_URL$]", "[$WALL_ENTRY_USER_ADDRESS$]", "[$WALL_ENTRY_USER_NAME$]" }, new String[] { fromAddress, fromName, toAddress, toName, wallEntryURL, wallEntryUser.getEmailAddress(), wallEntryUser.getFullName() }); InternetAddress from = new InternetAddress(fromAddress, fromName); InternetAddress to = new InternetAddress(toAddress, toName); MailMessage mailMessage = new MailMessage(from, to, subject, body, true); MailServiceUtil.sendEmail(mailMessage); }
@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(); }