Class JcmsApp

  • All Implemented Interfaces:
    JcmsRestConstants

    public class JcmsApp
    extends java.lang.Object
    implements JcmsRestConstants
    Represents one remote JCMS site on wich an HTTP client session is connected through the REST Open API.
    Since:
    JCMS-6.0
    Author:
    dissert
    • Method Detail

      • getDataPath

        public java.lang.String getDataPath​(java.lang.String dataId)
        Construct the URI for a data, given its JCMS id.
        Parameters:
        dataId - the JCMS id
        Returns:
        the path.
      • getData

        public JcmsResource getData​(java.lang.String dataId)
                             throws RestException
        Send a request to find a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        Returns:
        the resource
        Throws:
        RestException
      • getData

        public JcmsResource getData​(java.lang.String dataId,
                                    Authentication forcedAuthentication)
                             throws RestException
        Send a request to find a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        forcedAuthentication - possible specific authentication for this request
        Returns:
        the resource
        Throws:
        RestException
      • getData

        public JcmsResource getData​(java.lang.String dataId,
                                    Relateds relateds)
                             throws RestException
        Send a request to find a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        relateds - possible relateds
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getData

        public JcmsResource getData​(java.lang.String dataId,
                                    Authentication forcedAuthentication,
                                    Relateds relateds)
                             throws RestException
        Send a request to find a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        forcedAuthentication - possible specific authentication for this request
        relateds - possible relateds
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getDataList

        public JcmsResource getDataList​(java.lang.String[] dataId)
                                 throws RestException
        Send a request to find a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        Returns:
        the resource
        Throws:
        RestException
      • getChildrenDataPath

        public java.lang.String getChildrenDataPath​(java.lang.String dataId)
        Construct the URI to get the set of children of a data, given its JCMS id.
        Parameters:
        dataId - the JCMS id
        Returns:
        the path.
        Since:
        JCMS-6.1
      • getChildrenData

        public JcmsResource getChildrenData​(java.lang.String dataId)
                                     throws RestException
        Send a request to get the set of children of a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getChildren

        public java.util.List<DataElement> getChildren​(java.lang.String dataId)
        Gives the list of children of a data, given its id, if its type supports it (TreeNode, Group).
        Parameters:
        dataId -
        Returns:
        a list of DataElement
        Since:
        JCMS-6.1
      • getChildren

        public java.util.List<DataElement> getChildren​(java.lang.String dataId,
                                                       Authentication forcedAuthentication,
                                                       Relateds relateds)
        Gives the list of children of a data, given its id, if its type supports it (TreeNode, Group).
        Parameters:
        dataId -
        forcedAuthentication - possible specific authentication for this request
        relateds - possible relateds
        Returns:
        a list of DataElement
        Since:
        JCMS-6.1
      • getChildrenData

        public JcmsResource getChildrenData​(java.lang.String dataId,
                                            Authentication forcedAuthentication)
                                     throws RestException
        Send a request to get the set of children of a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        forcedAuthentication - possible specific authentication for this request
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getChildrenData

        public JcmsResource getChildrenData​(java.lang.String dataId,
                                            Relateds relateds)
                                     throws RestException
        Send a request to get the set of children of a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        relateds - possible relateds
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getChildrenData

        public JcmsResource getChildrenData​(java.lang.String dataId,
                                            Authentication forcedAuthentication,
                                            Relateds relateds)
                                     throws RestException
        Send a request to get the set of children of a data with a given JCMS id.
        Parameters:
        dataId - the JCMS id
        forcedAuthentication - possible specific authentication for this request
        relateds - possible relateds
        Returns:
        the resource
        Throws:
        RestException
        Since:
        JCMS-6.1
      • getSearchPath

        public java.lang.String getSearchPath()
      • getMemberListPath

        public java.lang.String getMemberListPath()
      • getMemberPath

        public java.lang.String getMemberPath​(java.lang.String login)
      • getUploadMemberPhotoPath

        public java.lang.String getUploadMemberPhotoPath​(java.lang.String login)
      • updateMemberPhoto

        public JcmsResource updateMemberPhoto​(java.lang.String login,
                                              java.io.File file)
        Update a member Photo.
        Parameters:
        login - the login od the member to update
        file - the new photo file (null to delete the previous photo)
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.1
      • whoAmI

        public JcmsResource whoAmI()
                            throws RestException
        Retrieve the MemberResource corresponding to the current logged Member. Useful when authentication is provided by SSO.

              ClientSession clientSession = new ClientSession("http://www.example.com/");
              JcmsApp jcmsApp = new JcmsApp(clientSession);
              JcmsResource memberResource = jcmsApp.whoAmI();
              MemberElement memberDataElement = MemberElement.getFirstMemberElement(memberResource, clientSession);
              String login = memberDataElement.getLogin();
         
        Returns:
        a JcmsResource if member was properly authenticated and its information could be retrieved
        Throws:
        RestException - if authentication could not be processed or if any other network error occured
      • disableMember

        public JcmsResource disableMember​(java.lang.String login)
        Call to the member resource, given its login, with action disable.
        Parameters:
        login - the login of the member to disable
        Returns:
        the resource corresponding to request
      • enableMember

        public JcmsResource enableMember​(java.lang.String login,
                                         java.lang.String password)
        Call to the member resource, given its login, with action enable, and with the password given in parameter (in post).
        Parameters:
        login - the login of the member to enable
        password - the new password : mandatory to activate the member
        Returns:
        the resource corresponding to request
      • getIdFromLogin

        public java.lang.String getIdFromLogin​(java.lang.String login)
        High level method. Return the id of a member, given its login. The member must not be desactivated.
        Parameters:
        login -
        Returns:
        the JCMS id bound to this login, null if it is not possible to get it.
      • getDataTypePath

        public java.lang.String getDataTypePath​(java.lang.String typeshortclassname)
      • getAllDataTypePath

        public java.lang.String getAllDataTypePath()
      • getAllWorkflowsPath

        public java.lang.String getAllWorkflowsPath()
      • getWorkflowPath

        public java.lang.String getWorkflowPath​(java.lang.String wfId)
      • getAdminStatusPath

        public java.lang.String getAdminStatusPath()
      • getCreateDataPath

        public java.lang.String getCreateDataPath​(java.lang.String dataTypeClassShortName)
        Retrieve the REST path to use to create a new instance of the specified class
        Parameters:
        dataTypeClassShortName - type of the data to be created
        Returns:
        the path.
      • createData

        public JcmsResource createData​(java.lang.String dataTypeClassShortName,
                                       org.restlet.data.Form fields)
        Create a data of type given by the dataTypeClassShortName and the values set in the form fields.
        Parameters:
        dataTypeClassShortName - type of the data to be created
        fields - values to create the new data
        Returns:
        the JcmsResource corresponding to the creation. The resource of the data is in the "Location" Header field.
      • createData

        public JcmsResource createData​(java.lang.String dataTypeClassShortName,
                                       org.restlet.data.Form fields,
                                       Authentication forcedAuthentication)
        Create a data of type given by the dataTypeClassShortName and the values set in the form fields.
        Parameters:
        dataTypeClassShortName - type of the data to be created
        fields - values to create the new data
        forcedAuthentication - possible authenticatio nto use for this request
        Returns:
        the JcmsResource corresponding to the creation. The resource of the data is in the "Location" Header field.
      • updateData

        public JcmsResource updateData​(java.lang.String dataId,
                                       org.restlet.data.Form fields)
      • updateData

        public JcmsResource updateData​(org.restlet.data.Reference dataRef,
                                       org.restlet.data.Form fields)
      • updateData

        public JcmsResource updateData​(java.lang.String dataId,
                                       org.restlet.data.Form fields,
                                       Authentication forcedAuthentication)
      • updateData

        public JcmsResource updateData​(org.restlet.data.Reference dataRef,
                                       org.restlet.data.Form fields,
                                       Authentication forcedAuthentication)
      • deleteData

        public JcmsResource deleteData​(java.lang.String dataId)
      • deleteData

        public JcmsResource deleteData​(org.restlet.data.Reference dataRef)
      • getCreateFileDocumentPath

        public java.lang.String getCreateFileDocumentPath()
        Deprecated.
        Gives the URI of the creation of a FileDocument.
        Returns:
        the URI
        Since:
        JCMS-6.1
      • getCreateDBFileDocumentPath

        public java.lang.String getCreateDBFileDocumentPath()
        Deprecated.
        Gives the URI of the creation of a DBFileDocument.
        Returns:
        the URI
        Since:
        JCMS-6.2
      • createFileDocument

        public JcmsResource createFileDocument​(java.lang.String filename,
                                               java.io.File file,
                                               org.restlet.data.Form parameters)
        Create a FileDocument wrapping the file with the filename and the values set in the form fields.
        Parameters:
        filename - the filename
        file - the file
        parameters - others parameters as set in DocUploadHandler
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.1
      • createFileDocument

        public JcmsResource createFileDocument​(java.io.File file,
                                               org.restlet.data.Form parameters)
        Create a FileDocument wrapping the file with the filename and the values set in the form fields.
        Parameters:
        file - the file
        parameters - others parameters as set in DocUploadHandler
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.1.2
      • createDBFileDocument

        public JcmsResource createDBFileDocument​(java.io.File file,
                                                 org.restlet.data.Form parameters)
        Create a DBFileDocument wrapping the file with the filename and the values set in the form fields.
        Parameters:
        file - the file
        parameters - others parameters as set in DocUploadHandler
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.2
      • createDocument

        public JcmsResource createDocument​(java.lang.String documentTypeClassShortName,
                                           java.lang.String filename,
                                           java.io.File file,
                                           org.restlet.data.Form parameters,
                                           java.io.File importDataXmlFile)
        Create a custom FileDocument instance of the specified class, wrapping the file with the filename and the values set in the form fields.
        Parameters:
        documentTypeClassShortName - the (eg: "FileDocument", "DBFileDocument", "MYCustomDocument")
        filename - the filename
        file - the file
        parameters - others parameters as set in DocUploadHandler
        importDataXmlFile - an optional XML file, resulting from an XML export in JCMS, to populate the fields of the document to create
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-9.0
      • getUpdateFileDocumentPath

        public java.lang.String getUpdateFileDocumentPath​(java.lang.String id)
        Gives the URI of the update of a FileDocument.
        Parameters:
        id - the id of the given FileDocument
        Returns:
        the URI
        Since:
        JCMS-6.1
      • updateFileDocument

        public JcmsResource updateFileDocument​(java.lang.String id,
                                               java.lang.String filename,
                                               java.io.File file,
                                               org.restlet.data.Form parameters)
        Update a FileDocument.
        Parameters:
        id - the id of the FileDocument
        filename - the filename
        file - the file
        parameters - others parameters as set in DocUploadHandler
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.1
      • updateFileDocument

        public JcmsResource updateFileDocument​(org.restlet.data.Reference dataRef,
                                               java.lang.String filename,
                                               java.io.File file,
                                               org.restlet.data.Form parameters)
        Update a FileDocument.
        Parameters:
        dataRef - the reference of the FileDocument
        filename - the filename
        file - the file
        parameters - others parameters as set in DocUploadHandler
        Returns:
        the JcmsResource wrapping the HTTP response.
        Since:
        JCMS-6.1
      • lock

        public JcmsResource lock​(java.lang.String fileDocId)
        Call to the FileDocument resource, given the id of the FileDocument, with action lock.
        Parameters:
        fileDocId - the id of the FileDocument
        Returns:
        the resource corresponding to request
        Since:
        jcms-6.1.0
      • lock

        public JcmsResource lock​(org.restlet.data.Reference fileDocRef)
        Call to the FileDocument resource, given the id of the FileDocument, with action lock.
        Parameters:
        fileDocRef - the Reference of the FileDocument
        Returns:
        the resource corresponding to request
        Since:
        jcms-6.1.0
      • unlock

        public JcmsResource unlock​(java.lang.String fileDocId)
        Call to the FileDocument resource, given the id of the FileDocument, with action unlock.
        Parameters:
        fileDocId - the id of the FileDocument
        Returns:
        the resource corresponding to request
        Since:
        jcms-6.1.0
      • unlock

        public JcmsResource unlock​(org.restlet.data.Reference fileDocRef)
        Call to the FileDocument resource, given the id of the FileDocument, with action unlock.
        Parameters:
        fileDocRef - the Reference of the FileDocument
        Returns:
        the resource corresponding to request
        Since:
        jcms-6.1.0
      • disableDataWrite

        public JcmsResource disableDataWrite​(java.lang.String msg)
      • enableDataWrite

        public JcmsResource enableDataWrite​(java.lang.String msg)
      • importDataFromSource

        public JcmsResource importDataFromSource​(java.lang.String importSourceId)
      • importDataFromSource

        public JcmsResource importDataFromSource​(java.lang.String importSourceId,
                                                 Authentication forcedAuthentication)
      • getRootCategoryData

        public JcmsResource getRootCategoryData()
                                         throws RestException
        Gives the root of JCMS categories, if it is visible for the loggedMember.
        Returns:
        the JcmsResource wrapping the response
        Throws:
        RestException
      • getRootCategory

        public DataElement getRootCategory()
        Gives the root of JCMS categories, if it is visible for the loggedMember.
        Returns:
        root of JCMS categories as a DataElement
      • getRootCategoryData

        public JcmsResource getRootCategoryData​(Authentication forcedAuthentication,
                                                Relateds relateds)
                                         throws RestException
        Gives the root of JCMS categories, if it is visible for the loggedMember.
        Parameters:
        forcedAuthentication -
        relateds -
        Returns:
        the JcmsResource wrapping the response
        Throws:
        RestException
      • getRootCategory

        public DataElement getRootCategory​(Authentication forcedAuthentication,
                                           Relateds relateds)
        Gives the root of JCMS categories, if it is visible for the loggedMember.
        Parameters:
        forcedAuthentication -
        relateds -
        Returns:
        root of JCMS categories as a DataElement
      • getDefaultWorkspaceData

        public JcmsResource getDefaultWorkspaceData()
                                             throws RestException
        Gives the default Workspace of JCMS, if it is visible for the loggedMember.
        Returns:
        the JcmsResource wrapping the response
        Throws:
        RestException
      • getDefaultWorkspace

        public DataElement getDefaultWorkspace()
        Gives the default Workspace of JCMS, if it is visible for the loggedMember.
        Returns:
        the default workspace, as a DataElement
      • getDefaultWorkspaceData

        public JcmsResource getDefaultWorkspaceData​(Authentication forcedAuthentication,
                                                    Relateds relateds)
                                             throws RestException
        Gives the default Workspace of JCMS, if it is visible for the loggedMember.
        Parameters:
        forcedAuthentication -
        relateds -
        Returns:
        the JcmsResource wrapping the response
        Throws:
        RestException
      • getDefaultWorkspace

        public DataElement getDefaultWorkspace​(Authentication forcedAuthentication,
                                               Relateds relateds)
        Gives the default Workspace of JCMS, if it is visible for the loggedMember.
        Parameters:
        forcedAuthentication -
        relateds -
        Returns:
        the default workspace, as a DataElement