02-21-2008 12:00 PM
public Reference getDocument(String docId) throws ServiceException, RemoteException, RepositoryFault, Exception {
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
String queryString = "@cm\\:name:\"" + docId + "\"";
Query query = new Query(Constants.QUERY_LANG_LUCENE, queryString);
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
Reference reference = null;
if (rows == null) {
System.out.println("No query results found.");
}
else if(rows.length > 1) {
throw new Exception("Too many results");
} else {
System.out.println("Results from query:");
outputResultSet(rows);
// Get the id of the first result
ResultSetRowNode node = rows[0].getNode();
String documentId = node.getId();
reference = new Reference(STORE, documentId, null);
}
return reference;
}
private void addAspect(Reference reference) {
// Setting a property
NamedValue[] specificationProps = new NamedValue[1];
specificationProps[0] = Utils.createNamedValue("popularity", "Very Popular");
String aspectString = Constants.createQNameString("mycompany.cars", "myAspect");
CMLAddAspect addAspect = new CMLAddAspect(aspectString, specificationProps, new Predicate(new Reference[] { reference }, null, null), "1");
CML cml = new CML();
cml.setAddAspect(new CMLAddAspect[] { addAspect });
UpdateResult[] results = null;
try {
results = WebServiceFactory.getRepositoryService().update(cml);
System.out.println("Aspect Added");
} catch (RepositoryFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
02-21-2008 05:15 PM
row 0: {}inxight.cars_x003a_myAspect_x003a_popularity = Quite Popular #7
row 0: {}inxight.cars_x003a_popularity = Quite Popular #4
row 0: {}ix_x003a_popularity = Quite Popular #5
row 0: {ix}popularity = Quite Popular #2
row 0: {inxight.cars}popularity = Quite Popular #8
row 0: {}popularity = Quite Popular #3
<namespaces>
<namespace uri="inxight.cars" prefix="ix"/>
</namespaces>
<aspects>
<aspect name="ix:myAspect">
<title>My Aspect</title>
<properties>
<property name="ix:popularity">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
02-21-2008 05:59 PM
// Setting a property
NamedValue[] props = new NamedValue[1];
props[0] = Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}popularity", "Quite Popular #9");
String aspectString = Constants.createQNameString("inxight.cars", "myAspect");
//CMLAddAspect addAspect = new CMLAddAspect(aspectString, specificationProps, new Predicate(new Reference[] { reference }, null, null), "1");
CMLAddAspect addAspect = new CMLAddAspect();
addAspect.setProperty(props);
addAspect.setAspect(aspectString);
addAspect.setWhere(new Predicate(new Reference[] {reference}, STORE, null));
CML cml = new CML();
cml.setAddAspect(new CMLAddAspect[] { addAspect });
UpdateResult[] results = null;
try {
results = WebServiceFactory.getRepositoryService().update(cml);
System.out.println("Aspect Added");
} catch (RepositoryFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.