04-24-2006 02:20 PM
// Create content
NamedValue[] properties2 = new NamedValue[]{new NamedValue(Constants.PROP_NAME, "SampleContent.txt")};
CMLCreate create2 = new CMLCreate("1", parentReference2, Constants.TYPE_CONTENT, properties2);
CML cml2 = new CML();
cml2.setCreate(new CMLCreate[]{create2});
UpdateResult[] results2 = WebServiceFactory.getRepositoryService().update(cml2);
// Save teh node id for later retrieval
String savedNodeId = results2[0].getDestination().getUuid();
// Set content
ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8");
byte[] content = "This is some test content provided by the Alfresco development team!".getBytes();
WebServiceFactory.getContentService().write(results2[0].getDestination(), Constants.PROP_CONTENT, content, format);
// Get a reference to the respository web service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Create a query object, looking for all items with alfresco in the name of text
Query query = new Query(QueryLanguageEnum.lucene, "@sys\\:node-uuid:\"" + savedNodeId + "\"");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, true);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows == null)
{
System.out.println("No query results found.");
}
else
{
// Get the id of the first result
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
}
I am assuming that a more direct way to go, assuming you know the node is there, is to just prepared the reference with the saved id, like this. Reference reference = new Reference(STORE, savedNodeId, null);
Can anyone offer any suggestions for a better way?04-25-2006 05:25 AM
// Get a reference to the respository web service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Create a query object, looking for all items with alfresco in the name of text
Query query = new Query(QueryLanguageEnum.lucene, "(ID:\"" + savedNodeId + "\")");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, true);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows == null)
{
System.out.println("No query results found.");
}
else
{
// Get the id of the first result
String firstResultId = rows[0].getNode().getId();
Reference reference = new Reference(STORE, firstResultId, null);
}
04-25-2006 10:23 AM
workspace->SpacesStore->Web Service Sample Folder-><file I'm looking for>
04-26-2006 08:46 AM
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.