Class FileResource

java.lang.Object
org.pentaho.platform.web.http.api.resources.AbstractJaxRSResource
org.pentaho.platform.web.http.api.resources.FileResource

public class FileResource extends AbstractJaxRSResource
This service provides methods for listing, creating, downloading, uploading, and removal of files.
Author:
aaron
  • Field Details

    • APPLICATION_ZIP

      public static final String APPLICATION_ZIP
      See Also:
    • REPOSITORY_ADMIN_USERNAME

      public static final String REPOSITORY_ADMIN_USERNAME
      See Also:
    • logger

      protected static final org.apache.commons.logging.Log logger
    • fileService

      protected FileService fileService
    • whitelist

      protected org.pentaho.platform.repository.RepositoryDownloadWhitelist whitelist
    • repository

      protected static org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository
    • repoWs

      protected static org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService repoWs
    • policy

      protected static org.pentaho.platform.api.engine.IAuthorizationPolicy policy
    • mimeResolver

      protected org.pentaho.platform.api.mimetype.IPlatformMimeResolver mimeResolver
  • Constructor Details

    • FileResource

      public FileResource()
    • FileResource

      public FileResource(javax.servlet.http.HttpServletResponse httpServletResponse)
  • Method Details

    • idToPath

      public static String idToPath(String pathId)
    • systemBackup

      public javax.ws.rs.core.Response systemBackup(@HeaderParam("user-agent") String userAgent)
      Performs a system back up of the Pentaho system. This includes content, schedules, users, roles, datasources, and the metastore.

      Example Request:
      GET pentaho/api/repo/files/backup

      Parameters:
      userAgent - A string representing the type of browser to use. Currently only applicable if contains 'FireFox' as FireFox requires a header with encoding information (UTF-8) and a quoted filename, otherwise encoding information is not supplied and the filename is not quoted.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

            Encrypted file stream
          
    • systemRestore

      public javax.ws.rs.core.Response systemRestore(InputStream fileUpload, String overwriteFile, String applyAclSettings, String overwriteAclSettings)
      Performs a system restore of the Hitachi Vantara system. This includes content, schedules, users, roles, datasources, and the metastore.

      Example Request:
      POST pentaho/api/repo/files/systemRestore

      Parameters:
      fileUpload - The zip file generated using the backup endpoint, used to do a full system restore.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doDeleteFiles

      public javax.ws.rs.core.Response doDeleteFiles(String params)
      Move a list of files to the user's trash folder.

      Example Request:
      PUT pentaho/api/repo/files/delete

      Important Note: This end-point is not intended for concurrent execution by the same user or session. It facilitates the User Console deletion UI, and should not be used in a manner inconsistent with how that UI operates.
      Parameters:
      params - Comma separated list of the files to be moved to trash folder.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doDeleteFilesPermanent

      public javax.ws.rs.core.Response doDeleteFilesPermanent(String params)
      Permanently deletes the selected list of files from the repository.

      Example Request:
      PUT pentaho/api/repo/files/deletepermanent

      Important Note: This end-point is not intended for concurrent execution by the same user or session. It facilitates the User Console deletion UI, and should not be used in a manner inconsistent with how that UI operates.
      Parameters:
      params - Comma separated list of the files to be deleted.
      Returns:
      Server Response indicating the success of the operation.
    • doMove

      public javax.ws.rs.core.Response doMove(String destPathId, String params)
      Moves a list of files from its current location to another.

      Example Request:
      PUT pentaho/api/repo/files/{pathId}/move

      Parameters:
      destPathId - Colon separated path for the destination path.
      params - Comma separated list of files to be moved.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doRestore

      public javax.ws.rs.core.Response doRestore(String params, Integer mode)
      Restores a list of files from the user's trash folder to their previous locations.

      Example Request:
      PUT pentaho/api/repo/files/restore - restore files to original location PUT pentaho/api/repo/files/restore?overwriteMode=2 - restore files to user home folder, RENAME mode

      Parameters:
      params - comma separated list of file ids to be restored.
      mode - needed only when restoring files to user home folder, representing which type of overwrite mode to use. Can be one of this values: MODE_OVERWRITE (1) - will just replace existing RENAME (2) - adds a number to the end of the file name. MODE_NO_OVERWRITE (3) - will not overwrite if file exist. null - no overwrite mode
    • createFile

      public javax.ws.rs.core.Response createFile(String pathId, InputStream fileContents)
      Creates a new file with the provided contents at a given path.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml
      PUT data:

          This PUT body does not contain data.
        

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      fileContents - An Input Stream with the contents of the file to be created.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doCopyFiles

      public javax.ws.rs.core.Response doCopyFiles(String pathId, Integer mode, String params)
      Copy selected list of files to a new specified location.

      Example Request:
      PUT pentaho/api/repo/files/{pathId}/children?mode=2

      Parameters:
      pathId - Colon separated path for the destination for files to be copied.
      mode - Default is RENAME (2) which adds a number to the end of the file name. MODE_OVERWRITE (1) will just replace existing or MODE_NO_OVERWRITE (3) will not copy if file exist.
      params - Comma separated list of file ids to be copied.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doGetFileOrDir

      public javax.ws.rs.core.Response doGetFileOrDir(String pathId)
      Takes a pathId and returns a Response with the output stream based on the file located at the pathId.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml

      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doGetDirAsZip

      public javax.ws.rs.core.Response doGetDirAsZip(String pathId)
    • doGetDirAsZip

      public javax.ws.rs.core.Response doGetDirAsZip(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile)
      Parameters:
      repositoryFile -
      Returns:
    • doIsParameterizable

      public String doIsParameterizable(String pathId) throws FileNotFoundException
      Determines whether a selected file supports parameters or not
      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      ("true" or "false")
      Throws:
      FileNotFoundException
    • doGetFileOrDirAsDownload

      public javax.ws.rs.core.Response doGetFileOrDirAsDownload(@HeaderParam("user-agent") String userAgent, String pathId, String strWithManifest)
      Download the selected file or folder from the repository. In order to download file from the repository, the user needs to have Publish action. How the file comes down to the user and where it is saved is system and browser dependent.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/download?locale=de

      Parameters:
      pathId - Colon separated path for the repository file.
      strWithManifest - true or false (download file with manifest). Defaults to true (include manifest) if this string can't be directly parsed to 'false' (case sensitive). This argument is only used if a directory is being downloaded.
      userAgent - A string representing the type of browser to use. Currently only applicable if contains 'FireFox' as FireFox requires a header with encoding information (UTF-8) and a quoted filename, otherwise encoding information is not supplied and the filename is not quoted.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

            Encrypted file stream
          
    • doGetFileAsInline

      public javax.ws.rs.core.Response doGetFileAsInline(String pathId)
      Retrieves the file from the repository as inline. This is mainly used for css and dependent files for the html document.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/inline

      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
          
    • setFileAcls

      public javax.ws.rs.core.Response setFileAcls(String pathId, StreamSource aclXml)
      This method is used to update and save the acls of the selected file to the repository.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
      PUT data:

          <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
        

      Parameters:
      pathId - Colon separated path for the repository file.
      aclXml - Acl of the repository file RepositoryFileAclDto.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • setFileAcls

      public javax.ws.rs.core.Response setFileAcls(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto acl)
      This method is used to update and save the acls of the selected file to the repository.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl
      PUT data:

          <?xml version="1.0" encoding="UTF-8" standalone="yes"?><repositoryFileAclDto><entriesInheriting>true</entriesInheriting><id>d45d4972-989e-48d5-8bd0-f7024a77f08f</id><owner>admin</owner><ownerType>0</ownerType></repositoryFileAclDto>
        

      Parameters:
      pathId - Colon separated path for the repository file.
      acl - Acl of the repository file RepositoryFileAclDto.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • getSecureXmlStreamReader

      protected XMLStreamReader getSecureXmlStreamReader(StreamSource xmlSource) throws XMLStreamException
      Throws:
      XMLStreamException
    • getUnmarshaller

      protected javax.xml.bind.Unmarshaller getUnmarshaller(Class<?> clazz) throws javax.xml.bind.JAXBException
      Throws:
      javax.xml.bind.JAXBException
    • doSetContentCreator

      public javax.ws.rs.core.Response doSetContentCreator(String pathId, StreamSource contentCreatorXml)
      Store content creator for the given path of created content.
      Parameters:
      pathId - colon separated path for the repository file that was created by the contenCreator below
                             :path:to:file:id
                             
      contentCreatorXml - Repository file that created the file at the above pathId location
                             <repositoryFileDto>
                             <createdDate>1402911997019</createdDate>
                             <fileSize>3461</fileSize>
                             <folder>false</folder>
                             <hidden>false</hidden>
                             <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id>
                             <lastModifiedDate>1406647160536</lastModifiedDate>
                             <locale>en</locale>
                             <localePropertiesMapEntries>
                             <localeMapDto>
                             <locale>default</locale>
                             <properties>
                             <stringKeyStringValueDto>
                             <key>file.title</key>
                             <value>myFile</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>jcr:primaryType</key>
                             <value>nt:unstructured</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>title</key>
                             <value>myFile</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>file.description</key>
                             <value>myFile Description</value>
                             </stringKeyStringValueDto>
                             </properties>
                             </localeMapDto>
                             </localePropertiesMapEntries>
                             <locked>false</locked>
                             <name>myFile.prpt</name></name>
                             <originalParentFolderPath>/public/admin</originalParentFolderPath>
                             <ownerType>-1</ownerType>
                             <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path>
                             <title>myFile</title>
                             <versionId>1.9</versionId>
                             <versioned>true</versioned>
                             </repositoryFileAclDto>
                             
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doSetContentCreator

      public javax.ws.rs.core.Response doSetContentCreator(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto contentCreator)
      Store content creator for the given path of created content.
      Parameters:
      pathId - colon separated path for the repository file that was created by the contenCreator below
                             :path:to:file:id
                             
      contentCreator - Repository file that created the file at the above pathId location
                             <repositoryFileDto>
                             <createdDate>1402911997019</createdDate>
                             <fileSize>3461</fileSize>
                             <folder>false</folder>
                             <hidden>false</hidden>
                             <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id>
                             <lastModifiedDate>1406647160536</lastModifiedDate>
                             <locale>en</locale>
                             <localePropertiesMapEntries>
                             <localeMapDto>
                             <locale>default</locale>
                             <properties>
                             <stringKeyStringValueDto>
                             <key>file.title</key>
                             <value>myFile</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>jcr:primaryType</key>
                             <value>nt:unstructured</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>title</key>
                             <value>myFile</value>
                             </stringKeyStringValueDto>
                             <stringKeyStringValueDto>
                             <key>file.description</key>
                             <value>myFile Description</value>
                             </stringKeyStringValueDto>
                             </properties>
                             </localeMapDto>
                             </localePropertiesMapEntries>
                             <locked>false</locked>
                             <name>myFile.prpt</name></name>
                             <originalParentFolderPath>/public/admin</originalParentFolderPath>
                             <ownerType>-1</ownerType>
                             <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path>
                             <title>myFile</title>
                             <versionId>1.9</versionId>
                             <versioned>true</versioned>
                             </repositoryFileAclDto>
                             
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.
    • doGetFileLocales

      public List<org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto> doGetFileLocales(String pathId)
      Retrieves the list of locale maps for the selected repository file.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/locales

      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      List the list of locales.

      Example Response:

          <localePropertiesMapEntries>
          <localeMapDto>
          <locale>default</locale>
          <properties>
          <stringKeyStringValueDto>
          <key>file.title</key>
          <value>myFile</value>
          </stringKeyStringValueDto>
          <stringKeyStringValueDto>
          <key>jcr:primaryType</key>
          <value>nt:unstructured</value>
          </stringKeyStringValueDto>
          <stringKeyStringValueDto>
          <key>title</key>
          <value>myFile</value>
          </stringKeyStringValueDto>
          <stringKeyStringValueDto>
          <key>file.description</key>
          <value>myFile Description</value>
          </stringKeyStringValueDto>
          </properties>
          </localeMapDto>
          </localePropertiesMapEntries>
        
    • doGetLocaleProperties

      public List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> doGetLocaleProperties(String pathId, String locale)
      Retrieve the list of locale properties for a given locale.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja

      Parameters:
      pathId - Colon separated path for the repository file.
      locale - The specified locale.
      Returns:
      A list of locale properties.

      Example Response:

          <stringKeyStringValueDtoes>
          <stringKeyStringValueDto>
          <key>file.title</key>
          <value>File Title</value>
          </stringKeyStringValueDto>
          <stringKeyStringValueDto>
          <key>jcr:primaryType</key>
          <value>nt:unstructured</value>
          </stringKeyStringValueDto>
          <stringKeyStringValueDto>
          <key>title</key>
          <value>File Title</value>
          </stringKeyStringValueDto>
          </stringKeyStringValueDtoes>
        
    • doSetLocaleProperties

      public javax.ws.rs.core.Response doSetLocaleProperties(String pathId, String locale, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> properties)
      Save list of locale properties for a given locale.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/localeProperties?locale=ja
      PUT data:

          <?xml version="1.0" encoding="UTF-8" standalone="yes"?><stringKeyStringValueDtoes><stringKeyStringValueDto><key>file.title</key><value>チャート選択リスト</value></stringKeyStringValueDto><stringKeyStringValueDto><key>jcr:primaryType</key><value>nt:unstructured</value></stringKeyStringValueDto><stringKeyStringValueDto><key>file.description</key><value>複数のチャートタイプを表示します</value></stringKeyStringValueDto></stringKeyStringValueDtoes>
        

      Parameters:
      pathId - Colon separated path for the repository file.
      locale - A string representation of the locale to set properties on.
      properties - The list of locale properties.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doDeleteLocale

      public javax.ws.rs.core.Response doDeleteLocale(String pathId, String locale)
      Delete the locale for the selected file.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/deleteLocale?locale=ja
      PUT data:

          This PUT body does not contain data.
        

      Parameters:
      pathId - Colon separated path for the repository file.
      locale - A string representations of the locale to be deleted.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doGetRootProperties

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetRootProperties()
      Retrieves the properties of the root directory.

      Example Request:
      GET pentaho/api/repo/files/properties

      Returns:
      file properties object RepositoryFileDto for the root directory.

      Example Response:

          <repositoryFileDto>
          <createdDate>1406731649407</createdDate>
          <fileSize>-1</fileSize>
          <folder>true</folder>
          <hidden>false</hidden>
          <id>6d93372c-4908-47af-9815-3aa6307e392c</id>
          <locale>en</locale>
          <locked>false</locked>
          <name/>
          <ownerType>-1</ownerType>
          <path>/</path>
          <title/>
          <versioned>false</versioned>
          </repositoryFileDto>
        
    • doGetCanAccessList

      public List<Setting> doGetCanAccessList(String pathId, String permissions)
      Checks whether the current user has permissions to the selected files. This can check for more than one permission at once but will only return true if all permissions checked are valid.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.txt/canAccessMap?permissions=1

      Parameters:
      pathId - Colon separated path for the repository file.
      permissions - Pipe separated permissions to be checked.
      Returns:
      List of permissions for the selected files.

      Example Response:

          {"setting":[{"name":"1","value":"true"}]}
        
    • doGetPathsAccessList

      public List<Setting> doGetPathsAccessList(StringListWrapper pathsWrapper)
      Checks whether the current user has permissions to the provided list of paths.

      Example Request:
      POST pentaho/api/repo/files/pathsAccessList
      POST data:

          <?xml version="1.0" encoding="UTF-8"?>
          <stringListWrapper>
          <strings>/public</strings>
          </stringListWrapper>
        

      Parameters:
      pathsWrapper - Collection of Strings containing the paths to be checked.
      Returns:
      A collection of the permission settings for the paths.

      Example Response:

          <settings>
          <setting>
          <name>
          /public
          </name>
          <value>
          0
          </value>
          </setting>
          <setting>
          <name>
          /public
          </name>
          <value>
          1
          </value>
          </setting>
          </settings>
        
    • doGetCanAccess

      public String doGetCanAccess(String pathId, String permissions)
      Check whether the current user has specific permission on the selected repository file.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/canAccess?permissions=1

      Parameters:
      pathId - Colon separated path for the repository file.
      permissions - Pipe separated list of permissions.
      Returns:
      String "true" if the user has requested permissions on the file, or "false" otherwise.

      Example Response:

            true
          
    • doGetCanAdminister

      public String doGetCanAdminister()
      Checks to see if the current user is an administer of the platform and returns a boolean response.

      Example Request:
      GET pentaho/api/repo/files/canAdminister

      Returns:
      String "true" if the user can administer the platform, or "false" otherwise.

      Example Response:

            true
          
    • doGetReservedChars

      public javax.ws.rs.core.Response doGetReservedChars()
      Returns the list of reserved characters from the repository.

      Example Request:
      GET pentaho/api/repo/files/reservedCharacters

      Returns:
      List of characters that are reserved by the repository.

      Example Response:

        "/ \"
       
    • doGetReservedCharactersDisplay

      public javax.ws.rs.core.Response doGetReservedCharactersDisplay()
      Returns the list of reserved characters from the repository.

      Example Request:
      GET pentaho/api/repo/files/reservedCharactersDisplay

      Returns:
      List of characters that are reserved by the repository.

      Example Response:

        "/, \, \t, \r, \nF"
       
    • doGetCanCreate

      public String doGetCanCreate()
      Checks the users permission to determine if that user can create new content in the repository.

      Example Request:
      GET pentaho/api/repo/files/canCreate

      Returns:
      String "true" if the user can create new content, or "false" otherwise.

      Example Response:

            true
          
    • doGetCanEdit

      public String doGetCanEdit()
      Checks the users permission to determine if that user can edit an existing content in the repository.

      Example Request:
      GET pentaho/api/repo/files/canEdit

      Returns:
      String "true" if the user can edit existing content, or "false" otherwise.

      Example Response:

            true
          
    • doGetFileAcl

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto doGetFileAcl(String pathId)
      Retrieves the ACL settings of the requested repository file in either xml or json format.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/acl

      Parameters:
      pathId - colon separated path for the repository file.
      Returns:
      RepositoryFileAclDto object containing the ACL settings of the requested file.

      Example Response:

          <repositoryFileAclDto>
          <aces>
          <modifiable>true</modifiable>
          <permissions>4</permissions>
          <recipient>admin</recipient>
          <recipientType>0</recipientType>
          </aces>
          <aces>
          <modifiable>false</modifiable>
          <permissions>4</permissions>
          <recipient>Administrator</recipient>
          <recipientType>1</recipientType>
          </aces>
          <entriesInheriting>true</entriesInheriting>
          <id>068390ba-f90d-46e3-8c55-bbe55e24b2fe</id>
          <owner>admin</owner>
          <ownerType>0</ownerType>
          </repositoryFileAclDto>
        
    • doGetProperties

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetProperties(String pathId)
      Retrieves the properties of a selected repository file.

      Example Request:
      GET pentaho/api/repo/files/:/properties

      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      A RepositoryDto object containing the properties for the given file.

      Example Response:

        {
          "createdDate":"1406732545857",
          "description":"description",
          "fileSize":"1234",
          "folder":"false",
          "hidden":"false",
          "id":"fileId",
          "lastModifiedDate":"1406732545858",
          "locale":"en",
          "localePropertiesMapEntries":[
            {
              "locale":"default",
              "properties":[
                {"key":"file.title","value":"afile"},
                {"key":"description","value":"afile.prpti"},
                {"key":"jcr:primaryType","value":"nt:unstructured"},
                {"key":"title","value":"afile"},
                {"key":"file.description","value":"afile.prpti"}
              ]
            }
          ],
          "locked":"false",
          "name":"filename",
          "ownerType":"-1","path":"pathToFile:filename",
          "title":"title","versioned":"false"
        }
       
    • doGetContentCreator

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetContentCreator(String pathId)
      Retrieves the file by creator id
      Parameters:
      pathId - Colon separated path for the destination for files to be copied.
      Returns:
      file properties object RepositoryFileDto
    • doGetGeneratedContent

      public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContent(String pathId)
      Retrieve the list of executed contents for a selected content from the repository.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContent?locale=de

      Parameters:
      pathId - Colon separated path for the destination for files to be copied.
      Returns:
      A list of RepositoryDto objects containing the executed contents for a selected content from the repository.

      Example Response:

        <List>
        <repositoryFileDto>
        <createdDate>1402911997019</createdDate>
        <fileSize>3461</fileSize>
        <folder>false</folder>
        <hidden>false</hidden>
        <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id>
        <lastModifiedDate>1406647160536</lastModifiedDate>
        <locale>en</locale>
        <localePropertiesMapEntries>
        <localeMapDto>
        <locale>default</locale>
        <properties>
        <stringKeyStringValueDto>
        <key>file.title</key>
        <value>myFile</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>jcr:primaryType</key>
        <value>nt:unstructured</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>title</key>
        <value>myFile</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>file.description</key>
        <value>myFile Description</value>
        </stringKeyStringValueDto>
        </properties>
        </localeMapDto>
        </localePropertiesMapEntries>
        <locked>false</locked>
        <name>myFile.prpt</name></name>
        <originalParentFolderPath>/public/admin</originalParentFolderPath>
        <ownerType>-1</ownerType>
        <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path>
        <title>myFile</title>
        <versionId>1.9</versionId>
        <versioned>true</versioned>
        </repositoryFileAclDto>
        </List>
       
    • doGetGeneratedContentForUser

      public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContentForUser(String pathId, String user)
      Retrieve the executed contents for a selected repository file and a given user.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/generatedContentForUser?user=admin

      Parameters:
      pathId - Colon separated path for the destination for files to be copied.
      user - The username for the generated content folder.
      Returns:
      A list of RepositoryDto objects containing the executed contents for a selected file from the repository.

      Example Response:

        <List>
        <repositoryFileDto>
        <createdDate>1402911997019</createdDate>
        <fileSize>3461</fileSize>
        <folder>false</folder>
        <hidden>false</hidden>
        <id>ff11ac89-7eda-4c03-aab1-e27f9048fd38</id>
        <lastModifiedDate>1406647160536</lastModifiedDate>
        <locale>en</locale>
        <localePropertiesMapEntries>
        <localeMapDto>
        <locale>default</locale>
        <properties>
        <stringKeyStringValueDto>
        <key>file.title</key>
        <value>myFile</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>jcr:primaryType</key>
        <value>nt:unstructured</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>title</key>
        <value>myFile</value>
        </stringKeyStringValueDto>
        <stringKeyStringValueDto>
        <key>file.description</key>
        <value>myFile Description</value>
        </stringKeyStringValueDto>
        </properties>
        </localeMapDto>
        </localePropertiesMapEntries>
        <locked>false</locked>
        <name>myFile.prpt</name></name>
        <originalParentFolderPath>/public/admin</originalParentFolderPath>
        <ownerType>-1</ownerType>
        <path>/public/admin/ff11ac89-7eda-4c03-aab1-e27f9048fd38</path>
        <title>myFile</title>
        <versionId>1.9</versionId>
        <versioned>true</versioned>
        </repositoryFileAclDto>
        </List>
       
    • doGetRootTree

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetRootTree(Integer depth, String filter, Boolean showHidden, Boolean includeAcls)
      Retrieve the recursive list of files from root of the repository based on the filters provided.

      Example Request:
      GET pentaho/api/repo/files/tree?showHidden=false&filter=*|FILES&_=1389042244670

      Parameters:
      depth - How many level should the search go.
      filter - Filter to be applied for search. The filter can be broken down into 3 parts; File types, Child Node Filter, and Member Filters. Each part is separated with a pipe (|) character.

      File Types are represented by a word phrase. This phrase is recognized as a file type phrase and processed accordingly. Valid File Type word phrases include "FILES", "FOLDERS", and "FILES_FOLDERS" and denote whether to return files, folders, or both files and folders, respectively.

      The Child Node Filter is a list of allowed names of files separated by the pipe (|) character. Each file name in the filter may be a full name or a partial name with one or more wildcard characters ("*"). The filter does not apply to root node.

      The Member Filter portion of the filter parameter allows the caller to specify which properties of the metadata to return. Member Filters start with "includeMembers=" or "excludeMembers=" followed by a list of comma separated field names that are to be included in, or, excluded from, the list. Valid field names can be found in org.pentaho.platform.repository2.unified.webservices#RepositoryFileAdapter. Omission of a member filter will return all members. It is invalid to both and includeMembers= and an excludeMembers= clause in the same service call.

      showHidden - Include or exclude hidden files from the file list.
      Returns:
      A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title.

      Example Response:

        <repositoryFileTreeDto>
        <children>
        <file>
        <createdDate>1405356318621</createdDate>
        <fileSize>-1</fileSize>
        <folder>true</folder>
        <hidden>false</hidden>
        <id>fileId;/id>
        <locale>en</locale>
        <locked>false</locked>
        <name>admin</name>
        <ownerType>-1</ownerType>
        <path>/path/to/dir</path>
        <title>admin</title>
        <versioned>false</versioned>
        </file>
        </children>
        </repositoryFileTreeDto>
       
    • doGetRootChildren

      public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetRootChildren(String filter, Boolean showHidden, Boolean includeAcls)
      Retrieve a list of child files from the root of the repository.

      Example Request:
      GET pentaho/api/repo/files/children?showHidden=false&filter=*|FILES&_=1389042244670

      Parameters:
      filter - Filter to be applied for search. The filter can be broken down into 3 parts; File types, Child Node Filter, and Member Filters. Each part is separated with a pipe (|) character.

      File Types are represented by a word phrase. This phrase is recognized as a file type phrase and processed accordingly. Valid File Type word phrases include "FILES", "FOLDERS", and "FILES_FOLDERS" and denote whether to return files, folders, or both files and folders, respectively.

      The Child Node Filter is a list of allowed names of files separated by the pipe (|) character. Each file name in the filter may be a full name or a partial name with one or more wildcard characters ("*"). The filter does not apply to root node.

      The Member Filter portion of the filter parameter allows the caller to specify which properties of the metadata to return. Member Filters start with "includeMembers=" or "excludeMembers=" followed by a list of comma separated field names that are to be included in, or, excluded from, the list. Valid field names can be found in org.pentaho.platform.repository2.unified.webservices#RepositoryFileAdapter. Omission of a member filter will return all members. It is invalid to both and includeMembers= and an excludeMembers= clause in the same service call.

      showHidden - Include or exclude hidden files from the file list.
      includeAcls - Include permission information about the file in the output.
      Returns:
      A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title.

      Example Response:

        <repositoryFileTreeDto>
        <children>
        <file>
        <createdDate>1405356318621</createdDate>
        <fileSize>-1</fileSize>
        <folder>true</folder>
        <hidden>false</hidden>
        <id>fileId;/id>
        <locale>en</locale>
        <locked>false</locked>
        <name>admin</name>
        <ownerType>-1</ownerType>
        <path>/path/to/dir</path>
        <title>admin</title>
        <versioned>false</versioned>
        </file>
        </children>
        </repositoryFileTreeDto>
       
    • doGetTree

      public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls, Boolean includeSystemFolders)
      Retrieve the recursive list of children of the selected repository file.

      Example Request:
      GET pentaho/api/repo/files/:public/tree?showHidden=false&filter=*|FILES&_=1389042244670

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      depth - How many level should the search go.
      filter - Filter to be applied for search. The filter can be broken down into 3 parts; File types, Child Node Filter, and Member Filters. Each part is separated with a pipe (|) character.

      File Types are represented by a word phrase. This phrase is recognized as a file type phrase and processed accordingly. Valid File Type word phrases include "FILES", "FOLDERS", and "FILES_FOLDERS" and denote whether to return files, folders, or both files and folders, respectively.

      The Child Node Filter is a list of allowed names of files separated by the pipe (|) character. Each file name in the filter may be a full name or a partial name with one or more wildcard characters ("*"). The filter does not apply to root node.

      The Member Filter portion of the filter parameter allows the caller to specify which properties of the metadata to return. Member Filters start with "includeMembers=" or "excludeMembers=" followed by a list of comma separated field names that are to be included in, or, excluded from, the list. Valid field names can be found in org.pentaho.platform.repository2.unified.webservices#RepositoryFileAdapter. Omission of a member filter will return all members. It is invalid to both and includeMembers= and an excludeMembers= clause in the same service call.

      showHidden - Include or exclude hidden files from the file list.
      includeAcls - Include permission information about the file in the output.
      Returns:
      A RepositoryFileTreeDto object containing the files at the root of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title.

      Example Response:

        <repositoryFileTreeDto>
        <children>
        <file>
        <createdDate>1405356318621</createdDate>
        <fileSize>-1</fileSize>
        <folder>true</folder>
        <hidden>false</hidden>
        <id>fileId;/id>
        <locale>en</locale>
        <locked>false</locked>
        <name>admin</name>
        <ownerType>-1</ownerType>
        <path>/path/to/dir</path>
        <title>admin</title>
        <versioned>false</versioned>
        </file>
        </children>
        </repositoryFileTreeDto>
       
    • doGetChildren

      public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetChildren(String pathId, String filter, Boolean showHidden, Boolean includeAcls)
      Retrieve a list of child files from the selected repository path of the repository.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test/children

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      filter - Filter to be applied for search. The filter can be broken down into 3 parts; File types, Child Node Filter, and Member Filters. Each part is separated with a pipe (|) character.

      File Types are represented by a word phrase. This phrase is recognized as a file type phrase and processed accordingly. Valid File Type word phrases include "FILES", "FOLDERS", and "FILES_FOLDERS" and denote whether to return files, folders, or both files and folders, respectively.

      The Child Node Filter is a list of allowed names of files separated by the pipe (|) character. Each file name in the filter may be a full name or a partial name with one or more wildcard characters ("*"). The filter does not apply to root node.

      The Member Filter portion of the filter parameter allows the caller to specify which properties of the metadata to return. Member Filters start with "includeMembers=" or "excludeMembers=" followed by a list of comma separated field names that are to be included in, or, excluded from, the list. Valid field names can be found in org.pentaho.platform.repository2.unified.webservices#RepositoryFileAdapter. Omission of a member filter will return all members. It is invalid to both and includeMembers= and an excludeMembers= clause in the same service call.

      showHidden - Include or exclude hidden files from the file list.
      includeAcls - Include permission information about the file in the output.
      Returns:
      A RepositoryFileTreeDto object containing the files at the selected repository path of the repository. Will return files but not folders under the "/" folder. The fields returned will include the name, filesize, description, id and title.

      Example Response:

        <repositoryFileTreeDto>
        <children>
        <file>
        <createdDate>1405356318621</createdDate>
        <fileSize>-1</fileSize>
        <folder>true</folder>
        <hidden>false</hidden>
        <id>fileId;/id>
        <locale>en</locale>
        <locked>false</locked>
        <name>admin</name>
        <ownerType>-1</ownerType>
        <path>/path/to/dir</path>
        <title>admin</title>
        <versioned>false</versioned>
        </file>
        </children>
        </repositoryFileTreeDto>
       
    • doGetDeletedFiles

      public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetDeletedFiles()
      Retrieve the list of files in the user's trash folder.

      Example Request:
      GET pentaho/api/repo/files/deleted

      Returns:
      A list of RepositoryDto objects containing the files in the trash folder of the repository.

      Example Response:

        <repositoryFileDtoes>
        <repositoryFileDto>
        <createdDate>1405356406448</createdDate>
        <deletedDate>1406573914167</deletedDate>
        <fileSize>10477</fileSize>
        <folder>false</folder>
        <hidden>false</hidden>
        <id>fileId</id>
        <lastModifiedDate>1405356406448</lastModifiedDate>
        <locale>en</locale>
        <localePropertiesMapEntries>
        <locale>default</locale>
        <properties>
        <key>file.title</key>
        <value>File Title</value>
        </properties>
        <properties>
        <key>jcr:primaryType</key>
        <value>nt:unstructured</value>
        </properties>
        <properties>
        <key>title</key>
        <value>filename</value>
        </properties>
        <properties>
        <key>file.description</key>
        <value />
        </properties>
        </localePropertiesMapEntries>
        <locked>false</locked>
        <name>filename.ext</name>
        <originalParentFolderPath>/original/path/to/file</originalParentFolderPath>
        <ownerType>-1</ownerType>
        <path>/path/to/file</path>
        <title>File Title</title>
        <versionId>1.3</versionId>
        <versioned>true</versioned>
        </repositoryFileDto>
        </repositoryFileDtoes>
       
    • doGetMetadata

      public List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> doGetMetadata(String pathId)
      Retrieve the metadata of the selected file. Even though the hidden flag is a property of the file node itself, and not the metadata child, it is considered metadata from PUC and is included in the setMetadata call.

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

        <stringKeyStringValueDtos>
        <stringKeyStringValueDto>
        <key>KEY<key>
        <value>KEY<value>
        </stringKeyStringValueDto>
        </stringKeyStringValueDtos>
       
    • doRename

      public javax.ws.rs.core.Response doRename(String pathId, String newName)
      Rename the selected file.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/rename?newName=test_file_8
      PUT data:

          This PUT body does not contain data.
        

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      newName - String indicating the new name of the file.
      Returns:
      Response with 200 OK, if the file does not exist to be renamed the response will return 200 OK with the string "File to be renamed does not exist".

      Example Response:

              This response does not contain data.
          
    • doSetMetadata

      public javax.ws.rs.core.Response doSetMetadata(String pathId, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> metadata)
      Store the metadata of the selected file. Even though the hidden flag is a property of the file node itself, and not the metadata child, it is considered metadata from PUC and is included in the setMetadata call.

      Example Request:
      PUT pentaho/api/repo/files/:jmeter-test:test_file_1.xml/metadata
      PUT data:

          <?xml version="1.0" encoding="UTF-8" standalone="yes"?><stringKeyStringValueDtoes><stringKeyStringValueDto><key>metadata.key.1</key><value>metadata.value.1</value></stringKeyStringValueDto></stringKeyStringValueDtoes>
        

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      metadata - A list of StringKeyStringValueDto objects.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doCreateDirs

      public javax.ws.rs.core.Response doCreateDirs(String pathId)
      Creates a new folder with the specified name.

      Example Request:
      PUT pentaho/api/repo/files/:public:jmeter-test-dir/createDir
      PUT data:

          This PUT body does not contain data.
        

      Parameters:
      pathId - The path from the root folder to the root node of the tree to return using colon characters in place of / or \ characters. To clarify /path/to/file, the encoded pathId would be :path:to:file.
      Returns:
      A jax-rs Response object with the appropriate status code, header, and body.

      Example Response:

              This response does not contain data.
          
    • doVersioningConfiguration

      public org.pentaho.platform.repository2.unified.webservices.FileVersioningConfiguration doVersioningConfiguration(String pathId)
      This method is used to determine whether versioning should be active for the given path

      Example Request:
      GET pentaho/api/repo/files/:jmeter-test:test_file_1.ktr/versioningConfiguration

      Parameters:
      pathId - Colon separated path for the repository file.
      Returns:
      The Versioning Configuration applicable to the path submitted

      Example Response:

       <fileVersioningConfiguration>
         <versionCommentEnabled>true</versionCommentEnabled>
         <versioningEnabled>true</versioningEnabled>
       </fileVersioningConfiguration>
        
    • canDownload

      public javax.ws.rs.core.Response canDownload(String dirPath)
      Validates if a current user is authorized to download content from the given dir.

      Example Request:
      GET pentaho/api/repo/files/canDownload

      Parameters:
      dirPath - to be validated for download action for the current user.
      Returns:
      A boolean response based on the current user being authorized to download within the system.

      Example Response:

           false
       
    • canUpload

      public javax.ws.rs.core.Response canUpload(String dirPath)
      Validates if a current user is authorized to upload content to the given dir

      Example Request:
      GET pentaho/api/repo/files/canUpload

      Parameters:
      dirPath - to be validated for upload action for the current user.
      Returns:
      A boolean response based on the current user being authorized to upload to given dir

      Example Response:

           false
       
    • isPathValid

      protected boolean isPathValid(String path)
    • getWhitelist

      public org.pentaho.platform.repository.RepositoryDownloadWhitelist getWhitelist()
    • setWhitelist

      public void setWhitelist(org.pentaho.platform.repository.RepositoryDownloadWhitelist whitelist)
    • getPolicy

      public static org.pentaho.platform.api.engine.IAuthorizationPolicy getPolicy()
    • getRepository

      public static org.pentaho.platform.api.repository2.unified.IUnifiedRepository getRepository()
    • getRepoWs

      public static org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService getRepoWs()
    • setConverterHandler

      public void setConverterHandler(org.pentaho.platform.api.repository2.unified.IRepositoryContentConverterHandler converterHandler)
    • setMimeResolver

      public void setMimeResolver(org.pentaho.platform.api.mimetype.IPlatformMimeResolver mimeResolver)
    • buildOkResponse

      protected javax.ws.rs.core.Response buildOkResponse()
    • buildOkResponse

      protected javax.ws.rs.core.Response buildOkResponse(String msg)
    • buildPlainTextOkResponse

      protected javax.ws.rs.core.Response buildPlainTextOkResponse(String msg)
    • buildStatusResponse

      protected javax.ws.rs.core.Response buildStatusResponse(javax.ws.rs.core.Response.Status status)
    • buildServerErrorResponse

      protected javax.ws.rs.core.Response buildServerErrorResponse(Throwable t)
    • buildServerErrorResponse

      protected javax.ws.rs.core.Response buildServerErrorResponse(String msg)
    • buildSafeHtmlServerErrorResponse

      protected javax.ws.rs.core.Response buildSafeHtmlServerErrorResponse(Exception e)
    • buildOkResponse

      protected javax.ws.rs.core.Response buildOkResponse(FileService.RepositoryFileToStreamWrapper wrapper)
    • buildZipOkResponse

      protected javax.ws.rs.core.Response buildZipOkResponse(FileService.DownloadFileWrapper wrapper)
    • buildOkResponse

      protected javax.ws.rs.core.Response buildOkResponse(Object o, String s)
    • getExporter

      protected Exporter getExporter()
    • getFileInputStream

      protected FileInputStream getFileInputStream(File file) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • getStreamingOutput

      protected javax.ws.rs.core.StreamingOutput getStreamingOutput(InputStream is)
    • hasParameterUi

      protected boolean hasParameterUi(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile)
    • getContentGenerator

      protected org.pentaho.platform.api.engine.IContentGenerator getContentGenerator(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile)
    • getSimpleParameterProvider

      protected org.pentaho.platform.engine.core.solution.SimpleParameterProvider getSimpleParameterProvider()
    • encode

      protected String encode(String s) throws UnsupportedEncodingException
      Throws:
      UnsupportedEncodingException
    • getSession

      protected org.pentaho.platform.api.engine.IPentahoSession getSession()
    • getByteArrayOutputStream

      protected ByteArrayOutputStream getByteArrayOutputStream()
    • parseText

      protected org.dom4j.Document parseText(String text) throws org.dom4j.DocumentException
      Throws:
      org.dom4j.DocumentException
    • getMessagesInstance

      protected Messages getMessagesInstance()
    • getUserHomeFolder

      protected String getUserHomeFolder()