/** * Puts a file entry in the file cache * * @param file The file to be put in the cache * @param document the cached document */ public void put(File file, Object document) throws java.io.IOException { if(!file.exists()) { throw new FileNotFoundException("File to cache: "+file.getAbsolutePath()+" does not exist."); } FileCacheEntry entry = new FileCacheEntryImpl(file, document); CacheElement element = this.cache.createElement(file.getCanonicalPath(), entry); cache.put(element); }
/** * Puts a file entry in the file cache * * @param key the full path name of the file * @param document the cached document * @param rootFile the root file handle */ public void put(String key, Object document, File rootFile) throws java.io.IOException { File file = new File(rootFile, key); if(!file.exists()) { throw new FileNotFoundException("File to cache: "+file.getAbsolutePath()+" does not exist."); } FileCacheEntry entry = new FileCacheEntryImpl(file, document); CacheElement element = this.cache.createElement(key, entry); this.cache.put(element); }
private IdentityToken createToken(String token) { IdentityToken identityToken = new IdentityTokenImpl(token); CacheElement element = cache.createElement(token, identityToken); cache.put(element); return identityToken; }
protected boolean addToCache(PortletWindow window) { String fullName = window.getPortletDefinition().getUniqueName(); CacheElement cachedElement = trackingCache.get(fullName); if (cachedElement == null) { List<String> windowIds = new ArrayList<String>(); windowIds.add(window.getWindowId()); cachedElement = trackingCache.createElement(fullName, windowIds); trackingCache.put(cachedElement); return true; } else { List<String> windowIds = (List<String>)cachedElement.getContent(); if (!windowIds.contains(window.getWindowId())) { windowIds.add(window.getWindowId()); trackingCache.put(cachedElement); return true; } } return false; }
protected boolean removeFromCache(PortletWindow window) { String fullName = window.getPortletDefinition().getUniqueName(); CacheElement cachedElement = trackingCache.get(fullName); if (cachedElement == null) { return false; } List<String> windowIds = (List<String>)cachedElement.getContent(); if (!windowIds.contains(window.getWindowId())) { windowIds.remove(window.getWindowId()); trackingCache.put(cachedElement); return true; } return false; }
protected void setCachedConfiguration( String name, String type, Properties props ) { if ( decorationConfigurationCache == null ) { if ( type.equals( ContentFragment.PORTLET ) ) { this.portletDecoratorProperties.put( name, props ); } else { this.layoutDecoratorProperties.put( name, props ); } } else { CacheElement cachedElement = decorationConfigurationCache.createElement( getCachedConfigurationKey( type, name ), props ); cachedElement.setTimeToIdleSeconds(decorationConfigurationCache.getTimeToIdleSeconds()); cachedElement.setTimeToLiveSeconds(decorationConfigurationCache.getTimeToLiveSeconds()); decorationConfigurationCache.put( cachedElement ); } } protected String getCachedConfigurationKey( String type, String name )
public synchronized static void cacheAdd(Identity oid, Object obj) { oidCache.remove(oid); CacheElement entry = new EhCacheElementImpl(oid, obj); oidCache.put(entry); PortletApplication pa = (PortletApplication)obj; DistributedCacheObject wrapper = new RegistryCacheObjectWrapper(oid, pa.getName()); nameCache.remove(pa.getName()); CacheElement nameEntry = nameCache.createElement(pa.getName(), wrapper); nameCache.put(nameEntry); if (listeners != null) { for (int ix=0; ix < listeners.size(); ix++) { RegistryEventListener listener = (RegistryEventListener)listeners.get(ix); listener.applicationUpdated((PortletApplication)obj); } } }
public synchronized static void cacheAdd(Identity oid, Object obj) { oidCache.remove(oid); PortletDefinition pd = (PortletDefinition)obj; if (pd.getApplication() == null) { return; } CacheElement entry = new EhCacheElementImpl(oid, obj); oidCache.put(entry); DistributedCacheObject wrapper = new RegistryCacheObjectWrapper(oid, pd.getUniqueName()); nameCache.remove(pd.getUniqueName()); CacheElement nameEntry = nameCache.createElement(pd.getUniqueName(), wrapper); nameCache.put(nameEntry); if (listeners != null) { for (int ix=0; ix < listeners.size(); ix++) { RegistryEventListener listener = (RegistryEventListener)listeners.get(ix); listener.portletUpdated((PortletDefinition)obj); } } }
principalPropertiesPathCache.put(principalPropertiesPathCache.createElement(principalKey, new DatabasePageManagerPrincipalKeyCacheObject(principalKey))); principalPropertiesPathCache.remove(principalKey); principalPropertiesPathCache.put(principalPropertiesPathCache.createElement(principalKey, new DatabasePageManagerPrincipalKeyCacheObject(principalKey))); principalPropertiesCache.put(principalPropertiesCache.createElement(principalKey, fragmentPropertyList));
private void setCachedContent( String cacheKey, String content ) { CacheElement cachedElement = desktopContentCache.createElement( cacheKey, content ); cachedElement.setTimeToIdleSeconds(desktopContentCache.getTimeToIdleSeconds()); cachedElement.setTimeToLiveSeconds(desktopContentCache.getTimeToLiveSeconds()); desktopContentCache.put( cachedElement ); }
protected void addToCache(NodeCache content) { CacheElement cachedElement = preferenceCache.createElement(content.getCacheKey(), content); cachedElement.setTimeToIdleSeconds(preferenceCache.getTimeToIdleSeconds()); cachedElement.setTimeToLiveSeconds(preferenceCache.getTimeToLiveSeconds()); preferenceCache.put(cachedElement); }
/** * Remove fragment property list from local and remote caches. * * @param fragmentKey fragment key for fragment property list */ public synchronized static void fragmentPropertyListCacheRemove(String fragmentKey) { // remove fragment properties list cached locally by key // and notify remote caches by fragment key if (fragmentKey != null) { propertiesCache.remove(fragmentKey); boolean removed = propertiesPathCache.remove(fragmentKey); // if a remove was not successful from the path cache, update // notification to distributed peers was not performed; // for updates of objects evicted from the cache, this is // problematic: put into path cache and remove a second time // to force notification if (!removed) { propertiesPathCache.put(propertiesPathCache.createElement(fragmentKey, new DatabasePageManagerFragmentKeyCacheObject(fragmentKey))); propertiesPathCache.remove(fragmentKey); } } }
/** * Remove principal fragment property list from local and remote caches. * * @param principalKey principal key fragment property list */ public synchronized static void principalFragmentPropertyListCacheRemove(String principalKey) { // remove fragment properties list cached locally and // notify remote caches by principal key if (principalKey != null) { principalPropertiesCache.remove(principalKey); boolean removed = principalPropertiesPathCache.remove(principalKey); // if a remove was not successful from the path cache, update // notification to distributed peers was not performed; // for updates of objects evicted from the cache, this is // problematic: put into path cache and remove a second time // to force notification if (!removed) { principalPropertiesPathCache.put(principalPropertiesPathCache.createElement(principalKey, new DatabasePageManagerPrincipalKeyCacheObject(principalKey))); principalPropertiesPathCache.remove(principalKey); } } }
pathCache.put(pathElement); pathCache.remove(path);
/** * Jetspeed: PortletPreferencesProvider */ public void preloadApplicationPreferences(String portletApplicationName) { JetspeedPreferencesMap map = new JetspeedPreferencesMap(); Criteria c = new Criteria(); c.addEqualTo(DTYPE, DISCRIMINATOR_PORTLET); c.addEqualTo(APPLICATION_NAME, portletApplicationName); String previousPortletName = ""; QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c); query.addOrderByAscending(DTYPE); query.addOrderByAscending(APPLICATION_NAME); query.addOrderByAscending(PORTLET_NAME); Iterator<DatabasePreference> preferences = getPersistenceBrokerTemplate().getIteratorByQuery(query); while (preferences.hasNext()) { DatabasePreference preference = preferences.next(); if (preference.getPortletName().equals(previousPortletName)) { map = new JetspeedPreferencesMap(); String defaultsCacheKey = getPortletPreferenceKey(portletApplicationName, preference.getPortletName()); preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map)); previousPortletName = preference.getPortletName(); } map.put(preference.getName(), new JetspeedPreferenceImpl(preference.getName(), preference.getValues(), preference.isReadOnly())); } }
protected void addToCache(RequestContext context, PortletContent content) { CacheElement cachedElement = portletContentCache.createElement(content.getCacheKey(), content); if (content.getExpiration() == -1) { cachedElement.setTimeToIdleSeconds(portletContentCache.getTimeToIdleSeconds()); cachedElement.setTimeToLiveSeconds(portletContentCache.getTimeToLiveSeconds()); } else { cachedElement.setTimeToIdleSeconds(content.getExpiration()); cachedElement.setTimeToLiveSeconds(content.getExpiration()); } portletContentCache.put(cachedElement); context.getPortalURL().getNavigationalState().registerPortletContentCachedForPublicRenderParameters(context, content); }
preferenceCache.put(preferenceCache.createElement(cacheKey, map)); previousKey = cacheKey;
preferenceCache.put(preferenceCache.createElement(userCacheKey, userPreferences));
public void removeDefaults(org.apache.jetspeed.om.portlet.PortletDefinition pd, String preferenceName) { Criteria c = new Criteria(); c.addEqualTo(DTYPE, DISCRIMINATOR_PORTLET); c.addEqualTo(APPLICATION_NAME, pd.getApplication().getName()); c.addEqualTo(PORTLET_NAME, pd.getPortletName()); c.addEqualTo("name", preferenceName); QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c); getPersistenceBrokerTemplate().deleteByQuery(query); String defaultsCacheKey = getPortletPreferenceKey(pd.getApplication().getName(), pd.getPortletName()); JetspeedPreferencesMap map = (JetspeedPreferencesMap) preferenceCache.get(defaultsCacheKey).getContent(); map.remove(preferenceName); preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map)); }