📄 cmschannelcontent.java
字号:
* @param cms the CmsObject to use.
* @param accessflags the new access flags of the cd.
*/
public void chmod(CmsObject cms, int accessflags) {
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!");
}
}
/**
* Copy method
* for copying content definition
* @param cms the CmsObject to use.
* @return int The id of the new content definition
*/
public int copy(CmsObject cms) {
if (I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() ) {
A_OpenCms.log(C_OPENCMS_INFO, "[CmsChannelContent] Channels can be copied!");
}
return -1;
}
/**
* write method
* to write the current content of the content definition to the database.
* @param cms the CmsObject to use.
*/
public void write(CmsObject cms) throws Exception {
CmsResource newChannel = null;
// is this a new row or an existing row?
cms.setContextToCos();
try{
if((I_CmsConstants.C_UNKNOWN_ID+"").equals(m_channelId)) {
// this is a new row - call the create statement
// first set the new channelId
setNewChannelId();
newChannel = cms.createResource(m_parentchannel, m_channelname, I_CmsConstants.C_TYPE_FOLDER_NAME, m_properties);
cms.lockResource(newChannel.getAbsolutePath(), true);
} else {
newChannel = cms.readFolder(m_channel.getAbsolutePath());
if (!newChannel.getAbsolutePath().equals(m_parentchannel+m_channelname+"/")){
// the parent and/or the channelname has changed,
// so move or rename the channel
if(!newChannel.getParent().equals(m_parentchannel)){
// move the channel to the new parent channel
cms.moveResource(newChannel.getAbsolutePath(), m_parentchannel+m_channelname);
} else if (!newChannel.getName().equals(m_channelname)){
// only rename the channel, the parent has not changed
cms.renameResource(newChannel.getAbsolutePath(), m_channelname);
}
}
// read the changed channel
newChannel = cms.readFolder(m_parentchannel+m_channelname+"/");
// update the title of the channel
String propTitle = cms.readProperty(newChannel.getAbsolutePath(), I_CmsConstants.C_PROPERTY_TITLE);
if (propTitle == null){
propTitle = "";
}
if (!propTitle.equals(this.getTitle())){
cms.writeProperty(newChannel.getAbsolutePath(), I_CmsConstants.C_PROPERTY_TITLE, this.getTitle());
}
// check if the lockstate has changed
if(newChannel.isLockedBy() != this.getLockstate() ||
newChannel.getLockedInProject() != cms.getRequestContext().currentProject().getId()){
if(this.getLockstate() == I_CmsConstants.C_UNKNOWN_ID){
// unlock the channel
cms.unlockResource(newChannel.getAbsolutePath());
} else {
// lock the channel
cms.lockResource(newChannel.getAbsolutePath(), true);
}
};
}
// check if the owner has changed
if(newChannel.getOwnerId() != this.getOwner()){
cms.chown(newChannel.getAbsolutePath(), this.getOwnerName());
};
// check if the group has changed
if(newChannel.getGroupId() != this.getGroupId()){
cms.chgrp(newChannel.getAbsolutePath(), this.getGroup());
};
// check if the accessflags has changed
if(newChannel.getAccessFlags() != this.getAccessFlags()){
cms.chmod(newChannel.getAbsolutePath(), this.getAccessFlags());
};
m_channel = cms.readFolder(newChannel.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 write channel "+m_channel.getAbsolutePath());
}
*/
} finally {
cms.setContextToVfs();
}
}
/**
* gets the unique Id of a content definition instance
* @param cms the CmsObject to use.
* @returns a string with the Id
*/
public String getUniqueId(CmsObject cms) {
return m_channel.getResourceId() + "";
}
/**
* gets the unique Id of a content definition instance
*
* @returns int The unique id
*/
public int getId() {
return m_channel.getResourceId();
}
/**
* Gets the projectId where the CD belongs to.
* This method is required for the use of the abstract backoffice.
* @returns int with the projectId.
*/
public int getLockedInProject() {
return m_channel.getLockedInProject();
}
/**
* Gets the state of a CD.
* This method is required for the use of the abstract backoffice.
* @returns int with the state.
*/
public int getState() {
return m_channel.getState();
}
/**
* Gets the projectId of a CD.
* This method is required for the use of the abstract backoffice.
* @returns int with the projectId.
*/
public int getProjectId() {
return m_channel.getProjectId();
}
/**
* gets the unique channel Id of a content definition instance
* @returns a string with the Id
*/
public String getChannelId() {
return m_channelId;
}
/**
* sets the unique channel Id of a content definition instance
*/
public void setChannelId(String id) {
m_properties.put(I_CmsConstants.C_PROPERTY_CHANNELID, id);
}
/**
* Gets the title of the channel
*/
public String getTitle(){
String title = (String)m_properties.get(I_CmsConstants.C_PROPERTY_TITLE);
if (title == null){
title = "";
}
return title;
}
/**
* sets the title of a content definition instance
*/
public void setTitle(String title) {
m_properties.put(I_CmsConstants.C_PROPERTY_TITLE, title);
}
/**
* Gets the lockstate.
* @returns a int with the user who has locked the ressource.
*/
public int getLockstate() {
return m_channel.isLockedBy();
}
/**
* Sets the lockstates
* @param the lockstate for the actual entry.
*/
public void setLockstate(int lockstate) {
m_channel.setLocked(lockstate);
}
/**
* Gets the ownername of this contentdefinition.
*/
public String getOwnerName() {
String ownername = "";
try{
ownername = m_cms.readUser(getOwner()).getName();
} catch (CmsException exc){
//nothing to do, return empty string
}
return ownername;
}
/**
* Gets the owner of this contentdefinition.
*/
public int getOwner() {
return m_userid;
}
/**
* Sets the owner of this contentdefinition.
*/
public void setOwner(int id) {
m_userid = id;
}
/**
* Gets the groupname
*/
public String getGroup() {
String groupname = "";
try{
groupname = m_cms.readGroup(this.getGroupId()).getName();
} catch (CmsException exc){
// nothing to do, return empty string
}
return groupname;
}
/**
* Gets the groupid
*/
public int getGroupId() {
return m_groupid;
}
/**
* Sets the group.
*/
public void setGroup(int id) {
m_groupid = id;
}
/**
* Gets the channelname
*/
public String getChannelPath() {
return m_channel.getParent()+m_channel.getName();
}
/**
* Gets the channelname
*/
public String getChannelName() {
return m_channelname;
}
/**
* Sets the channelname.
*/
public void setChannelName(String name) {
m_channelname = name;
}
/**
* Sets the parentname of the channel.
*/
public void setParentName(String name) {
m_parentchannel = name;
}
/**
* Gets the name of the parent channel
*/
public String getParentName() {
return m_parentchannel;
}
/**
* Sets the accessflags of the channel.
*/
public void setAccessFlags(int flags) {
m_accessflags = flags;
}
/**
* Gets the accessflags of the channel
*/
public int getAccessFlags() {
return m_accessflags;
}
/**
* Gets the date of the last modification of the channel
*/
public long getDateLastModified(){
return m_channel.getDateLastModified();
}
/**
* Gets the date of the creation of the channel
*/
public long getDateCreated(){
return m_channel.getDateCreated();
}
/**
* Gets the id of the user who has modified the channel
*/
public int getLastModifiedBy(){
return m_channel.getResourceLastModifiedBy();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -