HiI've got a custom aspect containing one property ('popularity'). In the UI I can see 'Popularity' on the properties page of a document I added. The value is blank.My Java then tries to populate this value which I do with the following code1) Get the reference to the document (docId is the filename e.g. Ford.html) 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;
}2) Now I have the document, add the aspect values
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();
}
}
The code runs OK (no exceptions anyhow) but back in the UI, my 'popularity' value is still blank, whereas I was expecting it to say 'Very Popular'.Just a thought: am I adding the aspect to the right thing?? Please help - thanks