@@ -61,78 +61,108 @@ public class Core_DataObject implements DataObject {
6161
6262 // Constructor
6363 //----------------------------------------------
64+
65+ /**
66+ * Setup a DataObject against a DataObjectMap backend.
67+ *
68+ * Generates a new GUID for the object.
69+ *
70+ * @param inTable The DataObjectMap backend to use
71+ */
72+ public Core_DataObject (DataObjectMap inTable ){
73+ this (inTable , null );
74+ }
75+
76+ /**
77+ * Setup a DataObject against a DataObjectMap backend.
78+ *
79+ * Generates a new GUID for the object if inOID is null, else uses the provided inOID.
80+ *
81+ * @param inTable The DataObjectMap backend to use
82+ * @param inOID The GUID to use for the new DataObject, can be null
83+ */
84+ public Core_DataObject (DataObjectMap inTable , String inOID ){
85+
86+ // Main table to use
87+ mainTable = (Core_DataObjectMap ) inTable ;
88+
89+ // Issue a GUID
90+ if (inOID == null ) {
91+ _oid = GUID .base58 ();
92+ } else {
93+ _oid = inOID ;
94+ }
95+
96+ if (_oid .length () < 4 ) {
97+ throw new RuntimeException ("_oid should be atleast 4 character long" );
98+ }
99+
100+ // // D= GUID collision check for LOLZ
101+ // remoteDataMap = mainTable.DataObjectRemoteDataMap_get(_oid);
102+ // if (remoteDataMap.size() > 0) {
103+ // throw new SecurityException("GUID Collision =.= DO YOU HAVE REAL ENTROPY? : " + _oid);
104+ // }
105+
106+ // Ensure oid is savable, needed to save blank objects
107+ deltaDataMap .put ("_oid" , _oid );
108+ deltaDataMap .put ("_createTimestamp" , System .currentTimeMillis ());
109+
110+ // Create remote data map (blank)
111+ remoteDataMap = new HashMap <String , Object >();
112+
113+ // Indicated that the provided map is "complete"
114+ isCompleteRemoteDataMap = true ;
115+
116+ }
64117
65118 /**
66119 * Setup a DataObject against a DataObjectMap backend.
67120 *
68121 * This allow the setup in the following modes
69122 *
70- * + No (or invalid) GUID : Assume a new DataObject is made with NO DATA. Issues a new GUID for the object
71123 * + GUID without remote data, will pull the required data when required
72124 * + GUID with complete remote data
73125 * + GUID with incomplete remote data, will pull the required data when required
74126 *
75127 * @param Meta table to use
76- * @param GUID to use, can be null
128+ * @param GUID to use
77129 * @param Remote mapping data used (this should be modifiable)
78130 * @param is complete remote map, use false if incomplete data
79131 **/
80132 public Core_DataObject (DataObjectMap inTable , String inOID , Map <String , Object > inRemoteData ,
81133 boolean isCompleteData ) {
134+
135+ // null / empty check for inOID
136+ if (inOID == null || inOID .isEmpty ()){
137+ throw new IllegalArgumentException ("inOID cannot be null or empty" );
138+ }
139+
82140 // Main table to use
83141 mainTable = (Core_DataObjectMap ) inTable ;
84142
85- // Generates a GUID if not given
86- if (inOID == null ) {
87- // Issue a GUID
88- if (_oid == null ) {
89- _oid = GUID .base58 ();
90- }
91-
92- if (_oid .length () < 4 ) {
93- throw new RuntimeException ("_oid should be atleast 4 character long" );
94- }
95-
96- // // D= GUID collision check for LOLZ
97- // remoteDataMap = mainTable.DataObjectRemoteDataMap_get(_oid);
98- // if (remoteDataMap.size() > 0) {
99- // throw new SecurityException("GUID Collision =.= DO YOU HAVE REAL ENTROPY? : " + _oid);
100- // }
101-
102- // Ensure oid is savable, needed to save blank objects
103- deltaDataMap .put ("_oid" , _oid );
104- deltaDataMap .put ("_createTimestamp" , System .currentTimeMillis ());
105-
106- // Create remote data map (blank)
107- remoteDataMap = new HashMap <String , Object >();
108-
109- // Indicated that the provided map is "complete"
110- isCompleteRemoteDataMap = true ;
111-
112- } else {
113- // _oid setup
114- _oid = inOID ;
115-
116- // Loading remote data map, only valid if _oid is given
117- remoteDataMap = inRemoteData ;
118-
119- // Indicates that isComplete is flagged if given
120- if (remoteDataMap != null ) {
121- isCompleteRemoteDataMap = isCompleteData ;
122- }
143+ // _oid setup
144+ _oid = inOID ;
145+
146+ // Loading remote data map, only valid if _oid is given
147+ remoteDataMap = inRemoteData ;
148+
149+ // Indicates that isComplete is flagged if given
150+ if (remoteDataMap != null ) {
151+ isCompleteRemoteDataMap = isCompleteData ;
123152 }
153+
124154 }
125155
126- /**
127- * Constructor, with DataObjectMap and GUID (auto generated if null)
128- * This is the shorten version of the larger constructor
129- *
130- * @param Meta table to use
131- * @param GUID to use, can be null
132- **/
133- public Core_DataObject (DataObjectMap inTable , String inOID ) {
134- this (inTable , inOID , null , false );
135- }
156+ // / **
157+ // * Constructor, with DataObjectMap and GUID (auto generated if null)
158+ // * This is the shorten version of the larger constructor
159+ // *
160+ // * @param Meta table to use
161+ // * @param GUID to use, can be null
162+ // **/
163+ // public Core_DataObject(DataObjectMap inTable, String inOID) {
164+ // this(inTable, inOID, null, false);
165+ // }
136166
137167 // DataObject ID
138168 //----------------------------------------------
0 commit comments