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

📄 jahiaobjecttool.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  JahiaObjectUtils//  MJ      12.03.2001////package org.jahia.utils;import java.util.*;                                     // HashMapimport org.jahia.exceptions.JahiaException;import org.jahia.registries.*;                      // ServicesRegistryimport org.jahia.data.fields.*;                     // JahiaFieldimport org.jahia.data.containers.*;                 // JahiaContainer, JahiaContainerListimport org.jahia.services.pages.*;                  // JahiaPage/** * Utility class to return characteristic strings with an input of (int objectType, int objectID) * intended for use by the audit log management system * * @author MJ */public class JahiaObjectTool{    private static JahiaObjectTool theObject           = null;    private static final String    MSG_INTERNAL_ERROR  = new String ("Object Tool internal error");    public static final int        FIELD_TYPE          = 1;    public static final int        CONTAINER_TYPE      = 2;    public static final int        CONTAINERLIST_TYPE  = 3;    public static final int        PAGE_TYPE           = 4;    public static final int        ACL_TYPE            = 5;    public static final int        APPLICATION_TYPE    = 6;    public static final int        SERVER_TYPE         = 7;    public static final int        TEMPLATE_TYPE       = 8;    /***        * returns the single instance of the object        *        */    public static synchronized JahiaObjectTool getInstance()    {        if (theObject == null) {            theObject = new JahiaObjectTool();        }        return theObject;    } // end getInstance    /***        * get the object name according to the object type and object ID (without engineMap)        * @author   Mikha雔 Janson        * @param    objectType        * @param    engineMap        * @return   the object name, as an <code>String</code>        */    public String getObjectName( int objectType, int objectID )    throws JahiaException    {        ServicesRegistry sReg = ServicesRegistry.getInstance();                switch(objectType) {            case CONTAINERLIST_TYPE: return sReg.getJahiaContainersService().loadContainerListInfo(objectID).getDefinition().getName();            case CONTAINER_TYPE:     return sReg.getJahiaContainersService().loadContainerInfo(objectID).getDefinition().getName();            case PAGE_TYPE:          return sReg.getJahiaPageService().lookupPage(objectID).getTitle();            case FIELD_TYPE:         return sReg.getJahiaFieldService().loadField(objectID).getDefinition().getName();            case APPLICATION_TYPE:   return sReg.getJahiaApplicationsManagerService().getApplication(objectID).getName();            case TEMPLATE_TYPE:   	 return sReg.getJahiaPageTemplateService().lookupPageTemplate(objectID).getName();            case SERVER_TYPE:        return "Jahia Server";            default:                 throw new JahiaException (MSG_INTERNAL_ERROR,                                                               "Incompatible Object Type passed to JahiaObjectTool.getObjectName(objectType, objectID)",                                                               JahiaException.SERVICE_ERROR,                                                               JahiaException.CRITICAL);        }    } // end getObjectName( int objectType, int objectID )    /***        * get the object name according to the object type        * @author   Mikha雔 Janson        * @param    objectType        * @param    engineMap        * @return   the object name, as an <code>String</code>        */    public String getObjectName( int objectType, HashMap engineMap )    throws JahiaException    {        switch(objectType) {            case CONTAINERLIST_TYPE: return ((JahiaContainerList) engineMap.get( "theContainerList" )).getDefinition().getName();            case CONTAINER_TYPE:     return ((JahiaContainer) engineMap.get( "theContainer" )).getDefinition().getName();            case PAGE_TYPE:          return ((JahiaPage) engineMap.get( "thePage" )).getTitle();            case FIELD_TYPE:         return ((JahiaField) engineMap.get( "theField" )).getDefinition().getName();            case TEMPLATE_TYPE:      return ((JahiaPageDefinition) engineMap.get( "theTemplate" )).getName();            default:                 throw new JahiaException (MSG_INTERNAL_ERROR,                                                               "Incompatible Object Type passed to JahiaObjectTool.getObjectName(objectType, engineMap)",                                                               JahiaException.SERVICE_ERROR,                                                               JahiaException.CRITICAL);        }    } // end getObjectName (int objectType, HashMap engineMap)    /***        * get an object type name from the objectType        * @author   Mikha雔 Janson        * @param    objectType     the object type, as an <code>int</code>        * @return   a <code>String</code> containing the name of the object type        *        */    public String getObjectTypeName( int objectType )    throws JahiaException    {        switch(objectType) {            case CONTAINERLIST_TYPE: return "containerlist";            case CONTAINER_TYPE:     return "container";            case PAGE_TYPE:          return "page";            case FIELD_TYPE:         return "field";            case TEMPLATE_TYPE:      return "template";            default:                 throw new JahiaException (MSG_INTERNAL_ERROR,                                                               "Incompatible Object Type passed to JahiaObjectTool.getObjectName(objectType)",                                                               JahiaException.SERVICE_ERROR,                                                               JahiaException.CRITICAL);        }    }    /***        * get the object ID according to the object type        * @author   Mikha雔 Janson        * @param    objectType        * @param    engineMap        * @return   the object ID, as an <code>int</code>        */    public int getObjectID( int objectType, HashMap engineMap )    throws JahiaException    {        switch(objectType) {            case CONTAINERLIST_TYPE: return ((JahiaContainerList) engineMap.get( "theContainerList" )).getID();            case CONTAINER_TYPE:     return ((JahiaContainer) engineMap.get( "theContainer" )).getID();            case PAGE_TYPE:          return ((JahiaPage) engineMap.get( "thePage" )).getID();            case FIELD_TYPE:         return ((JahiaField) engineMap.get( "theField" )).getID();            case TEMPLATE_TYPE:      return ((JahiaPageDefinition) engineMap.get( "theTemplate" )).getID();            default:                 throw new JahiaException (MSG_INTERNAL_ERROR,                                                               "Incompatible Object Type passed to JahiaObjectTool",                                                               JahiaException.SERVICE_ERROR,                                                               JahiaException.CRITICAL);        }    }} // end class JahiaObjectTool

⌨️ 快捷键说明

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