/** * @see java.io.OutputStream#flush() */ @Override public void flush() throws IOException { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_FLUSHED_1, m_servletStream)); } if (m_servletStream != null) { m_servletStream.flush(); } }
/** * @see java.io.OutputStream#flush() */ @Override public void flush() throws IOException { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_FLUSHED_1, m_servletStream)); } if (m_servletStream != null) { m_servletStream.flush(); } }
/** * @see org.opencms.cache.I_CmsLruCacheObject#removeFromLruCache() */ public void removeFromLruCache() { if ((m_variationMap != null) && (m_variationKey != null)) { m_variationMap.remove(m_variationKey); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key( Messages.LOG_FLEXCACHEENTRY_REMOVED_ENTRY_FOR_VARIATION_1, m_variationKey)); } }
/** * @see org.opencms.cache.I_CmsLruCacheObject#addToLruCache() */ public void addToLruCache() { // do nothing here... if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEENTRY_ADDED_ENTRY_1, this)); } }
/** * @see org.opencms.cache.I_CmsLruCacheObject#addToLruCache() */ public void addToLruCache() { // do nothing here... if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEENTRY_ADDED_ENTRY_1, this)); } }
/** * @see org.opencms.cache.I_CmsLruCacheObject#removeFromLruCache() */ public void removeFromLruCache() { if ((m_variationMap != null) && (m_variationKey != null)) { m_variationMap.remove(m_variationKey); } if (LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key( Messages.LOG_FLEXCACHEENTRY_REMOVED_ENTRY_FOR_VARIATION_1, m_variationKey)); } }
/** * Sets the expiration date of this Flex cache entry exactly to the * given time.<p> * * @param dateExpires the time to expire this cache entry */ public void setDateExpires(long dateExpires) { m_dateExpires = dateExpires; if (LOG.isDebugEnabled()) { long now = System.currentTimeMillis(); LOG.debug( Messages.get().getBundle().key( Messages.LOG_FLEXCACHEENTRY_SET_EXPIRATION_DATE_3, new Long(m_dateExpires), new Long(now), new Long(m_dateExpires - now))); } }
/** * Sets the expiration date of this Flex cache entry exactly to the * given time.<p> * * @param dateExpires the time to expire this cache entry */ public void setDateExpires(long dateExpires) { m_dateExpires = dateExpires; if (LOG.isDebugEnabled()) { long now = System.currentTimeMillis(); LOG.debug(Messages.get().getBundle().key( Messages.LOG_FLEXCACHEENTRY_SET_EXPIRATION_DATE_3, new Long(m_dateExpires), new Long(now), new Long(m_dateExpires - now))); } }
/** * Include an external (non-OpenCms) file using the standard dispatcher.<p> * * @param req the servlet request * @param res the servlet response * * @throws ServletException in case something goes wrong * @throws IOException in case something goes wrong */ private void includeExternal(ServletRequest req, ServletResponse res) throws ServletException, IOException { // This is an external include, probably to a JSP page, dispatch with system dispatcher if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key( Messages.LOG_FLEXREQUESTDISPATCHER_INCLUDING_EXTERNAL_TARGET_1, m_extTarget)); } m_rd.include(req, res); }
/** * Include an external (non-OpenCms) file using the standard dispatcher.<p> * * @param req the servlet request * @param res the servlet response * * @throws ServletException in case something goes wrong * @throws IOException in case something goes wrong */ private void includeExternal(ServletRequest req, ServletResponse res) throws ServletException, IOException { // This is an external include, probably to a JSP page, dispatch with system dispatcher if (LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key( Messages.LOG_FLEXREQUESTDISPATCHER_INCLUDING_EXTERNAL_TARGET_1, m_extTarget)); } m_rd.include(req, res); }
/** * A helper method for the parsing process which parses * Strings like groups=(a, b, c).<p> * * @param value the String to parse * @return a Map that contains of the parsed values, only the keyset of the Map is needed later */ private Set<String> parseValueList(String value) { if (value.charAt(0) == '(') { value = value.substring(1); } int len = value.length() - 1; if (value.charAt(len) == ')') { value = value.substring(0, len); } if (value.charAt(len - 1) == ',') { value = value.substring(0, len - 1); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_PARSE_VALUES_1, value)); } List<String> tokens = CmsStringUtil.splitAsList(value, ',', true); Set<String> result = new HashSet<String>(); result.addAll(tokens); return result; } }
/** * A helper method for the parsing process which parses * Strings like groups=(a, b, c).<p> * * @param value the String to parse * @return a Map that contains of the parsed values, only the keyset of the Map is needed later */ private Set parseValueList(String value) { if (value.charAt(0) == '(') { value = value.substring(1); } int len = value.length() - 1; if (value.charAt(len) == ')') { value = value.substring(0, len); } if (value.charAt(len - 1) == ',') { value = value.substring(0, len - 1); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_PARSE_VALUES_1, value)); } List tokens = CmsStringUtil.splitAsList(value, ',', true); Set result = new HashSet(); result.addAll(tokens); return result; } }
/** * Empties the cache completely.<p> */ private synchronized void clear() { if (!isEnabled()) { return; } m_keyCache.clear(); m_size = 0; m_variationCache.clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_0)); } }
/** * Completes this cache entry.<p> * * A completed cache entry is made "unmodifiable", * so that no further data can be added and existing data can not be changed.<p> * * This is to prevent the (unlikely) case that some user-written class * tries to make changes to a cache entry.<p> */ public void complete() { m_completed = true; // Prevent changing of the cached lists if (m_headers != null) { m_headers = Collections.unmodifiableMap(m_headers); } if (m_elements != null) { m_elements = Collections.unmodifiableList(m_elements); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEENTRY_ENTRY_COMPLETED_1, toString())); } }
/** * Emptys the cache completely.<p> */ private synchronized void clear() { if (!isEnabled()) { return; } m_keyCache.clear(); m_size = 0; m_variationCache.clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_0)); } }
/** * Method overload from the standard HttpServletRequest API.<p> * * @see javax.servlet.ServletResponse#setContentType(java.lang.String) */ @Override public void setContentType(String type) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_SETTING_CONTENTTYPE_1, type)); } // only if this is the "Top-Level" element, do set the content type // otherwise an included JSP could reset the type with some unwanted defaults if (!m_typeSet && m_isTopElement) { // type must be set only once, otherwise some Servlet containers (not Tomcat) generate errors m_typeSet = true; super.setContentType(type); return; } }
/** * Method overload from the standard HttpServletRequest API.<p> * * @see javax.servlet.ServletResponse#setContentType(java.lang.String) */ @Override public void setContentType(String type) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_SETTING_CONTENTTYPE_1, type)); } // only if this is the "Top-Level" element, do set the content type // otherwise an included JSP could reset the type with some unwanted defaults if (!m_typeSet && m_isTopElement) { // type must be set only once, otherwise some Servlet containers (not Tomcat) generate errors m_typeSet = true; super.setContentType(type); return; } }
/** * Completes this cache entry.<p> * * A completed cache entry is made "unmodifiable", * so that no further data can be added and existing data can not be changed.<p> * * This is to prevent the (unlikely) case that some user-written class * tries to make changes to a cache entry.<p> */ public void complete() { m_completed = true; // Prevent changing of the cached lists if (m_headers != null) { m_headers = Collections.unmodifiableMap(m_headers); } if (m_elements != null) { m_elements = Collections.unmodifiableList(m_elements); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEENTRY_ENTRY_COMPLETED_1, toString())); } }
/** * Sets an exception (Throwable) that was caught during inclusion of sub elements.<p> * * If another exception is already set in this controller, then the additional exception * is ignored.<p> * * @param throwable the exception (Throwable) to set * @param resource the URI of the VFS resource the error occurred on (might be <code>null</code> if unknown) * * @return the exception stored in the controller */ public Throwable setThrowable(Throwable throwable, String resource) { if (m_throwable == null) { m_throwable = throwable; m_throwableResourceUri = resource; } else { if (LOG.isDebugEnabled()) { if (resource != null) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCONTROLLER_IGNORED_EXCEPTION_1, resource)); } else { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCONTROLLER_IGNORED_EXCEPTION_0)); } } } return m_throwable; }
/** * Returns the CmsFlexCacheKey data structure for a given resource name.<p> * * @param resource the resource name for which to look up the key for * @return the CmsFlexCacheKey data structure found for the resource */ CmsFlexCacheKey getKey(String resource) { if (!isEnabled()) { return null; } Object o = m_keyCache.get(resource); if (o != null) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_FOUND_1, resource)); } return ((CmsFlexCacheVariation)o).m_key; } else { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_NOT_FOUND_1, resource)); } return null; } }