Fixed Header management
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@141776 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c29c5c9bca
commit
8a7542d5dd
1
pom.xml
1
pom.xml
|
@ -157,7 +157,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
|
|
|
@ -116,7 +116,6 @@ public class DatabaseIntializator {
|
|||
entityRegistrationAction.manageEmbeddedClass(Embedded.class);
|
||||
entityRegistrationAction.manageEmbeddedClass(ValueSchema.class);
|
||||
erDiscovery.manageDiscoveredERTypes(entityRegistrationAction);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -722,7 +722,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
|
||||
if(key.compareTo(ER.HEADER_PROPERTY)==0){
|
||||
// Keep the header
|
||||
HeaderOrient headerOrient = (HeaderOrient) object;
|
||||
HeaderOrient headerOrient = HeaderUtility.getHeaderOrient((ODocument) object);
|
||||
JSONObject headerObject = new JSONObject(headerOrient.toJSON("class"));
|
||||
properties.put(ER.HEADER_PROPERTY, headerObject);
|
||||
continue;
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.UUID;
|
|||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.informationsystem.impl.utils.Entities;
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
|
@ -22,6 +23,7 @@ import org.slf4j.LoggerFactory;
|
|||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
import com.tinkerpop.blueprints.Edge;
|
||||
import com.tinkerpop.blueprints.Element;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
|
@ -93,6 +95,24 @@ public class HeaderUtility {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static HeaderOrient getHeaderOrient(ODocument oDocument) throws ResourceRegistryException{
|
||||
if (oDocument instanceof HeaderOrient) {
|
||||
return (HeaderOrient) oDocument;
|
||||
}else{
|
||||
try {
|
||||
HeaderOrient headerOrient = new HeaderOrient();
|
||||
Header header = Entities.unmarshal(Header.class, oDocument.toJSON());
|
||||
headerOrient.setUUID(header.getUUID());
|
||||
headerOrient.setCreator(header.getCreator());
|
||||
headerOrient.setCreationTime(header.getCreationTime());
|
||||
headerOrient.setLastUpdateTime(header.getLastUpdateTime());
|
||||
return headerOrient;
|
||||
} catch (Exception e) {
|
||||
throw new ResourceRegistryException("Unable to recreate Header. This should not occur. Please contact Administrator.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Header addHeader(Vertex vertex, UUID uuid) {
|
||||
Header header = createHeader(uuid);
|
||||
vertex.setProperty(Entity.HEADER_PROPERTY, header);
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.UUID;
|
|||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.gcube.informationsystem.impl.utils.Entities;
|
||||
import org.gcube.informationsystem.model.embedded.Embedded;
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.relation.Relation;
|
||||
|
@ -127,16 +128,16 @@ public class Utility {
|
|||
}
|
||||
|
||||
|
||||
public static <T> T getEmbedded(Class<T> clz, Element element, String property)
|
||||
public static <E extends Embedded> E getEmbedded(Class<E> clz, Element element, String property)
|
||||
throws ResourceRegistryException {
|
||||
try {
|
||||
ODocument oDocument = element.getProperty(property);
|
||||
T t = Entities.unmarshal(clz, oDocument.toJSON());
|
||||
return t;
|
||||
} catch (Exception e) {
|
||||
E e = Entities.unmarshal(clz, oDocument.toJSON());
|
||||
return e;
|
||||
} catch (Exception ex) {
|
||||
String error = String.format("Error while getting %s from %s",
|
||||
property, toJsonString(element, true));
|
||||
throw new ResourceRegistryException(error, e);
|
||||
throw new ResourceRegistryException(error, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue