Package org.ametys.plugins.webcontentio
Class ContentIOManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.webcontentio.ContentIOManager
-
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
public class ContentIOManager extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Manager for importing contents
-
-
Field Summary
Fields Modifier and Type Field Description private ContentImporterExtensionPoint
_contentImporterExtensionPoint
private ContentTypeExtensionPoint
_contentTypeExtensionPoint
private Context
_context
private CurrentUserProvider
_currentUserProvider
private AmetysObjectResolver
_resolver
private RightManager
_rightsManager
private WorkflowProvider
_workflowProvider
static String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description ContentIOManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Content
_convertFileToContent(ContentImporter importer, File file, Site site, Sitemap sitemap, UserIdentity user, Map<String,String> params)
private ModifiablePage
_createPageAndSetContent(PagesContainer rootPage, Content content, Site site, Sitemap sitemap, Map<String,String> params, File file)
private int[]
_importFromDirectory(File dir, PagesContainer rootPage, UserIdentity user, boolean isContextExtern)
private ModifiablePage
_importFromFile(File file, PagesContainer rootPage, UserIdentity user, boolean isContextExtern)
Import a file into a new content and a new page.void
contextualize(Context context)
protected boolean
hasRight(String contentTypeId, PagesContainer page, UserIdentity user, boolean isContextExtern)
Test if the current user has the right needed by the content type to create a content.ModifiablePage
importContent(InputStream is, String mimeType, String contentName, UserIdentity user, PagesContainer rootPage, boolean isContextExtern)
Import an InputStream as a content into a new pageMap<String,Object>
importContent(String directoryPath, String rootPageId)
Import recursively documents contained in a directory on the server Created contents are of type 'article' and pages are also created upon successful content creation.int[]
importContent(String path, PagesContainer rootPage, UserIdentity user)
Import recursively documents contained in a directory on the server Created contents are of type 'article' and pages are also created upon successful content creation.void
service(ServiceManager manager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_contentImporterExtensionPoint
private ContentImporterExtensionPoint _contentImporterExtensionPoint
-
_contentTypeExtensionPoint
private ContentTypeExtensionPoint _contentTypeExtensionPoint
-
_rightsManager
private RightManager _rightsManager
-
_workflowProvider
private WorkflowProvider _workflowProvider
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_resolver
private AmetysObjectResolver _resolver
-
-
Constructor Detail
-
ContentIOManager
public ContentIOManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
importContent
public Map<String,Object> importContent(String directoryPath, String rootPageId) throws ProcessingException, AmetysRepositoryException
Import recursively documents contained in a directory on the server Created contents are of type 'article' and pages are also created upon successful content creation.- Parameters:
directoryPath
- The absolute path of directory on the serverrootPageId
- The id of parent page- Returns:
- An array containing the number of successful and unsuccessful content created.
- Throws:
AmetysRepositoryException
- If an error occurredProcessingException
- if an error occurs during processing.
-
importContent
public int[] importContent(String path, PagesContainer rootPage, UserIdentity user) throws ProcessingException
Import recursively documents contained in a directory on the server Created contents are of type 'article' and pages are also created upon successful content creation.- Parameters:
path
- The absolute path of directory on the serverrootPage
- The parent page of the new contentsuser
- The user responsible for contents import- Returns:
- An array containing the number of successful and unsuccessful content created.
- Throws:
ProcessingException
- if an error occurs during processing.
-
importContent
public ModifiablePage importContent(InputStream is, String mimeType, String contentName, UserIdentity user, PagesContainer rootPage, boolean isContextExtern) throws IOException
Import an InputStream as a content into a new page- Parameters:
is
- The input stream to importmimeType
- The Mime type of the input streamcontentName
- The name associated with the input streamuser
- The creatorrootPage
- The parent page of the newly created pageisContextExtern
- True if the current context is not in a site- Returns:
- The created page or null if failed to create the page
- Throws:
IOException
- if an error occurs with the temporary file.
-
_importFromDirectory
private int[] _importFromDirectory(File dir, PagesContainer rootPage, UserIdentity user, boolean isContextExtern)
-
_importFromFile
private ModifiablePage _importFromFile(File file, PagesContainer rootPage, UserIdentity user, boolean isContextExtern)
Import a file into a new content and a new page.- Parameters:
file
- The file to importrootPage
- The parent page of the newly created pageuser
- The userisContextExtern
- True if the current context is not in a site- Returns:
- True if the content and page was successfully created.
-
_convertFileToContent
private Content _convertFileToContent(ContentImporter importer, File file, Site site, Sitemap sitemap, UserIdentity user, Map<String,String> params) throws com.opensymphony.workflow.WorkflowException, AmetysRepositoryException
- Throws:
com.opensymphony.workflow.WorkflowException
AmetysRepositoryException
-
_createPageAndSetContent
private ModifiablePage _createPageAndSetContent(PagesContainer rootPage, Content content, Site site, Sitemap sitemap, Map<String,String> params, File file)
-
hasRight
protected boolean hasRight(String contentTypeId, PagesContainer page, UserIdentity user, boolean isContextExtern)
Test if the current user has the right needed by the content type to create a content.- Parameters:
contentTypeId
- the content type ID.page
- the current page.user
- The userisContextExtern
- True if the current context is not in a site- Returns:
- true if the user has the right needed, false otherwise.
-
-