Class DocumentService


  • public class DocumentService
    extends java.lang.Object
    This Service manages document actions (create, move, delete, validate ...) and notify listeners.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void archiveDocument​(Document document, fr.paris.lutece.portal.business.user.AdminUser user, int nStateId)
      Archive a document
      void changeDocumentState​(Document document, fr.paris.lutece.portal.business.user.AdminUser user, int nStateId)
      Change the state of the document
      void createDocument​(Document document, fr.paris.lutece.portal.business.user.AdminUser user)
      Create a new document
      void getActions​(Document document, java.util.Locale locale, fr.paris.lutece.portal.business.user.AdminUser user)
      Add to the document all permitted actions according to the current user and using the current locale
      java.lang.String getCreateForm​(java.lang.String strDocumentTypeCode, java.util.Locale locale, java.lang.String strBaseUrl)
      Build an HTML form for the document creation for a given document type
      java.lang.String getDocumentData​(fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest mRequest, Document document, java.util.Locale locale)
      Return the data of a document object
      static DocumentService getInstance()
      Get the unique instance of the service
      java.lang.String getModifyForm​(Document document, java.util.Locale locale, java.lang.String strBaseUrl)
      Build an HTML form for the document modification for a given document
      java.lang.String getModifyForm​(java.lang.String strDocumentId, java.util.Locale locale, java.lang.String strBaseUrl)
      Build an HTML form for the document modification for a given document ID.
      void getPublishedStatus​(Document document)
      Get the published status of a document
      boolean isAuthorizedAdminDocument​(int nIdSpace, java.lang.String strDocumentTypeId, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user)
      Check that a given user is allowed to access a document type for a given permission in a document space specified in parameter If permission is document creation, check if document creation is allowed for the specified space.
      void modifyDocument​(Document document, fr.paris.lutece.portal.business.user.AdminUser user)
      Modify a the content of a document
      void moveDocument​(Document document, fr.paris.lutece.portal.business.user.AdminUser user, int nNewSpace)
      Move a document from a space to another
      void validateDocument​(Document document, fr.paris.lutece.portal.business.user.AdminUser user, int nStateId)
      Validate a document
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static DocumentService getInstance()
        Get the unique instance of the service
        Returns:
        The unique instance
      • changeDocumentState

        public void changeDocumentState​(Document document,
                                        fr.paris.lutece.portal.business.user.AdminUser user,
                                        int nStateId)
                                 throws DocumentException
        Change the state of the document
        Parameters:
        document - The document
        user - The user doing the action
        nStateId - The new state Id
        Throws:
        DocumentException - raise when error occurs in event or rule
      • createDocument

        public void createDocument​(Document document,
                                   fr.paris.lutece.portal.business.user.AdminUser user)
                            throws DocumentException
        Create a new document
        Parameters:
        document - The document
        user - The user doing the action
        Throws:
        DocumentException - raise when error occurs in event or rule
      • modifyDocument

        public void modifyDocument​(Document document,
                                   fr.paris.lutece.portal.business.user.AdminUser user)
                            throws DocumentException
        Modify a the content of a document
        Parameters:
        document - The document
        user - The user doing the action
        Throws:
        DocumentException - raise when error occurs in event or rule
      • validateDocument

        public void validateDocument​(Document document,
                                     fr.paris.lutece.portal.business.user.AdminUser user,
                                     int nStateId)
                              throws DocumentException
        Validate a document
        Parameters:
        nStateId - The new state id for a validated document
        document - The document
        user - The user doing the action
        Throws:
        DocumentException - raise when error occurs in event or rule
      • archiveDocument

        public void archiveDocument​(Document document,
                                    fr.paris.lutece.portal.business.user.AdminUser user,
                                    int nStateId)
                             throws DocumentException
        Archive a document
        Parameters:
        nStateId - The new state id for a validated document
        document - The document
        user - The user doing the action
        Throws:
        DocumentException - raise when error occurs in event or rule
      • moveDocument

        public void moveDocument​(Document document,
                                 fr.paris.lutece.portal.business.user.AdminUser user,
                                 int nNewSpace)
                          throws DocumentException
        Move a document from a space to another
        Parameters:
        document - The document
        user - The user doing the action
        nNewSpace - The Id of the destination space
        Throws:
        DocumentException - raise when error occurs in event or rule
      • getActions

        public void getActions​(Document document,
                               java.util.Locale locale,
                               fr.paris.lutece.portal.business.user.AdminUser user)
        Add to the document all permitted actions according to the current user and using the current locale
        Parameters:
        user - The current user
        document - The document
        locale - The Locale
      • getPublishedStatus

        public void getPublishedStatus​(Document document)
        Get the published status of a document
        Parameters:
        document - The document to get the published status of
      • getCreateForm

        public java.lang.String getCreateForm​(java.lang.String strDocumentTypeCode,
                                              java.util.Locale locale,
                                              java.lang.String strBaseUrl)
        Build an HTML form for the document creation for a given document type
        Parameters:
        strDocumentTypeCode - The Document type code
        locale - The Locale
        strBaseUrl - The base Url
        Returns:
        The HTML form
      • getModifyForm

        public java.lang.String getModifyForm​(java.lang.String strDocumentId,
                                              java.util.Locale locale,
                                              java.lang.String strBaseUrl)
        Build an HTML form for the document modification for a given document ID. Warning : This method loads the binaries of the document.
        Parameters:
        strDocumentId - The Id of the document to modify
        locale - The Locale
        strBaseUrl - The base url
        Returns:
        The HTML form
      • getModifyForm

        public java.lang.String getModifyForm​(Document document,
                                              java.util.Locale locale,
                                              java.lang.String strBaseUrl)
        Build an HTML form for the document modification for a given document
        Parameters:
        document - The document
        locale - The Locale
        strBaseUrl - The base url
        Returns:
        The HTML form
      • isAuthorizedAdminDocument

        public boolean isAuthorizedAdminDocument​(int nIdSpace,
                                                 java.lang.String strDocumentTypeId,
                                                 java.lang.String strPermission,
                                                 fr.paris.lutece.portal.business.user.AdminUser user)
        Check that a given user is allowed to access a document type for a given permission in a document space specified in parameter If permission is document creation, check if document creation is allowed for the specified space.
        Parameters:
        nIdSpace - the id of the document space
        strDocumentTypeId - the id of the type document being considered
        strPermission - the permission needed
        user - the user trying to access the ressource
        Returns:
        true if the user can access the given resource with the given permission, false otherwise
      • getDocumentData

        public java.lang.String getDocumentData​(fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest mRequest,
                                                Document document,
                                                java.util.Locale locale)
        Return the data of a document object
        Parameters:
        mRequest - The MultipartHttpServletRequest
        document - The document object
        locale - The locale
        Returns:
        data of document object