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

📄 portletsbean.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *     * @author Jerome Bedat     *     */    public void movePortletRight(int thePortletID, int thePageID, String theUserName, String uRLtoTemplatesDir) {        try {            String theFile = theUserName + ".xml";            String theDefaultFile = theDefaultUser + ".xml";            XMLPortlets XMLFile = new XMLPortlets(uRLtoTemplatesDir, theFile, theDefaultFile, thePageID);            XMLFile.moveRightPortlet(thePortletID);        } catch (JahiaException e) {            JahiaConsole.println( "PortletsBean -> moveXMLPortletRight", e.toString() );        }    } // end movePortletRight    /**     * Move the portlet to the left column     *     * @author Jerome Bedat     *     */    public void movePortletLeft(int thePortletID, int thePageID, String theUserName, String uRLtoTemplatesDir) {        try {            String theFile = theUserName + ".xml";            String theDefaultFile = theDefaultUser + ".xml";            XMLPortlets XMLFile = new XMLPortlets(uRLtoTemplatesDir, theFile, theDefaultFile, thePageID);            XMLFile.moveLeftPortlet(thePortletID);        } catch (JahiaException e) {            JahiaConsole.println( "PortletsBean -> moveXMLPortletLeft", e.toString() );        }    } // end movePortletLeft    /**     * Move the portlet to the bottom row     *     * @author Jerome Bedat     *     */    public void movePortletBottom(int thePortletID, int thePageID, String theUserName, String uRLtoTemplatesDir) {        try {            String theFile = theUserName + ".xml";            String theDefaultFile = theDefaultUser + ".xml";            XMLPortlets XMLFile = new XMLPortlets(uRLtoTemplatesDir, theFile, theDefaultFile, thePageID);            XMLFile.moveBottomPortlet(thePortletID);        } catch (JahiaException e) {            JahiaConsole.println( "PortletsBean -> moveXMLPortletBottom", e.toString() );        }    } // end movePortletBottom    /**     * Move the portlet to the top row     *     * @author Jerome Bedat     *     */    public void movePortletTop(int thePortletID, int thePageID, String theUserName, String uRLtoTemplatesDir) {        try {            String theFile = theUserName + ".xml";            String theDefaultFile = theDefaultUser + ".xml";            XMLPortlets XMLFile = new XMLPortlets(uRLtoTemplatesDir, theFile, theDefaultFile, thePageID);            XMLFile.moveTopPortlet(thePortletID);        } catch (JahiaException e) {            JahiaConsole.println( "PortletsBean -> moveXMLPortletTop", e.toString() );        }    } // end movePortletTop    /**     * Copy the Portlet Group from the specified user XML file to the other users files     *     * @author Jerome Bedat     *     */    public void copyPortletGroup(int thePageID, String theUserName, String uRLtoTemplatesDir) {        try {            String theFile = theUserName + ".xml";            String theDefaultFile = theDefaultUser + ".xml";            XMLPortlets XMLFile = new XMLPortlets(uRLtoTemplatesDir, theFile, theDefaultFile, thePageID);            File   portletsAPIPathDir  = new File( uRLtoTemplatesDir + File.separator + "portlets_api" + File.separator );            File[] portletsAPIFileList = portletsAPIPathDir.listFiles();            Vector sourceIDList = XMLFile.copyXMLPortletGroup(uRLtoTemplatesDir + File.separator + "portlets_api" + File.separator + theDefaultFile);            for(int i=0; i<portletsAPIFileList.length; i++) {                if (!portletsAPIFileList[i].getAbsolutePath().equals(uRLtoTemplatesDir + File.separator + "portlets_api" + File.separator + theFile) && !portletsAPIFileList[i].getAbsolutePath().equals(uRLtoTemplatesDir + File.separator + "portlets_api" + File.separator + theDefaultFile)) {                    XMLFile.copyXMLPortletGroup(portletsAPIFileList[i].getAbsolutePath());                }            }            unassignRightsToPortlets (sourceIDList);        } catch (JahiaException e) {            JahiaConsole.println( "PortletsBean -> copyPortletGroup", e.toString() );        }    } // end copyPortletGroup    /**     * Load a Skin from the DataBase     *     * @author Jerome Bedat     *     */    public SkinObj loadSkin(String theType, int theID) {        try {            PortletsDBManager DB = PortletsDBManager.getInstance();            if (theType.equals("portlet")) {                theSkin = DB.load_portlet_skin(theID);            } else if (theType.equals("desktop")) {                theSkin = DB.load_desktop_skin(theID);            }            if (theSkin == null) {                theSkin = new SkinObj(1,"","");            }        } catch (JahiaException e) {            theSkin = new SkinObj(1,"","");            JahiaConsole.println( "PortletsBean -> loadSkin", e.toString() );        }        return theSkin;    } // end loadSkin    /**     * Print message in the JahiaConsole     *     * @author Jerome Bedat     *     */    public void consoleOutput(String theFirst, String theSecond) {        JahiaConsole.println( theFirst, theSecond );    } // end consoleOutput    //-------------------------------------------------------------------------    private void unassignRightsToPortlets (Vector ctnids) {        // get the administrator group name.        String adminGroupName =                JahiaGroupManagerService.ADMINISTRATORS_GROUPNAME;        // get the administrator group object.        JahiaGroup adminGroup = ServicesRegistry.getInstance().                getJahiaGroupManagerService ().                lookupGroup (JahiaGroupManagerService.ADMINISTRATORS_GROUPNAME);        // get the administrator group object.        JahiaGroup usersGroup = ServicesRegistry.getInstance().                getJahiaGroupManagerService ().                lookupGroup (JahiaGroupManagerService.USERS_GROUPNAME);        // get the administrator group object.        JahiaGroup guestGroup = ServicesRegistry.getInstance().                getJahiaGroupManagerService ().                lookupGroup (JahiaGroupManagerService.GUEST_GROUPNAME);        // if the administrators group is not available .. just leave.        // ok ok .. it's a hack, but I'll fix this later.   (Fulco) Fulco shame on you !        if (adminGroup == null) {            return;        }        // process all the fields to reset the rights.        for (int index = 0; index < ctnids.size(); index++) {            try {                // get the field ID                int ctnid = ((Integer)ctnids.get (index)).intValue();                // Get the container reference holding the field.                JahiaContainer container = ServicesRegistry.getInstance().                        getJahiaContainersService().loadContainerInfo (ctnid);                if (container != null) {                    // Get the ACL of the container                    try {                        JahiaBaseACL acl = new JahiaBaseACL (container.getAclID());                        if (acl != null) {                            // remove all the user who are not an                            // administrator for administrator users, keep                            // the existing entry.                            // get all the user entries.                            Vector usernames = acl.getUsernameList (null);                            if (usernames.size() > 0) {                                for (int i=0; i<usernames.size(); i++) {                                    String username = (String)usernames.get(i);                                    JahiaUser user = ServicesRegistry.                                            getInstance().                                            getJahiaUserManagerService().                                            // FIXME_MULTISITE Hollis sietid is deducted from container ....                                            lookupUser (container.getSiteID(),username);                                    if ((user != null) &&                                        (!user.isMemberOfGroup (container.getSiteID(),adminGroupName)))                                    {                                        acl.removeUserEntry (user);                                    }                                }                            }                            // disable the access to the users and guest group                            JahiaACLEntry entry = new JahiaACLEntry (0, 0);                            entry.setPermission (JahiaBaseACL.READ_RIGHTS, JahiaACLEntry.ACL_YES);                            acl.setGroupEntry (usersGroup, entry);                            acl.setGroupEntry (guestGroup, entry);                            // set the new administration group rights                            JahiaACLEntry adminEntry = new JahiaACLEntry ();                            for (int i=0; i<acl.size(); i++) {                                adminEntry.setPermission (i, JahiaACLEntry.ACL_YES);                            }                            acl.setGroupEntry (adminGroup, adminEntry);                        }                    }                    catch (ACLNotFoundException ex) {                        // the ACL was not found .. go to the next field.                    }                }            }            catch (JahiaException ex) {                // go to the next field.            }        }    }}

⌨️ 快捷键说明

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