/** * Returns a link <i>from</i> the URI stored in the provided OpenCms user context * <i>to</i> the given <code>link</code>, for use on web pages.<p> * * A number of tests are performed with the <code>link</code> in order to find out how to create the link:<ul> * <li>If <code>link</code> is empty, an empty String is returned. * <li>If <code>link</code> starts with an URI scheme component, for example <code>http://</code>, * and does not point to an internal OpenCms site, it is returned unchanged. * <li>If <code>link</code> is an absolute URI that starts with a configured site root, * the site root is cut from the link and * the same result as {@link #substituteLink(CmsObject, String, String)} is returned. * <li>Otherwise the same result as {@link #substituteLink(CmsObject, String)} is returned. * </ul> * * @param cms the current OpenCms user context * @param link the link to process * * @return a link <i>from</i> the URI stored in the provided OpenCms user context * <i>to</i> the given <code>link</code> */ public String substituteLinkForUnknownTarget(CmsObject cms, String link) { return substituteLinkForUnknownTarget(cms, link, false); }
/** * Returns a link <i>from</i> the URI stored in the provided OpenCms user context * <i>to</i> the given <code>link</code>, for use on web pages.<p> * * A number of tests are performed with the <code>link</code> in order to find out how to create the link:<ul> * <li>If <code>link</code> is empty, an empty String is returned. * <li>If <code>link</code> starts with an URI scheme component, for example <code>http://</code>, * and does not point to an internal OpenCms site, it is returned unchanged. * <li>If <code>link</code> is an absolute URI that starts with a configured site root, * the site root is cut from the link and * the same result as {@link #substituteLink(CmsObject, String, String)} is returned. * <li>Otherwise the same result as {@link #substituteLink(CmsObject, String)} is returned. * </ul> * * @param cms the current OpenCms user context * @param link the link to process * @param forceSecure forces the secure server prefix if the link target is secure * * @return a link <i>from</i> the URI stored in the provided OpenCms user context * <i>to</i> the given <code>link</code> */ public String substituteLinkForUnknownTarget(CmsObject cms, String link, boolean forceSecure) { return substituteLinkForUnknownTarget(cms, link, null, forceSecure); }
/** * Returns the reset password link.<p> * * @return the reset password link */ public String getResetPasswordLink() { return OpenCms.getLinkManager().substituteLinkForUnknownTarget( CmsLoginUI.m_adminCms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false) + "?" + CmsLoginHelper.PARAM_RESET_PASSWORD; }
/** * Returns the link to the login form.<p> * * @param cms the current cms context * * @return the login form link */ public static String getFormLink(CmsObject cms) { return OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false); }
/** * Returns the link for the given workplace resource. * * This should only be used for resources under /system or /shared.<p< * * @param cms the current OpenCms user context * @param resourceName the resource to generate the online link for * @param forceSecure forces the secure server prefix * * @return the link for the given resource */ public String getWorkplaceLink(CmsObject cms, String resourceName, boolean forceSecure) { String result = substituteLinkForUnknownTarget(cms, resourceName, forceSecure); return appendServerPrefix(cms, result, resourceName, true); }
/** * Returns the link for the given resource in the current project, with full server prefix.<p> * * Like <code>http://site.enterprise.com:8080/index.html</code>.<p> * * In case the resource name is a full root path, the site from the root path will be used. * Otherwise the resource is assumed to be in the current site set be the OpenCms user context.<p> * * @param cms the current OpenCms user context * @param resourceName the resource to generate the online link for * @param forceSecure forces the secure server prefix * * @return the link for the given resource in the current project, with full server prefix * * @see #getOnlineLink(CmsObject, String) */ public String getServerLink(CmsObject cms, String resourceName, boolean forceSecure) { String result = substituteLinkForUnknownTarget(cms, resourceName, forceSecure); return appendServerPrefix(cms, result, resourceName, false); }
/** * Returns the link for the given resource in the current project, with full server prefix.<p> * * Like <code>http://site.enterprise.com:8080/index.html</code>.<p> * * In case the resource name is a full root path, the site from the root path will be used. * Otherwise the resource is assumed to be in the current site set be the OpenCms user context.<p> * * @param cms the current OpenCms user context * @param resourceName the resource to generate the online link for * * @return the link for the given resource in the current project, with full server prefix * * @see #getOnlineLink(CmsObject, String) */ public String getServerLink(CmsObject cms, String resourceName) { String result = substituteLinkForUnknownTarget(cms, resourceName); return appendServerPrefix(cms, result); }
/** * Gets a link to the resource.<p> * * @return the link */ public String getLink() { return OpenCms.getLinkManager().substituteLinkForUnknownTarget( m_cms, m_cms.getRequestContext().getSitePath(this)); }
/** * @see org.opencms.gwt.CmsGwtActionElement#export() */ @Override public String export() throws Exception { String resourcePath = getRequest().getParameter(I_CmsAdePropertiesConstants.PARAM_RESOURCE); CmsObject cms = getCmsObject(); CmsResource resource = cms.readResource(resourcePath, CmsResourceFilter.IGNORE_EXPIRATION); StringBuffer buffer = new StringBuffer(); buffer.append(exportMeta(I_CmsAdePropertiesConstants.META_RESOURCE, resource.getStructureId().toString())); buffer.append( exportMeta( I_CmsAdePropertiesConstants.META_BACKLINK, OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, "/system/workplace/views/explorer/explorer_files.jsp"))); return buffer.toString(); }
/** * Generates the link to the icon CSS JSP, and appends a "prefix" request parameter with the given value.<p> * * @param cms the CMS context * @param prefix the value to put into the "prefix" request parameter * * @return the link to the icon CSS */ private static String iconCssLink(CmsObject cms, String prefix) { String param = ""; if (!CmsStringUtil.isEmpty(prefix)) { try { param = "?prefix=" + URLEncoder.encode(prefix, OpenCms.getSystemInfo().getDefaultEncoding()); } catch (UnsupportedEncodingException e) { //ignore, default encoding should be available } } return OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, ICON_CSS_URI) + param; }
public void run() { A_CmsUI.get().getPage().setLocation( OpenCms.getLinkManager().substituteLinkForUnknownTarget( CmsLoginUI.m_adminCms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false)); } });
public void run() { A_CmsUI.get().getPage().setLocation( OpenCms.getLinkManager().substituteLinkForUnknownTarget( CmsLoginUI.m_adminCms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false)); }
/** * @see org.opencms.widgets.I_CmsComplexWidget#getWidgetData(org.opencms.file.CmsObject) */ public CmsComplexWidgetData getWidgetData(CmsObject cms) { String configToUse = m_config; try { JSONObject json = new JSONObject(m_config); String icon = json.optString(CmsDataViewConstants.CONFIG_ICON); if (icon != null) { String iconLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, icon); json.put(CmsDataViewConstants.CONFIG_ICON, iconLink); configToUse = json.toString(); } } catch (Exception e) { LOG.error(e.getLocalizedMessage(), e); } return new CmsComplexWidgetData(CmsDataViewConstants.RENDERER_ID, configToUse, null); }
/** * Cancels the dialog.<p> */ public void cancel() { CmsObject cms = A_CmsUI.getCmsObject(); String link = OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false); A_CmsUI.get().getPage().setLocation(link); }
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (shouldShowLogin() && !isLoginUIRequest(request)) { String link = OpenCms.getLinkManager().substituteLinkForUnknownTarget( ((CmsUIServlet)getCurrent()).getCmsObject(), CmsWorkplaceLoginHandler.LOGIN_FORM); String requestedUri = ((HttpServletRequest)request).getRequestURI(); if (!requestedUri.endsWith(OpenCms.getSystemInfo().getWorkplaceContext())) { link += "?" + CmsWorkplaceManager.PARAM_LOGIN_REQUESTED_RESOURCE + URLEncoder.encode(requestedUri, "UTF-8"); } OpenCms.getAuthorizationHandler().requestAuthorization( (HttpServletRequest)request, (HttpServletResponse)response, link); return true; } return false; } };
/** * Returns a link to a file in the OpenCms VFS * that has been adjusted according to the web application path and the * OpenCms static export rules.<p> * * Since OpenCms version 7.0.2, you can also use this method in case you are not sure * if the link is internal or external, as * {@link CmsLinkManager#substituteLinkForUnknownTarget(org.opencms.file.CmsObject, String)} * is used to calculate the link target.<p> * * Relative links are converted to absolute links, using the current element URI as base.<p> * * @param target the link that should be calculated, can be relative or absolute * @param req the current request * * @return the target link adjusted according to the web application path and the OpenCms static export rules * * @see org.opencms.staticexport.CmsLinkManager#substituteLinkForUnknownTarget(org.opencms.file.CmsObject, String) */ public static String linkTagAction(String target, ServletRequest req) { CmsFlexController controller = CmsFlexController.getController(req); return OpenCms.getLinkManager().substituteLinkForUnknownTarget( controller.getCmsObject(), CmsLinkManager.getAbsoluteUri(target, controller.getCurrentRequest().getElementUri())); }
public void buttonClick(ClickEvent event) { String v1Param = version.getVersion().getVersionNumber() != null ? "" + version.getVersion().getVersionNumber() : "" + CmsHistoryResourceHandler.PROJECT_OFFLINE_VERSION; String link = CmsHistoryListUtil.getHistoryLink(cms, version.getStructureId(), v1Param); link = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, link); A_CmsUI.get().openPageOrWarn(link, "_blank"); }
try { cms.getRequestContext().setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID)); result = substituteLinkForUnknownTarget(cms, resourceName); result = appendServerPrefix(cms, result); } finally {
/** * Logs the current user out by invalidating the session an reloading the current URI.<p> * Important: This works only within vaadin apps.<p> */ public static void logout() { CmsObject cms = A_CmsUI.getCmsObject(); if (UI.getCurrent() instanceof CmsAppWorkplaceUi) { ((CmsAppWorkplaceUi)UI.getCurrent()).onWindowClose(); } String loggedInUser = cms.getRequestContext().getCurrentUser().getName(); UI.getCurrent().getSession().close(); String loginLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false); VaadinService.getCurrentRequest().getWrappedSession().invalidate(); Page.getCurrent().setLocation(loginLink); // logout was successful if (LOG.isInfoEnabled()) { LOG.info( org.opencms.jsp.Messages.get().getBundle().key( org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3, loggedInUser, "{workplace logout option}", cms.getRequestContext().getRemoteAddress())); } }
"Select principal", new ExternalResource( OpenCms.getLinkManager().substituteLinkForUnknownTarget( A_CmsUI.getCmsObject(), "/system/workplace/commons/principal_selection.jsp") + parameters));