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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextualize(Context context) protected booleanhasRight(String contentTypeId, SitemapElement page, UserIdentity user, boolean isContextExtern) Test if the current user has the right needed by the content type to create a content.importContent(InputStream is, String mimeType, String contentName, UserIdentity user, SitemapElement rootPage, boolean isContextExtern) Import an InputStream as a content into a new pageimportContent(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, SitemapElement 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.voidservice(ServiceManager manager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
ContentIOManager
public ContentIOManager()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
- Specified by:
servicein 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, SitemapElement 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, SitemapElement 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, SitemapElement 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.
-