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

📄 page_field.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    engineMap.put("pageTitle"+ theField.getDefinition().getName(), pageTitle);                    //System.out.println("##### pageTitle2: "+pageTitle);                    // we are coming from the Tree popup                    // default operation is "link"                    choiceID = 1;                    // in the other case, it's "copy/move"                    if( (operation != null) && !operation.equals("link") ) {                        if(operation.equals("copy")) {                            choiceID = 5;                        } else {                            choiceID = 3;                        }                    }                    JahiaConsole.println(CLASS_NAME + ".getFormData",                            "Operation : [" + operation + "] - CHANGED");                    // notifies changes                    // CHANGED, because sourcePageID was found in treeEngine...                    changed = true;                }            }        }        // sets the subEngineMap to null, in order not to re-process the pop-up window at next reload        // only if we are not reloading from Tree Engine...        // the saveData method needs the Map to pass it to CopyTree_Engine.execute() so we create a        // copy of it, stored in the engineMap.        if( (reload == null) && (subEngineMap != null) ) {            JahiaConsole.println(CLASS_NAME + ".getFormData", "KILLING subEngineMap");            HashMap treeDataMap = (HashMap)subEngineMap.clone();            engineMap.put("treeDataMap", treeDataMap);            subEngineMap = null;            jParams.getRequest().getSession().setAttribute("org.jahia.engines.CopyTree_Engine.engineMap", null );        }        // ----------------------------------------------------------------------------------------        // STEP 3 : if form or pop-up data received, change Page Data  ----------------------------        // ----------------------------------------------------------------------------------------        if (changed)        {            // sets page title            if (FormDataManager.getInstance().checkIntegrity(pageTitle)) {                thePage.setTitle( FormDataManager.getInstance().encode( pageTitle ) );            }            /*             else {                out = false;            }            */            // sets page type & data            JahiaConsole.println(CLASS_NAME + ".getFormData", "STEP 3, choice: " + choiceID);            switch (choiceID) {                case (0) :                    thePage.setPageTemplateID( templateID );                    thePage.setPageType( JahiaPage.TYPE_DIRECT );                    break;                case (1)  :                    if( (pageLinkID != null) && (reload != null) ) {                        remotePageID = pageLinkID.intValue();                    }                    if(remotePageID > 0)                    {                        thePage.setPageLinkID (remotePageID);                    }                    thePage.setPageType( JahiaPage.TYPE_LINK );                    break;                case (2)   :                    if (remoteUrl != null) {                        thePage.setRemoteURL (FormDataManager.getInstance().encode (remoteUrl));                        thePage.setPageType( JahiaPage.TYPE_URL );                    } else {                        out = false;                    }                    break;            }            checkPageTitle(thePage);            // saves values in session            engineMap.put( "templateID", new Integer( templateID ) );            engineMap.put( "pageID", new Integer( remotePageID ) );            engineMap.put( "remoteUrl", remoteUrl );            engineMap.put( "choiceID"+theField.getDefinition().getName(), new Integer( choiceID ) );            JahiaConsole.println(CLASS_NAME + ".getFormData", "Set choiceID of " +                    theField.getDefinition().getName() + " to: " + choiceID);            JahiaConsole.println(CLASS_NAME + ".getFormData", "Operation : " + operation);            jParams.getRequest().getSession().setAttribute( "PageBean"+ theField.getDefinition().getName(), thePage );        }        // if we're not updating a page...        // earmark the field to prevent overwriting the cache PageBean        if(theField.getObject() == null) {            theField.setObject("new page");        }        jParams.getRequest().getSession().setAttribute( "PageBean"+ theField.getDefinition().getName(), thePage );        return out;    } // end getFormData    //--------------------------------------------------------------------------    /**     * Verify page title integrity     *     * @param JahiaPageEngineTempBean, the page     */    private void checkPageTitle(JahiaPageEngineTempBean page)    {        JahiaConsole.println(CLASS_NAME+".checkPageTitle","Started");        if ( page == null ){            return;        }        try {            String title = page.getTitle();            if ( title == null || title.trim().equals("") )            {                switch (page.getPageType ()) {                    case (JahiaPage.TYPE_DIRECT) :                        int templateID = page.getPageTemplateID();                        JahiaPageTemplateService templateServ = ServicesRegistry.getInstance().getJahiaPageTemplateService();                        JahiaPageDefinition template = templateServ.lookupPageTemplate(templateID);                        if ( template != null ){                            page.setTitle(template.getName());                        }                        break;                    case (JahiaPage.TYPE_LINK)  :                        JahiaConsole.println(CLASS_NAME+".checkPageTitle","Page is TYPE_LINK");                        int pageLinkID = page.getPageLinkID();                        JahiaPage linkPage = ServicesRegistry.getInstance().getJahiaPageService().lookupPage(pageLinkID);                        if ( linkPage != null ){                            page.setTitle( linkPage.getTitle() );                        }                        break;                    case (JahiaPage.TYPE_URL)   :                        page.setTitle(page.getRemoteURL ());                        break;                }            }        } catch ( Throwable t ){            t.printStackTrace();        } finally {            if ( page != null                 && (page.getTitle()==null && page.getTitle().trim().equals("") ) ) {                page.setTitle("Undefined Page Title");            }        }    }    /***        * saves data in datasource        *        * @param        jParams             a ParamBean object        * @param        engineMap           the engine hashmap        * @param        theField            the field we are working on        * @return       true if everything went okay, false if not        *        */    private boolean saveData( ParamBean jParams, HashMap engineMap, JahiaField theField )    throws JahiaException    {        //System.out.println(">> Page_Field :: saveData");        boolean isPageMove = false;        boolean flagsave   =  true;        JahiaConsole.println(CLASS_NAME + ".saveData", "Flagsave : " + flagsave);        Integer choiceID = (Integer) engineMap.get("choiceID"+theField.getDefinition().getName());        //System.out.println(">> Page_Field :: saveData :: choiceID : "+choiceID);        String rem_url = (String) engineMap.get("remoteUrl");        if (rem_url == null)        {            rem_url = "";        }        // if nothing has been selected, don't save the field and don't create a page        //if ( (choiceID != null) && (choiceID.intValue() == 2) && (rem_url.equals("http://www")) )        //{           // return true;        //}        if ( (choiceID != null) && (choiceID.intValue() == 9) )        {            // ------------- BEGIN CASE : Remove link ---------------------------            if (theField != null)            {                JahiaBaseACL fieldAcl = new JahiaBaseACL(theField.getAclID());                ServicesRegistry.getInstance().getJahiaFieldService().deleteField(theField.getID(), jParams);                theField.setValue("<jahia_linkonly>");                //theField.setID(0);                theField.setAclID(0);                theField.setObject("createFieldWithCurrentID");                ServicesRegistry.getInstance().getJahiaFieldService().saveField(theField,fieldAcl.getParentID(),jParams);                return true;            }            else            {                return false;            }            // ------------- END CASE: Remove link --------------------------------        }        else        {        // ---------------------  BEGIN CASE : PAGE COPY/MOVE  --------------------        // if we are copying or moving a page...        if( (choiceID != null) && ((choiceID.intValue() == 3) || (choiceID.intValue() == 5))  ) {            isPageMove = true;            HashMap treeDataMap = (HashMap)engineMap.get("treeDataMap");            if(treeDataMap == null) {                return false;            }            Integer sourcePageID      = (Integer)treeDataMap.get(CopyTree_Engine.SOURCEPAGE_ID);            Integer targetPageID      = (Integer)treeDataMap.get("targetPageID");            if(sourcePageID == null) {                return false;            }            if(targetPageID == null) {                return false;            }            // have the link container and field in the old parent page            // disconnected and deleted...            // have the page parent ID and parent ACL ID changed...            if(!CopyTree_Engine.getInstance().execute(jParams, treeDataMap)) {                return false;            } else {                Integer movedPageID = (Integer) treeDataMap.get("movedPageID");                if(movedPageID == null) {                    return false;                }                JahiaPage movedPage =  ServicesRegistry.getInstance().getJahiaPageService().lookupPage(movedPageID.intValue());                if(movedPage != null) {                    theField.setObject(movedPage);                    engineMap.put("pageTitle"+ theField.getDefinition().getName(), movedPage.getTitle());                } else {                    return false;                }            }        } // -------------------  END CASE : PAGE COPY/MOVE  ------------------------        // ---------------------  BEGIN CASE : NO PAGE / DELETE PAGE ----------------        if( (choiceID != null) && (choiceID.intValue() == 4) ) {            JahiaPage theVictim = (JahiaPage)theField.getObject();            if(theVictim != null) {                // since we have made modifications concerning this page, let's flush                // the content cache for all the users and browsers...                ServicesRegistry.getInstance().getCacheServerService().removeEntry(Integer.toString(theVictim.getID()));                ServicesRegistry.getInstance().getJahiaPageService().deletePage(theVictim, jParams);            }            return true;        } // -------------------  END CASE : NO PAGE / DELETE PAGE  ------------------        JahiaPageEngineTempBean pageBean = (JahiaPageEngineTempBean)jParams.getRequest().getSession().getAttribute( "PageBean" + theField.getDefinition().getName());        // ok we have the bean to save! let's create the page (if needed) and save it...        if (pageBean != null)        {            //////////////////////////////////////////////////////////////           // FIXME -Mik-           //           //   Would we enter here if we are moving a page ?           //           ///////////////////////////////////////////////////////////////            if( theField.getObject() instanceof String ) {                theField.setObject(null);            }            JahiaPage thePage = (JahiaPage)theField.getObject();            String pageTitle = (String) engineMap.get("pageTitle"+ theField.getDefinition().getName());            if( (thePage != null) && (pageTitle != null) ) {                thePage.setTitle(pageTitle);                if (thePage.getTitle().trim().equals("") )                {                    thePage.setTitle( "Undefined Page " + nextUndefined() );                }            }            // checks if the page already exist            if (thePage == null) {                // nope -> let's create a new page with info from the bean                // NB : the parent ACL is now the FIELD acl ! not the page ! can be changed...                //toDebug("############# Page_Field :: pageType: "+pageBean.getPageType());                //toDebug("############# Page_Field :: pageLinkID: "+pageBean.getPageLinkID());                if (pageBean.getTitle().trim().equals("") )                {                    pageBean.setTitle( "Undefined Page " + nextUndefined() );                    flagsave = false;                }                if (engineMap.get("createPage_" + theField.getDefinition().getName()) != null) {                        thePage = ServicesRegistry.getInstance().getJahiaPageService().                          createPage   (pageBean.getSiteID(),                                        pageBean.getParentID(),                                        pageBean.getPageType(),                                        pageBean.getTitle(),                                        pageBean.getPageTemplateID(),                                        pageBean.getRemoteURL(),                                        pageBean.getPageLinkID(),                                        pageBean.getCreator(),                                        theField.getAclID(),                                        jParams);                        //toDebug("####### create page: "+pageBean.getTitle());                }            } else {                // the page already exists...                if(isPageMove) {                    thePage.setTitle(pageTitle);                }                switch (pageBean.getPageType()) {                    case JahiaPage.TYPE_DIRECT :                        if(!isPageMove) {                            thePage.setPageTemplateID (pageBean.getPageTemplateID());

⌨️ 快捷键说明

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