/** * Notify all event listeners that a particular event has occurred.<p> * * The event will be given to all registered <code>{@link I_CmsEventListener}</code>s.<p> * * @param type the type of the event * @param data a data object that contains data used by the event listeners * * @see OpenCms#addCmsEventListener(I_CmsEventListener) * @see OpenCms#addCmsEventListener(I_CmsEventListener, int[]) */ private void fireEvent(int type, Object data) { OpenCms.fireCmsEvent(type, Collections.singletonMap("data", data)); }
/** * Notify all event listeners that a particular event has occurred.<p> * * The event will be given to all registered <code>{@link I_CmsEventListener}</code>s.<p> * * @param type the type of the event * @param data a data object that contains data used by the event listeners * * @see OpenCms#addCmsEventListener(I_CmsEventListener) * @see OpenCms#addCmsEventListener(I_CmsEventListener, int[]) */ private void fireEvent(int type, Object data) { OpenCms.fireCmsEvent(type, Collections.singletonMap("data", data)); }
/** * Clears all OpenCms internal caches.<p> * * @throws Exception if something goes wrong */ public void clearCaches() throws Exception { OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, new HashMap<String, Object>())); }
/** * Purges the jsp repository.<p> * * @throws Exception if something goes wrong * * @see org.opencms.flex.CmsFlexCache#cmsEvent(org.opencms.main.CmsEvent) */ public void purgeJspRepository() throws Exception { OpenCms.fireCmsEvent( new CmsEvent(I_CmsEventListener.EVENT_FLEX_PURGE_JSP_REPOSITORY, new HashMap<String, Object>())); }
/** * Clears all OpenCms internal caches.<p> * * @throws Exception if something goes wrong */ public void clearCaches() throws Exception { OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, Collections.EMPTY_MAP)); }
/** * Purges the jsp repository.<p> * * @throws Exception if something goes wrong * * @see org.opencms.flex.CmsFlexCache#cmsEvent(org.opencms.main.CmsEvent) */ public void purgeJspRepository() throws Exception { OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_FLEX_PURGE_JSP_REPOSITORY, new HashMap(0))); }
/** * Commits the edited group to the db.<p> */ @Override public void actionCommit() { try { float age = (System.currentTimeMillis() - Long.parseLong(m_time)) / (60f * 60f * 1000f); OpenCms.fireCmsEvent( new CmsEvent( I_CmsEventListener.EVENT_CLEAR_CACHES, Collections.<String, Object> singletonMap(CmsImageLoader.PARAM_CLEAR_IMAGES_CACHE, "" + age))); } catch (Exception e) { setCommitErrors(Collections.singletonList((Throwable)e)); } }
/** * Purges the jsp repository.<p> * * @throws JspException if something goes wrong */ public void actionPurgeJspRepository() throws JspException { OpenCms.fireCmsEvent( new CmsEvent(I_CmsEventListener.EVENT_FLEX_PURGE_JSP_REPOSITORY, Collections.<String, Object> emptyMap())); OpenCms.fireCmsEvent( new CmsEvent( I_CmsEventListener.EVENT_FLEX_CACHE_CLEAR, Collections.<String, Object> singletonMap("action", new Integer(CmsFlexCache.CLEAR_ENTRIES)))); setAction(CmsDialog.ACTION_CANCEL); actionCloseDialog(); }
/** * Clears the OpenCms caches.<p> */ protected void clearCaches() { if ((m_lastClearCache + INTERVAL_CLEAR) > System.currentTimeMillis()) { // if the cache has already been cleared less then 15 minutes ago we skip this because // clearing the caches to often will hurt system performance and the // setup seems to be in trouble anyway return; } m_lastClearCache = System.currentTimeMillis(); if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CLEAR_CACHE_MEM_CONS_0)); } OpenCms.fireCmsEvent(new CmsEvent( I_CmsEventListener.EVENT_CLEAR_CACHES, Collections.<String, Object> emptyMap())); System.gc(); }
/** * Clears the OpenCms caches.<p> */ protected void clearCaches() { if ((m_lastClearCache + INTERVAL_CLEAR) > System.currentTimeMillis()) { // if the cache has already been cleared less then 15 minutes ago we skip this because // clearing the caches to often will hurt system performance and the // setup seems to be in trouble anyway return; } m_lastClearCache = System.currentTimeMillis(); if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.LOG_CLEAR_CACHE_MEM_CONS_0)); } OpenCms.fireCmsEvent( new CmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, Collections.<String, Object> emptyMap())); System.gc(); }
/** * Sends a clear caches event.<p> * * @throws JspException if something goes wrong */ public void actionClearCaches() throws JspException { OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, null)); setAction(CmsDialog.ACTION_CANCEL); actionCloseDialog(); }
/** * Writes an access control entries to a given resource.<p> * * @param dbc the current database context * @param resource the resource * @param ace the entry to write * * @throws CmsException if something goes wrong */ public void writeAccessControlEntry(CmsDbContext dbc, CmsResource resource, CmsAccessControlEntry ace) throws CmsException { // write the new ace m_userDriver.writeAccessControlEntry(dbc, dbc.currentProject(), ace); // update the "last modified" information setDateLastModified(dbc, resource, resource.getDateLastModified()); // clear the cache m_monitor.clearAccessControlListCache(); // fire a resource modification event HashMap data = new HashMap(2); data.put(I_CmsEventListener.KEY_RESOURCE, resource); data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_ACCESSCONTROL)); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data)); }
/** * Removes an access control entry for a given resource and principal.<p> * * @param dbc the current database context * @param resource the resource * @param principal the id of the principal to remove the the access control entry for * * @throws CmsException if something goes wrong */ public void removeAccessControlEntry(CmsDbContext dbc, CmsResource resource, CmsUUID principal) throws CmsException { // remove the ace m_userDriver.removeAccessControlEntry(dbc, dbc.currentProject(), resource.getResourceId(), principal); // update the "last modified" information setDateLastModified(dbc, resource, resource.getDateLastModified()); // clear the cache m_monitor.clearAccessControlListCache(); // fire a resource modification event HashMap data = new HashMap(2); data.put(I_CmsEventListener.KEY_RESOURCE, resource); data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_ACCESSCONTROL)); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data)); }
/** * Deletes a property definition.<p> * * @param dbc the current database context * @param name the name of the property definition to delete * * @throws CmsException if something goes wrong */ public void deletePropertyDefinition(CmsDbContext dbc, String name) throws CmsException { CmsPropertyDefinition propertyDefinition = null; try { // first read and then delete the metadefinition. propertyDefinition = readPropertyDefinition(dbc, name); m_vfsDriver.deletePropertyDefinition(dbc, propertyDefinition); m_historyDriver.deletePropertyDefinition(dbc, propertyDefinition); } finally { // fire an event that a property of a resource has been deleted OpenCms.fireCmsEvent(new CmsEvent( I_CmsEventListener.EVENT_PROPERTY_DEFINITION_MODIFIED, Collections.singletonMap("propertyDefinition", propertyDefinition))); } }
/** * Updates the user information. <p> * * The user id has to be a valid OpenCms user id.<br> * * The user with the given id will be completely overridden * by the given data.<p> * * @param dbc the current database context * @param user the user to be updated * * @throws CmsException if operation was not successful */ public void writeUser(CmsDbContext dbc, CmsUser user) throws CmsException { CmsUser oldUser = readUser(dbc, user.getId()); m_monitor.clearUserCache(oldUser); m_userDriver.writeUser(dbc, user); m_monitor.flushCache(CmsMemoryMonitor.CacheType.USERGROUPS); // fire user modified event Map eventData = new HashMap(); eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString()); eventData.put(I_CmsEventListener.KEY_USER_NAME, oldUser.getName()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData)); }
/** * Updates the user information. <p> * * The user id has to be a valid OpenCms user id.<br> * * The user with the given id will be completely overridden * by the given data.<p> * * @param dbc the current database context * @param user the user to be updated * * @throws CmsException if operation was not successful */ public void writeUser(CmsDbContext dbc, CmsUser user) throws CmsException { CmsUser oldUser = readUser(dbc, user.getId()); m_monitor.clearUserCache(oldUser); getUserDriver(dbc).writeUser(dbc, user); m_monitor.flushCache(CmsMemoryMonitor.CacheType.USERGROUPS, CmsMemoryMonitor.CacheType.USER_LIST); if (!dbc.getProjectId().isNullUUID()) { // user modified event is not needed return; } // fire user modified event Map<String, Object> eventData = new HashMap<String, Object>(); eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString()); eventData.put(I_CmsEventListener.KEY_USER_NAME, oldUser.getName()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER); eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(user.getChanges(oldUser))); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData)); }
/** * Deletes a property definition.<p> * * @param dbc the current database context * @param name the name of the property definition to delete * * @throws CmsException if something goes wrong */ public void deletePropertyDefinition(CmsDbContext dbc, String name) throws CmsException { CmsPropertyDefinition propertyDefinition = null; try { // first read and then delete the metadefinition. propertyDefinition = readPropertyDefinition(dbc, name); getVfsDriver(dbc).deletePropertyDefinition(dbc, propertyDefinition); getHistoryDriver(dbc).deletePropertyDefinition(dbc, propertyDefinition); } finally { // fire an event that a property of a resource has been deleted OpenCms.fireCmsEvent( new CmsEvent( I_CmsEventListener.EVENT_PROPERTY_DEFINITION_MODIFIED, Collections.<String, Object> singletonMap("propertyDefinition", propertyDefinition))); } }
/** * Performs the re-initialization report, will be called by the JSP page.<p> * * @throws JspException if including the error JSP element fails */ public void actionReport() throws JspException { // save initialized instance of this class in request attribute for included sub-elements getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); switch (getAction()) { case ACTION_CONFIRMED: default: try { // re-initialize the workplace OpenCms.getWorkplaceManager().initialize(getCms()); // fire "clear caches" event to reload all cached resource bundles OpenCms.fireCmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, new HashMap<String, Object>()); actionCloseDialog(); } catch (Throwable t) { // create a new Exception with custom message includeErrorpage(this, t); } break; } }
/** * Writes an already existing group.<p> * * The group id has to be a valid OpenCms group id.<br> * * The group with the given id will be completely overridden * by the given data.<p> * * @param dbc the current database context * @param group the group that should be written * * @throws CmsException if operation was not successful */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsException { CmsGroup oldGroup = readGroup(dbc, group.getName()); m_monitor.uncacheGroup(oldGroup); getUserDriver(dbc).writeGroup(dbc, group); m_monitor.cacheGroup(group); if (!dbc.getProjectId().isNullUUID()) { // group modified event is not needed return; } // fire group modified event Map<String, Object> eventData = new HashMap<String, Object>(); eventData.put(I_CmsEventListener.KEY_GROUP_ID, group.getId().toString()); eventData.put(I_CmsEventListener.KEY_GROUP_NAME, oldGroup.getName()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_GROUP_MODIFIED_ACTION_WRITE); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_GROUP_MODIFIED, eventData)); }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }