📄 a_cmsresourcetype.java
字号:
newProperties);
// process the (optional) copy resources from the configuration
processCopyResources(cms, resourcename, resolver);
// return the created resource
return result;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#createSibling(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, CmsResource, java.lang.String, java.util.List)
*/
public void createSibling(
CmsObject cms,
CmsSecurityManager securityManager,
CmsResource source,
String destination,
List properties) throws CmsException {
securityManager.createSibling(
cms.getRequestContext(),
source,
cms.getRequestContext().addSiteRoot(destination),
properties);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#deleteResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)
*/
public void deleteResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int siblingMode)
throws CmsException {
securityManager.deleteResource(cms.getRequestContext(), resource, siblingMode);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#getCachePropertyDefault()
*/
public String getCachePropertyDefault() {
return null;
}
/**
* Returns the configured class name of this resource type.<p>
*
* @see org.opencms.file.types.I_CmsResourceType#getClassName()
*/
public String getClassName() {
return m_className;
}
/**
* @see org.opencms.configuration.I_CmsConfigurationParameterHandler#getConfiguration()
*/
public Map getConfiguration() {
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_GET_CONFIGURATION_1, this));
}
return null;
}
/**
* Returns the (unmodifiable) list of copy resources.<p>
*
* @return the (unmodifiable) list of copy resources
*/
public List getConfiguredCopyResources() {
return m_copyResources;
}
/**
* Returns the default properties for this resource type in an unmodifiable List.<p>
*
* @return the default properties for this resource type in an unmodifiable List
*/
public List getConfiguredDefaultProperties() {
return m_defaultProperties;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#getConfiguredMappings()
*/
public List getConfiguredMappings() {
return m_mappings;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#getLoaderId()
*/
public abstract int getLoaderId();
/**
* @see org.opencms.file.types.I_CmsResourceType#getTypeId()
*/
public int getTypeId() {
return m_typeId;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#getTypeName()
*/
public String getTypeName() {
return m_typeName;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#importResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, org.opencms.file.CmsResource, byte[], List)
*/
public CmsResource importResource(
CmsObject cms,
CmsSecurityManager securityManager,
String resourcename,
CmsResource resource,
byte[] content,
List properties) throws CmsException {
// this triggers the interal "is touched" state
// and prevents the security manager from inserting the current time
resource.setDateLastModified(resource.getDateLastModified());
// ensure resource record is updated
resource.setState(CmsResource.STATE_NEW);
return securityManager.importResource(
cms.getRequestContext(),
cms.getRequestContext().addSiteRoot(resourcename),
resource,
content,
properties,
true);
}
/**
* @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration()
*/
public final void initConfiguration() {
// final since subclassed should NOT implement this, but rather the version with 3 String parameters (see below)
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_INIT_CONFIGURATION_1, this));
}
}
/**
* Special version of the configuration initialization used with resource types
* to set resource type and id, unsing the name of this class instance.<p>
*
* @param name the resource type name
* @param id the resource type id
*
* @throws CmsConfigurationException if the configuration is invalid
*
* @deprecated use <code>{@link #initConfiguration(String, String, String)}</code> instead
*
* @see I_CmsResourceType#initConfiguration(String, String, String)
*/
public void initConfiguration(String name, String id) throws CmsConfigurationException {
// use this class instance name for the class name
initConfiguration(name, id, this.getClass().getName());
}
/**
* @see org.opencms.file.types.I_CmsResourceType#initConfiguration(java.lang.String, java.lang.String, java.lang.String)
*/
public void initConfiguration(String name, String id, String className) throws CmsConfigurationException {
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_INIT_CONFIGURATION_3, this, name, id));
}
if (m_frozen) {
// configuration already frozen
throw new CmsConfigurationException(org.opencms.configuration.Messages.get().container(
org.opencms.file.types.Messages.ERR_CONFIG_FROZEN_3,
className,
getTypeName(),
new Integer(getTypeId())));
}
// freeze the configuration
m_frozen = true;
// set type name and id (please note that some resource types have a fixed type / id)
if (name != null) {
m_typeName = name;
}
if (id != null) {
m_typeId = Integer.valueOf(id).intValue();
}
if (className != null) {
m_className = className;
}
// check type id, type name and classs name
if ((getTypeId() < 0) || (getTypeName() == null) || (getClassName() == null)) {
throw new CmsConfigurationException(Messages.get().container(
Messages.ERR_INVALID_RESTYPE_CONFIG_3,
className,
m_typeName,
new Integer(m_typeId)));
}
m_defaultProperties = Collections.unmodifiableList(m_defaultProperties);
m_copyResources = Collections.unmodifiableList(m_copyResources);
m_mappings = Collections.unmodifiableList(m_mappings);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#initialize(org.opencms.file.CmsObject)
*/
public void initialize(CmsObject cms) {
// most resource type do not require any runtime information
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_INITIALIZE_1, this));
}
}
/**
* @see org.opencms.file.types.I_CmsResourceType#isAdditionalModuleResourceType()
*/
public boolean isAdditionalModuleResourceType() {
return m_addititionalModuleResourceType;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#isDirectEditable()
*/
public boolean isDirectEditable() {
return false;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#isFolder()
*/
public boolean isFolder() {
return false;
}
/**
* @see org.opencms.file.types.I_CmsResourceType#lockResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)
*/
public void lockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int mode)
throws CmsException {
securityManager.lockResource(cms.getRequestContext(), resource, mode);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#moveResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, java.lang.String)
*/
public void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination)
throws CmsException {
String dest = cms.getRequestContext().addSiteRoot(destination);
if (resource.getRootPath().equals(dest)) {
// move to target with same name is not allowed
throw new CmsVfsException(org.opencms.file.Messages.get().container(
org.opencms.file.Messages.ERR_MOVE_SAME_NAME_1,
destination));
}
// check if the user has write access and if resource is locked
// done here since copy is ok without lock, but delete is not
securityManager.checkPermissions(
cms.getRequestContext(),
resource,
CmsPermissionSet.ACCESS_WRITE,
true,
CmsResourceFilter.IGNORE_EXPIRATION);
// check if the resource to move is new or existing
boolean isNew = resource.getState() == CmsResource.STATE_NEW;
copyResource(cms, securityManager, resource, destination, CmsResource.COPY_AS_SIBLING);
deleteResource(cms, securityManager, resource, CmsResource.DELETE_PRESERVE_SIBLINGS);
// make sure lock is switched
CmsResource destinationResource = securityManager.readResource(
cms.getRequestContext(),
dest,
CmsResourceFilter.ALL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -