📄 cmsobject.java
字号:
* Copies a file.
*
* @param source the complete path of the sourcefile.
* @param destination the complete path of the destinationfolder.
*
* @exception CmsException if the file couldn't be copied, or the user
* has not the appropriate rights to copy the file.
*/
protected void doCopyFile(String source, String destination) throws CmsException {
m_rb.copyFile(m_context.currentUser(), m_context.currentProject(), getSiteRoot(source), getSiteRoot(destination));
}
/**
* Copies a folder.
*
* @param source the complete path of the sourcefolder.
* @param destination the complete path of the destinationfolder.
*
* @exception CmsException if the folder couldn't be copied, or if the
* user has not the appropriate rights to copy the folder.
*/
protected void doCopyFolder(String source, String destination) throws CmsException {
m_rb.copyFolder(m_context.currentUser(), m_context.currentProject(), getSiteRoot(source), getSiteRoot(destination));
}
/**
* Copies a file.
*
* @param source the complete path of the sourcefile.
* @param destination the complete path of the destinationfolder.
*
* @exception CmsException if the file couldn't be copied, or the user
* has not the appropriate rights to copy the file.
*
* @deprecated Use copyResource instead.
*/
public void copyFile(String source, String destination) throws CmsException {
copyResource(source, destination);
}
/**
* Copies a folder.
*
* @param source the complete path of the sourcefolder.
* @param destination the complete path of the destinationfolder.
*
* @exception CmsException if the folder couldn't be copied, or if the
* user has not the appropriate rights to copy the folder.
*
* @deprecated Use copyResource instead.
*/
public void copyFolder(String source, String destination) throws CmsException {
copyResource(source, destination);
}
/**
* Copies a resource from the online project to a new, specified project.
* <br>
* Copying a resource will copy the file header or folder into the specified
* offline project and set its state to UNCHANGED.
*
* @param resource the name of the resource.
* @exception CmsException if operation was not successful.
*/
public void copyResourceToProject(String resource) throws CmsException {
CmsResource res = readFileHeader(resource);
I_CmsResourceType rt = getResourceType(res.getType());
rt.copyResourceToProject(this, resource);
}
/**
* Copies a resource from the online project to a new, specified project.
* <br>
* Copying a resource will copy the file header or folder into the specified
* offline project and set its state to UNCHANGED.
*
* @param resource the name of the resource.
* @exception CmsException if operation was not successful.
*/
protected void doCopyResourceToProject(String resource) throws CmsException {
m_rb.copyResourceToProject(m_context.currentUser(), m_context.currentProject(), getSiteRoot(resource));
}
/**
* Returns the copyright information for this OpenCms.
*
* @return copyright a String arry containing copyright information.
*/
public String[] copyright() {
return C_COPYRIGHT;
}
/**
* Counts the locked resources in a project.
*
* @param id the id of the project
* @return the number of locked resources in this project.
*
* @exception CmsException if operation was not successful.
*/
public int countLockedResources(int id) throws CmsException {
return m_rb.countLockedResources(m_context.currentUser(), m_context.currentProject(), id);
}
/**
* Creates a new file with the given content and resourcetype.<br>
*
* @param folder the complete path to the folder in which the file will be created.
* @param filename the name of the new file.
* @param contents the contents of the new file.
* @param type the resourcetype of the new file.
*
* @return file a <code>CmsFile</code> object representing the newly created file.
*
* @exception if the resourcetype is set to folder. The CmsException is also thrown, if the
* filename is not valid or if the user has not the appropriate rights to create a new file.
*
* @deprecated Use createResource instead.
*/
public CmsFile createFile(String folder, String filename, byte[] contents, String type) throws CmsException {
return (CmsFile)createResource(folder, filename, type, null, contents);
}
/**
* Creates a new file with the given content and resourcetype.
*
* @param folder the complete path to the folder in which the file will be created.
* @param filename the name of the new file.
* @param contents the contents of the new file.
* @param type the resourcetype of the new file.
* @param properties A Hashtable of properties, that should be set for this file.
* The keys for this Hashtable are the names for properties, the values are
* the values for the properties.
*
* @return file a <code>CmsFile</code> object representing the newly created file.
*
* @exception CmsException or if the resourcetype is set to folder.
* The CmsException is also thrown, if the filename is not valid or if the user
* has not the appropriate rights to create a new file.
*
* @deprecated Use createResource instead.
*/
public CmsFile createFile(String folder, String filename, byte[] contents, String type, Hashtable properties) throws CmsException {
return (CmsFile)createResource(folder, filename, type, properties, contents);
}
/**
* Creates a new folder.
*
* @param folder the complete path to the folder in which the new folder
* will be created.
* @param newFolderName the name of the new folder.
*
* @return folder a <code>CmsFolder</code> object representing the newly created folder.
*
* @exception CmsException if the foldername is not valid, or if the user has not the appropriate rights to create
* a new folder.
*
* @deprecated Use createResource instead.
*/
public CmsFolder createFolder(String folder, String newFolderName) throws CmsException {
return (CmsFolder)createResource(folder, newFolderName, C_TYPE_FOLDER_NAME);
}
/**
* Creates a new channel.
*
* @param parentChannel the complete path to the channel in which the new channel
* will be created.
* @param newChannelName the name of the new channel.
*
* @return folder a <code>CmsFolder</code> object representing the newly created channel.
*
* @exception CmsException if the channelname is not valid, or if the user has not the appropriate rights to create
* a new channel.
*
*/
public CmsFolder createChannel(String parentChannel, String newChannelName) throws CmsException {
try {
setContextToCos();
Hashtable properties = new Hashtable();
int newChannelId = com.opencms.dbpool.CmsIdGenerator.nextId(com.opencms.defaults.master.CmsChannelBackoffice.C_TABLE_CHANNELID);
properties.put(I_CmsConstants.C_PROPERTY_CHANNELID, newChannelId+"");
return (CmsFolder)createResource(parentChannel, newChannelName, C_TYPE_FOLDER_NAME, properties);
} finally {
setContextToVfs();
}
}
/**
* Creates a new folder.
*
* @param folder the complete path to the folder in which the new folder will
* be created.
* @param newFolderName the name of the new folder.
* @param properties A Hashtable of properties, that should be set for this folder.
* The keys for this Hashtable are the names for property-definitions, the values are
* the values for the properties.
*
* @return a <code>CmsFolder</code> object representing the newly created folder.
* @exception CmsException if the foldername is not valid, or if the user has not the appropriate rights to create
* a new folder.
*
* @deprecated Use createResource instead.
*/
public CmsFolder createFolder(String folder, String newFolderName, Hashtable properties) throws CmsException {
return (CmsFolder)createResource(folder, newFolderName, C_TYPE_FOLDER_NAME, properties);
}
public CmsResource createResource(String folder, String name, String type) throws CmsException {
return createResource(folder, name, type, new Hashtable());
}
public CmsResource createResource(String folder, String name, String type, Hashtable properties) throws CmsException {
return createResource(folder, name, type, properties, new byte[0]);
}
public CmsResource createResource(String folder, String name, String type, Hashtable properties, byte[] contents) throws CmsException {
I_CmsResourceType rt = getResourceType(type);
return rt.createResource(this, folder, name, properties, contents);
}
/**
* Creates a new file with the given content and resourcetype.<br>
*
* @param folder the complete path to the folder in which the file will be created.
* @param filename the name of the new file.
* @param contents the contents of the new file.
* @param type the resourcetype of the new file.
*
* @return file a <code>CmsFile</code> object representing the newly created file.
*
* @exception CmsException if the resourcetype is set to folder. The CmsException is also thrown, if the
* filename is not valid or if the user has not the appropriate rights to create a new file.
*/
protected CmsFile doCreateFile(String folder, String filename, byte[] contents, String type) throws CmsException {
CmsFile file = m_rb.createFile(m_context.currentUser(), m_context.currentGroup(),
m_context.currentProject(), getSiteRoot(folder), filename, contents,
type, new Hashtable());
return file;
}
/**
* Creates a new file with the given content and resourcetype.
*
* @param folder the complete path to the folder in which the file will be created.
* @param filename the name of the new file.
* @param contents the contents of the new file.
* @param type the resourcetype of the new file.
* @param properties A Hashtable of properties, that should be set for this file.
* The keys for this Hashtable are the names for properties, the values are
* the values for the properties.
*
* @return file a <code>CmsFile</code> object representing the newly created file.
*
* @exception CmsException if the wrong properties are given, or if the resourcetype is set to folder.
* The CmsException is also thrown, if the filename is not valid or if the user
* has not the appropriate rights to create a new file.
*/
protected CmsFile doCreateFile(String folder, String filename, byte[] contents, String type, Hashtable properties) throws CmsException {
// avoid null-pointer exceptions
if(properties == null) {
properties = new Hashtable();
}
CmsFile file = m_rb.createFile(m_context.currentUser(), m_context.currentGroup(),
m_context.currentProject(), getSiteRoot(folder), filename, contents,
type, properties);
return file;
}
/**
* Creates a new folder.
*
* @param folder the complete path to the folder in which the new folder
* will be created.
* @param newFolderName the name of the new folder.
*
* @return folder a <code>CmsFolder</code> object representing the newly created folder.
*
* @exception CmsException if the foldername is not valid, or if the user has not the appropriate rights to create
* a new folder.
*/
protected CmsFolder doCreateFolder(String folder, String newFolderName) throws CmsException {
CmsFolder cmsFolder = m_rb.createFolder(m_context.currentUser(), m_context.currentGroup(), m_context.currentProject(),
getSiteRoot(folder), newFolderName, new Hashtable());
return cmsFolder;
}
/**
* Creates a new folder.
*
* @param folder the complete path to the folder in which the new folder will
* be created.
* @param newFolderName the name of the new folder.
* @param properties A Hashtable of properties, that should be set for this folder.
* The keys for this Hashtable are the names for property-definitions, the values are
* the values for the properties.
*
* @return a <code>CmsFolder</code> object representing the newly created folder.
* @exception CmsException if the foldername is not valid, or if the user has not the appropriate rights to create
* a new folder.
*
*/
protected CmsFolder doCreateFolder(String folder, String newFolderName, Hashtable properties) throws CmsException {
CmsFolder cmsFolder = m_rb.createFolder(m_context.currentUser(), m_context.currentGroup(), m_context.currentProject(),
getSiteRoot(folder), newFolderName, properties);
return cmsFolder;
}
/**
* Creates a new project for task handling.
*
* @param projectname the name of the project
* @param projectType the type of the Project
* @param role a Usergroup for the project
* @param timeout the time when the Project must finished
* @param priority a Priority for the Project
*
* @return a <code>CmsTask</code> object representing the newly created task.
*
* @exception CmsException if operation was not successful.
*/
public CmsTask createProject(String projectname, int projectType, String roleName, long timeout, int priority) throws CmsException {
return m_rb.createProject(m_context.currentUser(), projectname, projectType, roleName, timeout, priority);
}
/**
* Creates a new project.
*
* @param name the name of the project to read.
* @param description the description for the new project.
* @param groupname the name of the group to be set.
* @param managergroupname the name of the managergroup to be set.
*
* @exception CmsException if operation was not successful.
*/
public CmsProject createProject(String name, String description, String groupname, String managergroupname) throws CmsException
{
CmsProject newProject = m_rb.createProject(m_context.currentUser(), m_context.currentProject(), name, description, groupname, managergroupname);
return (newProject);
}
/**
* Creates a new project.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -