Class FileService
- java.lang.Object
-
- org.pentaho.platform.web.http.api.resources.services.FileService
-
public class FileService extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FileService.DownloadFileWrapper
static class
FileService.InvalidNameException
class
FileService.RepositoryFileToStreamWrapper
-
Field Summary
Fields Modifier and Type Field Description protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService
defaultUnifiedRepositoryWebService
static Integer
MODE_NO_OVERWRITE
static Integer
MODE_OVERWRITE
static Integer
MODE_RENAME
protected org.pentaho.platform.api.engine.IAuthorizationPolicy
policy
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository
repository
protected SessionResource
sessionResource
protected org.pentaho.platform.repository.RepositoryDownloadWhitelist
whitelist
-
Constructor Summary
Constructors Constructor Description FileService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addAdminRole(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto fileAcl)
boolean
canRestoreToFolderWithNoConflicts(String pathToFolder, String params)
int
copy(InputStream input, OutputStream output)
void
createFile(String charsetName, String pathId, InputStream fileContents)
Creates a new file with the provided contents at a given pathprotected String
decode(String folder)
boolean
doCanAdminister()
Checks whether the current user can administer the platform.void
doCopyFiles(String pathId, Integer mode, String params)
Copy files to a new locationboolean
doCreateDir(String pathId)
Deprecated.usedoCreateDirSafe(String)
insteadboolean
doCreateDirSafe(String pathId)
Creates a new folder withpathId
as name if it does not contain reserved characters.void
doDeleteFiles(String params)
Moves the list of files to the user's trash foldervoid
doDeleteFilesPermanent(String params)
Permanently deletes the selected list of files from the repositoryvoid
doDeleteLocale(String pathId, String locale)
Delete the locale for the selected file and localeboolean
doesExist(String pathId)
Check whether the selected repository file exist or notString
doGetCanAccess(String pathId, String permissions)
Check whether the current user has specific permission on the selected repository fileList<Setting>
doGetCanAccessList(String pathId, String permissions)
String
doGetCanCreate()
Gets the permission for whether or not a user can create filesString
doGetCanEdit()
Gets the permission for whether or not a user can edit filesList<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto>
doGetChildren(String pathId, String filter, Boolean showHidden, Boolean includeAcls)
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto
doGetContentCreator(String pathId)
Gets the content creator of the specified fileString
doGetDefaultLocation(String pathId)
List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto>
doGetDeletedFiles()
Get deleted filesorg.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto
doGetFileAcl(String pathId)
Retrieves the acls of the selected repository fileFileService.RepositoryFileToStreamWrapper
doGetFileAsInline(String pathId)
Retrieves the file from the repository as inline.List<org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto>
doGetFileLocales(String pathId)
Retrieves the list of locale map for the selected repository file.FileService.RepositoryFileToStreamWrapper
doGetFileOrDir(String pathId)
Takes a pathId and returns a response object with the output stream based on the file located at the pathIDFileService.DownloadFileWrapper
doGetFileOrDirAsDownload(String userAgent, String pathId, String strWithManifest)
List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto>
doGetGeneratedContent(String pathId)
Retrieve the executed contents for a selected repository fileList<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto>
doGetGeneratedContent(String pathId, String user)
Retrieve the executed contents for a selected repository file and a given userString
doGetIsVisible(String pathId)
Check whether the selected repository folder is visible to the current userList<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto>
doGetLocaleProperties(String pathId, String locale)
Retrieve the list of locale properties for a given localeList<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto>
doGetMetadata(String pathId)
Get metadata for a file by path idList<Setting>
doGetPathsAccessList(StringListWrapper pathsWrapper)
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto
doGetProperties(String pathId)
Retrieves the properties of a selected repository fileStringBuffer
doGetReservedCharactersDisplay()
StringBuffer
doGetReservedChars()
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto
doGetRootProperties()
Retrieves the properties of the root directoryorg.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto
doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls)
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto
doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls, Boolean includeSystemFolders)
void
doMoveFiles(String destPathId, String params)
Moves a list of files from its current location to another.boolean
doRename(String pathId, String newName)
Rename the name of the selected filevoid
doRestoreFiles(String params)
Restores a list of files from the user's trash folderboolean
doRestoreFilesInHomeDir(String params, int overwriteMode)
Restores a list of files from the trash folder to user's home folder, ignoring files previous locations (with no change of file owner)void
doSetContentCreator(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto contentCreator)
Store content creator of the selected repository filevoid
doSetLocaleProperties(String pathId, String locale, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> properties)
Set the list of locale properties for a given localevoid
doSetMetadata(String pathId, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> metadata)
Set the metadata on a fileprotected String
escapeJava(String value)
protected Collator
getCollator(int strength)
protected Collator
getCollatorInstance()
protected String
getCommaSeparatedFileIds(List<String> fileIdsList)
protected ExportHandler
getDownloadExportHandler()
protected BaseExportProcessor
getDownloadExportProcessor(String path, boolean requiresZip, boolean withManifest)
protected javax.ws.rs.core.StreamingOutput
getDownloadStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, BaseExportProcessor exportProcessor)
String
getFolderFileIdsThatConflictWithSource(String pathToFolder, String params)
org.pentaho.platform.api.engine.IAuthorizationPolicy
getPolicy()
org.pentaho.platform.api.repository2.unified.IUnifiedRepository
getRepository()
org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream
getRepositoryFileInputStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile)
org.pentaho.platform.repository2.unified.fileio.RepositoryFileOutputStream
getRepositoryFileOutputStream(String path)
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest
getRepositoryRequest(String path, Boolean showHidden, Integer depth, String filter)
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest
getRepositoryRequest(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto, Boolean showHidden, String filter, Boolean includeAcls)
protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService
getRepoWs()
protected org.pentaho.platform.api.engine.IPentahoSession
getSession()
protected SessionResource
getSessionResource()
Gets an instance of SessionResourceprotected String
getSourceFileIdsThatNotConflictWithFolderFiles(String pathToFolder, String params)
Conflict occurs if one of source files has the same name with any of folder files.javax.ws.rs.core.StreamingOutput
getStreamingOutput(InputStream is)
org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto
getStringKeyStringValueDto(String key, String value)
org.pentaho.platform.repository.RepositoryDownloadWhitelist
getWhitelist()
String
idToPath(String pathId)
boolean
isFolder(String pathId)
Check whether the selected repository object is a folder or notboolean
isPath(String pathId)
boolean
isPathValid(String path)
boolean
isShowingTitle(org.pentaho.platform.api.repository2.unified.RepositoryRequest repositoryRequest)
boolean
isValidFileName(String name)
Check if a given name can be used as a file name.boolean
isValidFolderName(String path)
protected List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto>
searchGeneratedContent(String userDir, String targetComparator, String metadataConstant)
void
setFileAcls(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto acl)
Save the acls of the selected file to the repository This method is used to update and save the acls of the selected file to the repositoryvoid
sortByLocaleTitle(Collator collator, List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> repositoryFileDtoList)
void
sortByLocaleTitle(Collator collator, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto tree)
FileService.DownloadFileWrapper
systemBackup(String userAgent)
void
systemRestore(InputStream fileUpload, String overwriteFile, String applyAclSettings, String overwriteAclSettings)
org.pentaho.platform.api.repository2.unified.RepositoryFile
toFile(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto)
protected org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto
toFileDto(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, Set<String> memberSet, boolean exclude)
protected void
validateDownloadAccess(String importDir)
-
-
-
Field Detail
-
MODE_OVERWRITE
public static final Integer MODE_OVERWRITE
-
MODE_RENAME
public static final Integer MODE_RENAME
-
MODE_NO_OVERWRITE
public static final Integer MODE_NO_OVERWRITE
-
policy
protected org.pentaho.platform.api.engine.IAuthorizationPolicy policy
-
defaultUnifiedRepositoryWebService
protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService defaultUnifiedRepositoryWebService
-
repository
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository
-
whitelist
protected org.pentaho.platform.repository.RepositoryDownloadWhitelist whitelist
-
sessionResource
protected SessionResource sessionResource
-
-
Method Detail
-
systemBackup
public FileService.DownloadFileWrapper systemBackup(String userAgent) throws IOException, ExportException
- Throws:
IOException
ExportException
-
systemRestore
public void systemRestore(InputStream fileUpload, String overwriteFile, String applyAclSettings, String overwriteAclSettings) throws PlatformImportException, SecurityException
-
doDeleteFiles
public void doDeleteFiles(String params) throws Exception
Moves the list of files to the user's trash folder Move a list of files to the user's trash folder, the list should be comma separated.- Parameters:
params
- Comma separated list of the files to be deleted- Throws:
Exception
- containing the string, "SystemResource.GENERAL_ERROR"
-
doDeleteFilesPermanent
public void doDeleteFilesPermanent(String params) throws Exception
Permanently deletes the selected list of files from the repository Permanently deletes a comma separated list of files without sending them to the trash folder- Parameters:
params
- Comma separated list of the files to be deleted- Throws:
Exception
-
doDeleteLocale
public void doDeleteLocale(String pathId, String locale) throws Exception
Delete the locale for the selected file and locale- Parameters:
pathId
- Colon separated path for the repository filelocale
- The locale to be deleted- Throws:
Exception
- containing the string, "SystemResource.GENERAL_ERROR"
-
doGetPathsAccessList
public List<Setting> doGetPathsAccessList(StringListWrapper pathsWrapper)
-
createFile
public void createFile(String charsetName, String pathId, InputStream fileContents) throws Exception
Creates a new file with the provided contents at a given path- Parameters:
pathId
- (colon separated path for the repository file)fileContents
- (content of the file)- Throws:
IOException
Exception
-
doMoveFiles
public void doMoveFiles(String destPathId, String params) throws FileNotFoundException
Moves a list of files from its current location to another. Moves a list of files from its current location to another, the list should be comma separated.- Parameters:
destPathId
- colon separated path for the repository file:path:to:file:id
params
- comma separated list of files to be movedpath1,path2,...
- Throws:
FileNotFoundException
-
doRestoreFiles
public void doRestoreFiles(String params) throws InternalError
Restores a list of files from the user's trash folder Restores a list of files from the user's trash folder to their previous locations. The list should be comma separated.- Parameters:
params
- Comma separated list of files to be restored- Throws:
Exception
- containing the string, "SystemResource.GENERAL_ERROR"InternalError
-
doRestoreFilesInHomeDir
public boolean doRestoreFilesInHomeDir(String params, int overwriteMode)
Restores a list of files from the trash folder to user's home folder, ignoring files previous locations (with no change of file owner)- Parameters:
params
- Comma separated list of files to be restoredoverwriteMode
- 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.
-
getFolderFileIdsThatConflictWithSource
public String getFolderFileIdsThatConflictWithSource(String pathToFolder, String params)
-
getSourceFileIdsThatNotConflictWithFolderFiles
protected String getSourceFileIdsThatNotConflictWithFolderFiles(String pathToFolder, String params)
Conflict occurs if one of source files has the same name with any of folder files.- Parameters:
params
- String with file ids, separated by commapathToFolder
- path to folder- Returns:
- String with file ids of not conflict files, separated by comma
-
getCommaSeparatedFileIds
protected String getCommaSeparatedFileIds(List<String> fileIdsList)
- Parameters:
fileIdsList
- List with file ids.- Returns:
- - String of file ids, separated by comma
- Empty String if
fileIdList
is null or empty
-
doGetFileOrDirAsDownload
public FileService.DownloadFileWrapper doGetFileOrDirAsDownload(String userAgent, String pathId, String strWithManifest) throws Throwable
- Throws:
Throwable
-
doGetFileAsInline
public FileService.RepositoryFileToStreamWrapper doGetFileAsInline(String pathId) throws FileNotFoundException
Retrieves the file from the repository as inline. This is mainly used for css or and dependent files for the html document- Parameters:
pathId
- (colon separated path for the repository file)- Returns:
- RepositoryFileToStreamWrapper
- Throws:
FileNotFoundException
-
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- Parameters:
pathId
- (colon separated path for the repository file)locale
-- Returns:
-
doSetLocaleProperties
public void doSetLocaleProperties(String pathId, String locale, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> properties) throws Exception
Set the list of locale properties for a given locale- Parameters:
pathId
-locale
-properties
-- Throws:
Exception
-
doCopyFiles
public void doCopyFiles(String pathId, Integer mode, String params)
Copy files to a new location- Parameters:
pathId
-mode
-params
-
-
doGetFileOrDir
public FileService.RepositoryFileToStreamWrapper doGetFileOrDir(String pathId) throws FileNotFoundException
Takes a pathId and returns a response object with the output stream based on the file located at the pathID- Parameters:
pathId
- pathId to the file- Returns:
- Response object containing the file stream for the file located at the pathId, along with the mimetype, and file name.
- Throws:
FileNotFoundException
-
setFileAcls
public void setFileAcls(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto acl) throws FileNotFoundException
Save the acls of the selected file to the repository This method is used to update and save the acls of the selected file to the repository- Parameters:
pathId
-pathId
- colon separated path for the repository file:path:to:file:id
acl
- Acl of the repository fileRepositoryFileAclDto
- Throws:
FileNotFoundException
-
doGetIsVisible
public String doGetIsVisible(String pathId)
Check whether the selected repository folder is visible to the current user- Parameters:
pathId
-- Returns:
- true or false
-
isFolder
public boolean isFolder(String pathId)
Check whether the selected repository object is a folder or not- Parameters:
pathId
-- Returns:
- true or false
-
doesExist
public boolean doesExist(String pathId)
Check whether the selected repository file exist or not- Parameters:
pathId
-- Returns:
- true or false
-
doGetDefaultLocation
public String doGetDefaultLocation(String pathId)
- Parameters:
pathId
-- Returns:
- default path to where user can save or open the artifact
-
doGetCanAccess
public String doGetCanAccess(String pathId, String permissions)
Check whether the current user has specific permission on the selected repository file- Parameters:
pathId
-permissions
-- Returns:
-
doGetReservedChars
public StringBuffer doGetReservedChars()
-
doGetReservedCharactersDisplay
public StringBuffer doGetReservedCharactersDisplay()
-
doGetRootProperties
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetRootProperties()
Retrieves the properties of the root directory- Returns:
- file properties object
RepositoryFileDto
for the root directory
-
doGetProperties
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetProperties(String pathId) throws FileNotFoundException
Retrieves the properties of a selected repository file- Parameters:
pathId
-pathId
- colon separated path for the repository file:path:to:file:id
- Returns:
- file properties object
RepositoryFileDto
- Throws:
FileNotFoundException
-
doGetCanEdit
public String doGetCanEdit()
Gets the permission for whether or not a user can edit files- Returns:
- Boolean representing whether or not user can edit files
-
doGetCanCreate
public String doGetCanCreate()
Gets the permission for whether or not a user can create files- Returns:
- Boolean representing whether or not user can create files
-
doGetContentCreator
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetContentCreator(String pathId) throws FileNotFoundException
Gets the content creator of the specified file- Parameters:
pathId
-- Returns:
- Throws:
FileNotFoundException
-
doGetDeletedFiles
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetDeletedFiles()
Get deleted files- Returns:
-
doGetMetadata
public List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> doGetMetadata(String pathId) throws FileNotFoundException
Get metadata for a file by path id- Parameters:
pathId
-- Returns:
- Throws:
FileNotFoundException
-
doSetMetadata
public void doSetMetadata(String pathId, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> metadata) throws GeneralSecurityException
Set the metadata on a file- Parameters:
pathId
-metadata
-- Throws:
GeneralSecurityException
-
toFileDto
protected org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto toFileDto(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, Set<String> memberSet, boolean exclude)
-
toFile
public org.pentaho.platform.api.repository2.unified.RepositoryFile toFile(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto)
-
getWhitelist
public org.pentaho.platform.repository.RepositoryDownloadWhitelist getWhitelist()
-
isPathValid
public boolean isPathValid(String path)
-
isPath
public boolean isPath(String pathId)
-
canRestoreToFolderWithNoConflicts
public boolean canRestoreToFolderWithNoConflicts(String pathToFolder, String params)
- Parameters:
params
- id of files, separated by ','- Returns:
- false if homeFolder has files with names and extension equal to passed files true otherwise
- Throws:
IllegalArgumentException
- ifparams
is null
-
getPolicy
public org.pentaho.platform.api.engine.IAuthorizationPolicy getPolicy()
-
doSetContentCreator
public void doSetContentCreator(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto contentCreator) throws FileNotFoundException
Store content creator of the selected repository file- Parameters:
pathId
- colon separated path for the repository file:path:to:file:id
contentCreator
- repository file<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>
- Throws:
FileNotFoundException
-
doGetFileLocales
public List<org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto> doGetFileLocales(String pathId) throws FileNotFoundException
Retrieves the list of locale map for the selected repository file. The list will be empty if a problem occurs.- Parameters:
pathId
- colon separated path for the repository file:path:to:file:id
- Returns:
List
the list of locales<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>
- Throws:
FileNotFoundException
-
doCanAdminister
public boolean doCanAdminister()
Checks whether the current user can administer the platform. The conditions areRepositoryReadAction
,RepositoryCreateAction
andAdministerSecurityAction
- Returns:
boolean
-
doGetFileAcl
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto doGetFileAcl(String pathId)
Retrieves the acls of the selected repository file- Parameters:
pathId
- (colon separated path for the repository file)- Returns:
RepositoryFileAclDto
-
addAdminRole
protected void addAdminRole(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto fileAcl)
-
doGetTree
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls)
-
doGetTree
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls, Boolean includeSystemFolders)
-
sortByLocaleTitle
public void sortByLocaleTitle(Collator collator, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto tree)
-
doGetGeneratedContent
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContent(String pathId) throws FileNotFoundException
Retrieve the executed contents for a selected repository file- Parameters:
pathId
- the path for the file- Returns:
- list of
repositoryFileDto
- Throws:
FileNotFoundException
- if the file is not found
-
doGetGeneratedContent
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContent(String pathId, String user) throws FileNotFoundException
Retrieve the executed contents for a selected repository file and a given user- Parameters:
pathId
- the path for the fileuser
- the username for the generated content folder- Returns:
- list of
repositoryFileDto
- Throws:
FileNotFoundException
-
searchGeneratedContent
protected List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> searchGeneratedContent(String userDir, String targetComparator, String metadataConstant) throws FileNotFoundException
- Parameters:
userDir
- the user home directorytargetComparator
- the comparator to filtermetadataConstant
- the property used to get the file property to compare- Returns:
- list of
repositoryFileDto
- Throws:
FileNotFoundException
-
getSessionResource
protected SessionResource getSessionResource()
Gets an instance of SessionResource- Returns:
SessionResource
-
doRename
public boolean doRename(String pathId, String newName) throws Exception
Rename the name of the selected file- Parameters:
pathId
- (colon separated path for the repository file)newName
- (New name of the file)- Returns:
- Throws:
Exception
-
doCreateDir
@Deprecated public boolean doCreateDir(String pathId)
Deprecated.usedoCreateDirSafe(String)
insteadCreates a new folder with the specified name- 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:path:to:file
- Returns:
- A jax-rs Response object with the appropriate status code, header, and body.
-
doCreateDirSafe
public boolean doCreateDirSafe(String pathId) throws FileService.InvalidNameException
Creates a new folder withpathId
as name if it does not contain reserved characters. To obtain them, the method callsdoGetReservedChars()
. Additionally, it is checked that folder name is not '.' or '..' and does not contain '/'.- Parameters:
pathId
- the desired path- Returns:
true
if the folder has been created- Throws:
FileService.InvalidNameException
- ifpathId
contains prohibited characters.
-
isValidFolderName
public boolean isValidFolderName(String path)
-
isValidFileName
public boolean isValidFileName(String name)
Check if a given name can be used as a file name.
- Parameters:
name
- the name to be tested- Returns:
true
if the given name is valid for a file andfalse
otherwise
-
getRepoWs
protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService getRepoWs()
-
copy
public int copy(InputStream input, OutputStream output) throws IOException
- Throws:
IOException
-
getRepositoryFileOutputStream
public org.pentaho.platform.repository2.unified.fileio.RepositoryFileOutputStream getRepositoryFileOutputStream(String path)
-
getRepositoryFileInputStream
public org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream getRepositoryFileInputStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getStreamingOutput
public javax.ws.rs.core.StreamingOutput getStreamingOutput(InputStream is)
-
getStringKeyStringValueDto
public org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto getStringKeyStringValueDto(String key, String value)
-
getRepository
public org.pentaho.platform.api.repository2.unified.IUnifiedRepository getRepository()
-
getSession
protected org.pentaho.platform.api.engine.IPentahoSession getSession()
-
getDownloadExportProcessor
protected BaseExportProcessor getDownloadExportProcessor(String path, boolean requiresZip, boolean withManifest)
-
getDownloadExportHandler
protected ExportHandler getDownloadExportHandler()
-
getDownloadStream
protected javax.ws.rs.core.StreamingOutput getDownloadStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, BaseExportProcessor exportProcessor) throws ExportException, IOException
- Throws:
ExportException
IOException
-
getRepositoryRequest
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest getRepositoryRequest(String path, Boolean showHidden, Integer depth, String filter)
-
getCollatorInstance
protected Collator getCollatorInstance()
-
doGetChildren
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetChildren(String pathId, String filter, Boolean showHidden, Boolean includeAcls)
-
isShowingTitle
public boolean isShowingTitle(org.pentaho.platform.api.repository2.unified.RepositoryRequest repositoryRequest)
-
sortByLocaleTitle
public void sortByLocaleTitle(Collator collator, List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> repositoryFileDtoList)
-
getRepositoryRequest
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest getRepositoryRequest(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto, Boolean showHidden, String filter, Boolean includeAcls)
-
getCollator
protected Collator getCollator(int strength)
-
validateDownloadAccess
protected void validateDownloadAccess(String importDir) throws org.pentaho.platform.api.engine.PentahoAccessControlException
- Throws:
org.pentaho.platform.api.engine.PentahoAccessControlException
-
-