use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeService method processRevisionDeletion.
private void processRevisionDeletion(PurgeUtilitySpecification purgeSpecification) throws PurgeDeletionException {
RepositoryRequest repositoryRequest = new RepositoryRequest(purgeSpecification.getPath(), true, -1, purgeSpecification.getFileFilter());
repositoryRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
repositoryRequest.setIncludeMemberSet(new HashSet<String>(Arrays.asList(new String[] { "name", "id", "folder", "path", "versioned", "versionId", "locked" })));
getLogger().debug("Creating file list");
RepositoryFileTreeDto tree = getRepoWs().getTreeFromRequest(repositoryRequest);
processPurgeForTree(tree, purgeSpecification);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeService method processPurgeForTree.
private void processPurgeForTree(RepositoryFileTreeDto tree, PurgeUtilitySpecification purgeSpecification) {
for (RepositoryFileTreeDto child : tree.getChildren()) {
try {
if (!child.getChildren().isEmpty()) {
processPurgeForTree(child, purgeSpecification);
}
RepositoryFileDto file = child.getFile();
getLogger().setCurrentFilePath(file.getPath());
if (file.isVersioned()) {
if (purgeSpecification.isPurgeFiles()) {
getLogger().info("Purge File");
// the latest version will be removed with deleteFileWithPermanentFlag
keepNumberOfVersions(file.getId(), 1);
getRepoWs().deleteFileWithPermanentFlag(file.getId(), true, "purge utility");
} else if (purgeSpecification.isPurgeRevisions()) {
getLogger().info("Purging Revisions");
deleteAllVersions(file.getId());
} else {
if (purgeSpecification.getBeforeDate() != null) {
getLogger().info("Checking/purging by Revision date");
deleteVersionsBeforeDate(file.getId(), purgeSpecification.getBeforeDate());
}
if (purgeSpecification.getVersionCount() >= 0) {
getLogger().info("Checking/purging by number of Revisions");
keepNumberOfVersions(file.getId(), purgeSpecification.getVersionCount());
}
}
}
} catch (Exception e) {
getLogger().error(e);
}
}
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetTree.
@Test
public void testDoGetTree() {
Integer depth = 0;
String filter = "filter";
Boolean showHidden = Boolean.TRUE;
Boolean includeAcls = Boolean.TRUE;
Boolean includeSysDirs = Boolean.FALSE;
RepositoryFileTreeDto mockRepositoryFileTreeDto = mock(RepositoryFileTreeDto.class);
doReturn(mockRepositoryFileTreeDto).when(fileResource.fileService).doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
RepositoryFileTreeDto testDto = fileResource.doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
assertEquals(mockRepositoryFileTreeDto, testDto);
verify(fileResource.fileService).doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto in project pentaho-platform by pentaho.
the class FileResourceTest method testDoGetRootTree.
@Test
public void testDoGetRootTree() {
Integer depth = 0;
String filter = "filter";
Boolean showHidden = Boolean.TRUE;
Boolean includeAcls = Boolean.TRUE;
RepositoryFileTreeDto mockRepositoryFileTreeDto = mock(RepositoryFileTreeDto.class);
doReturn(mockRepositoryFileTreeDto).when(fileResource.fileService).doGetTree(FileUtils.PATH_SEPARATOR, depth, filter, showHidden, includeAcls);
RepositoryFileTreeDto testDto = fileResource.doGetRootTree(depth, filter, showHidden, includeAcls);
assertEquals(mockRepositoryFileTreeDto, testDto);
verify(fileResource.fileService, times(1)).doGetTree(FileUtils.PATH_SEPARATOR, depth, filter, showHidden, includeAcls);
}
use of org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method getPurgeService.
// create the necessary mocks for running a full Purge Utility job
private static UnifiedRepositoryPurgeService getPurgeService(IUnifiedRepository mockRepo) {
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
DefaultUnifiedRepositoryWebService mockRepoWs = mock(DefaultUnifiedRepositoryWebService.class);
UnifiedRepositoryPurgeService.repoWs = mockRepoWs;
// Create a mocked tree to be returned
JAXBContext jc;
RepositoryFileTreeDto tree = null;
try {
jc = JAXBContext.newInstance(RepositoryFileTreeDto.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
ByteArrayInputStream xml = new ByteArrayInputStream(treeResponse.getBytes());
tree = (RepositoryFileTreeDto) unmarshaller.unmarshal(xml);
} catch (JAXBException e) {
e.printStackTrace();
fail("Test class has invalid xml representation of tree");
}
when(mockRepoWs.getTreeFromRequest(any(RepositoryRequest.class))).thenReturn(tree);
return purgeService;
}
Aggregations