📄 cmschannelcontent.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/defaults/master/CmsChannelContent.java,v $
* Date : $Date: 2005/06/27 23:22:25 $
* Version: $Revision: 1.5 $
*
* 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
*/
// TODO: remove group/user
package com.opencms.defaults.master;
import org.opencms.db.CmsDbUtil;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProperty;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.types.CmsResourceTypeFolder;
import org.opencms.lock.CmsLock;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsPermissionSet;
import org.opencms.util.CmsUUID;
import com.opencms.defaults.A_CmsContentDefinition;
import com.opencms.defaults.CmsFilterMethod;
import com.opencms.defaults.I_CmsExtendedContentDefinition;
import com.opencms.legacy.CmsLegacyException;
import com.opencms.legacy.CmsXmlTemplateLoader;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;
/**
* 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.5 $
* $Date: 2005/06/27 23:22:25 $
*
* @deprecated Will not be supported past the OpenCms 6 release.
*/
public class CmsChannelContent extends A_CmsContentDefinition implements I_CmsExtendedContentDefinition{
// definition of the error codes used by this content defintion
private static String C_CHANNELNAME_ERRFIELD="channelname";
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
/** 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 Map m_properties;
/**
* The groupid of the channel
*/
// private CmsUUID m_GroupId;
/**
* The userid of the channel
*/
// private CmsUUID 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 channelId) throws CmsException {
new CmsChannelContent(cms, new CmsUUID(channelId));
}
/**
* 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, CmsUUID channelId) throws CmsException {
throw new RuntimeException("Method CmsChannelContent(CmsObject cms, CmsUUID channelId) not longer supported");
}
/**
* 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 = CmsDbUtil.UNKNOWN_ID+"";
String fullName = cms.getSitePath(resource);
m_cms = cms;
m_channel = resource;
m_channelname = resource.getName();
m_parentchannel = CmsResource.getParentFolder(cms.getSitePath(resource));
// m_GroupId = resource.getGroupId();
// m_UserId = resource.getOwnerId();
// m_accessflags = resource.getAccessFlags();
try{
m_properties = cms.readProperties(fullName);
channelId = (String)m_properties.get(CmsPropertyDefinition.PROPERTY_CHANNELID);
} catch (CmsException exc){
m_properties = new Hashtable();
m_properties.put(CmsPropertyDefinition.PROPERTY_CHANNELID, CmsDbUtil.UNKNOWN_ID+"");
} finally {
if(channelId == null || "".equals(channelId)){
channelId = CmsDbUtil.UNKNOWN_ID+"";
}
m_channelId = channelId;
}
}
/**
* This method initialises all needed members with default-values.
*/
protected void initValues() {
m_channelId = CmsDbUtil.UNKNOWN_ID+"";
m_channelname = "";
m_parentchannel = "";
m_accessflags = com.opencms.core.I_CmsConstants.C_ACCESS_DEFAULT_FLAGS;
// create the resource object for the channel:
m_channel = new CmsResource(CmsUUID.getNullUUID(), CmsUUID.getNullUUID(),
"", CmsResourceTypeFolder.RESOURCE_TYPE_ID, true, 0,
m_cms.getRequestContext().currentProject().getId(),
1, System.currentTimeMillis(),
m_cms.getRequestContext().currentUser().getId(), System.currentTimeMillis(),
m_cms.getRequestContext().currentUser().getId(), CmsResource.DATE_RELEASED_DEFAULT,
CmsResource.DATE_EXPIRED_DEFAULT, 1, 0);
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.getRequestContext().saveSiteRoot();
cms.getRequestContext().setSiteRoot(CmsResource.VFS_FOLDER_CHANNELS);
try{
cms.deleteResource(cms.getSitePath(m_channel), CmsResource.DELETE_PRESERVE_SIBLINGS);
} 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 "+cms.readPath(m_channel));
}
*/
} finally {
cms.getRequestContext().restoreSiteRoot();
}
}
/**
* undelete method
* for undelete instance of content definition
* @param cms the CmsObject to use.
*/
public void undelete(CmsObject cms) throws Exception {
cms.getRequestContext().saveSiteRoot();
cms.getRequestContext().setSiteRoot(CmsResource.VFS_FOLDER_CHANNELS);
try{
cms.undeleteResource(cms.getSitePath(m_channel));
} catch (CmsException exc){
if (CmsLog.getLog(this).isErrorEnabled() ) {
CmsLog.getLog(this).error("Could not undelete channel " + cms.getSitePath(m_channel), exc);
}
} finally {
cms.getRequestContext().restoreSiteRoot();
}
}
/**
* publish method
* for publish instance of content definition
* @param cms the CmsObject to use.
*/
public void publishResource(CmsObject cms) {
if (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("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 (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("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, CmsUUID owner) {
if (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("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, CmsUUID group) {
if (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("Permissions of Channels can be changed only in EditBackoffice");
}
}
/**
* Change access flags method
* for changing permissions of content definition
* @param cms the CmsObject to use.
* @param accessflags the new access flags of the cd.
*/
public void chmod(CmsObject cms, int accessflags) {
if (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("Permissions of Channels can be changed only in EditBackoffice");
}
}
/**
* Copy method
* for copying content definition
* @param cms the CmsObject to use.
* @return int The id of the new content definition
*/
public CmsUUID copy(CmsObject cms) {
if (CmsLog.getLog(this).isWarnEnabled() ) {
CmsLog.getLog(this).warn("Channels can't be copied!");
}
return CmsUUID.getNullUUID();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -