use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceTest method testSetContentCreator.
@Test
public void testSetContentCreator() throws Exception {
RepositoryFileDto mockRepositoryFileDto = mock(RepositoryFileDto.class);
doNothing().when(fileResource.fileService).doSetContentCreator(PATH_ID, mockRepositoryFileDto);
Response mockOkResponse = mock(Response.class);
doReturn(mockOkResponse).when(fileResource).buildOkResponse();
Response testResponse = fileResource.doSetContentCreator(PATH_ID, mockRepositoryFileDto);
assertEquals(mockOkResponse, testResponse);
verify(fileResource.fileService, times(1)).doSetContentCreator(PATH_ID, mockRepositoryFileDto);
verify(fileResource, times(1)).buildOkResponse();
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileResourceIT method testDeleteFiles.
@Test
public void testDeleteFiles() {
loginAsRepositoryAdmin();
ITenant systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminAuthorityName, authenticatedAuthorityName, "Anonymous");
userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminAuthorityName });
ITenant mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminAuthorityName, authenticatedAuthorityName, "Anonymous");
userRoleDao.createUser(mainTenant_1, "admin", "password", "", new String[] { adminAuthorityName });
try {
login("admin", mainTenant_1, new String[] { authenticatedAuthorityName });
String testFile1Id = "abc.txt";
String testFile2Id = "def.txt";
// set object in PentahoSystem
mp.defineInstance(IUnifiedRepository.class, repo);
String publicFolderPath = ClientRepositoryPaths.getPublicFolderPath();
createTestFile(publicFolderPath.replaceAll("/", ":") + ":" + testFile1Id, "abcdefg");
createTestFile(publicFolderPath.replaceAll("/", ":") + ":" + testFile2Id, "abcdefg");
createTestFolder(":home:admin");
RepositoryFile file1 = repo.getFile(publicFolderPath + "/" + testFile1Id);
RepositoryFile file2 = repo.getFile(publicFolderPath + "/" + testFile2Id);
WebResource webResource = resource();
webResource.path("repo/files/delete").entity(file1.getId() + "," + file2.getId()).put();
RepositoryFileDto[] deletedFiles = webResource.path("repo/files/deleted").accept(APPLICATION_XML).get(RepositoryFileDto[].class);
assertEquals(2, deletedFiles.length);
webResource.path("repo/files/deletepermanent").entity(file2.getId()).put();
} catch (Throwable ex) {
TestCase.fail();
} finally {
cleanupUserAndRoles(mainTenant_1);
cleanupUserAndRoles(systemTenant);
}
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertFromRepositoryFile.
public static RepositoryFileDto convertFromRepositoryFile(RepositoryFile file) {
RepositoryFileDto repositoryFile = new RepositoryFileDto();
repositoryFile.setCreatedDate(file.getCreatedDate());
repositoryFile.setDeletedDate(file.getDeletedDate());
repositoryFile.setDescription(file.getDescription());
repositoryFile.setFolder(file.isFolder());
repositoryFile.setHidden(file.isHidden());
repositoryFile.setAclNode(false);
repositoryFile.setId(file.getId());
repositoryFile.setLastModifiedDate(file.getLastModifiedDate());
repositoryFile.setLocale(file.getLocale());
repositoryFile.setLockDate(file.getLockDate());
repositoryFile.setLocked(file.isLocked());
repositoryFile.setLockMessage(file.getLockMessage());
repositoryFile.setLockOwner(file.getLockOwner());
repositoryFile.setName(file.getName());
repositoryFile.setOriginalParentFolderPath(file.getOriginalParentFolderPath());
repositoryFile.setOriginalParentFolderPath(file.getOriginalParentFolderPath());
repositoryFile.setOwner(file.getOwner());
repositoryFile.setPath(file.getPath());
repositoryFile.setTitle(file.getTitle());
repositoryFile.setVersionId(file.getVersionId());
return repositoryFile;
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto in project pentaho-platform by pentaho.
the class FileService method doGetLocaleProperties.
/**
* Retrieve the list of locale properties for a given locale
*
* @param pathId (colon separated path for the repository file)
* @param locale
* @return
*/
public List<StringKeyStringValueDto> doGetLocaleProperties(String pathId, String locale) {
RepositoryFileDto file = getRepoWs().getFile(idToPath(pathId));
List<StringKeyStringValueDto> keyValueList = new ArrayList<StringKeyStringValueDto>();
if (file != null) {
PropertiesWrapper propertiesWrapper = getRepoWs().getLocalePropertiesForFileById(file.getId(), locale);
if (propertiesWrapper != null) {
Properties properties = propertiesWrapper.getProperties();
if (properties != null && !properties.isEmpty()) {
for (String key : properties.stringPropertyNames()) {
keyValueList.add(getStringKeyStringValueDto(key, properties.getProperty(key)));
}
}
}
}
return keyValueList;
}
use of org.pentaho.platform.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;
}
Aggregations