use of org.apache.chemistry.opencmis.commons.server.CmisService in project alfresco-repository by Alfresco.
the class CMISTest method testSearchPreviousDelete.
@Test
public void testSearchPreviousDelete() {
final ExecutorService executorService = Executors.newSingleThreadExecutor();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
try {
final NodeRef companyHome = repositoryHelper.getCompanyHome();
// create parentFolder
RetryingTransactionCallback<Object> testCallbackFolder = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
NodeRef parentFolder = createFolder(companyHome, "testCreateParent" + GUID.generate(), ContentModel.TYPE_FOLDER);
return parentFolder;
}
};
final NodeRef parentFolder = (NodeRef) transactionService.getRetryingTransactionHelper().doInTransaction(testCallbackFolder, false, true);
// create children Folders
final List<NodeRef> folders = new ArrayList<NodeRef>();
RetryingTransactionCallback<Object> testCallbackChilds = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
for (int i = 0; i < 10; i++) {
folders.add(createFolder(parentFolder, "testCreateList-" + GUID.generate() + i, ContentModel.TYPE_FOLDER));
}
return folders;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(testCallbackChilds, false, true);
// remove children nodes
executorService.submit(new Runnable() {
public void run() {
for (final NodeRef node : folders) {
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>() {
public Void doWork() throws Exception {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable {
nodeService.deleteNode(node);
return null;
}
}, false, true);
return null;
}
}, AuthenticationUtil.getAdminUserName());
}
}
});
// select children nodes removed
withCmisService(new CmisServiceCallback<String>() {
@Override
public String execute(CmisService cmisService) {
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0);
String repositoryId = repo.getId();
// prepare cmis query
String queryString = "SELECT cmis:name, cmis:objectId FROM cmis:folder WHERE IN_FOLDER('" + parentFolder + "')";
cmisService.query(repositoryId, queryString, Boolean.FALSE, Boolean.TRUE, IncludeRelationships.NONE, "", BigInteger.TEN, BigInteger.ZERO, null);
return "";
}
}, CmisVersion.CMIS_1_1);
} catch (Exception e) {
fail(e.toString());
} finally {
executorService.shutdownNow();
}
}
Aggregations