hi all, i'm creating a custom operation that aims to take a blob (xml-file) and create a document with the blob attached and some of the metadata filled from the xml-file. I'm using this operation via the Automation API to upload a xml-file and have the document auto-created. It all seems to work fine, except that the document doesn't appear in the webUI and when i try to access it via the Automation interface (for a subsequent Blob.Attach) I get a 404 Not Found response. So I must be doing something wrong here. The java code i have is below, it's roughly based on Document.Create and Blob.Attach:
@Operation(id=APAS_CreatePlate.ID, category=Constants.CAT_SERVICES, label="APAS_CreatePlate", description="")
public class APAS_CreatePlate {
public static final String ID = "APAS_CreatePlate";
@Context
protected CoreSession session;
@Param(name = "folder", required = true)
protected DocumentModel m_parent;
@OperationMethod
public DocumentModel run(Blob input) throws ClientException {
// first create the document model for type Plate
DocumentModel newPlate = session.createDocumentModel(m_parent.getPathAsString(), "Plate", "Plate");
try {
<<-- snipped away some JAXB init code -->>
// create xml reader
XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(input.getString()));
Plate xmlPlate = (Plate)jaxbUnmarshaller.unmarshal(xsr, Plate.class).getValue();
Properties props = new Properties();
props.put("plate:sample_type", xmlPlate.getSampleType());
// TODO the other relevant properties
DocumentHelper.setProperties(session, newPlate, props);
DocumentHelper.addBlob(newPlate.getProperty("file:content"), input);
DocumentModel doc = session.createDocument(newPlate);
return session.saveDocument(doc);
} <<-- snipped exception handling -->>
Now when using this code via the URL and JSON payload (and the attached blob of course):
http://localhost:8080/nuxeo/site/automation/APAS_CreatePlate
{"params":{"folder": "c5667b68-f712-42ec-a814-fa211e8c89dd"}
I get a JSON response:
{
"versionLabel": "0.0",
"changeToken": "1385697404589",
"uid": "33a41d27-528a-46f2-9e89-8fd60e430930",
"repository": "default",
"title": "Plate",
"lastModified": "2013-11-29T03:56:44.58Z",
"facets": [
"Downloadable",
"Commentable",
"Asset",
"SuperSpace",
"Versionable",
"Publishable",
"HasRelatedText"
],
"entity-type": "document",
"state": "project",
"isCheckedOut": true,
"contextParameters": {},
"path": "/default-domain/workspaces/amp/plates/Plate",
"type": "Plate"
}
Which seems to indicate to me the document has been created just fine. However, it is apparently not stored, because the next invocation gives the 404:
http://localhost:8080/nuxeo/site/automation/Blob.Attach
{"params":{"document": "33a41d27-528a-46f2-9e89-8fd60e430930","xpath": "plate:top_image"}
Can anyone suggest a way forward for me?
Cheers!
Chris