📄 cmschannelcontent.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/defaults/master/CmsChannelContent.java,v $
* Date : $Date: 2002/03/25 14:39:34 $
* Version: $Revision: 1.10 $
*
* 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 com.opencms.core.*;
import com.opencms.core.exceptions.*;
import com.opencms.dbpool.*;
import com.opencms.defaults.*;
import com.opencms.file.*;
import com.opencms.template.*;
import java.util.*;
import java.lang.*;
/**
* This class is the master of several Modules. It carries a lot of generic
* data-fileds which can be used for a special Module.
*
* The module creates a set of methods to support project-integration, history
* and import - export.
*
* @author E. Falkenhan $
* $Revision: 1.10 $
* $Date: 2002/03/25 14:39:34 $
*/
public class CmsChannelContent extends A_CmsContentDefinition
implements I_CmsContent, I_CmsLogChannels, I_CmsExtendedContentDefinition{
/**
* The name of the "tablekey" for the channel id
*/
private static final String C_TABLE_CHANNELID = I_CmsConstants.C_TABLE_CHANNELID;
// definition of the error codes used by this content defintion
private static String C_CHANNELNAME_ERRFIELD="channelname";
private static String C_OWNER_ERRFIELD="channelowner";
private static String C_GROUP_ERRFIELD="channelgroup";
private static String C_PARENT_ERRFIELD="channelparent";
//error code for empty inputs
private static String C_ERRCODE_EMPTY="empty";
//error code for no text input
private static String C_ERRCODE_NOTEXT="notext";
/** The cms-object to get access to the cms-ressources */
protected CmsObject m_cms = null;
/**
* The channel ID
*/
private String m_channelId;
/**
* The resource object that contains the information for the channel
*/
private CmsResource m_channel;
/**
* The name of the channel
*/
private String m_channelname;
/**
* The name of the parent channel
*/
private String m_parentchannel;
/**
* The properties of the channel
*/
private Hashtable m_properties;
/**
* The groupid of the channel
*/
private int m_groupid;
/**
* The userid of the channel
*/
private int m_userid;
/**
* The accessflags of the channel
*/
private int m_accessflags;
/**
* Constructor to create a new contentdefinition. You can set data with your
* set-Methods. After you have called the write-method this definition gets
* a unique id.
*/
public CmsChannelContent(CmsObject cms) {
m_cms = cms;
initValues();
}
/**
* Constructor to read a existing contentdefinition from the database. The
* data read from the database will be filled into the member-variables.
* You can read them with the get- and modify them with the set-methods.
* Changes you have made must be written back to the database by calling
* the write-method.
* @param cms the cms-object for access to cms-resources.
* @param resourceid the resource id of the channel to read.
* @throws CmsException if the data couldn't be read from the database.
*/
public CmsChannelContent(CmsObject cms, String resourceid) throws CmsException {
new CmsChannelContent(cms, new Integer(resourceid));
}
/**
* Constructor to read a existing contentdefinition from the database. The
* data read from the database will be filled into the member-variables.
* You can read them with the get- and modify them with the set-methods.
* Changes you have made must be written back to the database by calling
* the write-method.
* @param cms the cms-object for access to cms-resources.
* @param channelname the name of the channel to read.
* @throws CmsException if the data couldn't be read from the database.
*/
public CmsChannelContent(CmsObject cms, Integer resourceid) throws CmsException {
m_cms = cms;
initValues();
m_cms.setContextToCos();
try{
m_channel = (CmsResource) m_cms.readFolder(resourceid.intValue(), true);
m_channelname = m_channel.getName();
m_parentchannel = m_channel.getParent();
m_groupid = m_channel.getGroupId();
m_userid = m_channel.getOwnerId();
m_accessflags = m_channel.getAccessFlags();
m_properties = m_cms.readAllProperties(m_channel.getAbsolutePath());
m_channelId = (String)m_properties.get(I_CmsConstants.C_PROPERTY_CHANNELID);
} catch (CmsException exc){
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Could not get channel "+resourceid);
}
} finally {
m_cms.setContextToVfs();
}
}
/**
* Constructor to create a new contentdefinition. You can set data with your
* set-Methods. After you have called the write-method this definition gets
* a unique id.
*/
public CmsChannelContent(CmsObject cms, CmsResource resource) {
String channelId = C_UNKNOWN_ID+"";
String title = "";
m_cms = cms;
m_channel = resource;
m_channelname = resource.getName();
m_parentchannel = resource.getParent();
m_groupid = resource.getGroupId();
m_userid = resource.getOwnerId();
m_accessflags = resource.getAccessFlags();
try{
m_properties = cms.readAllProperties(resource.getAbsolutePath());
channelId = (String)m_properties.get(I_CmsConstants.C_PROPERTY_CHANNELID);
} catch (CmsException exc){
m_properties = new Hashtable();
m_properties.put(I_CmsConstants.C_PROPERTY_CHANNELID, C_UNKNOWN_ID+"");
} finally {
if(channelId == null || "".equals(channelId)){
channelId = C_UNKNOWN_ID+"";
}
m_channelId = channelId;
}
}
/**
* This method initialises all needed members with default-values.
*/
protected void initValues() {
m_channelId = I_CmsConstants.C_UNKNOWN_ID+"";
m_channelname = "";
m_parentchannel = "";
m_groupid = m_cms.getRequestContext().currentGroup().getId();
m_userid = m_cms.getRequestContext().currentUser().getId();
m_accessflags = I_CmsConstants.C_ACCESS_DEFAULT_FLAGS;
// create the resource object for the channel:
// int resourceId, int parentId, int fileId, String resourceName, int resourceType,
// int resourceFlags, int user, int group, int projectId, int accessFlags, int state,
// int lockedBy, int launcherType, String launcherClassname, long dateCreated,
// long dateLastModified, int resourceLastModifiedBy,int size, int lockedInProject
m_channel = new CmsResource(I_CmsConstants.C_UNKNOWN_ID, I_CmsConstants.C_UNKNOWN_ID,
I_CmsConstants.C_UNKNOWN_ID, "", I_CmsConstants.C_TYPE_FOLDER, 0,
m_cms.getRequestContext().currentUser().getId(),
m_cms.getRequestContext().currentGroup().getId(),
m_cms.getRequestContext().currentProject().getId(),
I_CmsConstants.C_ACCESS_DEFAULT_FLAGS, 1,
m_cms.getRequestContext().currentUser().getId(),
I_CmsConstants.C_UNKNOWN_ID, "",
System.currentTimeMillis(), System.currentTimeMillis(),
m_cms.getRequestContext().currentUser().getId(), 0,
m_cms.getRequestContext().currentProject().getId());
m_properties = new Hashtable();
}
/**
* delete method
* for delete instance of content definition
* @param cms the CmsObject to use.
*/
public void delete(CmsObject cms) throws Exception {
cms.setContextToCos();
try{
cms.deleteResource(m_channel.getAbsolutePath());
} catch (CmsException exc){
throw exc;
/*
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Could not delete channel "+m_channel.getAbsolutePath());
}
*/
} finally {
cms.setContextToVfs();
}
}
/**
* undelete method
* for undelete instance of content definition
* @param cms the CmsObject to use.
*/
public void undelete(CmsObject cms) throws Exception {
cms.setContextToCos();
try{
cms.undeleteResource(m_channel.getAbsolutePath());
} catch (CmsException exc){
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Could not undelete channel "+m_channel.getAbsolutePath());
}
} finally {
cms.setContextToVfs();
}
}
/**
* publish method
* for publish instance of content definition
* @param cms the CmsObject to use.
*/
public void publishResource(CmsObject cms) {
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Channels can't be published directly!");
}
}
/**
* restore method
* for restore instance of content definition from history
* @param cms the CmsObject to use.
* @param versionId The id of the version to restore
*/
public void restore(CmsObject cms, int versionId) {
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Channels can't be restored from history!");
}
}
/**
* Change owner method
* for changing permissions of content definition
* @param cms the CmsObject to use.
* @param owner the new owner of the cd.
*/
public void chown(CmsObject cms, int owner) {
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Permissions of Channels can be changed only in EditBackoffice!");
}
}
/**
* Change group method
* for changing permissions of content definition
* @param cms the CmsObject to use.
* @param group the new group of the cd.
*/
public void chgrp(CmsObject cms, int group) {
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Permissions of Channels can be changed only in EditBackoffice!");
}
}
/**
* Change access flags method
* for changing permissions of content definition
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -