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

📄 application_field.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  Application_Field//  EV  14.01.20001//	NK	19.04.2001 Lot of changes with roles to work with new user/group and in multi site////  handleField( mode, jParams )//package org.jahia.engines.shared;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;import java.security.acl.Group;import java.security.Principal;import org.jahia.exceptions.*;                  // JahiaExceptionimport org.jahia.utils.*;                       // JahiaConsoleimport org.jahia.data.*;                        // JahiaData, ConnectionTypesimport org.jahia.params.*;                      // ParamBeanimport org.jahia.engines.*;                     // JahiaEngine interfaceimport org.jahia.engines.applications.*;        // Applications_Engineimport org.jahia.data.fields.*;                 // JahiaField, FieldTypesimport org.jahia.data.applications.*;import org.jahia.services.shares.*;import org.jahia.services.sites.*;import org.jahia.data.containers.*;import org.jahia.services.acl.*;import org.jahia.services.applications.*;import org.jahia.services.usermanager.*;import org.jahia.registries.*;                  // ServicesRegistrypublic class Application_Field{    private static          Application_Field   theObject   = null;    private static final    String              JSP_FILE    = "/jsp/jahia/engines/shared/application_field.jsp";    public  static final    String  READONLY_JSP  			= "/jsp/jahia/engines/shared/readonly_application_field.jsp";    /***        * getInstance        * AK    19.12.2000        *        */    public static synchronized Application_Field getInstance()    {        if (theObject == null) {            theObject = new Application_Field();        }        return theObject;    } // end getInstance    /***        * handles the field actions        *        * @param        jParams             a ParamBean object        * @param        mode                the mode, according to JahiaEngine        * @return       true if everything went okay, false if not        * @see          org.jahia.engines.JahiaEngine        *        */    public boolean handleField( ParamBean jParams, Integer modeInt, HashMap engineMap )    throws JahiaException    {        int mode = modeInt.intValue();        JahiaField theField = (JahiaField) engineMap.get( "theField" );        if ( theField == null ){            JahiaConsole.println("Application_Field.handleField","the field is null");        }        switch (mode)        {            case (JahiaEngine.LOAD_MODE)            :   return composeEngineMap( jParams, engineMap, theField );            case (JahiaEngine.UPDATE_MODE)          :   return getFormData( jParams, engineMap, theField );            case (JahiaEngine.SAVE_MODE)            :   return saveData( jParams, engineMap, theField );        }        return false;    } // end handleField    /***        * gets POST data from the form and saves it in session        *        * @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 getFormData( ParamBean jParams, HashMap engineMap, JahiaField theField )    throws JahiaException    {        JahiaConsole.println("Application_Field.getFormData","started");        boolean out             = true;        String fieldValue       = jParams.getRequest().getParameter( "_" + new Integer(theField.getID()).toString() );        String engineParams     = jParams.getRequest().getParameter( "engine_params" );        EngineParams eParams    = new EngineParams( engineParams );        String localSwitch      = eParams.getParameter( "localswitch" );        String dataSourceUrl    = eParams.getParameter( "dsurl" );        if (dataSourceUrl != null) {            theField.setValue( dataSourceUrl );            theField.setConnectType( ConnectionTypes.DATASOURCE );        } else if (localSwitch != null) {            theField.setObject( "-1" );            theField.setConnectType( ConnectionTypes.LOCAL );        } else if (fieldValue != null) {            theField.setObject( fieldValue );        }        return out;    } // end getFormData    /***        * 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    {        JahiaConsole.println("Application_Field.saveData","started");        if (engineMap.get("createApplication_" + theField.getDefinition().getName()) != null) {            theField.setValue( (String)theField.getObject() );            // 0 for parentAclID in saveField, because field already exists            //  -> field already has an aclID            //  -> no need to create a new one            ServicesRegistry.getInstance().getJahiaFieldService().saveField( theField, 0, jParams );            // get the application's roles list            Integer appID = new Integer(theField.getValue());			ApplicationContext appContext = ServicesRegistry.getInstance()															.getJahiaApplicationContextService()															.getApplicationContext(appID.intValue());			Enumeration roles = appContext.getRoles().elements();            Vector authMembers = null;            Enumeration members = null;            // Handle roles changes            if ( roles != null ){                String role = null;                while (roles.hasMoreElements()){                    role = (String)roles.nextElement();                    JahiaGroup grp = ServicesRegistry                                            .getInstance()                                            .getJahiaGroupManagerService()                                            .lookupGroup(0, appID + "_" + theField.getID() + "_" + role );                    if ( grp != null ){                        // Handle Users                        if ( engineMap.get( "authUsers" + role ) != null ){                            JahiaConsole.println("Application_Field.saveData","auhtUsers is not null for role " + role);                            authMembers = (Vector)engineMap.get( "authUsers" + role );                            JahiaUser user = null;                            // first remove all users                            members = grp.members();                            Principal p = null;                            while( members.hasMoreElements() ){                                p = (Principal)members.nextElement();

⌨️ 快捷键说明

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