}
}
- private void addOutputPart(Map<String, Object> unQObjectProperties, String schema, ObjectPartType partMeta)
+ protected void addOutputPart(Map<String, Object> unQObjectProperties, String schema, ObjectPartType partMeta)
throws Exception {
Document doc = DocumentUtils.buildDocument(partMeta, schema,
unQObjectProperties);
*/
protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
throws Exception {
+ return extractPart( docModel, schema, partMeta, null );
+ }
+
+ /**
+ * extractPart extracts an XML object from given DocumentModel
+ * @param docModel
+ * @param schema of the object to extract
+ * @param partMeta metadata for the object to extract
+ * @throws Exception
+ */
+ protected Map<String, Object> extractPart(
+ DocumentModel docModel, String schema, ObjectPartType partMeta,
+ Map<String, Object> addToMap)
+ throws Exception {
Map<String, Object> result = null;
MediaType mt = MediaType.valueOf(partMeta.getContent().getContentType());
Map<String, Object> objectProps = docModel.getProperties(schema);
//unqualify properties before sending the doc over the wire (to save bandwidh)
//FIXME: is there a better way to avoid duplication of a collection?
- Map<String, Object> unQObjectProperties = new HashMap<String, Object>();
+ Map<String, Object> unQObjectProperties =
+ (addToMap!=null)? addToMap:(new HashMap<String, Object>());
Set<Entry<String, Object>> qualifiedEntries = objectProps.entrySet();
for(Entry<String, Object> entry : qualifiedEntries){
String unqProp = getUnQProperty(entry.getKey());
* @param partMeta metadata for the object to fill\r
* @throws Exception\r
*/\r
+ @Override\r
protected void fillPart(InputPart part, DocumentModel docModel, ObjectPartType partMeta)\r
throws Exception {\r
InputStream payload = part.getBody(InputStream.class, null);\r
}\r
}\r
\r
+ /**\r
+ * extractPart extracts an XML object from given DocumentModel\r
+ * This overridden form checks for schemas that extend subitem, and merges\r
+ * in the subitem properties for that part.\r
+ * @param docModel\r
+ * @param schema of the object to extract\r
+ * @param partMeta metadata for the object to extract\r
+ * @throws Exception\r
+ */\r
+ @Override\r
+ protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)\r
+ throws Exception {\r
+ Map<String, Object> map = extractPart( docModel, schema, partMeta, null ); \r
+ if(schemaHasSubItem(schema)) {\r
+ extractPart(docModel, SI_LABEL, partMeta, map);\r
+ }\r
+ return map;\r
+ }\r
+ \r
+ // TODO HACK - should make this info be configured in the part metadata.\r
+ public abstract boolean schemaHasSubItem(String schema);\r
\r
}\r
client.getCommonPartName(), NotesCommon.class);\r
Assert.assertNotNull(note);\r
\r
- // Update the content of this resource.\r
+ // Update the content of this resource, both the subitem, and the content\r
note.setContent("updated-" + note.getContent());\r
- note.setAuthor("updated-" + note.getAuthor());\r
+ note.setOrder(note.getOrder()+10);\r
if(logger.isDebugEnabled()){\r
logger.debug("to be updated object");\r
logger.debug(objectAsXmlString(note, NotesCommon.class));\r
client.getCommonPartName(), NotesCommon.class);\r
Assert.assertNotNull(updatedNote);\r
\r
- Assert.assertEquals(updatedNote.getContent(),\r
- note.getContent(),\r
+ Assert.assertEquals(updatedNote.getContent(), note.getContent(),\r
"Data in updated object did not match submitted data.");\r
-\r
+ Assert.assertEquals(updatedNote.getOrder(), note.getOrder(),\r
+ "Data in updated object (subitem) did not match submitted data.");\r
}\r
\r
// Failure outcomes\r
\r
/** The owner. */\r
private String owner;\r
+ \r
+ private final String commonSchemaName = "notes_common";\r
+ \r
+ public boolean schemaHasSubItem(String schema) {\r
+ return commonSchemaName.equals(schema);\r
+ }\r
+\r
\r
/**\r
* Gets the owner.\r