Class SaveContentTypeComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contenttypeseditor.edition.SaveContentTypeComponent
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class SaveContentTypeComponent extends AbstractLogEnabled implements Component, Serviceable
This component save a content type
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__DEFAULT_CATALOGUE
The name of the default i18n catalogueprivate static String
__I18N_CATALOG_DIR
The directory path of application i18n keyprivate static String
__RIGHT_CATEGORY
The right category of a content typeprivate static String
__RIGHTS_FILE
The path of rights on content typesprivate static String
__SAVE_CONTENT_TYPE_RIGHT
The url to save the right of content typeprotected ContentAttributeTypeExtensionPoint
_contentAttributeTypeExtensionPoint
The extension point for available attribute typesprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content type extension point instanceprotected ContentTypesHelper
_contentTypesHelper
The content types helperprotected ContentTypeStateComponent
_contentTypeStateComponent
The content type state instanceprotected EditContentTypeHelper
_editContentTypeHelper
The edit content type component instanceprotected EditContentTypeInformationHelper
_editContentTypeInformationHelper
The edit content type helper instanceprivate int
_fieldsetNumber
private Map<String,I18nCatalog>
_i18nCatalogs
Representation of i18n catalog according to the languageprotected I18nUtils
_i18nUtils
I18nUtils instanceprotected SourceResolver
_sourceResolver
The source resolverprivate List<TranslatedValue>
_translatedValues
static String
ROLE
The Avalon role name
-
Constructor Summary
Constructors Constructor Description SaveContentTypeComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_addCategory(ContentTypeDefinition contentTypeDefinition, Object recoveredCategory, Object recoveredNewCategory, String pluginName)
private void
_addChildren(ModelItemGroup modelItemGroup, ModelItem existingModelItem, Map<String,Object> modelItemInfo, String pluginName, String contentTypeId)
private void
_addChildrenToViewItemContainer(ViewItemContainer viewItemContainer, ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemContainerInfo, String pluginName, String contentTypeId)
private void
_addCustomEnumerator(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String enumeratorName)
private void
_addCustomValidator(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String validatorName)
private void
_addDefaultEnumerator(AttributeDefinition attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
private void
_addDefaultValidator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
private void
_addEnumerator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
private void
_addGeneralInformation(ContentTypeDefinition contentType, ContentType existingContentType, Map<String,Object> contentTypeInfos, String pluginName, String contentTypeId)
private void
_addIconGlyph(ContentTypeDefinition contentTypeDefinition, Object recoverIconGlyph)
private void
_addIsAbstract(ContentTypeDefinition contentTypeDefinition, Object recoverIsAbstract)
private void
_addModelItemGeneralInformation(ModelItem modelItem, ModelItem existingModelItem, Map<String,Object> modelItemInfo, String name, String pluginName, String contentTypeId, String typeId)
private void
_addModelItems(ContentTypeDefinition contentType, ContentType existingContentType, Map<String,Object> contentTypeInfos, String pluginName, String realContentTypeId)
private void
_addRight(ContentTypeDefinition contentTypeDefinition, String contentTypeId, String pluginName)
private void
_addSpecificInfoForContentAttribute(ContentAttributeDefinition attributeDefinition, Map<String,Object> attributeInfo)
private void
_addSupertypeIds(ContentTypeDefinition contentTypeDefinition, Object recoverSupertypes)
private void
_addTags(ContentTypeDefinition contentTypeDefinition, Object recoverTags, Object recoverIsPrivate, Object recoverIsReferenceTable, Object recoverIsMixin)
private void
_addValidator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
private void
_addViews(ContentTypeDefinition contentTypeDefinition, ContentType existingContentType, String realContentTypeId, Map<String,Object> contentTypeInfos, String pluginName, String contentTypeId)
private void
_addWidget(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
private boolean
_areElementDefinitionsEqual(ElementDefinition oldElem, ElementDefinition newElem)
private boolean
_areEnumeratorsEqual(Enumerator oldEnumerator, Enumerator newEnumerator)
private boolean
_areModelItemGroupsEqual(ModelItemGroup oldGroup, ModelItemGroup newGroup, List<String> overriddenAttributes)
private boolean
_areModelItemsEqual(ModelItem oldModelItem, ModelItem newModelItem, List<String> overriddenAttributes)
private boolean
_areValidatorsEqual(Validator oldValidator, Validator newValidator)
private int
_compareValuesAnd18nizableText(Map<String,Object> newText, I18nizableText existingI18nizableText)
Compare recovered values stored in a map with existing values stored in a 18nizableTextprivate ElementDefinition
_createDefaultTitleModelItem()
private Map<String,Map<String,String>>
_createNewI18nCatalogs()
private String
_generateCategoryI18nKey(String pluginName, Map<String,Object> recoveredCategory)
private String
_generateContentTypeIdKey(String contentTypeId)
private String
_generateI18nKey(String pluginName, String type, String contentTypeId, String label)
private AttributeDefinition<? extends Object>
_getAttributeDefinition(String typeId)
private ModelItem
_getAttributeDefinition(Map<String,Object> attributeInfo, ModelItem existingModelItem, String pluginName, String contentTypeId, String name, String typeId)
private boolean
_getBoolean(Object recoverValue)
private ContentTypeDefinition
_getContentTypeDefinition(Map<String,Object> contentTypeInfos)
private I18nizableText
_getExistingCategory(Map categoryMap)
private I18nizableText
_getI18nizableText(I18nizableText existingI18nizableText, Object recoverValue, String key)
private I18nizableText
_getI18nizableText(I18nizableText i18nizableText, Object recoverValue, String pluginName, String type, String contentTypeId, String label)
private int
_getInteger(Object recoverValue)
private ModelItem
_getModelItem(Map<String,Object> modelItemInfo, ModelItem existingModelItem, String pluginName, String contentTypeId)
private ModelItem
_getModelItemFromContentTypeDefinition(Collection<? extends ModelItem> modelItems, String modelItemName)
private I18nizableText
_getNewCategory(Object recoveredNewCategory, String pluginName)
private ModelItem
_getRepeater(Map<String,Object> repeaterInfo, RepeaterDefinition existingRepeaterDefinition, String name, String pluginName, String contentTypeId)
private SimpleViewItemGroup
_getSimpleViewItemGroup(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemInfo, String viewItemName, String pluginName, String contentTypeId)
private String
_getString(Object recoverValue)
private View
_getView(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewInfo, String viewName, String pluginName, String contentTypeId)
private ViewItem
_getViewItem(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemInfo, String viewItemName, String viewItemPath, String pluginName, String contentTypeId)
private Map<String,String>
_readI18nCatalog(String path)
private void
_saveI18nCalatog(Map<String,String> i18nMessages, String catalogPath, String language)
private void
_saxCatalogs(Map<String,Map<String,String>> newI18nMessages)
private void
_saxI18nCatalog(TransformerHandler handler, Map<String,String> i18nMessages, String language)
private void
_saxRightsParam(String id, String label, String description)
private Map<String,String>
_updateI18nMessages(Map<String,String> i18nMessages, Map<String,String> newI18nMessages)
boolean
saveContentType(Map<String,Object> contentTypeInfos)
Save content typevoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__I18N_CATALOG_DIR
private static final String __I18N_CATALOG_DIR
The directory path of application i18n key- See Also:
- Constant Field Values
-
__RIGHTS_FILE
private static final String __RIGHTS_FILE
The path of rights on content types- See Also:
- Constant Field Values
-
__RIGHT_CATEGORY
private static final String __RIGHT_CATEGORY
The right category of a content type- See Also:
- Constant Field Values
-
__SAVE_CONTENT_TYPE_RIGHT
private static final String __SAVE_CONTENT_TYPE_RIGHT
The url to save the right of content type- See Also:
- Constant Field Values
-
__DEFAULT_CATALOGUE
private static final String __DEFAULT_CATALOGUE
The name of the default i18n catalogue- See Also:
- Constant Field Values
-
_sourceResolver
protected SourceResolver _sourceResolver
The source resolver
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content type extension point instance
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
The content types helper
-
_contentAttributeTypeExtensionPoint
protected ContentAttributeTypeExtensionPoint _contentAttributeTypeExtensionPoint
The extension point for available attribute types
-
_contentTypeStateComponent
protected ContentTypeStateComponent _contentTypeStateComponent
The content type state instance
-
_editContentTypeInformationHelper
protected EditContentTypeInformationHelper _editContentTypeInformationHelper
The edit content type helper instance
-
_editContentTypeHelper
protected EditContentTypeHelper _editContentTypeHelper
The edit content type component instance
-
_i18nUtils
protected I18nUtils _i18nUtils
I18nUtils instance
-
_i18nCatalogs
private Map<String,I18nCatalog> _i18nCatalogs
Representation of i18n catalog according to the language
-
_translatedValues
private List<TranslatedValue> _translatedValues
-
_fieldsetNumber
private int _fieldsetNumber
-
-
Constructor Detail
-
SaveContentTypeComponent
public SaveContentTypeComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
saveContentType
public boolean saveContentType(Map<String,Object> contentTypeInfos)
Save content type- Parameters:
contentTypeInfos
- all information about the content type to save- Returns:
- True if the content type was successfully saved
-
_getContentTypeDefinition
private ContentTypeDefinition _getContentTypeDefinition(Map<String,Object> contentTypeInfos)
-
_addGeneralInformation
private void _addGeneralInformation(ContentTypeDefinition contentType, ContentType existingContentType, Map<String,Object> contentTypeInfos, String pluginName, String contentTypeId)
-
_addCategory
private void _addCategory(ContentTypeDefinition contentTypeDefinition, Object recoveredCategory, Object recoveredNewCategory, String pluginName)
-
_getNewCategory
private I18nizableText _getNewCategory(Object recoveredNewCategory, String pluginName)
-
_getExistingCategory
private I18nizableText _getExistingCategory(Map categoryMap)
-
_addIconGlyph
private void _addIconGlyph(ContentTypeDefinition contentTypeDefinition, Object recoverIconGlyph)
-
_addTags
private void _addTags(ContentTypeDefinition contentTypeDefinition, Object recoverTags, Object recoverIsPrivate, Object recoverIsReferenceTable, Object recoverIsMixin)
-
_addSupertypeIds
private void _addSupertypeIds(ContentTypeDefinition contentTypeDefinition, Object recoverSupertypes)
-
_addIsAbstract
private void _addIsAbstract(ContentTypeDefinition contentTypeDefinition, Object recoverIsAbstract)
-
_addRight
private void _addRight(ContentTypeDefinition contentTypeDefinition, String contentTypeId, String pluginName)
-
_addModelItems
private void _addModelItems(ContentTypeDefinition contentType, ContentType existingContentType, Map<String,Object> contentTypeInfos, String pluginName, String realContentTypeId)
-
_areModelItemsEqual
private boolean _areModelItemsEqual(ModelItem oldModelItem, ModelItem newModelItem, List<String> overriddenAttributes)
-
_areElementDefinitionsEqual
private boolean _areElementDefinitionsEqual(ElementDefinition oldElem, ElementDefinition newElem)
-
_areModelItemGroupsEqual
private boolean _areModelItemGroupsEqual(ModelItemGroup oldGroup, ModelItemGroup newGroup, List<String> overriddenAttributes)
-
_areEnumeratorsEqual
private boolean _areEnumeratorsEqual(Enumerator oldEnumerator, Enumerator newEnumerator)
-
_areValidatorsEqual
private boolean _areValidatorsEqual(Validator oldValidator, Validator newValidator)
-
_compareValuesAnd18nizableText
private int _compareValuesAnd18nizableText(Map<String,Object> newText, I18nizableText existingI18nizableText)
Compare recovered values stored in a map with existing values stored in a 18nizableText- Parameters:
newText
- values recovered after a user modification of the contentexistingI18nizableText
- existing values we need to compare to know if the content has changed- Returns:
- the value 0 if there is no difference between old and new values, a value less than 0 if the key is already overridden or a value greater than 0 if the new value has changed from the old value.
-
_createDefaultTitleModelItem
private ElementDefinition _createDefaultTitleModelItem()
-
_getModelItem
private ModelItem _getModelItem(Map<String,Object> modelItemInfo, ModelItem existingModelItem, String pluginName, String contentTypeId)
-
_getRepeater
private ModelItem _getRepeater(Map<String,Object> repeaterInfo, RepeaterDefinition existingRepeaterDefinition, String name, String pluginName, String contentTypeId)
-
_getAttributeDefinition
private ModelItem _getAttributeDefinition(Map<String,Object> attributeInfo, ModelItem existingModelItem, String pluginName, String contentTypeId, String name, String typeId)
-
_getAttributeDefinition
private AttributeDefinition<? extends Object> _getAttributeDefinition(String typeId)
-
_addWidget
private void _addWidget(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
-
_addEnumerator
private void _addEnumerator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
-
_addCustomEnumerator
private void _addCustomEnumerator(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String enumeratorName)
-
_addDefaultEnumerator
private void _addDefaultEnumerator(AttributeDefinition attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
-
_addValidator
private void _addValidator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
-
_addCustomValidator
private void _addCustomValidator(AttributeDefinition<? extends Object> attributeDefinition, Map<String,Object> attributeInfo, String validatorName)
-
_addDefaultValidator
private void _addDefaultValidator(AttributeDefinition<? extends Object> attributeDefinition, ModelItem existingModelItem, Map<String,Object> attributeInfo, String name, String pluginName, String contentTypeId)
-
_addSpecificInfoForContentAttribute
private void _addSpecificInfoForContentAttribute(ContentAttributeDefinition attributeDefinition, Map<String,Object> attributeInfo)
-
_addModelItemGeneralInformation
private void _addModelItemGeneralInformation(ModelItem modelItem, ModelItem existingModelItem, Map<String,Object> modelItemInfo, String name, String pluginName, String contentTypeId, String typeId)
-
_addChildren
private void _addChildren(ModelItemGroup modelItemGroup, ModelItem existingModelItem, Map<String,Object> modelItemInfo, String pluginName, String contentTypeId)
-
_addViews
private void _addViews(ContentTypeDefinition contentTypeDefinition, ContentType existingContentType, String realContentTypeId, Map<String,Object> contentTypeInfos, String pluginName, String contentTypeId)
-
_getView
private View _getView(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewInfo, String viewName, String pluginName, String contentTypeId)
-
_addChildrenToViewItemContainer
private void _addChildrenToViewItemContainer(ViewItemContainer viewItemContainer, ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemContainerInfo, String pluginName, String contentTypeId)
-
_getViewItem
private ViewItem _getViewItem(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemInfo, String viewItemName, String viewItemPath, String pluginName, String contentTypeId)
-
_getSimpleViewItemGroup
private SimpleViewItemGroup _getSimpleViewItemGroup(ContentTypeDefinition contentTypeDefinition, Map<String,Object> viewItemInfo, String viewItemName, String pluginName, String contentTypeId)
-
_getModelItemFromContentTypeDefinition
private ModelItem _getModelItemFromContentTypeDefinition(Collection<? extends ModelItem> modelItems, String modelItemName)
-
_getBoolean
private boolean _getBoolean(Object recoverValue)
-
_getString
private String _getString(Object recoverValue)
-
_getInteger
private int _getInteger(Object recoverValue)
-
_getI18nizableText
private I18nizableText _getI18nizableText(I18nizableText i18nizableText, Object recoverValue, String pluginName, String type, String contentTypeId, String label)
-
_getI18nizableText
private I18nizableText _getI18nizableText(I18nizableText existingI18nizableText, Object recoverValue, String key)
-
_generateContentTypeIdKey
private String _generateContentTypeIdKey(String contentTypeId)
-
_generateCategoryI18nKey
private String _generateCategoryI18nKey(String pluginName, Map<String,Object> recoveredCategory)
-
_generateI18nKey
private String _generateI18nKey(String pluginName, String type, String contentTypeId, String label)
-
_saxCatalogs
private void _saxCatalogs(Map<String,Map<String,String>> newI18nMessages) throws Exception
- Throws:
Exception
-
_readI18nCatalog
private Map<String,String> _readI18nCatalog(String path) throws Exception
- Throws:
Exception
-
_updateI18nMessages
private Map<String,String> _updateI18nMessages(Map<String,String> i18nMessages, Map<String,String> newI18nMessages)
-
_saveI18nCalatog
private void _saveI18nCalatog(Map<String,String> i18nMessages, String catalogPath, String language) throws Exception
- Throws:
Exception
-
_saxI18nCatalog
private void _saxI18nCatalog(TransformerHandler handler, Map<String,String> i18nMessages, String language) throws SAXException
- Throws:
SAXException
-
_saxRightsParam
private void _saxRightsParam(String id, String label, String description) throws MalformedURLException, IOException
- Throws:
MalformedURLException
IOException
-
-