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

📄 jahiaapplicationfield.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
//  JahiaApplicationField//  YG      17.07.2001package org.jahia.data.fields;import java.util.*;                     // Vector, Calendarimport org.jahia.utils.*; import org.jahia.data.applications.*;import org.jahia.registries.*;      // Registriesimport org.jahia.exceptions.JahiaException;import org.apache.regexp.*;             // Regular Expressionimport org.jahia.services.applications.*; // Jahia Applications Serviceimport org.jahia.params.*;          // ParamBeanimport org.jahia.data.*;            // JahiaDataimport org.jahia.sharing.*;         // JahiaDataSourceManagerimport org.jahia.registries.*;      // Registriespublic class JahiaApplicationField extends JahiaField{        /***        * constructor        * YG    17.07.2001        *        */    public JahiaApplicationField(Integer    ID,                            Integer         jahiaID,                            Integer         pageID,                            Integer         ctnid,                            Integer         fieldDefID,                            Integer         fieldType,                            Integer         connectType,                            String          fieldValue,                            Integer         rank,                            Integer         aclID )    {        super(ID, jahiaID, pageID, ctnid, fieldDefID, fieldType, connectType,              fieldValue, rank, aclID);    } // end constructor            public void load(int loadFlag, ParamBean jParams)    throws JahiaException    {        if ((loadFlag & LoadFlags.APPLICATION) != 0)        {            switch (this.getConnectType())            {                case (ConnectionTypes.LOCAL) :                    this.setObject(this.getValue()); // to save the app id... used in engines                    ServicesRegistry tmpServicesRegistry = ServicesRegistry.getInstance();                    //System.out.println("ID: "+this.getID()+" Value: "+this.getValue());                    String tmpValue = "";                    if (jParams != null)                    {                        tmpValue = ServicesRegistry.getInstance().                        getJahiaApplicationsDispatchingService().                        getAppOutput( this.getID(), this.getValue(), jParams);                    }                    try {                        tmpValue = (new RE("</?html>",RE.MATCH_CASEINDEPENDENT)).                            subst(tmpValue,"");                    } catch (RESyntaxException e) {                        JahiaConsole.println("JahiaFieldBaseService",e.toString());                    }										try {						                    this.setValue(FormDataManager.getInstance().	                    decode(new StringBuffer().append("<html>").	                    append(tmpValue).append("</html>").toString()));					} catch ( Throwable t ){						t.printStackTrace();	                    this.setValue(tmpValue);					}                    break;                case (ConnectionTypes.DATASOURCE) :                if ((loadFlag & LoadFlags.DATASOURCE) != 0) {                    this.setValue( JahiaDataSourceManager.getInstance().                    fields().getInstance().getRemoteFieldValue(                     this.getValue() ));                }                break;            }        }    }        public void save(ParamBean jParams)    throws JahiaException    {        switch (this.getConnectType())        {        case (ConnectionTypes.LOCAL) :        if ( this.getValue() != null && !this.getValue().equals("<empty>") ){            int appID = Integer.parseInt(this.getValue());            ApplicationBean app = ServicesRegistry.getInstance()                                  .getJahiaApplicationsManagerService()                                  .getApplication(appID);                                              if ( app != null ){                // check if the app has changed                String oldAppID = (String)this.getObject();                if ( (oldAppID!=null) && !oldAppID.equals(this.getValue()) ){                    // App has changed, so delete old groups                    ApplicationBean oldApp 	= ServicesRegistry                                              .getInstance()                                              .getJahiaApplicationsManagerService()                                              .getApplication(Integer.parseInt(oldAppID));                    ServicesRegistry.getInstance()                        .getJahiaApplicationsManagerService()                        .deleteApplicationGroups(oldApp,this);                }                // Create new groups on this field ( only if not exists )                ServicesRegistry.getInstance()                    .getJahiaApplicationsManagerService()                    .createApplicationGroups(app,this);            }        }        break;        }    }        public void delete(ParamBean jParams)    throws JahiaException    {        switch (this.getConnectType())        {        case (ConnectionTypes.LOCAL) :            if ( this.getValue() != null ){                try {                    int appID = Integer.parseInt(this.getValue());                    ApplicationBean app = ServicesRegistry.getInstance().                        getJahiaApplicationsManagerService().                        getApplication(appID);                    if ( app != null ){                        ServicesRegistry.getInstance().                            getJahiaApplicationsManagerService().                            deleteApplicationGroups(app,this);                    }                } catch (NumberFormatException nfe){                    //                 }            }            break;        }    }    /**     * Returns an hashtable of indexable attributes , pairs [attribute name/value].      * Returned pairs:     * 					none     *     * @return Hashtable a map of indexable attributes , pairs [attribute name/value]     */    public Hashtable getIndexableAttributes(){    	Hashtable hash = new Hashtable();    	return hash;    }        public String getEngineName()    {        return "org.jahia.engines.shared.Application_Field";    }        public String getFieldContent4Ranking()    throws JahiaException    {        String fieldInfo = "";        String appIDStr = (String)this.getObject();        int appID = 0;        if (appIDStr != null)        {            try {                    appID = Integer.parseInt(appIDStr);                } catch (NumberFormatException nfe) {                    ;                }            }                ApplicationBean app = ServicesRegistry.getInstance().                              getJahiaApplicationsManagerService().                              getApplication(appID);                if (app != null)        {            fieldInfo = app.getName();        }        else        {            fieldInfo = this.getValue();         }        return fieldInfo;    }        public String getIconNameOff()    {        return "application";    }        public String getIconNameOn()    {        return "application_on";    }        public JahiaField cloneField(int newctnid, int newPageID, int clonedAclID, boolean childrenCloned)    throws JahiaException    {        JahiaField clonedField = ServicesRegistry.getInstance().getJahiaFieldService().                                 createJahiaField(0, this.getJahiaID(),                                 newPageID, newctnid,                                 this.getFieldDefID(), this.getType(),                                 this.getConnectType(),                                 (String)this.getObject(), this.getRank(),                                 clonedAclID );        //toDebug("cloneField(): value = "+this.getValue());        if (clonedField == null)        {            throw new JahiaException ("Could not clone field.",                "Could not instanciate a new JahiaField object.",                JahiaException.PAGE_ERROR, JahiaException.CRITICAL);        }        clonedField.setRawValue(this.getRawValue());        clonedField.setObject( this.getObject() );        clonedField.setProperties( (Hashtable)(this.getProperties()).clone() );                return clonedField;    }        public Object clone()    {        Object objItem = this.getObject();        JahiaApplicationField app = new JahiaApplicationField (new Integer(ID), new Integer(jahiaID),                                        new Integer(pageID),                                         new Integer(ctnid),                                        new Integer(fieldDefID),                                         new Integer(fieldType),                                         new Integer(connectType),                                         fieldValue, new Integer(rank),                                         new Integer(aclID) );        app.setObject(objItem);        return app;    }            }

⌨️ 快捷键说明

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