3636public class LRJSONDocument extends LREnvelope
3737{
3838 /**
39- * Create a new simple documet with specified details
39+ * Create a new simple document with specified details
4040 *
4141 * @param resourceData value for "resource_data"
4242 * @param resourceDataType value for "resource_data_type"
@@ -57,32 +57,13 @@ public LRJSONDocument(JSONObject resourceData, String resourceDataType, String r
5757 String payloadPlacement , String payloadSchemaLocator , String [] payloadSchema ,
5858 String submitter , String submitterType , String submissionTOS , String submissionAttribution , String signer ) throws LRException
5959 {
60- try
61- {
62- this .resourceData = new ObjectMapper ().readValue (resourceData .toString (), HashMap .class );
63- }
64- catch (IOException e )
65- {
66- throw new LRException (LRException .INVALID_JSON );
67- }
68-
69- this .resourceDataType = StringUtil .nullifyBadInput (resourceDataType );
70- this .resourceLocator = StringUtil .nullifyBadInput (resourceLocator );
71- this .curator = StringUtil .nullifyBadInput (curator );
72- this .owner = StringUtil .nullifyBadInput (owner );
73- this .tags = StringUtil .removeDuplicates (tags );
74- this .payloadPlacement = StringUtil .nullifyBadInput (payloadPlacement );
75- this .payloadSchemaLocator = StringUtil .nullifyBadInput (payloadSchemaLocator );
76- this .payloadSchema = StringUtil .nullifyBadInput (payloadSchema );
77- this .submissionTOS = StringUtil .nullifyBadInput (submissionTOS );
78- this .submissionAttribution = StringUtil .nullifyBadInput (submissionAttribution );
79- this .submitterType = StringUtil .nullifyBadInput (submitterType );
80- this .submitter = StringUtil .nullifyBadInput (submitter );
81- this .signer = StringUtil .nullifyBadInput (signer );
60+ initProperties (this , resourceData , resourceDataType , resourceLocator , curator , owner , tags , payloadPlacement ,
61+ payloadSchemaLocator , payloadSchema , submitter , submitterType , submissionTOS ,
62+ submissionAttribution , signer , null );
8263 }
8364
8465 /**
85- * Create a new simple documet with specified details
66+ * Create a new simple document with specified details
8667 *
8768 * @param resourceData value for "resource_data"
8869 * @param resourceDataType value for "resource_data_type"
@@ -106,30 +87,72 @@ public LRJSONDocument(String resourceData, String resourceDataType, String resou
10687 try
10788 {
10889 JSONObject resourceJSON = new JSONObject (resourceData );
109- this .resourceData = new ObjectMapper ().readValue (resourceJSON .toString (), HashMap .class );
90+ initProperties (this , resourceJSON , resourceDataType , resourceLocator , curator , owner , tags , payloadPlacement ,
91+ payloadSchemaLocator , payloadSchema , submitter , submitterType , submissionTOS ,
92+ submissionAttribution , signer , null );
11093 }
111- catch (IOException e )
94+ catch (JSONException e )
11295 {
11396 throw new LRException (LRException .INVALID_JSON );
11497 }
115- catch (JSONException e )
98+ }
99+
100+ /**
101+ * Create a new simple document with specified details
102+ *
103+ * @param resourceData value for "resource_data"
104+ * @param resourceDataType value for "resource_data_type"
105+ * @param resourceLocator value for "resource_locator"
106+ * @param curator value for "curator"
107+ * @param owner value for "owner"
108+ * @param tags value for "keys"
109+ * @param payloadPlacement value for "payload_placement"
110+ * @param payloadSchemaLocator value for "payload_schema_locator"
111+ * @param payloadSchema value for "payload_schema"
112+ * @param submitter value for "submitter"
113+ * @param submitterType value for "submitter_type"
114+ * @param submissionTOS value for "submission_TOS"
115+ * @param submissionAttribution value for "submission_attribution"
116+ * @param signer value for "signer"
117+ * @param replaces array of document IDs to be replaced by this document
118+ */
119+ public LRJSONDocument (JSONObject resourceData , String resourceDataType , String resourceLocator , String curator , String owner , String [] tags ,
120+ String payloadPlacement , String payloadSchemaLocator , String [] payloadSchema ,
121+ String submitter , String submitterType , String submissionTOS , String submissionAttribution , String signer ,
122+ String [] replaces ) throws LRException
123+ {
124+ initProperties (this , resourceData , resourceDataType , resourceLocator , curator , owner , tags , payloadPlacement ,
125+ payloadSchemaLocator , payloadSchema , submitter , submitterType , submissionTOS ,
126+ submissionAttribution , signer , replaces );
127+ }
128+
129+ protected void initProperties (LRJSONDocument document , JSONObject resourceData , String resourceDataType , String resourceLocator , String curator , String owner , String [] tags ,
130+ String payloadPlacement , String payloadSchemaLocator , String [] payloadSchema ,
131+ String submitter , String submitterType , String submissionTOS , String submissionAttribution , String signer ,
132+ String [] replaces ) throws LRException
133+ {
134+ try
135+ {
136+ document .resourceData = new ObjectMapper ().readValue (resourceData .toString (), HashMap .class );
137+ document .resourceDataType = StringUtil .nullifyBadInput (resourceDataType );
138+ document .resourceLocator = StringUtil .nullifyBadInput (resourceLocator );
139+ document .curator = StringUtil .nullifyBadInput (curator );
140+ document .owner = StringUtil .nullifyBadInput (owner );
141+ document .tags = StringUtil .removeDuplicates (tags );
142+ document .payloadPlacement = StringUtil .nullifyBadInput (payloadPlacement );
143+ document .payloadSchemaLocator = StringUtil .nullifyBadInput (payloadSchemaLocator );
144+ document .payloadSchema = StringUtil .nullifyBadInput (payloadSchema );
145+ document .submissionTOS = StringUtil .nullifyBadInput (submissionTOS );
146+ document .submissionAttribution = StringUtil .nullifyBadInput (submissionAttribution );
147+ document .submitterType = StringUtil .nullifyBadInput (submitterType );
148+ document .submitter = StringUtil .nullifyBadInput (submitter );
149+ document .signer = StringUtil .nullifyBadInput (signer );
150+ document .replaces = StringUtil .removeDuplicates (replaces );
151+ }
152+ catch (IOException e )
116153 {
117154 throw new LRException (LRException .INVALID_JSON );
118155 }
119-
120- this .resourceDataType = StringUtil .nullifyBadInput (resourceDataType );
121- this .resourceLocator = StringUtil .nullifyBadInput (resourceLocator );
122- this .curator = StringUtil .nullifyBadInput (curator );
123- this .owner = StringUtil .nullifyBadInput (owner );
124- this .tags = StringUtil .removeDuplicates (tags );
125- this .payloadPlacement = StringUtil .nullifyBadInput (payloadPlacement );
126- this .payloadSchemaLocator = StringUtil .nullifyBadInput (payloadSchemaLocator );
127- this .payloadSchema = StringUtil .nullifyBadInput (payloadSchema );
128- this .submissionTOS = StringUtil .nullifyBadInput (submissionTOS );
129- this .submissionAttribution = StringUtil .nullifyBadInput (submissionAttribution );
130- this .submitterType = StringUtil .nullifyBadInput (submitterType );
131- this .submitter = StringUtil .nullifyBadInput (submitter );
132- this .signer = StringUtil .nullifyBadInput (signer );
133156 }
134157
135158 public Object getResourceData ()
0 commit comments