use of org.apache.chemistry.opencmis.client.api.Session in project camel by apache.
the class CMISTestSupport method deleteAllContent.
protected void deleteAllContent() {
Session session = createSession();
Folder rootFolder = session.getRootFolder();
ItemIterable<CmisObject> children = rootFolder.getChildren();
for (CmisObject cmisObject : children) {
if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
List<String> notDeltedIdList = ((Folder) cmisObject).deleteTree(true, UnfileObject.DELETE, true);
if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
throw new RuntimeException("Cannot empty repo");
}
} else {
cmisObject.delete(true);
}
}
session.getBinding().close();
}
use of org.apache.chemistry.opencmis.client.api.Session in project iaf by ibissource.
the class CmisSender method connect.
private Session connect(String userName, String password) {
log.debug(getLogPrefix() + "connecting with url [" + getUrl() + "] repository [" + getRepository() + "]");
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, userName);
parameter.put(SessionParameter.PASSWORD, password);
if (getBindingType().equalsIgnoreCase("atompub")) {
parameter.put(SessionParameter.ATOMPUB_URL, getUrl());
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
} else if (getBindingType().equalsIgnoreCase("browser")) {
parameter.put(SessionParameter.BROWSER_URL, getUrl());
parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
} else {
parameter.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, getUrl() + "/RepositoryService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, getUrl() + "/NavigationService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, getUrl() + "/ObjectService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, getUrl() + "/VersioningService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, getUrl() + "/DiscoveryService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, getUrl() + "/RelationshipService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, getUrl() + "/MultiFilingService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, getUrl() + "/PolicyService.svc?wsdl");
parameter.put(SessionParameter.WEBSERVICES_ACL_SERVICE, getUrl() + "/ACLService.svc?wsdl");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value());
}
parameter.put(SessionParameter.REPOSITORY_ID, getRepository());
// SSL
if (getCertificate() != null || getTruststore() != null || isAllowSelfSignedCertificates()) {
CredentialFactory certificateCf = new CredentialFactory(getCertificateAuthAlias(), null, getCertificatePassword());
CredentialFactory truststoreCf = new CredentialFactory(getTruststoreAuthAlias(), null, getTruststorePassword());
parameter.put("certificateUrl", getCertificate());
parameter.put("certificatePassword", certificateCf.getPassword());
parameter.put("keystoreType", getKeystoreType());
parameter.put("keyManagerAlgorithm", getKeyManagerAlgorithm());
parameter.put("truststoreUrl", getTruststore());
parameter.put("truststorePassword", truststoreCf.getPassword());
parameter.put("truststoreType", getTruststoreType());
parameter.put("trustManagerAlgorithm", getTrustManagerAlgorithm());
}
// SSL+
parameter.put("isAllowSelfSignedCertificates", "" + isAllowSelfSignedCertificates());
parameter.put("isVerifyHostname", "" + isVerifyHostname());
parameter.put("isIgnoreCertificateExpiredException", "" + isIgnoreCertificateExpiredException());
// PROXY
if (StringUtils.isNotEmpty(getProxyHost())) {
CredentialFactory pcf = new CredentialFactory(getProxyAuthAlias(), getProxyUserName(), getProxyPassword());
parameter.put("proxyHost", getProxyHost());
parameter.put("proxyPort", "" + getProxyPort());
parameter.put("proxyUserName", pcf.getUsername());
parameter.put("proxyPassword", pcf.getPassword());
}
// Custom IBIS HttpSender to support ssl connections and proxies
parameter.put(SessionParameter.HTTP_INVOKER_CLASS, "nl.nn.adapterframework.extensions.cmis.CmisHttpInvoker");
Session session = sessionFactory.createSession(parameter);
log.debug(getLogPrefix() + "connected with repository [" + getRepositoryInfo(session) + "]");
return session;
}
use of org.apache.chemistry.opencmis.client.api.Session in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method run.
@Override
public void run() throws Exception {
Session session;
SessionParameterMap parameters = new SessionParameterMap(getParameters());
if (!parameters.containsKey(SessionParameter.USER_AGENT)) {
parameters.setUserAgent(TCK_USER_AGENT);
}
String repId = parameters.get(SessionParameter.REPOSITORY_ID);
if (repId != null && repId.length() > 0) {
session = factory.createSession(parameters);
} else {
session = factory.getRepositories(parameters).get(0).createSession();
}
// switch off the cache
session.getDefaultContext().setCacheEnabled(false);
try {
run(session);
} catch (Exception e) {
if (!(e instanceof FatalTestException)) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Exception: " + e, e, true));
}
} catch (Error err) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Error: " + err, err, true));
} finally {
testFolder = null;
}
}
use of org.apache.chemistry.opencmis.client.api.Session in project SearchServices by Alfresco.
the class CMISDataCreatorTest method testCreateLots.
public void testCreateLots() throws Exception {
Session session = getSession("admin", "admin");
Folder root = session.getRootFolder();
String folderNameBase = getRootFolderName();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderNameBase);
Folder base = root.createFolder(properties);
for (int i = 0; i < 10; i++) {
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("" + i + i + i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.ALL);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
base.addAcl(addAces, AclPropagation.PROPAGATE);
}
Thread last = null;
for (int i = 0; i < 10; i++) {
Creator creator = new Creator(base.getPath(), i);
Thread thread = new Thread(creator);
thread.start();
last = thread;
}
if (last != null) {
last.join();
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
// result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
// assertTrue(result.getTotalNumItems() > 0);
}
use of org.apache.chemistry.opencmis.client.api.Session in project SearchServices by Alfresco.
the class CMISDataCreatorTest method testQueryFolderProperties.
public void testQueryFolderProperties() {
Session session = getSession("admin", "admin");
String folderName = getRootFolderName();
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderName);
// create the folder
Folder newFolder = root.createFolder(properties);
ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '" + folderName + "'", false);
assertEquals(1, result.getTotalNumItems());
String uniqueName = getUniqueName();
Map<String, Object> uProperties = new HashMap<String, Object>();
uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
uProperties.put(PropertyIds.NAME, uniqueName);
Folder uniqueFolder = newFolder.createFolder(uProperties);
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND IN_FOLDER('" + uniqueFolder.getParentId() + "')", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where IN_FOLDER('" + uniqueFolder.getParentId() + "')", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:createdBy = '" + uniqueFolder.getCreatedBy() + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:objectId = '" + uniqueFolder.getId() + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:lastModifiedBy = '" + uniqueFolder.getLastModifiedBy() + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueFolder.getName() + "'", false);
assertEquals(1, result.getTotalNumItems());
String creationDate = ISO8601DateFormat.format(uniqueFolder.getCreationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:creationDate = '" + creationDate + "'", false);
assertEquals(1, result.getTotalNumItems());
String modificationDate = ISO8601DateFormat.format(uniqueFolder.getLastModificationDate().getTime());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:lastModificationDate = '" + modificationDate + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:objectTypeId = '" + uniqueFolder.getType().getQueryName() + "'", false);
assertEquals(1, result.getTotalNumItems());
result = session.query("select * from cmis:folder where cmis:name = '" + uniqueName + "' AND cmis:baseTypeId = '" + uniqueFolder.getBaseType().getQueryName() + "'", false);
assertEquals(1, result.getTotalNumItems());
}
Aggregations