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 private static String
__CONTENT_TYPE_PREFIX
The prefix for id of automatic content typesprivate static String
__CONTENT_TYPES_DIR
The directory path of content typesprivate static String
__NAMESPACE_URI
The namespace uriprotected 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 private void
_archiveContentType(ContentType contentType)
private boolean
_isAutomaticContentType(String contentTypeId)
private boolean
_isInUseContentType(String contentTypeId)
private boolean
_isLeafContentType(String contentTypeId)
private void
_saxChildrenModelItems(ModelItemContainer modelItemContainer, TransformerHandler handler)
private void
_saxComposite(CompositeDefinition composite, TransformerHandler handler)
private void
_saxContentType(ContentTypeDefinition contentTypeDef, boolean override)
private void
_saxContentType(ContentTypeDefinition contentTypeDef, boolean override, TransformerHandler handler)
private void
_saxCustomEnumerator(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxCustomValidator(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxDefaultEnumerator(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxDefaultValidator(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxDefaultView(String name, String view, TransformerHandler handler)
private void
_saxDefaultViews(TransformerHandler handler)
private void
_saxElementDefinition(ElementDefinition<? extends Object> elementDefinition, TransformerHandler handler)
private void
_saxEnumeration(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxGeneralInformation(ContentTypeDefinition contentTypeDef, TransformerHandler handler)
private void
_saxI18nizableText(TransformerHandler handler, String tagName, I18nizableText text)
private void
_saxI18nizableText(TransformerHandler handler, String tagName, I18nizableText text, AttributesImpl attrs)
private void
_saxIcons(String iconGlyph, TransformerHandler handler)
private void
_saxModelItem(ModelItem modelItem, TransformerHandler handler)
private void
_saxModelItems(ContentTypeDefinition contentTypeDef, TransformerHandler handler)
private void
_saxParentRef(String parentRef, TransformerHandler handler)
private void
_saxRepeater(RepeaterDefinition repeater, TransformerHandler handler)
private void
_saxRight(String right, TransformerHandler handler)
private void
_saxTags(Set<String> tags, TransformerHandler handler)
private void
_saxValidator(ElementDefinition elementDefinition, TransformerHandler handler)
private void
_saxView(View view, TransformerHandler handler)
private void
_saxViewItem(ViewItem viewItem, TransformerHandler handler)
private void
_saxViews(ContentTypeDefinition contentType, TransformerHandler handler)
private void
_saxWidget(ElementDefinition<? extends Object> elementDefinition, TransformerHandler handler)
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
-
__CONTENT_TYPES_DIR
private static final String __CONTENT_TYPES_DIR
The directory path of content types- See Also:
- Constant Field Values
-
__CONTENT_TYPE_PREFIX
private static final String __CONTENT_TYPE_PREFIX
The prefix for id of automatic content types- See Also:
- Constant Field Values
-
__NAMESPACE_URI
private static final String __NAMESPACE_URI
The namespace uri- See Also:
- Constant Field Values
-
_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
-
_saxContentType
private void _saxContentType(ContentTypeDefinition contentTypeDef, boolean override) throws EditContentTypeException
- Throws:
EditContentTypeException
-
_saxContentType
private void _saxContentType(ContentTypeDefinition contentTypeDef, boolean override, TransformerHandler handler) throws SAXException, EditContentTypeException, ConfigurationException
-
_saxGeneralInformation
private void _saxGeneralInformation(ContentTypeDefinition contentTypeDef, TransformerHandler handler) throws SAXException, EditContentTypeException
- Throws:
SAXException
EditContentTypeException
-
_saxIcons
private void _saxIcons(String iconGlyph, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxTags
private void _saxTags(Set<String> tags, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxParentRef
private void _saxParentRef(String parentRef, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxRight
private void _saxRight(String right, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxModelItems
private void _saxModelItems(ContentTypeDefinition contentTypeDef, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxModelItem
private void _saxModelItem(ModelItem modelItem, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxRepeater
private void _saxRepeater(RepeaterDefinition repeater, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxComposite
private void _saxComposite(CompositeDefinition composite, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxChildrenModelItems
private void _saxChildrenModelItems(ModelItemContainer modelItemContainer, TransformerHandler handler) throws ConfigurationException, SAXException
- Throws:
ConfigurationException
SAXException
-
_saxElementDefinition
private void _saxElementDefinition(ElementDefinition<? extends Object> elementDefinition, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxWidget
private void _saxWidget(ElementDefinition<? extends Object> elementDefinition, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxEnumeration
private void _saxEnumeration(ElementDefinition elementDefinition, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxDefaultEnumerator
private void _saxDefaultEnumerator(ElementDefinition elementDefinition, TransformerHandler handler)
-
_saxCustomEnumerator
private void _saxCustomEnumerator(ElementDefinition elementDefinition, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxValidator
private void _saxValidator(ElementDefinition elementDefinition, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxDefaultValidator
private void _saxDefaultValidator(ElementDefinition elementDefinition, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxCustomValidator
private void _saxCustomValidator(ElementDefinition elementDefinition, TransformerHandler handler) throws SAXException, ConfigurationException
- Throws:
SAXException
ConfigurationException
-
_saxViews
private void _saxViews(ContentTypeDefinition contentType, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxDefaultViews
private void _saxDefaultViews(TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxDefaultView
private void _saxDefaultView(String name, String view, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxView
private void _saxView(View view, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxViewItem
private void _saxViewItem(ViewItem viewItem, TransformerHandler handler) throws SAXException
- Throws:
SAXException
-
_saxI18nizableText
private void _saxI18nizableText(TransformerHandler handler, String tagName, I18nizableText text) throws SAXException
- Throws:
SAXException
-
_saxI18nizableText
private void _saxI18nizableText(TransformerHandler handler, String tagName, I18nizableText text, AttributesImpl attrs) throws SAXException
- Throws:
SAXException
-
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
-
_archiveContentType
private void _archiveContentType(ContentType contentType) throws RemoveContentTypeException
- Throws:
RemoveContentTypeException
-
_isInUseContentType
private boolean _isInUseContentType(String contentTypeId)
-
_isAutomaticContentType
private boolean _isAutomaticContentType(String contentTypeId)
-
_isLeafContentType
private boolean _isLeafContentType(String contentTypeId)
-
-