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

📄 jahiafielddefinitionsregistry.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  EV      25.11.2000//package org.jahia.registries;import java.util.*;                     // Vectorimport org.jahia.utils.*;           // JahiaConsoleimport org.jahia.data.fields.*;     // JahiaFieldimport org.jahia.services.*;        // ServicesRegistryimport org.jahia.exceptions.JahiaException;public class JahiaFieldDefinitionsRegistry {    private static  JahiaFieldDefinitionsRegistry   theObject   = null;    private static final String KEY_SEPARATOR = "###";    private         Map          fieldDefTable;    private         Map          fieldDefSiteAndNameTable;    /***     * constructor     * EV    25.11.2000     *     */    private JahiaFieldDefinitionsRegistry()    {        JahiaConsole.println( "JahiaFieldDefinitionsRegistry", "***** Starting FieldDefinitions Registry *****" );    } // end constructor    /***     * getInstance     * EV    25.11.2000     *     */    public static synchronized JahiaFieldDefinitionsRegistry getInstance()    {        if (theObject == null) {            theObject = new JahiaFieldDefinitionsRegistry();        }        return theObject;    } // end getInstance    /***     * init     * EV    25.11.2000     *     */    public void init()    throws JahiaException    {        loadAllDefinitions();    } // end init    /***     * loadAllDefinitions     * EV    29.12.2000     *     */    public synchronized void loadAllDefinitions()            throws JahiaException    {        fieldDefTable = new HashMap();        fieldDefSiteAndNameTable = new HashMap();        Vector ids = ServicesRegistry.getInstance().getJahiaFieldService().getAllFieldDefinitionIDs();        Enumeration fieldDefIDEnum = ids.elements();        while (fieldDefIDEnum.hasMoreElements()) {            Integer currentID = ((Integer)fieldDefIDEnum.nextElement());            JahiaFieldDefinition curDefinition = ServicesRegistry.getInstance().getJahiaFieldService().loadFieldDefinition(currentID.intValue());            fieldDefTable.put(currentID, curDefinition);            fieldDefSiteAndNameTable.put(curDefinition.getName() + KEY_SEPARATOR + Integer.toString(curDefinition.getJahiaID()), curDefinition);        }    } // end loadAllDefinitions    /***     * getDefinition     * EV    29.12.2000     *     */    public JahiaFieldDefinition getDefinition( int defID )    throws JahiaException    {        JahiaFieldDefinition result = (JahiaFieldDefinition) fieldDefTable.get(new Integer(defID));        if (result != null) {            return result;        }        String errorMsg = "The FielddescRegistry could not find the definition ID " + defID;        JahiaConsole.println ("JahiaFieldDefinitionsRegistry", errorMsg + " -> BAILING OUT");        throw new JahiaException ("Database synchronisation error",                                  errorMsg, JahiaException.REGISTRY_ERROR, JahiaException.CRITICAL);    } // end getDefinition    //--------------------------------------------------------------------------    // 11.07.2001 update to multi site by adding siteID    /***     * getDefinition     * EV    25.11.2000     *     */    public JahiaFieldDefinition getDefinition( int siteID, String fieldName )    {        JahiaFieldDefinition result = (JahiaFieldDefinition) fieldDefSiteAndNameTable.get(fieldName + KEY_SEPARATOR + Integer.toString(siteID));        return result;    } // end getDefinition    /***     * setDefinition     * EV    25.11.2000     *     */    public synchronized void setDefinition( JahiaFieldDefinition theFieldDef )    throws JahiaException    {        JahiaFieldDefinition aFieldDef = getDefinition( theFieldDef.getJahiaID(), theFieldDef.getName() );        if (aFieldDef != null) {            // field definition already exists, just have to update            // check if the field def has changed            // We ensure to perform an update            theFieldDef.setID(aFieldDef.getID());            ServicesRegistry.getInstance().getJahiaFieldService().saveFieldDefinition( theFieldDef );            fieldDefTable.put(new Integer(theFieldDef.getID()), theFieldDef);            fieldDefSiteAndNameTable.put(theFieldDef.getName() + KEY_SEPARATOR + Integer.toString(theFieldDef.getJahiaID()), theFieldDef);        } else {            // field definition doesn't exist, need to add to registry            //We ensure to create a new one            theFieldDef.setID(0);            ServicesRegistry.getInstance().getJahiaFieldService().saveFieldDefinition( theFieldDef );            fieldDefTable.put(new Integer(theFieldDef.getID()), theFieldDef);            fieldDefSiteAndNameTable.put(theFieldDef.getName() + KEY_SEPARATOR + Integer.toString(theFieldDef.getJahiaID()), theFieldDef);        }    } // end setDefinition    /***     * remove a Field Definition     * NK    02.08.2001     *     */    public synchronized void removeFieldDefinition( int fieldDefID )    throws JahiaException    {        JahiaFieldDefinition fieldDef = getDefinition(fieldDefID);        fieldDefTable.remove(new Integer(fieldDefID));        fieldDefSiteAndNameTable.remove(fieldDef.getName() + KEY_SEPARATOR + Integer.toString(fieldDef.getJahiaID()));    } // end setDefinition}

⌨️ 快捷键说明

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