use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetChildren.
public List<RepositoryFileDto> doGetChildren(String pathId, String filter, Boolean showHidden, Boolean includeAcls) {
List<RepositoryFileDto> repositoryFileDtoList = new ArrayList<RepositoryFileDto>();
RepositoryFileDto repositoryFileDto = getRepoWs().getFile(FileUtils.idToPath(pathId));
if (repositoryFileDto != null && isPathValid(repositoryFileDto.getPath())) {
RepositoryRequest repositoryRequest = getRepositoryRequest(repositoryFileDto, showHidden, filter, includeAcls);
repositoryFileDtoList = getRepoWs().getChildrenFromRequest(repositoryRequest);
// BISERVER-9599 - Use special sort order
if (isShowingTitle(repositoryRequest)) {
Collator collator = getCollator(Collator.PRIMARY);
sortByLocaleTitle(collator, repositoryFileDtoList);
}
}
return repositoryFileDtoList;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetFileAcl.
/**
* Retrieves the acls of the selected repository file
*
* @param pathId (colon separated path for the repository file)
* @return <code> RepositoryFileAclDto </code>
*/
public RepositoryFileAclDto doGetFileAcl(String pathId) {
RepositoryFileDto file = getRepoWs().getFile(FileUtils.idToPath(pathId));
RepositoryFileAclDto fileAcl = getRepoWs().getAcl(file.getId());
if (fileAcl.isEntriesInheriting()) {
List<RepositoryFileAclAceDto> aces = getRepoWs().getEffectiveAcesWithForceFlag(file.getId(), fileAcl.isEntriesInheriting());
fileAcl.setAces(aces, fileAcl.isEntriesInheriting());
}
addAdminRole(fileAcl);
return fileAcl;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method searchGeneratedContent.
/**
* @param userDir the user home directory
* @param targetComparator the comparator to filter
* @param metadataConstant the property used to get the file property to compare
* @return list of <code> repositoryFileDto </code>
* @throws FileNotFoundException
* @private
*/
protected List<RepositoryFileDto> searchGeneratedContent(String userDir, String targetComparator, String metadataConstant) throws FileNotFoundException {
List<RepositoryFileDto> content = new ArrayList<RepositoryFileDto>();
RepositoryFile workspaceFolder = getRepository().getFile(userDir);
if (workspaceFolder != null) {
List<RepositoryFile> children = getRepository().getChildren(workspaceFolder.getId());
for (RepositoryFile child : children) {
if (!child.isFolder()) {
Map<String, Serializable> fileMetadata = getRepository().getFileMetadata(child.getId());
String creatorId = (String) fileMetadata.get(metadataConstant);
if (creatorId != null && creatorId.equals(targetComparator)) {
content.add(toFileDto(child, null, false));
}
}
}
} else {
logger.error(Messages.getInstance().getString("FileResource.WORKSPACE_FOLDER_NOT_FOUND", userDir));
throw new FileNotFoundException(userDir);
}
return content;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method canRestoreToFolderWithNoConflicts.
/**
* @param params
* id of files, separated by ','
*
* @return false if homeFolder has files
* with names and extension equal to passed files
* true otherwise
*
* @throws IllegalArgumentException
* if {@code params} is null
*/
public boolean canRestoreToFolderWithNoConflicts(String pathToFolder, String params) {
if (params == null) {
throw new IllegalArgumentException("parameters cannot be null");
}
List<RepositoryFileDto> filesInFolder = doGetChildren(pathToFolder, null, false, true);
String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray(params);
for (RepositoryFileDto fileInFolder : filesInFolder) {
for (String sourceFileId : sourceFileIds) {
RepositoryFile fileToRestore = getRepository().getFileById(sourceFileId);
if (fileToRestore.getName().equals(fileInFolder.getName())) {
return false;
}
}
}
return true;
}
use of org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetFileLocales.
/**
* Retrieves the list of locale map for the selected repository file. The list will be empty if a problem occurs.
*
* @param pathId colon separated path for the repository file
* <pre function="syntax.xml">
* :path:to:file:id
* </pre>
* @return <code>List<LocaleMapDto></code> the list of locales
* <pre function="syntax.xml">
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <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>
* </pre>
* @throws FileNotFoundException
*/
public List<LocaleMapDto> doGetFileLocales(String pathId) throws FileNotFoundException {
List<LocaleMapDto> availableLocales = new ArrayList<LocaleMapDto>();
RepositoryFileDto file = getRepoWs().getFile(idToPath(pathId));
if (file == null) {
throw new FileNotFoundException();
}
try {
List<PentahoLocale> locales = getRepoWs().getAvailableLocalesForFileById(file.getId());
if (locales != null && !locales.isEmpty()) {
for (PentahoLocale locale : locales) {
availableLocales.add(new LocaleMapDto(locale.toString(), null));
}
}
} catch (Exception e) {
throw new InternalError();
}
return availableLocales;
}
Aggregations