/** * Convenience method to get the initialized resource type instance for the given resource, * with a fall back to special "unknown" resource types in case the resource type is not configured.<p> * * @param resource the resource to get the type for * * @return the initialized resource type instance for the given resource */ public I_CmsResourceType getResourceType(CmsResource resource) { I_CmsResourceType result = m_configuration.getResourceTypeById(resource.getTypeId()); if (result == null) { // this resource type is unknown, return the default files instead if (resource.isFolder()) { // resource is a folder if (m_restypeUnknownFolder != null) { result = m_restypeUnknownFolder; } else { result = m_configuration.getResourceTypeByName(CmsResourceTypeFolder.getStaticTypeName()); } } else { // resource is a file if (m_restypeUnknownFile != null) { result = m_restypeUnknownFile; } else { result = m_configuration.getResourceTypeByName(CmsResourceTypeBinary.getStaticTypeName()); } } } return result; }
/** * Returns the initialized resource type instance for the given resource type name.<p> * * @param typeName the name of the resource type to get * * @return the initialized resource type instance for the given name * * @throws CmsLoaderException if no resource type is available for the given name */ public I_CmsResourceType getResourceType(String typeName) throws CmsLoaderException { I_CmsResourceType result = m_configuration.getResourceTypeByName(typeName); if (result != null) { return result; } throw new CmsLoaderException(Messages.get().container(Messages.ERR_UNKNOWN_RESTYPE_NAME_REQ_1, typeName)); }
/** * Returns the initialized resource type instance for the given resource type name.<p> * * @param typeName the name of the resource type to get * * @return the initialized resource type instance for the given name * * @throws CmsLoaderException if no resource type is available for the given name */ public I_CmsResourceType getResourceType(String typeName) throws CmsLoaderException { I_CmsResourceType result = m_configuration.getResourceTypeByName(typeName); if (result != null) { return result; } throw new CmsLoaderException(Messages.get().container(Messages.ERR_UNKNOWN_RESTYPE_NAME_REQ_1, typeName)); }
/** * Checks if an initialized resource type instance for the given resource type name is available.<p> * * @param typeName the name of the resource type to check * @return <code>true</code> if such a resource type has been configured, <code>false</code> otherwise * * @see #getResourceType(String) */ public boolean hasResourceType(String typeName) { return m_configuration.getResourceTypeByName(typeName) != null; }
/** * Checks if an initialized resource type instance for the given resource type name is available.<p> * * @param typeName the name of the resource type to check * @return <code>true</code> if such a resource type has been configured, <code>false</code> otherwise * * @see #getResourceType(String) */ public boolean hasResourceType(String typeName) { return m_configuration.getResourceTypeByName(typeName) != null; }