/** * Clears the caches in the export manager.<p> * * @param event the event that requested to clear the caches */ protected void clearCaches(CmsEvent event) { // synchronization of this method is not required as the individual maps are all synchronized maps anyway, // and setExportnames() is doing it's own synchronization // flush all caches m_cacheOnlineLinks.clear(); m_cacheExportUris.clear(); m_cacheSecureLinks.clear(); m_cacheExportLinks.clear(); m_exportnameResources = null; if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLUSHED_CACHES_1, new Integer(event.getType()))); } }
/** * Sets specific http header for the static export.<p> * * The format of the headers must be "header:value".<p> * * @param exportHeader a specific http header */ public void setExportHeader(String exportHeader) { if (CmsStringUtil.splitAsArray(exportHeader, ':').length == 2) { if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_EXPORT_HEADERS_1, exportHeader)); } m_exportHeaders.add(exportHeader); } else { if (CmsLog.INIT.isWarnEnabled()) { CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_INVALID_HEADER_1, exportHeader)); } } }
/** * Sets specific http header for the static export.<p> * * The format of the headers must be "header:value".<p> * * @param exportHeader a specific http header */ public void setExportHeader(String exportHeader) { if (CmsStringUtil.splitAsArray(exportHeader, ':').length == 2) { if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_EXPORT_HEADERS_1, exportHeader)); } m_exportHeaders.add(exportHeader); } else { if (CmsLog.INIT.isWarnEnabled()) { CmsLog.INIT.warn(Messages.get().getBundle().key(Messages.INIT_INVALID_HEADER_1, exportHeader)); } } }
/** * Shuts down all this static export manager.<p> * * This is required since there may still be a thread running when the system is being shut down.<p> */ public synchronized void shutDown() { int count = 0; // if the handler is still running, we must wait up to 30 seconds until it is finished while ((count < HANDLER_FINISH_TIME) && m_handler.isBusy()) { count++; try { if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_STATIC_EXPORT_SHUTDOWN_3, m_handler.getClass().getName(), String.valueOf(count), String.valueOf(HANDLER_FINISH_TIME))); } wait(1000); } catch (InterruptedException e) { // if interrupted we ignore the handler, this will produce some log messages but should be ok count = HANDLER_FINISH_TIME; } } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName())); } }
/** * Shuts down all this static export manager.<p> * * This is required since there may still be a thread running when the system is being shut down.<p> */ public synchronized void shutDown() { int count = 0; // if the handler is still running, we must wait up to 30 seconds until it is finished while ((count < HANDLER_FINISH_TIME) && m_handler.isBusy()) { count++; try { if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_STATIC_EXPORT_SHUTDOWN_3, m_handler.getClass().getName(), String.valueOf(count), String.valueOf(HANDLER_FINISH_TIME))); } wait(1000); } catch (InterruptedException e) { // if interrupted we ignore the handler, this will produce some log messages but should be ok count = HANDLER_FINISH_TIME; } } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName())); } }
/** * Clears the caches in the export manager.<p> * * @param event the event that requested to clear the caches */ protected void clearCaches(CmsEvent event) { // synchronization of this method is not required as the individual maps are all synchronized maps anyway, // and setExportnames() is doing it's own synchronization // flush all caches m_cacheOnlineLinks.clear(); m_cacheExportUris.clear(); m_cacheSecureLinks.clear(); m_cacheExportLinks.clear(); setExportnames(); if (LOG.isDebugEnabled()) { String eventType = "EVENT_CLEAR_CACHES"; if (event.getType() != I_CmsEventListener.EVENT_CLEAR_CACHES) { eventType = "EVENT_PUBLISH_PROJECT"; } LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLUSHED_CACHES_1, eventType)); } }
/** * Creates the parent folder for a exported resource in the RFS.<p> * * @param exportPath the path to export the file * @param rfsName the rfs name of the resource * * @throws CmsException if the folder could not be created */ protected void createExportFolder(String exportPath, String rfsName) throws CmsException { String exportFolderName = CmsFileUtil.normalizePath(exportPath + CmsResource.getFolderPath(rfsName)); File exportFolder = new File(exportFolderName); if (!exportFolder.exists()) { // in case of concurrent requests to create this folder, check the folder existence again if (!exportFolder.mkdirs() && !exportFolder.exists()) { throw new CmsStaticExportException(Messages.get().container(Messages.ERR_CREATE_FOLDER_1, rfsName)); } } }
/** * Returns a map of all export names with export name as key * and the vfs folder path as value.<p> * * @return a map of export names */ public Map<CmsExportname, String> getExportnames() { if (m_exportnameResources == null) { try { TreeMap<CmsExportname, String> sort = new TreeMap<CmsExportname, String>(new CmsExportNameComparator()); sort.putAll(computeVfsExportnames()); m_exportnameResources = sort; } catch (Throwable t) { LOG.error(t.getMessage(), t); } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_UPDATE_EXPORTNAME_PROP_FINISHED_0)); } return Collections.unmodifiableMap(m_exportnameResources); }
/** * Shuts down the VFS bundle manager.<p> * * This will cause the internal reloading Thread not reload in case it is still running.<p> */ public void shutDown() { // we don't want to listen to further events OpenCms.getEventManager().removeCmsEventListener(this); setReloadScheduled(false); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( org.opencms.staticexport.Messages.get().getBundle().key( org.opencms.staticexport.Messages.INIT_SHUTDOWN_1, this.getClass().getName())); } }
/** * Deletes the given file from the RFS, with error handling and logging.<p> * * @param file the file to delete * @param vfsName the VFS name of the file (required for logging) */ private void deleteFile(File file, String vfsName) { try { if (file.exists() && file.canWrite()) { file.delete(); // write log message if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); } } } catch (Throwable t) { // ignore, nothing to do about this if (LOG.isWarnEnabled()) { LOG.warn( Messages.get().getBundle().key(Messages.LOG_FILE_DELETION_FAILED_1, getRfsName(file, vfsName)), t); } } }
/** * Creates the parent folder for a exported resource in the RFS.<p> * * @param exportPath the path to export the file * @param rfsName the rfs name of the resource * * @throws CmsException if the folder could not be created */ protected void createExportFolder(String exportPath, String rfsName) throws CmsException { String exportFolderName = CmsFileUtil.normalizePath(exportPath + CmsResource.getFolderPath(rfsName)); File exportFolder = new File(exportFolderName); if (!exportFolder.exists()) { if (!exportFolder.mkdirs()) { throw new CmsStaticExportException(Messages.get().container(Messages.ERR_CREATE_FOLDER_1, rfsName)); } } }
LOG.warn(Messages.get().getBundle().key(Messages.LOG_FETCHING_SIBLINGS_FAILED_1, resPath), e);
/** * Sets the rfs export Path after normalizing.<p> * * @param exportPath the rfs export Path to set */ public void setExportPath(String exportPath) { if (exportPath.equals(OpenCms.getSystemInfo().getWebApplicationRfsPath())) { // not allowed because a full static export would delete the opencms directory throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_EXPORT_PATH_1, m_name)); } m_exportPath = exportPath; }
LOG.warn(Messages.get().getBundle().key(Messages.LOG_FETCHING_SIBLINGS_FAILED_1, resPath), e);
/** * Sets the rfs export work Path after normalizing.<p> * * @param exportWorkPath the rfs export Work Path to set */ public void setExportWorkPath(String exportWorkPath) { if (exportWorkPath.equals(OpenCms.getSystemInfo().getWebApplicationRfsPath())) { // not allowed because a full static export would delete the opencms directory throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_EXPORT_PATH_1, m_name)); } m_exportWorkPath = exportWorkPath; }
/** * Sets the rfs export work Path after normalizing.<p> * * @param exportWorkPath the rfs export Work Path to set */ public void setExportWorkPath(String exportWorkPath) { if (exportWorkPath.equals(OpenCms.getSystemInfo().getWebApplicationRfsPath())) { // not allowed because a full static export would delete the opencms directory throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_EXPORT_PATH_1, m_name)); } m_exportWorkPath = exportWorkPath; }
LOG.info(Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); if (LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key(Messages.LOG_FILE_DELETED_1, getRfsName(file, vfsName))); Messages.get().getBundle().key(Messages.LOG_FILE_DELETION_FAILED_1, getRfsName(file, vfsName)), t);
/** * Sets the rfs export Path after normalizing.<p> * * @param exportPath the rfs export Path to set */ public void setExportPath(String exportPath) { if (exportPath.equals(OpenCms.getSystemInfo().getWebApplicationRfsPath())) { // not allowed because a full static export would delete the opencms directory throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_EXPORT_PATH_1, m_name)); } m_exportPath = exportPath; }
/** * @see org.opencms.staticexport.I_CmsStaticExportHandler#performEventPublishProject(org.opencms.util.CmsUUID, org.opencms.report.I_CmsReport) */ @Override public void performEventPublishProject(CmsUUID publishHistoryId, I_CmsReport report) { try { m_busy = true; exportAfterPublish(publishHistoryId, report); } catch (Throwable t) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_STATIC_EXPORT_ERROR_0), t); } if (report != null) { report.addError(t); } } finally { m_busy = false; } }
/** * @see org.opencms.staticexport.I_CmsStaticExportHandler#performEventPublishProject(org.opencms.util.CmsUUID, org.opencms.report.I_CmsReport) */ @Override public void performEventPublishProject(CmsUUID publishHistoryId, I_CmsReport report) { try { m_busy = true; exportAfterPublish(publishHistoryId, report); } catch (Throwable t) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_STATIC_EXPORT_ERROR_0), t); } if (report != null) { report.addError(t); } } finally { m_busy = false; } }