Class DocumentService

java.lang.Object
fr.paris.lutece.plugins.document.service.DocumentService

@ApplicationScoped @Named("document.DocumentService") public class DocumentService extends Object
This Service manages document actions (create, move, delete, validate ...) and notify listeners.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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, 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
    getCreateForm(String strDocumentTypeCode, Locale locale, String strBaseUrl)
    Build an HTML form for the document creation for a given document type
    getDocumentData(fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest mRequest, Document document, Locale locale)
    Return the data of a document object
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use @Inject to obtain the DocumentService instance.
    getModifyForm(Document document, Locale locale, String strBaseUrl)
    Build an HTML form for the document modification for a given document
    getModifyForm(String strDocumentId, Locale locale, String strBaseUrl)
    Build an HTML form for the document modification for a given document ID.
    void
    Get the published status of a document
    void
    initializedService(jakarta.servlet.ServletContext context)
    This method observes the initialization of the ApplicationScoped context.
    boolean
    isAuthorizedAdminDocument(int nIdSpace, String strDocumentTypeId, 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
  • Constructor Details

    • DocumentService

      public DocumentService()
  • Method Details

    • getInstance

      @Deprecated(since="8.0", forRemoval=true) public static DocumentService getInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use @Inject to obtain the DocumentService instance. This method will be removed in future versions.
      Returns the unique instance of the DocumentService service.

      This method is deprecated and is provided for backward compatibility only. For new code, use dependency injection with @Inject to obtain the DocumentService instance instead.

      Returns:
      The unique instance of DocumentService.
    • 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, 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 String getCreateForm(String strDocumentTypeCode, Locale locale, 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 String getModifyForm(String strDocumentId, Locale locale, 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 String getModifyForm(Document document, Locale locale, 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, String strDocumentTypeId, 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 String getDocumentData(fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest mRequest, Document document, 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
    • initializedService

      public void initializedService(@Observes @Initialized(jakarta.enterprise.context.ApplicationScoped.class) jakarta.servlet.ServletContext context)
      This method observes the initialization of the ApplicationScoped context. It ensures that this CDI beans are instantiated at the application startup.

      This method is triggered automatically by CDI when the ApplicationScoped context is initialized, which typically occurs during the startup of the application server.

      Parameters:
      context - the ServletContext that is initialized. This parameter is observed and injected automatically by CDI when the ApplicationScoped context is initialized.