}
String parts[] = gidString.split("/");
String ecid = parts[0];
String entityName = parts[1];
EOEditingContext ec = null;
if(ecid != null) {
ec = editingContextForKey(ecid);
}
if(ec == null) {
ec = _editingContextFactory.newEditingContext();
registerEditingContext(ec);
}
ec.lock();
try {
String type = null;
String pk = null;
if (parts.length > 2) {
type = parts[2];
pk = parts[3];
}
EOEnterpriseObject eo;
EOGlobalID gid;
if(pk != null && pk.length() > 0) {
if ("T".equals(type)) {
byte[] bytes = ERXStringUtilities.hexStringToByteArray(pk);
gid = EOTemporaryGlobalID._gidForRawBytes(bytes);
eo = ec.objectForGlobalID(gid);
}
else {
pk = ERXStringUtilities.urlDecode(pk);
gid = ERXEOControlUtilities.globalIDForString(ec, entityName, pk);
eo = ec.faultForGlobalID(gid, ec);
}
}
else if (_canInsert(entityName)) {
eo = ERXEOControlUtilities.createAndInsertObject(ec, entityName);
}
else {
eo = null;
}
if (eo != null) {
NSArray<String> attributeNames = _writableAttributeNames(eo);
NSArray<String> relationshipNames = _includedRelationshipNames(eo);
for (Iterator iterator = eoDict.keys(); iterator.hasNext();) {
String key = (String) iterator.next();
if(!("javaClass".equals(key) || "gid".equals(key))) {
Object value = eoDict.get(key);
Object obj = ser.unmarshall(state, null, value);
if (attributeNames.containsObject(key)) {
if (obj == null && !relationshipNames.containsObject(key) && (eo.toOneRelationshipKeys().containsObject(key) || eo.toManyRelationshipKeys().containsObject(key))) {
// ignore nulls for non-included relationships
}
else {
eo.takeValueForKey(obj, key);
}
}
}
}
}
state.setSerialized(o, eo);
return eo;
}
finally {
ec.unlock();
}
}
catch (JSONException e) {
throw new UnmarshallException("Failed to unmarshall EO.", e);
}