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
-
-
Constructor Summary
Constructors Constructor Description ContentIOManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
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.
-
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.
-
-