/** * Returns the server path for initializing the explorer view.<p> * * @return the server path */ public String getServerPath() { return OpenCms.getStaticExportManager().getVfsPrefix(); }
/** * Returns the server path for initializing the explorer view.<p> * * @return the server path */ public String getServerPath() { return OpenCms.getStaticExportManager().getVfsPrefix(); }
/** * Returns the regular expression to remove the static resource path prefix.<p> * * @return the regular expression to remove the static resource path prefix */ private static String getRemovePrefixRegex() { if (m_removePrefixRegex == null) { m_removePrefixRegex = "^(" + OpenCms.getStaticExportManager().getVfsPrefix() + ")?" + STATIC_RESOURCE_PREFIX + "(/v-?\\d+v/)?"; } return m_removePrefixRegex; }
/** * Returns the rfs export Path.<p> * * @return the rfs export Path */ public String getExportPath() { if (OpenCms.getStaticExportManager().isUseTempDir() && OpenCms.getStaticExportManager().isFullStaticExport()) { return getExportWorkPath(); } return m_exportPath; }
/** * Returns the rfs export Path.<p> * * @return the rfs export Path */ public String getExportPath() { if (OpenCms.getStaticExportManager().isUseTempDir() && OpenCms.getStaticExportManager().isFullStaticExport()) { return getExportWorkPath(); } return m_exportPath; }
/** * Returns the export file name starting from the OpenCms webapp folder.<p> * * @param file the file to delete * @param vfsName the VFS name of the file (required for logging) * * @return the export file name starting from the OpenCms webapp folder */ private String getRfsName(File file, String vfsName) { String filePath = file.getAbsolutePath(); String result = CmsFileUtil.normalizePath(OpenCms.getStaticExportManager().getRfsPrefix(vfsName) + filePath.substring(OpenCms.getStaticExportManager().getExportPath(vfsName).length())); return CmsStringUtil.substitute(result, new String(new char[] {File.separatorChar}), "/"); } }
/** * Returns the export file name starting from the OpenCms webapp folder.<p> * * @param file the file to delete * @param vfsName the VFS name of the file, the root path! * * @return the export file name starting from the OpenCms webapp folder */ private String getRfsName(File file, String vfsName) { CmsStaticExportManager manager = OpenCms.getStaticExportManager(); String filePath = file.getAbsolutePath(); String result = CmsFileUtil.normalizePath( manager.getRfsPrefix(vfsName) + filePath.substring(OpenCms.getStaticExportManager().getExportPath(vfsName).length())); return CmsStringUtil.substitute(result, new String(new char[] {File.separatorChar}), "/"); }
/** * Given a path to a VFS resource, the method removes the OpenCms context, * in case the path is prefixed by that context. * @param path the path where the OpenCms context should be removed * @return the adjusted path */ public static String removeOpenCmsContext(final String path) { String context = OpenCms.getSystemInfo().getOpenCmsContext(); if (path.startsWith(context + "/")) { return path.substring(context.length()); } String renderPrefix = OpenCms.getStaticExportManager().getVfsPrefix(); if (path.startsWith(renderPrefix + "/")) { return path.substring(renderPrefix.length()); } return path; }
/** * @see org.opencms.workplace.tools.I_CmsToolHandler#isEnabled(org.opencms.file.CmsObject) */ @Override public boolean isEnabled(CmsObject cms) { return OpenCms.getStaticExportManager().isStaticExportEnabled() && super.isEnabled(cms); } }
/** * Checks if the link target is a secure link.<p * * @param cms the current CMS context * @param vfsName the path of the link target * @param targetSite the target site containing the detail page * @param secureRequest true if the currently running request is secure * * @return true if the link should be a secure link */ protected boolean isSecureLink(CmsObject cms, String vfsName, CmsSite targetSite, boolean secureRequest) { return OpenCms.getStaticExportManager().isSecureLink(cms, vfsName, targetSite.getSiteRoot(), secureRequest); }
/** * Adds the VFS prefix to the VFS name and potentially adjusts request parameters<p> * This method is required as a hook used in {@link CmsLocalePrefixLinkSubstitutionHandler}.<p> * * @param cms the cms context * @param vfsName the VFS name * @param targetSite the target site * @param parameters the request parameters * * @return the path and the (adjusted) request parameters. */ protected CmsPair<String, String> addVfsPrefix( CmsObject cms, String vfsName, CmsSite targetSite, String parameters) { return new CmsPair<String, String>(OpenCms.getStaticExportManager().getVfsPrefix().concat(vfsName), parameters); }
/** * Purges a list of files from the rfs.<p> * * @param files the list of files to purge * @param vfsName the vfs name of the originally file to purge * @param scrubbedFiles the list which stores all the scrubbed files */ private void purgeFiles(List<File> files, String vfsName, Set<String> scrubbedFiles) { for (File file : files) { purgeFile(file.getAbsolutePath(), vfsName); String rfsName = CmsFileUtil.normalizePath( OpenCms.getStaticExportManager().getRfsPrefix(vfsName) + "/" + file.getAbsolutePath().substring( OpenCms.getStaticExportManager().getExportPath(vfsName).length())); rfsName = CmsStringUtil.substitute(rfsName, new String(new char[] {File.separatorChar}), "/"); scrubbedFiles.add(rfsName); } } }
/** * @see org.opencms.staticexport.CmsAfterPublishStaticExportHandler#getRelatedFilesToPurge(java.lang.String, java.lang.String) */ @Override protected List<File> getRelatedFilesToPurge(String exportFileName, String vfsName) { CmsStaticExportManager manager = OpenCms.getStaticExportManager(); List<File> result = new ArrayList<File>(); if (m_rules == null) { // get the locale matching rules CmsLocaleManager locManager = OpenCms.getLocaleManager(); m_rules = new ArrayList<CmsStaticExportRfsRule>(); Iterator<CmsStaticExportRfsRule> itRules = manager.getRfsRules().iterator(); while (itRules.hasNext()) { CmsStaticExportRfsRule rule = itRules.next(); Locale locale = CmsLocaleManager.getLocale(rule.getName()); if (locManager.getDefaultLocales().contains(locale)) { m_rules.add(rule); } } } // add paths for all possible locales Iterator<CmsStaticExportRfsRule> it = m_rules.iterator(); while (it.hasNext()) { CmsStaticExportRfsRule rule = it.next(); result.add(new File(rule.getLocalizedRfsName(exportFileName, File.separator))); } return result; } }
/** * Returns the context for static resources served from the class path, e.g. "/opencms/opencms/handleStatic".<p> * * @return the static resource context */ public String getStaticResourceContext() { if (m_staticResourcePathFragment == null) { m_staticResourcePathFragment = CmsStaticResourceHandler.getStaticResourceContext( OpenCms.getStaticExportManager().getVfsPrefix(), getVersionNumber()); } return m_staticResourcePathFragment; }
/** * @see org.opencms.loader.I_CmsResourceLoader#export(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public byte[] export(CmsObject cms, CmsResource resource, HttpServletRequest req, HttpServletResponse res) throws IOException, CmsException { CmsFile file = cms.readFile(resource); // if no request and response are given, the resource only must be exported and no // output must be generated if ((req != null) && (res != null)) { // overwrite headers if set as default for (Iterator i = OpenCms.getStaticExportManager().getExportHeaders().listIterator(); i.hasNext();) { String header = (String)i.next(); // set header only if format is "key: value" String[] parts = CmsStringUtil.splitAsArray(header, ':'); if (parts.length == 2) { res.setHeader(parts[0], parts[1]); } } load(cms, file, req, res); } return file.getContents(); }
/** * @see org.opencms.loader.I_CmsResourceLoader#export(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public byte[] export(CmsObject cms, CmsResource resource, HttpServletRequest req, HttpServletResponse res) throws IOException, CmsException { CmsFile file = cms.readFile(resource); // if no request and response are given, the resource only must be exported and no // output must be generated if ((req != null) && (res != null)) { // overwrite headers if set as default for (Iterator<String> i = OpenCms.getStaticExportManager().getExportHeaders().listIterator(); i.hasNext();) { String header = i.next(); // set header only if format is "key: value" String[] parts = CmsStringUtil.splitAsArray(header, ':'); if (parts.length == 2) { res.setHeader(parts[0], parts[1]); } } load(cms, file, req, res); } return file.getContents(); }
/** * Returns the base URI.<p> * * @param req the servlet request * @param cms the CmsObject * * @return the base URI */ private String getBaseUri(HttpServletRequest req, CmsObject cms) { String baseUri = req.getParameter(PARAM_BASE_URI); if (CmsStringUtil.isEmptyOrWhitespaceOnly(baseUri)) { String referer = req.getHeader(HEADER_REFERER_KEY); CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); if (site != null) { String prefix = site.getServerPrefix(cms, "/") + OpenCms.getStaticExportManager().getVfsPrefix(); if ((referer != null) && referer.startsWith(prefix)) { baseUri = referer.substring(prefix.length()); } } } return baseUri; } }
/** * Returns the base URI.<p> * * @param req the servlet request * @param cms the CmsObject * * @return the base URI */ private String getBaseUri(HttpServletRequest req, CmsObject cms) { String baseUri = req.getParameter(PARAM_BASE_URI); if (CmsStringUtil.isEmptyOrWhitespaceOnly(baseUri)) { String referer = req.getHeader(HEADER_REFERER_KEY); CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(cms.getRequestContext().getSiteRoot()); if (site != null) { String prefix = site.getServerPrefix(cms, "/") + OpenCms.getStaticExportManager().getVfsPrefix(); if ((referer != null) && referer.startsWith(prefix)) { baseUri = referer.substring(prefix.length()); } } } return baseUri; } }
/** * Returns the server prefix for the given resource in this site, used to distinguish between * secure (https) and non-secure (http) sites.<p> * * This is required since a resource may have an individual "secure" setting using the property * {@link org.opencms.file.CmsPropertyDefinition#PROPERTY_SECURE}, which means this resource * must be delivered only using a secure protocol.<p> * * The result will look like <code>http://site.enterprise.com:8080/</code> or <code>https://site.enterprise.com/</code>.<p> * * @param cms the current users OpenCms context * @param resourceName the resource name * * @return the server prefix for the given resource in this site * * @see #getSecureUrl() * @see #getUrl() */ public String getServerPrefix(CmsObject cms, String resourceName) { if (resourceName.startsWith(cms.getRequestContext().getSiteRoot())) { // make sure this can also be used with a resource root path resourceName = resourceName.substring(cms.getRequestContext().getSiteRoot().length()); } boolean secure = OpenCms.getStaticExportManager().isSecureLink( cms, resourceName, cms.getRequestContext().isSecureRequest()); return (secure ? getSecureUrl() : getUrl()); }
if (OpenCms.getStaticExportManager().isExportLink(cms, uri)) {