Refs #11288: Made resource-registry more RESTful
Task-Url: https://support.d4science.org/issues/11288 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@169103 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bb242f83bb
commit
4f42103a1f
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DefaultValue;
|
import javax.ws.rs.DefaultValue;
|
||||||
|
@ -29,6 +30,7 @@ import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.
|
||||||
import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
||||||
|
import org.gcube.informationsystem.types.TypeBinder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -74,11 +76,22 @@ public class SchemaManager {
|
||||||
logger.info("Requested {} creation with schema {}", type, json);
|
logger.info("Requested {} creation with schema {}", type, json);
|
||||||
setCalledMethod(HTTPMETHOD.PUT, type);
|
setCalledMethod(HTTPMETHOD.PUT, type);
|
||||||
|
|
||||||
|
|
||||||
AccessType accessType = null;
|
AccessType accessType = null;
|
||||||
|
String firstGotType = null;
|
||||||
try {
|
try {
|
||||||
accessType = ERManagementUtility.getBaseAccessType(type);
|
Set<String> superClasses = TypeBinder.deserializeTypeDefinition(json).getSuperClasses();
|
||||||
|
if(superClasses.size()==0) {
|
||||||
|
throw new ResourceRegistryException("No superclasses defined");
|
||||||
|
}
|
||||||
|
for(String superClass : superClasses) {
|
||||||
|
accessType = ERManagementUtility.getBaseAccessType(superClass);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (ResourceRegistryException e) {
|
||||||
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
String error = String.format("Cannot register %s schema", type);
|
String error = String.format("Cannot register %s schema. Superclass %s not found", type, firstGotType);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue