use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetMetadata.
/**
* Get metadata for a file by path id
*
* @param pathId
* @return
*/
public List<StringKeyStringValueDto> doGetMetadata(String pathId) throws FileNotFoundException {
List<StringKeyStringValueDto> list = null;
String path = null;
if (pathId == null || pathId.equals(FileUtils.PATH_SEPARATOR)) {
path = FileUtils.PATH_SEPARATOR;
} else {
if (!pathId.startsWith(FileUtils.PATH_SEPARATOR)) {
path = idToPath(pathId);
}
}
final RepositoryFileDto file = getRepoWs().getFile(path);
if (file == null) {
throw new FileNotFoundException();
}
list = getRepoWs().getFileMetadata(file.getId());
if (list != null) {
boolean hasSchedulable = false;
for (StringKeyStringValueDto value : list) {
if (value.getKey().equals(RepositoryFile.SCHEDULABLE_KEY)) {
hasSchedulable = true;
break;
}
}
if (!hasSchedulable) {
StringKeyStringValueDto schedPerm = new StringKeyStringValueDto(RepositoryFile.SCHEDULABLE_KEY, "true");
list.add(schedPerm);
}
// check file object for hidden value and add it to the list
list.add(new StringKeyStringValueDto(RepositoryFile.HIDDEN_KEY, String.valueOf(file.isHidden())));
}
return list;
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doSetContentCreator.
/**
* Store content creator of the selected repository file
*
* @param pathId colon separated path for the repository file
* <pre function="syntax.xml">
* :path:to:file:id
* </pre>
* @param contentCreator repository file
* <pre function="syntax.xml">
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <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>
* </pre>
* @throws FileNotFoundException
*/
public void doSetContentCreator(String pathId, RepositoryFileDto contentCreator) throws FileNotFoundException {
RepositoryFileDto file = getRepoWs().getFile(idToPath(pathId));
if (file == null) {
throw new FileNotFoundException();
}
try {
Map<String, Serializable> fileMetadata = getRepository().getFileMetadata(file.getId());
fileMetadata.put(PentahoJcrConstants.PHO_CONTENTCREATOR, contentCreator.getId());
getRepository().setFileMetadata(file.getId(), fileMetadata);
} catch (Exception e) {
throw new InternalError();
}
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doSetLocaleProperties.
/**
* Set the list of locale properties for a given locale
*
* @param pathId
* @param locale
* @param properties
*/
public void doSetLocaleProperties(String pathId, String locale, List<StringKeyStringValueDto> properties) throws Exception {
RepositoryFileDto file = getRepoWs().getFile(idToPath(pathId));
Properties fileProperties = new Properties();
if (properties != null && !properties.isEmpty()) {
for (StringKeyStringValueDto dto : properties) {
fileProperties.put(dto.getKey(), dto.getValue());
}
}
getRepoWs().setLocalePropertiesForFileByFileId(file.getId(), locale, fileProperties);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method getFolderFileIdsThatConflictWithSource.
public String getFolderFileIdsThatConflictWithSource(String pathToFolder, String params) {
if (params == null) {
throw new IllegalArgumentException("parameters cannot be null");
}
String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray(params);
List<String> conflictFileIdsList = new ArrayList<>();
List<RepositoryFileDto> homeFolderFiles = doGetChildren(pathToFolder, null, false, true);
for (RepositoryFileDto fileInHomeFolder : homeFolderFiles) {
for (String sourceFileId : sourceFileIds) {
RepositoryFile fileToRestore = getRepository().getFileById(sourceFileId);
if (fileToRestore.getName().equals(fileInHomeFolder.getName())) {
conflictFileIdsList.add(fileInHomeFolder.getId());
}
}
}
return getCommaSeparatedFileIds(conflictFileIdsList);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doMoveFiles.
/**
* Moves a list of files from its current location to another.
* <p/>
* Moves a list of files from its current location to another, the list should be comma separated.
*
* @param destPathId colon separated path for the repository file
* <pre function="syntax.xml">
* :path:to:file:id
* </pre>
* @param params comma separated list of files to be moved
* <pre function="syntax.xml">
* path1,path2,...
* </pre>
*
* @return boolean <code>true</code> if all files were moved correctly or <code>false</code> if the destiny path is
* not available
* @throws FileNotFoundException
*/
public void doMoveFiles(String destPathId, String params) throws FileNotFoundException {
String idToPath = idToPath(destPathId);
RepositoryFileDto repositoryFileDto = getRepoWs().getFile(idToPath);
if (repositoryFileDto == null) {
throw new FileNotFoundException(idToPath);
}
String[] sourceFileIds = FileUtils.convertCommaSeparatedStringToArray(params);
int i = 0;
try {
for (; i < sourceFileIds.length; i++) {
getRepoWs().moveFile(sourceFileIds[i], repositoryFileDto.getPath(), null);
}
} catch (IllegalArgumentException | UnifiedRepositoryAccessDeniedException e) {
throw e;
} catch (Exception e) {
throw new InternalError();
}
}
Aggregations