From 604a2013320caadf28bbccc3363a91fec42efd9c Mon Sep 17 00:00:00 2001 From: Sanjay Dalal Date: Mon, 5 Oct 2009 22:54:59 +0000 Subject: [PATCH] CSPACE-502 separated fillPart into a protected method so that it could be overridden. --- .../java/RemoteDocumentModelHandler.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java index 5c2fb152c..aa3c14370 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java @@ -58,9 +58,9 @@ public abstract class RemoteDocumentModelHandler public void setServiceContext(ServiceContext ctx) { if(ctx instanceof RemoteServiceContext){ super.setServiceContext(ctx); - } else { - throw new IllegalArgumentException("setServiceContext requires instance of " + - RemoteServiceContext.class.getName()); + }else{ + throw new IllegalArgumentException("setServiceContext requires instance of " + + RemoteServiceContext.class.getName()); } } @@ -122,22 +122,35 @@ public abstract class RemoteDocumentModelHandler if(!partsMetaMap.containsKey(partLabel)){ continue; } - InputStream payload = part.getBody(InputStream.class, null); - - //check if this is an xml part - if(part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)){ - if(payload != null){ - Document document = DocumentUtils.parseDocument(payload); - //TODO: callback to handler if registered to validate the - //document - Map objectProps = DocumentUtils.parseProperties(document); - docModel.setProperties(partLabel, objectProps); - } - } + ObjectPartType partMeta = partsMetaMap.get(partLabel); + fillPart(part, docModel, partMeta); }//rof } + /** + * fillPart fills an XML part into given document model + * @param part to fill + * @param docModel for the given object + * @param partMeta metadata for the object to fill + * @throws Exception + */ + protected void fillPart(InputPart part, DocumentModel docModel, ObjectPartType partMeta) + throws Exception { + InputStream payload = part.getBody(InputStream.class, null); + + //check if this is an xml part + if(part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)){ + if(payload != null){ + Document document = DocumentUtils.parseDocument(payload); + //TODO: callback to handler if registered to validate the + //document + Map objectProps = DocumentUtils.parseProperties(document); + docModel.setProperties(partMeta.getLabel(), objectProps); + } + } + } + /** * extractPart extracts an XML object from given DocumentModel * @param docModel -- 2.47.3