Package org.ametys.cms.contenttype
Class EditContentTypeHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.contenttype.EditContentTypeHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class EditContentTypeHelper extends AbstractLogEnabled implements Component, Serviceable
Helper for create, edit and remove a content type
-
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver
_ametysObjectResolver
The ametys object resolver instanceprotected ContentDAO
_contentDAO
DAO for contentsprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content type extension point instanceprotected SourceResolver
_sourceResolver
The source resolverstatic String
ROLE
The Avalon role name
-
Constructor Summary
Constructors Constructor Description EditContentTypeHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRemoveContentType(String contentTypeId)
Determines if the content type can be removedvoid
createContentType(ContentTypeDefinition contentTypeDef)
Create a new content type.void
editContentType(ContentTypeDefinition contentTypeDef)
Modify a existing content type.File
getArchiveRootDirectory()
Get the root directory for all archived content types.File
getArchiveRootDirectory(ContentType contentType)
Get the root archive directory for a given content type.File
getContentTypeDirectory(ContentType contentType)
Get the root directory for a given content type.File
getContentTypeDirectory(ContentTypeDefinition contentType, boolean override)
Get the root directory for a given content type.File
getContentTypeFile(ContentType contentType)
Get the XML definition file for a given content type.File
getContentTypeFile(ContentTypeDefinition contentType, boolean override)
Get the XML definition file for a given content type.File
getContentTypeRootDirectory()
Get the root directory for all custom content types.void
removeContentType(String contentTypeId)
Remove a existing content type defined in WEB-INF/param/content-types directory.
This method archived the content type into the WEB-INF/param/content-types/_archives/pluginName folder.void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_sourceResolver
protected SourceResolver _sourceResolver
The source resolver
-
_ametysObjectResolver
protected AmetysObjectResolver _ametysObjectResolver
The ametys object resolver instance
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content type extension point instance
-
_contentDAO
protected ContentDAO _contentDAO
DAO for contents
-
-
Constructor Detail
-
EditContentTypeHelper
public EditContentTypeHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getContentTypeRootDirectory
public File getContentTypeRootDirectory() throws MalformedURLException, IOException
Get the root directory for all custom content types. The directory is created if does not exist.- Returns:
- the root directory for all custom content types.
- Throws:
MalformedURLException
- if failed to get the root directoryIOException
- if failed to get the root directory
-
getArchiveRootDirectory
public File getArchiveRootDirectory() throws MalformedURLException, IOException
Get the root directory for all archived content types. The directory is created if does not exist.- Returns:
- the root directory for archived content types.
- Throws:
MalformedURLException
- if failed to get the root directoryIOException
- if failed to get the root directory
-
getArchiveRootDirectory
public File getArchiveRootDirectory(ContentType contentType) throws MalformedURLException, IOException
Get the root archive directory for a given content type. The directory is created if does not exist.- Parameters:
contentType
- The content type- Returns:
- the root archive directory for this content type.
- Throws:
MalformedURLException
- if failed to get the archive directoryIOException
- if failed to get the archive directory
-
getContentTypeDirectory
public File getContentTypeDirectory(ContentTypeDefinition contentType, boolean override) throws MalformedURLException, IOException
Get the root directory for a given content type. The directory is created if does not exist.- Parameters:
contentType
- The content type definitionoverride
- true if this is a overriden content type.- Returns:
- the root directory for this content type.
- Throws:
MalformedURLException
- if failed to get the archive directoryIOException
- if failed to get the archive directory
-
getContentTypeDirectory
public File getContentTypeDirectory(ContentType contentType) throws MalformedURLException, IOException
Get the root directory for a given content type. The directory is created if does not exist.- Parameters:
contentType
- The content type- Returns:
- the root directory for this content type.
- Throws:
MalformedURLException
- if failed to get the archive directoryIOException
- if failed to get the archive directory
-
getContentTypeFile
public File getContentTypeFile(ContentTypeDefinition contentType, boolean override) throws MalformedURLException, IOException
Get the XML definition file for a given content type.- Parameters:
contentType
- The content type definitionoverride
- true if this is a overriden content type.- Returns:
- the XML definition file for this content type.
- Throws:
MalformedURLException
- if failed to get the archive directoryIOException
- if failed to get the archive directory
-
getContentTypeFile
public File getContentTypeFile(ContentType contentType) throws MalformedURLException, IOException
Get the XML definition file for a given content type.- Parameters:
contentType
- The content type- Returns:
- the XML definition file for this content type.
- Throws:
MalformedURLException
- if failed to get the archive directoryIOException
- if failed to get the archive directory
-
createContentType
public void createContentType(ContentTypeDefinition contentTypeDef) throws EditContentTypeException
Create a new content type. This method creates a new xml file into WEB-INF/param/content-types folder.- Parameters:
contentTypeDef
- The content type definition- Throws:
EditContentTypeException
- if failed to create the content type
-
editContentType
public void editContentType(ContentTypeDefinition contentTypeDef) throws EditContentTypeException
Modify a existing content type. This method edit the corresponding XML file of the content type in WEB-INF/param/content-types folder.- Parameters:
contentTypeDef
- The content type definition- Throws:
EditContentTypeException
- if failed to edit this content type
-
canRemoveContentType
public boolean canRemoveContentType(String contentTypeId)
Determines if the content type can be removed- Parameters:
contentTypeId
- The id of content type- Returns:
- true if the content type can be removed
-
removeContentType
public void removeContentType(String contentTypeId) throws RemoveContentTypeException
Remove a existing content type defined in WEB-INF/param/content-types directory.
This method archived the content type into the WEB-INF/param/content-types/_archives/pluginName folder.- Parameters:
contentTypeId
- the id of content type to remove- Throws:
RemoveContentTypeException
- if the content type could not be removed
-
-