Package org.ametys.web.content
Class FOContentCreationHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.web.content.FOContentCreationHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class FOContentCreationHelper extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
Helper for creating and editing a content from the submitted form
-
-
Field Summary
Fields Modifier and Type Field Description private ContentTypesHelper
_contentTypeHelper
private ContentWorkflowHelper
_contentWorkflowHelper
private Context
_context
private ContentTypeExtensionPoint
_cTypeExtPt
private CurrentUserProvider
_currentUserProvider
private JSONUtils
_jsonUtils
private FrontOfficeSearcherFactory
_searcherFactory
private SourceResolver
_srcResolver
private UploadManager
_uploadManager
static String
ROLE
The component role.
-
Constructor Summary
Constructors Constructor Description FOContentCreationHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Request
_getRequest()
Get the requestprivate Map<String,Object>
_getUploadFileValue(Part partUploaded)
private void
_saxContentEnumeratorValue(ContentHandler contentHandler, MetadataDefinition metadataDef, String language)
Sax enumeration value for enum or a content metadataprivate boolean
_validateFormField(MetadataDefinition metadataDef, String fieldName, Object value, Multimap<String,I18nizableText> errors)
void
contextualize(Context context)
Map<String,Object>
createAndEditContent(int initActionId, String[] contentTypeIds, String[] mixinIds, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName, Map<String,Object> inputs)
Create and edit a contentMap<String,Object>
createAndEditContent(int initActionId, String contentTypeId, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName)
Create and edit a contentMap<String,Object>
createAndEditContent(int initActionId, String contentTypeId, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName, Map<String,Object> inputs)
Create and edit a contentMap<String,Object>
getAndValidateFormValues(Map<String,Object> rawValues, ContentType contentType, String viewName, Multimap<String,I18nizableText> errors)
Get the values for this content type from requestMap<String,Object>
getAndValidateFormValues(Request request, ContentType contentType, String viewName, Multimap<String,I18nizableText> errors)
Get the values for this content type from requestprotected Map<String,String>
getContentValues(String cTypeId, String language)
Get values for contents enumerationvoid
saxContentValues(ContentHandler contentHandler, ContentType contentType, String rootTagName, String language)
SAX contents values for metadata of type CONTENTvoid
saxViewIfExists(ContentHandler contentHandler, ContentType contentType, String rootTagName, String viewName)
SAX the view of a content typevoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_contentTypeHelper
private ContentTypesHelper _contentTypeHelper
-
_jsonUtils
private JSONUtils _jsonUtils
-
_uploadManager
private UploadManager _uploadManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_contentWorkflowHelper
private ContentWorkflowHelper _contentWorkflowHelper
-
_srcResolver
private SourceResolver _srcResolver
-
_cTypeExtPt
private ContentTypeExtensionPoint _cTypeExtPt
-
_searcherFactory
private FrontOfficeSearcherFactory _searcherFactory
-
-
Constructor Detail
-
FOContentCreationHelper
public FOContentCreationHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
_getRequest
protected Request _getRequest()
Get the request- Returns:
- the request
-
saxViewIfExists
public void saxViewIfExists(ContentHandler contentHandler, ContentType contentType, String rootTagName, String viewName) throws SAXException
SAX the view of a content type- Parameters:
contentHandler
- The content handler to sax intocontentType
- The content typerootTagName
- the root tag nameviewName
- The view name- Throws:
SAXException
- if an error occurs
-
saxContentValues
public void saxContentValues(ContentHandler contentHandler, ContentType contentType, String rootTagName, String language) throws SAXException
SAX contents values for metadata of type CONTENT- Parameters:
contentHandler
- The content handler to sax intocontentType
- The content typerootTagName
- The root tag namelanguage
- the current language- Throws:
SAXException
- if an error occurs when saxing
-
_saxContentEnumeratorValue
private void _saxContentEnumeratorValue(ContentHandler contentHandler, MetadataDefinition metadataDef, String language) throws SAXException
Sax enumeration value for enum or a content metadata- Parameters:
contentHandler
- The content handler to sax intometadataDef
- The metadata definition.language
- The current language- Throws:
SAXException
- If an error occurred while saxing
-
getContentValues
protected Map<String,String> getContentValues(String cTypeId, String language)
Get values for contents enumeration- Parameters:
cTypeId
- The id of content typelanguage
- The current language- Returns:
- The contents
-
getAndValidateFormValues
public Map<String,Object> getAndValidateFormValues(Map<String,Object> rawValues, ContentType contentType, String viewName, Multimap<String,I18nizableText> errors)
Get the values for this content type from request- Parameters:
rawValues
- the input valuescontentType
- the edited content typeviewName
- the view nameerrors
- The errors to fill- Returns:
- The values
-
getAndValidateFormValues
public Map<String,Object> getAndValidateFormValues(Request request, ContentType contentType, String viewName, Multimap<String,I18nizableText> errors)
Get the values for this content type from request- Parameters:
request
- the requestcontentType
- the edited content typeviewName
- the view nameerrors
- The errors to fill- Returns:
- The values
-
createAndEditContent
public Map<String,Object> createAndEditContent(int initActionId, String contentTypeId, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Create and edit a content- Parameters:
initActionId
- The initial workflow action id for creation and editioncontentTypeId
- The id of content typesiteName
- The current site namecontentName
- The content namecontentTitle
- The content titlelanguage
- The content languagevalues
- The submitted valuesworkflowName
- The workflow nameviewName
- The view name- Returns:
- The workflow result
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
createAndEditContent
public Map<String,Object> createAndEditContent(int initActionId, String contentTypeId, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName, Map<String,Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Create and edit a content- Parameters:
initActionId
- The initial workflow action id for creation and editioncontentTypeId
- The id of content typesiteName
- The current site namecontentName
- The content namecontentTitle
- The content titlelanguage
- The content languagevalues
- The submitted valuesworkflowName
- The workflow nameviewName
- The view nameinputs
- The initial workflow inputs- Returns:
- The workflow result
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
createAndEditContent
public Map<String,Object> createAndEditContent(int initActionId, String[] contentTypeIds, String[] mixinIds, String siteName, String contentName, String contentTitle, String language, Map<String,Object> values, String workflowName, String viewName, Map<String,Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Create and edit a content- Parameters:
initActionId
- The initial workflow action id for creation and editioncontentTypeIds
- The new content types. Cannot be null. Cannot be empty.mixinIds
- The new mixins. Can be null. Can be empty.siteName
- The current site namecontentName
- The content namecontentTitle
- The content titlelanguage
- The content languagevalues
- The submitted valuesworkflowName
- The workflow nameviewName
- The view nameinputs
- The initial workflow inputs- Returns:
- The workflow result
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
_validateFormField
private boolean _validateFormField(MetadataDefinition metadataDef, String fieldName, Object value, Multimap<String,I18nizableText> errors)
-
_getUploadFileValue
private Map<String,Object> _getUploadFileValue(Part partUploaded)
-
-