public class FileService extends Object
Modifier and Type | Class and Description |
---|---|
class |
FileService.DownloadFileWrapper |
static class |
FileService.InvalidNameException |
class |
FileService.RepositoryFileToStreamWrapper |
Modifier and Type | Field and 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 and Description |
---|
FileService() |
Modifier and Type | Method and 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 path
|
protected 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 location
|
boolean |
doCreateDir(String pathId)
Deprecated.
use
doCreateDirSafe(String) instead |
protected boolean |
doCreateDirFor(String pathWithSlashes) |
boolean |
doCreateDirSafe(String pathId)
Creates a new folder with
pathId as name if it does not contain reserved characters. |
void |
doDeleteFiles(String params)
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.
|
void |
doDeleteFilesPermanent(String params)
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
|
void |
doDeleteLocale(String pathId,
String locale)
Delete the locale for the selected file and locale
|
String |
doGetCanAccess(String pathId,
String permissions)
Check whether the current user has specific permission on the selected repository file
|
List<Setting> |
doGetCanAccessList(String pathId,
String permissions) |
String |
doGetCanCreate()
Gets the permission for whether or not a user can create files
|
List<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 file
|
List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> |
doGetDeletedFiles()
Get deleted files
|
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto |
doGetFileAcl(String pathId)
Retrieves the acls of the selected repository file
|
FileService.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 pathID
|
FileService.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 file
|
List<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 user
|
List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> |
doGetLocaleProperties(String pathId,
String locale)
Retrieve the list of locale properties for a given locale
|
List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> |
doGetMetadata(String pathId)
Get metadata for a file by path id
|
List<Setting> |
doGetPathsAccessList(StringListWrapper pathsWrapper) |
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto |
doGetProperties(String pathId)
Retrieves the properties of a selected repository file
|
StringBuffer |
doGetReservedCharactersDisplay() |
StringBuffer |
doGetReservedChars() |
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto |
doGetRootProperties()
Retrieves the properties of the root directory
|
org.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 file
|
void |
doRestoreFiles(String params)
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.
|
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)
|
void |
doSetContentCreator(String pathId,
org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto contentCreator)
Store content creator of the selected repository file
|
void |
doSetLocaleProperties(String pathId,
String locale,
List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> properties)
Set the list of locale properties for a given locale
|
void |
doSetMetadata(String pathId,
List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> metadata)
Set the metadata on a file
|
protected 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(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto,
Boolean showHidden,
String filter,
Boolean includeAcls) |
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest |
getRepositoryRequest(String path,
Boolean showHidden,
Integer depth,
String filter) |
protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService |
getRepoWs() |
protected org.pentaho.platform.api.engine.IPentahoSession |
getSession() |
protected SessionResource |
getSessionResource()
Gets an instance of SessionResource
|
protected 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 |
isPath(String pathId) |
boolean |
isPathValid(String path) |
boolean |
isShowingTitle(org.pentaho.platform.api.repository2.unified.RepositoryRequest repositoryRequest) |
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 repository
|
void |
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) |
public static final Integer MODE_OVERWRITE
public static final Integer MODE_RENAME
public static final Integer MODE_NO_OVERWRITE
protected org.pentaho.platform.api.engine.IAuthorizationPolicy policy
protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService defaultUnifiedRepositoryWebService
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository repository
protected org.pentaho.platform.repository.RepositoryDownloadWhitelist whitelist
protected SessionResource sessionResource
public FileService.DownloadFileWrapper systemBackup(String userAgent) throws IOException, ExportException
IOException
ExportException
public void systemRestore(InputStream fileUpload, String overwriteFile, String applyAclSettings, String overwriteAclSettings) throws PlatformImportException, SecurityException
public void doDeleteFiles(String params) throws Exception
params
- Comma separated list of the files to be deletedException
- containing the string, "SystemResource.GENERAL_ERROR"public void doDeleteFilesPermanent(String params) throws Exception
params
- Comma separated list of the files to be deletedException
public void doDeleteLocale(String pathId, String locale) throws Exception
pathId
- Colon separated path for the repository filelocale
- The locale to be deletedException
- containing the string, "SystemResource.GENERAL_ERROR"public List<Setting> doGetPathsAccessList(StringListWrapper pathsWrapper)
public void createFile(String charsetName, String pathId, InputStream fileContents) throws Exception
pathId
- (colon separated path for the repository file)fileContents
- (content of the file)IOException
Exception
public void doMoveFiles(String destPathId, String params) throws FileNotFoundException
destPathId
- colon separated path for the repository file
:path:to:file:id
params
- comma separated list of files to be moved
path1,path2,...
FileNotFoundException
public void doRestoreFiles(String params) throws InternalError
params
- Comma separated list of files to be restoredException
- containing the string, "SystemResource.GENERAL_ERROR"InternalError
public boolean doRestoreFilesInHomeDir(String params, int overwriteMode)
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.public String getFolderFileIdsThatConflictWithSource(String pathToFolder, String params)
protected String getSourceFileIdsThatNotConflictWithFolderFiles(String pathToFolder, String params)
params
- String with file ids, separated by commapathToFolder
- path to folderprotected String getCommaSeparatedFileIds(List<String> fileIdsList)
fileIdsList
- List with file ids.fileIdList
is null or emptypublic FileService.DownloadFileWrapper doGetFileOrDirAsDownload(String userAgent, String pathId, String strWithManifest) throws Throwable
Throwable
public FileService.RepositoryFileToStreamWrapper doGetFileAsInline(String pathId) throws FileNotFoundException
pathId
- (colon separated path for the repository file)FileNotFoundException
public List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> doGetLocaleProperties(String pathId, String locale)
pathId
- (colon separated path for the repository file)locale
- public void doSetLocaleProperties(String pathId, String locale, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> properties) throws Exception
pathId
- locale
- properties
- Exception
public void doCopyFiles(String pathId, Integer mode, String params)
pathId
- mode
- params
- public FileService.RepositoryFileToStreamWrapper doGetFileOrDir(String pathId) throws FileNotFoundException
pathId
- pathId to the fileFileNotFoundException,
- IllegalArgumentExceptionFileNotFoundException
public void setFileAcls(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto acl) throws FileNotFoundException
pathId
- @param pathId colon separated path for the repository file
:path:to:file:id
acl
- Acl of the repository file RepositoryFileAclDto
FileNotFoundException
public String doGetCanAccess(String pathId, String permissions)
pathId
- permissions
- public StringBuffer doGetReservedChars()
public StringBuffer doGetReservedCharactersDisplay()
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetRootProperties()
RepositoryFileDto
for the root directorypublic org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetProperties(String pathId) throws FileNotFoundException
pathId
- @param pathId colon separated path for the repository file
:path:to:file:id
RepositoryFileDto
FileNotFoundException
public String doGetCanCreate()
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto doGetContentCreator(String pathId) throws FileNotFoundException
pathId
- FileNotFoundException
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetDeletedFiles()
public List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> doGetMetadata(String pathId) throws FileNotFoundException
pathId
- FileNotFoundException
public void doSetMetadata(String pathId, List<org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto> metadata) throws GeneralSecurityException
pathId
- metadata
- GeneralSecurityException
protected org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto toFileDto(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, Set<String> memberSet, boolean exclude)
public org.pentaho.platform.api.repository2.unified.RepositoryFile toFile(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto repositoryFileDto)
public org.pentaho.platform.repository.RepositoryDownloadWhitelist getWhitelist()
public boolean isPathValid(String path)
public boolean isPath(String pathId)
public boolean canRestoreToFolderWithNoConflicts(String pathToFolder, String params)
params
- id of files, separated by ','IllegalArgumentException
- if params
is nullpublic org.pentaho.platform.api.engine.IAuthorizationPolicy getPolicy()
public void doSetContentCreator(String pathId, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto contentCreator) throws FileNotFoundException
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>
FileNotFoundException
public List<org.pentaho.platform.api.repository2.unified.webservices.LocaleMapDto> doGetFileLocales(String pathId) throws FileNotFoundException
pathId
- colon separated path for the repository file
:path:to:file:id
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>
FileNotFoundException
public boolean doCanAdminister()
RepositoryReadAction
, RepositoryCreateAction
and
AdministerSecurityAction
boolean
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto doGetFileAcl(String pathId)
pathId
- (colon separated path for the repository file) RepositoryFileAclDto
protected void addAdminRole(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileAclDto fileAcl)
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls)
public org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto doGetTree(String pathId, Integer depth, String filter, Boolean showHidden, Boolean includeAcls, Boolean includeSystemFolders)
public void sortByLocaleTitle(Collator collator, org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto tree)
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContent(String pathId) throws FileNotFoundException
pathId
- the path for the file repositoryFileDto
FileNotFoundException
- if the file is not foundpublic List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetGeneratedContent(String pathId, String user) throws FileNotFoundException
pathId
- the path for the fileuser
- the username for the generated content folder repositoryFileDto
FileNotFoundException
protected List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> searchGeneratedContent(String userDir, String targetComparator, String metadataConstant) throws FileNotFoundException
userDir
- the user home directorytargetComparator
- the comparator to filtermetadataConstant
- the property used to get the file property to compare repositoryFileDto
FileNotFoundException
protected SessionResource getSessionResource()
SessionResource
public boolean doRename(String pathId, String newName) throws Exception
pathId
- (colon separated path for the repository file)newName
- (New name of the file)Exception
@Deprecated public boolean doCreateDir(String pathId)
doCreateDirSafe(String)
insteadpathId
- 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
protected boolean doCreateDirFor(String pathWithSlashes)
public boolean doCreateDirSafe(String pathId) throws FileService.InvalidNameException
pathId
as name if it does not contain reserved characters. To obtain them, the
method calls doGetReservedChars()
. Additionally, it is checked that folder name is not '.' or '..' and
does not contain '/'.pathId
- the desired pathtrue
if the folder has been createdFileService.InvalidNameException
- if pathId
contains prohibited characters.protected org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService getRepoWs()
public int copy(InputStream input, OutputStream output) throws IOException
IOException
public org.pentaho.platform.repository2.unified.fileio.RepositoryFileOutputStream getRepositoryFileOutputStream(String path)
public org.pentaho.platform.repository2.unified.fileio.RepositoryFileInputStream getRepositoryFileInputStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile) throws FileNotFoundException
FileNotFoundException
public javax.ws.rs.core.StreamingOutput getStreamingOutput(InputStream is)
public org.pentaho.platform.api.repository2.unified.webservices.StringKeyStringValueDto getStringKeyStringValueDto(String key, String value)
public org.pentaho.platform.api.repository2.unified.IUnifiedRepository getRepository()
protected org.pentaho.platform.api.engine.IPentahoSession getSession()
protected BaseExportProcessor getDownloadExportProcessor(String path, boolean requiresZip, boolean withManifest)
protected ExportHandler getDownloadExportHandler()
protected javax.ws.rs.core.StreamingOutput getDownloadStream(org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile, BaseExportProcessor exportProcessor) throws ExportException, IOException
ExportException
IOException
protected org.pentaho.platform.api.repository2.unified.RepositoryRequest getRepositoryRequest(String path, Boolean showHidden, Integer depth, String filter)
protected Collator getCollatorInstance()
public List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> doGetChildren(String pathId, String filter, Boolean showHidden, Boolean includeAcls)
public boolean isShowingTitle(org.pentaho.platform.api.repository2.unified.RepositoryRequest repositoryRequest)
public void sortByLocaleTitle(Collator collator, List<org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto> repositoryFileDtoList)
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 Collator getCollator(int strength)
protected void validateDownloadAccess(String importDir) throws org.pentaho.platform.api.engine.PentahoAccessControlException
org.pentaho.platform.api.engine.PentahoAccessControlException
Copyright © 2019 Hitachi Vantara. All rights reserved.