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

📄 jahiacontainer.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }        }    } // end addField    //-------------------------------------------------------------------------    /***        * addField        * EV    27.12.2000        *        */    public synchronized void addField( JahiaField theField )    throws JahiaException    {        if (theField != null) {            fields.add( theField );        }    } // end addField    //-------------------------------------------------------------------------    /***        * getContainerList        * EV    27.12.2000        *        */    public JahiaContainerList getContainerList( String listName )    throws JahiaException    {        JahiaContainerList theList = null;        for (int i=0; i < containerLists.size(); i++) {            JahiaContainerList aList = (JahiaContainerList) containerLists.elementAt(i);            if (aList.getDefinition().getName().equals(listName)) {                theList = aList;            }        }        if (theList == null) {            JahiaContainerDefinition theDef = JahiaContainerDefinitionsRegistry.            getInstance().getDefinition( this.jahiaID, listName );            theList = new JahiaContainerList( 0, this.getID(), this.getPageID(),                      theDef.getID(), 0 );        }        return theList;    } // end getContainerList    //-------------------------------------------------------------------------    /***        * addContainerList        * EV    27.12.2000        *        */    public synchronized void addContainerList( JahiaContainerList theList )    throws JahiaException    {        if (theList != null) {            containerLists.add( theList );        }    } // end addList    //-------------------------------------------------------------------------    /***        * Order the fields in the exact order in which they are declared in template.        * Create new declared fields for old containers.        *        * NK    04.06.2002        *        * @param ParamBean jParams        */	public synchronized void fieldsStructureCheck(ParamBean jParams)	throws JahiaException	{		// let's order fields as they appear in template declaration !        Vector fieldOrder = new Vector();        Vector orderedFields = new Vector();        Hashtable fieldDefs = new Hashtable();        JahiaPage sourcePage = ServicesRegistry.getInstance().getJahiaPageService().lookupPage(this.getPageID());        if ( sourcePage != null && this.fields != null && this.fields.size()>1 )        {	        int pageDefID = sourcePage.getPageTemplateID();	        Enumeration structure = this.getDefinition().getStructure(	                        "", pageDefID, JahiaContainerStructure.JAHIA_FIELD );	        while (structure.hasMoreElements()) {	            JahiaContainerStructure theStruct =	                        (JahiaContainerStructure) structure.nextElement();	            JahiaFieldDefinition theDef =	                        (JahiaFieldDefinition) theStruct.getObjectDef();				fieldOrder.add(theDef.getName());				orderedFields.add(null); //fake element				fieldDefs.put(theDef.getName(),theDef);	        }			JahiaField field = null;	        for (int i=0; i < fields.size(); i++) {                field = (JahiaField)fields.get(i);				int fieldPos = fieldOrder.indexOf(field.getDefinition().getName());				if ( fieldPos != -1 ){					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","Field " + field.getDefinition().getName() + " has pos : " + fieldPos);					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");					orderedFields.setElementAt(field,fieldPos);					fieldDefs.remove(field.getDefinition().getName());				} else {					// seems that we encountered a field for which the definition has benn removed from the container declaration					// so we ignore this field				}	        }	        // We check here if the container declaration has changed and if we have to create new	        // declared field for this container.	        Enumeration enum = fieldDefs.elements();	        JahiaFieldDefinition fieldDef = null;	        while( enum.hasMoreElements() ){	        	fieldDef = (JahiaFieldDefinition)enum.nextElement();				JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");				JahiaConsole.println("JahiaContainer.fieldsStructureCheck","Field " + fieldDef.getName() + " is missing, we have to create a new one ");				JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");        		int fieldType = fieldDef.getType( pageDefID );        		int connectType = 0;        		int rank = 0;        		int aclID = 0;        		String fieldValue = fieldDef.getDefaultValue( pageDefID );        		field = ServicesRegistry.getInstance().                               getJahiaFieldService().                               createJahiaField( 0, this.getJahiaID(), this.getPageID(),                               this.getID(), fieldDef.getID(), fieldType,                               connectType, fieldValue, rank, aclID );                if ( field != null )                {                	// save the field                	ServicesRegistry.getInstance().getJahiaFieldService().                        saveField( field, this.getAclID(), jParams );					int fieldPos = fieldOrder.indexOf(fieldDef.getName());					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","Field " + field.getDefinition().getName() + " has pos : " + fieldPos);					JahiaConsole.println("JahiaContainer.fieldsStructureCheck","----------------------------------------------------------");					orderedFields.setElementAt(field,fieldPos);				}	        }			this.fields = orderedFields;		}	}    //-------------------------------------------------------------------------    /**     * Check if the user has read access for the specified container. Read access means     * the user can display container data (he needs to have the rights for each field/     * containerlist too)     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has read access for the specified container,     *           or false in any other case.     */    public final boolean checkReadAccess (JahiaUser user)    {        return checkAccess (user, JahiaBaseACL.READ_RIGHTS);    }    //-------------------------------------------------------------------------    /**     * Check if the user has Write access for the specified container. Write access means     * updating container data data (he needs to have the rights for each field/containerlist too)     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has write access for the specified container,     *           or false in any other case.     */    public final boolean checkWriteAccess (JahiaUser user)    {        return checkAccess (user, JahiaBaseACL.WRITE_RIGHTS);    }    //-------------------------------------------------------------------------    /**     * Check if the user has Admin access for the specified container. Admin access means     * setting container rights (he needs to have the rights for each field/containerlist too)     *     * @param    user    Reference to the user.     *     * @return   Return true if the user has admin access for the specified container,     *           or false in any other case.     */    public final boolean checkAdminAccess (JahiaUser user)    {        return checkAccess (user, JahiaBaseACL.ADMIN_RIGHTS);    }    //-------------------------------------------------------------------------    private boolean checkAccess (JahiaUser user, int permission)    {        if (user == null) {            return false;        }        boolean result = false;        try        {            // Try to instanciate the ACL.            JahiaBaseACL containerACL = new JahiaBaseACL (aclID);            // Test the access rights            result = containerACL.getPermission (user, permission, this.getJahiaID());            // destroy the object.            containerACL = null;        }        catch (ACLNotFoundException ex) {            //JahiaConsole.println ("JahiaContainer", "Could not find the ACL ["+Integer.toString(aclID)+            //        "] for container ["+Integer.toString(ID)+"]");        }        catch (JahiaException ex) {            //JahiaConsole.println ("JahiaContainer", "JahiaException caught in checkAccess.");        }        //if (!result) {        //    JahiaConsole.println ("JahiaContainer", "Permission denied for user ["+        //            user.getName()+"] to container ["+Integer.toString(ID)+        //            "] for access permission ["+Integer.toString(permission)+"]");        //}        return result;    }} // end JahiaContainer

⌨️ 快捷键说明

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