Refactoring due to package renaming in resource-registry-api
This commit is contained in:
parent
ab0e2b11ee
commit
6bd1cc11d0
|
@ -16,8 +16,8 @@ import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
|||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||
|
|
|
@ -24,9 +24,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresen
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresen
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.EntityAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.informationsystem.model.reference.entities.Facet;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetNotFoundException;
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceNotFoundException;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.RelationNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
|||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
|
||||
|
|
|
@ -32,9 +32,8 @@ public class QueryTemplateManager {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(QueryTemplateManager.class);
|
||||
|
||||
/*
|
||||
* GET /query-templates
|
||||
*
|
||||
/**
|
||||
** GET /query-templates
|
||||
*/
|
||||
@GET
|
||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||
|
@ -49,9 +48,32 @@ public class QueryTemplateManager {
|
|||
|
||||
/*
|
||||
* PUT /query-templates/{QUERY_TEMPLATE_NAME}
|
||||
* e.g. PUT /query-templates/GetAllRunningInstances
|
||||
* e.g. PUT /query-templates/GetAllEServiceWithState
|
||||
*
|
||||
* BODY: {...}
|
||||
* BODY:
|
||||
*
|
||||
* {
|
||||
* "name" : "GetAllEServiceWithState",
|
||||
* "description" : "The following query return all the EService having the state provided as parameters, e.g. down, ready.
|
||||
* The content of the request to run this query template will be something like {\"$state\": "ready"}",
|
||||
* "template": {
|
||||
* "@class": "EService",
|
||||
* "consistsOf": [{
|
||||
* "@class": "ConsistsOf",
|
||||
* "target": {
|
||||
* "@class": "StateFacet",
|
||||
* "value": "$state"
|
||||
* }
|
||||
* }]
|
||||
* },
|
||||
* "templateVariables" = {
|
||||
* "$state" : {
|
||||
* "name": "$state",
|
||||
* "description": "The state of the EService, e.g. down, ready.",
|
||||
* "defaultValue": "ready"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
@PUT
|
||||
|
@ -73,8 +95,7 @@ public class QueryTemplateManager {
|
|||
|
||||
/*
|
||||
* GET /query-templates/{QUERY_TEMPLATE_NAME}
|
||||
* e.g. GET /query-templates/GetAllRunningInstances
|
||||
*
|
||||
* e.g. GET /query-templates/GetAllEServiceWithState
|
||||
*/
|
||||
@GET
|
||||
@Path("{" + AccessPath.QUERY_TEMPLATE_NAME_PATH_PARAM + "}")
|
||||
|
@ -89,6 +110,14 @@ public class QueryTemplateManager {
|
|||
return queryTemplateManagement.read();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* POST /query-templates/{QUERY_TEMPLATE_NAME}
|
||||
* e.g. GET /query-templates/GetAllEServiceWithState
|
||||
*
|
||||
* params = { "$state" : "ready" }
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("{" + AccessPath.QUERY_TEMPLATE_NAME_PATH_PARAM + "}")
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
|
@ -106,7 +135,7 @@ public class QueryTemplateManager {
|
|||
|
||||
/*
|
||||
* DELETE /query-templates/{QUERY_TEMPLATE_NAME}
|
||||
* e.g. DELETE /query-templates/GetAllRunningInstances
|
||||
* e.g. DELETE /query-templates/GetAllEServiceWithState
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.gcube.informationsystem.contexts.reference.entities.Context;
|
|||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.resource.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
|||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
|
|
|
@ -22,6 +22,10 @@ public class QueryTemplateManagementTest extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(QueryTemplateManagementTest.class);
|
||||
|
||||
public static final String STATE_VARIABLE_NAME = "$state";
|
||||
public static final String NAME_VARIABLE_NAME = "$name";
|
||||
public static final String GROUP_VARIABLE_NAME = "$group";
|
||||
|
||||
public File getQueryTemplatesDirectory() throws Exception {
|
||||
URL logbackFileURL = JsonQueryTest.class.getClassLoader().getResource("logback-test.xml");
|
||||
File logbackFile = new File(logbackFileURL.toURI());
|
||||
|
@ -29,6 +33,52 @@ public class QueryTemplateManagementTest extends ContextTest {
|
|||
return new File(resourcesDirectory, "queryTemplates");
|
||||
}
|
||||
|
||||
protected QueryTemplate getQueryTemplate(String name, JsonNode jsonNode) {
|
||||
QueryTemplate queryTemplate = new QueryTemplateImpl();
|
||||
queryTemplate.setName(name);
|
||||
queryTemplate.setDescription("A Test Query Template");
|
||||
queryTemplate.setTemplate(jsonNode);
|
||||
|
||||
TemplateVariable stateTemplateVariable = new TemplateVariableImpl();
|
||||
stateTemplateVariable.setName(STATE_VARIABLE_NAME);
|
||||
stateTemplateVariable.setDescription("StateFacet value");
|
||||
stateTemplateVariable.setDefaultValue("running");
|
||||
queryTemplate.addTemplateVariable(stateTemplateVariable);
|
||||
|
||||
TemplateVariable nameTemplateVariable = new TemplateVariableImpl();
|
||||
nameTemplateVariable.setName(NAME_VARIABLE_NAME);
|
||||
nameTemplateVariable.setDescription("SoftwareFacet name");
|
||||
nameTemplateVariable.setDefaultValue("resource-registry");
|
||||
queryTemplate.addTemplateVariable(nameTemplateVariable);
|
||||
|
||||
TemplateVariable groupTemplateVariable = new TemplateVariableImpl();
|
||||
groupTemplateVariable.setName(GROUP_VARIABLE_NAME);
|
||||
groupTemplateVariable.setDescription("SoftwareFacet group");
|
||||
groupTemplateVariable.setDefaultValue("information-system");
|
||||
queryTemplate.addTemplateVariable(groupTemplateVariable);
|
||||
|
||||
return queryTemplate;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarshallingUnMarshalling() throws Exception {
|
||||
File queryTemplatesDirectory = getQueryTemplatesDirectory();
|
||||
File jsonQueryTemplateFile = new File(queryTemplatesDirectory, "queryTemplate" + 1 + ".json");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonQueryTemplateFile);
|
||||
|
||||
String name = "Test";
|
||||
|
||||
QueryTemplate queryTemplate = getQueryTemplate(name, jsonNode);
|
||||
String json = ElementMapper.marshal(queryTemplate);
|
||||
logger.info("Marshalled {} - {}", QueryTemplate.NAME, ElementMapper.marshal(queryTemplate));
|
||||
|
||||
QueryTemplate gotQueryTemplate = ElementMapper.unmarshal(QueryTemplate.class, json);
|
||||
logger.info("Marshalled/UnMarshalled/Marshalled {} - {}", QueryTemplate.NAME, ElementMapper.marshal(gotQueryTemplate));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void completeTest() throws Exception {
|
||||
File queryTemplatesDirectory = getQueryTemplatesDirectory();
|
||||
|
@ -38,32 +88,7 @@ public class QueryTemplateManagementTest extends ContextTest {
|
|||
|
||||
String name = "Test";
|
||||
|
||||
QueryTemplate queryTemplate = new QueryTemplateImpl();
|
||||
queryTemplate.setName(name);
|
||||
queryTemplate.setDescription("A Test Query Template");
|
||||
queryTemplate.setTemplate(jsonNode);
|
||||
|
||||
TemplateVariable stateTemplateVariable = new TemplateVariableImpl();
|
||||
String stateVariableName = "$state";
|
||||
stateTemplateVariable.setName(stateVariableName);
|
||||
stateTemplateVariable.setDescription("StateFacet value");
|
||||
stateTemplateVariable.setDefaultValue("running");
|
||||
queryTemplate.addTemplateVariable(stateTemplateVariable);
|
||||
|
||||
TemplateVariable nameTemplateVariable = new TemplateVariableImpl();
|
||||
String nameVariableName = "$name";
|
||||
nameTemplateVariable.setName(nameVariableName);
|
||||
nameTemplateVariable.setDescription("SoftwareFacet name");
|
||||
nameTemplateVariable.setDefaultValue("resource-registry");
|
||||
queryTemplate.addTemplateVariable(nameTemplateVariable);
|
||||
|
||||
TemplateVariable groupTemplateVariable = new TemplateVariableImpl();
|
||||
String groupVariableName = "$group";
|
||||
groupTemplateVariable.setName(groupVariableName);
|
||||
groupTemplateVariable.setDescription("SoftwareFacet group");
|
||||
groupTemplateVariable.setDefaultValue("information-system");
|
||||
queryTemplate.addTemplateVariable(groupTemplateVariable);
|
||||
|
||||
QueryTemplate queryTemplate = getQueryTemplate(name, jsonNode);
|
||||
String json = ElementMapper.marshal(queryTemplate);
|
||||
|
||||
QueryTemplate gotQueryTemplate = ElementMapper.unmarshal(QueryTemplate.class, json);
|
||||
|
@ -124,9 +149,9 @@ public class QueryTemplateManagementTest extends ContextTest {
|
|||
queryTemplateManagement.setName(name);
|
||||
|
||||
ObjectNode params = objectMapper.createObjectNode();
|
||||
params.put(stateVariableName, "running");
|
||||
params.put(groupVariableName, "DataAccess");
|
||||
params.put(nameVariableName, "StorageHub");
|
||||
params.put(STATE_VARIABLE_NAME, "running");
|
||||
params.put(GROUP_VARIABLE_NAME, "DataAccess");
|
||||
params.put(NAME_VARIABLE_NAME, "StorageHub");
|
||||
queryTemplateManagement.setParams(params);
|
||||
|
||||
queryTemplateManagement.run();
|
||||
|
|
Loading…
Reference in New Issue