⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operationmanager.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                    return; // exit handling here !                                }                            }                        }                    }                    if ((ParamBean.CACHE_OFFONCE.equals (jParams.getCacheStatus ())) ||                            (ParamBean.CACHE_BYPASS.equals (jParams.getCacheStatus ())) ||                            (ParamBean.CACHE_ONLYUPDATE.equals (jParams.getCacheStatus ()))                       ) {                        jParams.setCacheStatus(ParamBean.CACHE_ON);                    }                }                if ( jParams.getPage () != null ){                    jData = new JahiaData (jParams);                } else {                    jData = new JahiaData (jParams,false);                }            }            if ( jData == null ){                // at least create a jData with minimum data for taglibs usage everywhere                jData = new JahiaData (jParams,false);            }            // for JSp            jParams.getRequest().setAttribute("org.jahia.data.JahiaData",jData);            theEngine.handleActions (jParams, jData);            JahiaConsole.println(CLASS_NAME+".handleOperation",                                 "Operation handled for engine " + engineName);            HttpSession session = jParams.getRequest().getSession();            // save last engine name in session            session.setAttribute(ParamBean.SESSION_LAST_ENGINE_NAME,                                 jParams.getEngine());            // save last requested page id in session            session.setAttribute(ParamBean.SESSION_LAST_REQUESTED_PAGE_ID,                                 new Integer(jParams.getPageID()));            // destroys request-dependant objects            jData = null;        } else {            JahiaConsole.println ("OperationManager.handleOperations",                                  "Could not get the engine [" + engineName +                                  "] instance.");        }        try {        // Let's retrieve the generated content from the response wrapper object.        String generatedOutput = jParams.getGeneratedOutput();            HttpServletResponse realResp = jParams.getRealResponse();            String curContentType = jParams.getContentType();            if (jParams.getRedirectLocation() != null) {                JahiaConsole.println("OperationsManager.handleOperations",                                     "sendRedirect call detected during output generation, no other output...");                realResp.sendRedirect (                        realResp.encodeRedirectURL (jParams.getRedirectLocation ()));            } else {                /** @todo we should really find a more elegant way to handle this                 *  case, especially when handling a file manager download that                 *  has already accessed the RealResponse object.                 */                if (!realResp.isCommitted()) {                    JahiaConsole.println("OperationsManager.handleOperations",                                         "Printing content output to real writer");                    if (curContentType != null) {                        realResp.setContentType(curContentType);                    }                    PrintWriter writer = realResp.getWriter();                    writer.print(generatedOutput);                } else {                    JahiaConsole.println("OperationsManager.handleOperations",                                         "Output has already been committed, aborting display...");                }            }            if (jParams.settings().isOutputCacheActivated()) {                storeInCache (jParams, generatedOutput, curContentType, contentCache);            }        } catch (java.io.IOException ioe) {            JahiaConsole.println ("OperationManager.handleOperations",                    "Error retrieving real response writer object");        }    }    /**     * Stores the generated HTML content into the specified HTML cache.     *     * @param jParams         the parameter bean     * @param generatedOutput the html content body to be stored     * @param curContentType     the html content type     * @param generatedOutput   the generated output     */    private void storeInCache (ParamBean jParams, String generatedOutput,                                               String curContentType,                                               CacheServerService contentCache) {                if ( ("core".equals(jParams.getEngine())) &&                ((ParamBean.CACHE_ON.equals (jParams.getOriginalCacheStatus ())) ||                (ParamBean.CACHE_ONLYUPDATE.equals (jParams.getOriginalCacheStatus ())) ||                (ParamBean.CACHE_OFFONCE.equals (jParams.getOriginalCacheStatus ()))                ))        {                    // let's update the cache...                    CacheEntry newEntry = new CacheEntry();                    newEntry.setOperationMode(jParams.getOperationMode());                    newEntry.setContentBody(generatedOutput);                    if (curContentType != null) {                        newEntry.setContentType(curContentType);                    }            // compute the entry's expiration date            if (jParams.settings().getOutputCacheDefaultExpirationDelay () != -1) {                Date nowDate = new Date ();                // create the expiration date by adding an expiration timeout to the                // current system date.                Date expirationDate = new Date (nowDate.getTime () +                        jParams.settings ().getOutputCacheDefaultExpirationDelay ());                JahiaConsole.println ("OperationsManager.handleOperations",                        "Set the expiration date");                newEntry.setExpirationDate (expirationDate);            }            // if a default expiration date has been set, us this instead.            if (jParams.getCacheExpirationDate () != null) {                JahiaConsole.println ("OperationManager.handleOperations",                        "Using default expiration date");                newEntry.setExpirationDate (jParams.getCacheExpirationDate ());            }            // Cannot proceed if the user information is not available.            if (jParams.getUser() == null) {                return;            }                    contentCache.setEntry(Integer.toString(jParams.getPageID()),                                          jParams.getUser().getUsername(),                                          jParams.getUserAgent(),                                          newEntry);            JahiaConsole.println("OperationManager.handleOperations",                    "Added HTML page into the cache!!!!!");        }    }    /**     * Retrieve the requested engine instance.     *     * @param name the engine name     * @return the reference to the engine, or <code>null</code> when the engine name     *         is unknown in the Engines Registry.     * @throws JahiaException when the Engines Registry reference could not be retrieved.     */    private JahiaEngine getEngineInstance (String name) throws JahiaException {        // Get the Engines Registry        EnginesRegistry registry = EnginesRegistry.getInstance ();        if (registry == null)            throw new JahiaException ("Internal Error",                    "Could not get the Engines Registry instance!",                    JahiaException.INITIALIZATION_ERROR, JahiaException.ERROR);        // Return the requested engine        return (JahiaEngine) registry.getEngine (name);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -