a_cmsresourcetype.java
来自「找了很久才找到到源代码」· Java 代码 · 共 1,047 行 · 第 1/3 页
JAVA
1,047 行
* @see #isIdentical(I_CmsResourceType)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof I_CmsResourceType) {
I_CmsResourceType other = (I_CmsResourceType)obj;
if (getTypeId() == other.getTypeId()) {
return true;
}
if ((getTypeName() != null) && (getTypeName().equals(other.getTypeName()))) {
return true;
}
}
return false;
}
/**
* @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;
}
/**
* The hash code implementation simply returns the unique type id of this resource type.
*
* @see #getTypeId()
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return getTypeId();
}
/**
* @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 internal "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 ((getTypeName() == null)
|| (getClassName() == null)
|| ((getTypeId() < 0) && (!m_typeName.equals(CmsResourceTypeUnknownFile.getStaticTypeName())) && (!m_typeName.equals(CmsResourceTypeUnknownFolder.getStaticTypeName())))) {
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#isIdentical(org.opencms.file.types.I_CmsResourceType)
*/
public boolean isIdentical(I_CmsResourceType type) {
if (type == null) {
return false;
}
return (getTypeId() == type.getTypeId()) && (getTypeName().equals(type.getTypeName()));
}
/**
* @see org.opencms.file.types.I_CmsResourceType#lockResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, org.opencms.lock.CmsLockType)
*/
public void lockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsLockType type)
throws CmsException {
securityManager.lockResource(cms.getRequestContext(), resource, type);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#moveResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, java.lang.String)
*/
public void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination)
throws CmsException, CmsIllegalArgumentException {
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 the destination
try {
securityManager.readResource(cms.getRequestContext(), dest, CmsResourceFilter.ALL);
throw new CmsVfsException(org.opencms.file.Messages.get().container(
org.opencms.file.Messages.ERR_OVERWRITE_RESOURCE_2,
cms.getRequestContext().removeSiteRoot(resource.getRootPath()),
destination));
} catch (CmsVfsResourceNotFoundException e) {
// ok
}
// move
securityManager.moveResource(cms.getRequestContext(), resource, dest);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#removeResourceFromProject(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource)
*/
public void removeResourceFromProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
throws CmsException {
securityManager.removeResourceFromProject(cms.getRequestContext(), resource);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#replaceResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int, byte[], List)
*/
public void replaceResource(
CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int type,
byte[] content,
List properties) throws CmsException {
securityManager.replaceResource(cms.getRequestContext(), resource, type, content, properties);
// type may have changed from non link parseable to link parseable
createRelations(cms, securityManager, resource.getRootPath());
}
/**
* @see org.opencms.file.types.I_CmsResourceType#restoreResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)
*/
public void restoreResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version)
throws CmsException {
securityManager.restoreResource(cms.getRequestContext(), resource, version);
// type may have changed from non link parseable to link parseable
createRelations(cms, securityManager, resource.getRootPath());
}
/**
* @see org.opencms.file.types.I_CmsResourceType#restoreResourceBackup(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)
*
* @deprecated Use {@link #restoreResource(CmsObject,CmsSecurityManager,CmsResource,int)} instead
*/
public void restoreResourceBackup(
CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int version) throws CmsException {
restoreResource(cms, securityManager, resource, version);
}
/**
* @see org.opencms.file.types.I_CmsResourceType#setAdditionalModuleResourceType(boolean)
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?