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

📄 cmschannelbackoffice.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/defaults/master/CmsChannelBackoffice.java,v $
* Date   : $Date: 2005/06/27 23:22:25 $
* Version: $Revision: 1.2 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001  The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org 
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.opencms.defaults.master;

import org.opencms.db.CmsDbUtil;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsUser;
import org.opencms.i18n.CmsEncoder;
import org.opencms.main.CmsException;
import org.opencms.util.CmsUUID;
import org.opencms.workplace.CmsWorkplace;

import com.opencms.core.I_CmsSession;
import com.opencms.defaults.A_CmsBackoffice;
import com.opencms.legacy.CmsXmlTemplateLoader;
import com.opencms.template.A_CmsXmlContent;
import com.opencms.workplace.CmsXmlLanguageFile;
import com.opencms.workplace.CmsXmlWpTemplateFile;

import java.util.Hashtable;
import java.util.List;

/**
 * @deprecated Will not be supported past the OpenCms 6 release.
 */
public class CmsChannelBackoffice extends A_CmsBackoffice{
    
    /**
     * The COS channel.
     */
    private CmsChannelContent m_channel;
    
    /**
     * The ID of the channel which is set as a property on the folder representing the channel.
     */
    private String m_channelId = "0";
    
    /**
     * The resource ID of the folder representing the channel.
     */
    private CmsUUID m_folderId;

    public Class getContentDefinitionClass() {
        return CmsChannelContent.class;
    }

    public String getCreateUrl(CmsObject cms, String tagcontent,
                             A_CmsXmlContent doc, Object userObject) throws Exception{
        return CmsWorkplace.VFS_PATH_WORKPLACE.substring(1) + "administration/channels/EditBackoffice.html";
    }

    public String getBackofficeUrl(CmsObject cms, String tagcontent,
                                 A_CmsXmlContent doc, Object userObject) throws Exception {
        return CmsWorkplace.VFS_PATH_WORKPLACE.substring(1) + "administration/channels/Backoffice.html";
    }

    public String getEditUrl(CmsObject cms, String tagcontent,
                           A_CmsXmlContent doc, Object userObject) throws Exception {
        return CmsWorkplace.VFS_PATH_WORKPLACE.substring(1) + "administration/channels/EditBackoffice.html";
    }

    public String getPublishUrl(CmsObject cms, String tagcontent,
                                 A_CmsXmlContent doc, Object userObject) throws Exception {
        return CmsWorkplace.VFS_PATH_WORKPLACE.substring(1) + "administration/channels/Backoffice.html";
    }

    // removed for testing
    public String getSetupUrl(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) throws Exception {
        return "";
    }

    /**
     * Gets the content of a given template file.
     * <P>
     *
     * @param cms A_CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName not used here
     * @param parameters get the parameters action for the button activity
     *                   and id for the used content definition instance object
     *                   and the author, title, text content for setting the new/changed data
     * @param templateSelector template section that should be processed.
     * @return Processed content of the given template file.
     * @throws CmsException
     */
    public byte[] getContentEdit(CmsObject cms, CmsXmlWpTemplateFile template, String elementName,
                             Hashtable parameters, String templateSelector) throws CmsException {
        //get the Languagedata
        CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);
        //create appropriate class name with underscores for labels
        String moduleName = "";
        moduleName = getClass().toString(); //get name
        moduleName = moduleName.substring(5); //remove 'class' substring at the beginning
        moduleName = moduleName.trim();
        moduleName = moduleName.replace('.', '_'); //replace dots with underscores
        //session
        I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
        //default error
        String error="";
        //get values of all fields
        //gets the parameter action from the hashtable.
        String action = (String) parameters.get("action");
        if (action == null){
            action="";
        } else if (action.equals("exit")){
            clearSession(session);
            templateSelector= "done";
            return startProcessing(cms, template, "", parameters, templateSelector);
        }

        // Get the parameter values

        // get value of id
        String id = (String) parameters.get("id");        
        String channelId = (String) parameters.get("channelId");
        String resourceId = (String) parameters.get("resourceid");
        String nullUUIDStr = CmsUUID.getNullUUID().toString();
        
        // get value of parentId
        String parentName = (String) parameters.get("parentName");
        if(parentName == null || parentName.equals("")){
            parentName="/";
        }
        
        // channelname
        String channelname = (String) parameters.get("channelName");
        if(channelname == null){
            channelname = "";
        }
        
        // plausibility check
        if(!action.equals("") && channelname.trim().equals("")){
            error = lang.getLanguageValue(moduleName+".error.message2");
        }
        
        // title of channel
        String title = (String) parameters.get("title");

        String owner=(String) parameters.get("owner");
        owner=(owner!=null?owner.trim():"");
        String group=(String) parameters.get("groupId");
        group=(group!=null?group.trim():"");

        int accessFlags = this.getAccessValue(parameters);

        //new channel
        if (id == null || id.equals("")){
            id = "new";
        }
        if(channelId==null || channelId.trim().equals("")){
            channelId="-1";
        }
        if(resourceId==null || resourceId.trim().equals("")){
            resourceId=nullUUIDStr;
        }
        if(id.equals("new")){
            if(resourceId.equals(nullUUIDStr)){
                m_channel=null;
            }else{
                id=resourceId;
            }
        }
        // for the first call check if the id exist, i.e. if the category is to edit
        // and it is not created new one then read the information of category
        if (action.equals("") && !id.equals("new")) {            
//            try {
//                Integer.parseInt(id);
//            } catch (Exception err) {
//                throw new CmsException(err.getMessage());
//            }
            // gets the already existing ouputchannel's content definition.
            m_channel = new CmsChannelContent(cms,new CmsUUID(id));

⌨️ 快捷键说明

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