📄 operationmanager.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//// Here is the check to see if the page is Forbidden for the current user!//package org.jahia.operations;import org.jahia.data.JahiaData;import org.jahia.engines.JahiaEngine;import org.jahia.exceptions.JahiaException;import org.jahia.exceptions.JahiaForbiddenAccessException;import org.jahia.exceptions.JahiaSessionExpirationException;import org.jahia.params.ParamBean;import org.jahia.registries.EnginesRegistry;import org.jahia.registries.ServicesRegistry;import org.jahia.services.htmlcache.CacheEntry;import org.jahia.services.htmlcache.CacheServerService;import org.jahia.settings.JahiaPrivateSettings;import org.jahia.utils.JahiaConsole;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import java.io.PrintWriter;import java.util.Date;/** * This class is responsible for dispatching to an engine. In the special * case of the Core engine (output of CMS data), the output caching mechanism * is interrogated to avoid processing a request and generate HTML if it isn't * needed. * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Jahia Inc.</p> * * @author Eric Vassalli * @author Serge Huber * @version 3.0 */public class OperationManager { private static final String CLASS_NAME = OperationManager.class.getName(); /** * constructor * EV 05.11.2000 */ public OperationManager () { JahiaConsole.println( "OperationManager", "Starting up..." ); } /** * handleOperations * EV 19.11.2000 * EV 15.12.2000 destroys request-dependant objects */ public void handleOperations (ParamBean jParams, JahiaPrivateSettings jSettings) throws JahiaException, JahiaSessionExpirationException, JahiaForbiddenAccessException { JahiaData jData = null; // JahiaConsole.println("OperationsManager.handleOperations","Processing request..."); // first order of business is to do all cache processing, in order to // minimize what we have to do. CacheServerService contentCache = ServicesRegistry.getInstance () .getCacheServerService (); if (jParams.getSite() == null) { ServletContext context = jParams.getContext(); if ( context != null ){ try { jParams.getRequest().setAttribute("Jahia_ParamBean",jParams); context.getRequestDispatcher ("/jsp/jahia/errors/site_not_found.jsp") .forward (jParams.getRequest (), jParams.getResponse ()); } catch (Throwable t ){ t.printStackTrace(); throw new JahiaException ("400 Page Not Found: No site specified", "The requested site not found" , JahiaException.SECURITY_ERROR, JahiaException.ERROR); } return; } else { throw new JahiaException ("400 Page Not Found:", "Context is null" , JahiaException.SECURITY_ERROR, JahiaException.ERROR); } } // Get the engine instance (can throw a JahiaException) String engineName = jParams.getEngine(); JahiaEngine theEngine = getEngineInstance (engineName); if (theEngine != null) { // JahiaConsole.println(CLASS_NAME+".handleOperation","Engine=" + engineName); if (theEngine.needsJahiaData (jParams)) { // JahiaConsole.println(CLASS_NAME+".handleOperation","Engine need JahiaData"); // Check the rights for the current page. We do this here because it the // engine doesn't need a JahiaData it means that it is not related to // the current page, so we let the user display the engine! // if no read access -> launch exception if (jParams.getPage () != null && !jParams.getPage ().checkReadAccess (jParams.getUser ())) { throw new JahiaException ("403 Forbidden - Page:"+ jParams.getPageID(), "No read access for page " + jParams.getPageID() + " user=" + jParams.getUser().getUsername() + " acl=" + jParams.getPage().getAclID(), JahiaException.SECURITY_ERROR, JahiaException.ERROR); } if (jParams.settings().isOutputCacheActivated()) { /** we only do HTML content caching if it is a core engine call * and if the HTTP method is GET. We might extend on this later * on but for the sake of simplicity of implementation we * restrict it for now. We might be interested in doing more * work here in order to cache more often. */ if ( ("core".equals(jParams.getEngine())) && (jParams.getHttpMethod () == ParamBean.GET_METHOD) && (ParamBean.CACHE_ON.equals (jParams.getCacheStatus ())) ) { // JahiaConsole.println("OperationsManager.handleOperations", // "Requested page is : " + jParams.getPageID() ); CacheEntry cacheEntry = contentCache.getEntry ( Integer.toString (jParams.getPageID ()), jParams.getUser().getUsername(), jParams.getUserAgent()); if ( cacheEntry != null) { String htmlContent = cacheEntry.getContentBody(); if (cacheEntry.getOperationMode() != jParams.getOperationMode()) { JahiaConsole.println("OperationsManager.handleOperations", "Cache entry mode is NOT equal to current mode, flushing page entry and generating page..."); contentCache.removeEntry ( Integer.toString (jParams.getPageID ()), jParams.getUser().getUsername(), jParams.getUserAgent()); } else { if (htmlContent != null) { JahiaConsole.println("OperationsManager.handleOperations", "Found content in cache, writing directly bypassing processing..."); HttpServletResponse realResp = jParams.getRealResponse(); String contentType = cacheEntry.getContentType(); if (contentType != null) { realResp.setContentType(contentType); } try { PrintWriter writer = realResp.getWriter(); writer.print(htmlContent); } catch (java.io.IOException ioe) { JahiaConsole.println ("OperationsManager", "Error writing cache output, IOException generated error"); throw new JahiaException ( "OperationsManager.handleOperations", "Error writing cache content to writer", JahiaException.SECURITY_ERROR, JahiaException.ERROR, ioe); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -