Exposing AddToContext APi refs #5701
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134082 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
810ec013bf
commit
dfb9d513ce
|
@ -57,7 +57,6 @@ public class SecurityContext {
|
|||
SecurityContext.allowSecurityContextRoles(oSecurity,
|
||||
edge.getRecord(), context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addToSecurityContext(OrientGraph orientGraph, Edge edge,
|
||||
|
@ -86,7 +85,7 @@ public class SecurityContext {
|
|||
SecurityContextMapper.PermissionMode.READER,
|
||||
SecurityContextMapper.SecurityType.ROLE, context));
|
||||
|
||||
oDocument.save();
|
||||
// oDocument.save();
|
||||
|
||||
// oSecurity.allowRole(oDocument, ORestrictedOperation.ALLOW_ALL,
|
||||
// DEFAULT_WRITER_ROLE);
|
||||
|
@ -96,7 +95,7 @@ public class SecurityContext {
|
|||
}
|
||||
|
||||
public static void createSecurityContext(OrientGraph orientGraph,
|
||||
UUID context, boolean commit) {
|
||||
UUID context) {
|
||||
|
||||
ODatabaseDocumentTx oDatabaseDocumentTx = orientGraph.getRawGraph();
|
||||
OSecurity oSecurity = oDatabaseDocumentTx.getMetadata().getSecurity();
|
||||
|
@ -143,9 +142,7 @@ public class SecurityContext {
|
|||
readerUser.save();
|
||||
logger.trace("{} created", readerUser);
|
||||
|
||||
if(commit){
|
||||
oDatabaseDocumentTx.commit();
|
||||
}
|
||||
|
||||
logger.trace(
|
||||
"Security Context (roles and users) with UUID {} successfully created",
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class SecurityContextMapper {
|
|||
if (created) {
|
||||
OrientGraph orientGraph = factory.getTx();
|
||||
SecurityContext.createSecurityContext(orientGraph,
|
||||
MANAGEMENT_SECURITY_CONTEXT_UUID, true);
|
||||
MANAGEMENT_SECURITY_CONTEXT_UUID);
|
||||
|
||||
getSecurityContextFactory(MANAGEMENT_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.READER);
|
||||
|
|
|
@ -16,14 +16,10 @@ import javax.ws.rs.core.MediaType;
|
|||
|
||||
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.InternalException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
|
||||
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.entity.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.EntityPath;
|
||||
import org.gcube.informationsystem.resourceregistry.resources.impl.ContextManagementImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -46,10 +42,7 @@ public class ContextManager {
|
|||
protected ContextManagement contextManager = new ContextManagementImpl();
|
||||
|
||||
/**
|
||||
* e.g. PUT
|
||||
* /resource-registry/context?name=myVRE&parentContextId=a2fe0030-7b3d
|
||||
* -4617-ba37-532c0e4b778d
|
||||
*
|
||||
* e.g. PUT /resource-registry/context?name=myVRE&parentContextId=a2fe0030-7b3d-4617-ba37-532c0e4b778d
|
||||
* @param parentUUID
|
||||
* @param name
|
||||
* @return
|
||||
|
@ -67,9 +60,7 @@ public class ContextManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* e.g. DELETE
|
||||
* /resource-registry/context/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||
*
|
||||
* e.g. DELETE /resource-registry/context/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||
* @param uuid
|
||||
* @return
|
||||
* @throws ContextException
|
||||
|
@ -84,10 +75,7 @@ public class ContextManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* e.g. POST
|
||||
* /resource-registry/context/rename/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||
* ?name=newNameVRE
|
||||
*
|
||||
* e.g. POST /resource-registry/context/rename/c0f314e7-2807-4241-a792-2a6c79ed4fd0?name=newNameVRE
|
||||
* @param uuid
|
||||
* @param name
|
||||
* @return
|
||||
|
@ -105,10 +93,7 @@ public class ContextManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* e.g. POST
|
||||
* /resource-registry/context/move/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||
* ?parentContextId=68cf247a-b1ed-44cd-9d2e-c16d865bade7
|
||||
*
|
||||
* e.g. POST /resource-registry/context/move/c0f314e7-2807-4241-a792-2a6c79ed4fd0?parentContextId=68cf247a-b1ed-44cd-9d2e-c16d865bade7
|
||||
* @param uuid
|
||||
* @param newParentUUID
|
||||
* @return
|
||||
|
@ -128,18 +113,4 @@ public class ContextManager {
|
|||
UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addResourceToContext(String uuid) throws ResourceNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return contextManager.addResourceToContext(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addFacetToContext(String uuid) throws FacetNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return contextManager.addFacetToContext(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.informationsystem.model.relation.ConsistsOf;
|
|||
import org.gcube.informationsystem.model.relation.IsRelatedTo;
|
||||
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
|
@ -234,4 +235,19 @@ public class EntityManager {
|
|||
return entityManager.detachResource(UUID.fromString(relatedToUUID));
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addResourceToContext(String uuid) throws ResourceNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return entityManager.addResourceToContext(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addFacetToContext(String uuid) throws FacetNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return entityManager.addFacetToContext(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
throw new ContextCreationException(e.getMessage());
|
||||
}
|
||||
|
||||
SecurityContext.createSecurityContext(orientGraph, uuid, true);
|
||||
SecurityContext.createSecurityContext(orientGraph, uuid);
|
||||
|
||||
OrientVertex context = orientGraph.addVertex("class:"
|
||||
+ Context.NAME);
|
||||
|
|
|
@ -28,9 +28,12 @@ import org.gcube.informationsystem.model.relation.IsRelatedTo;
|
|||
import org.gcube.informationsystem.model.relation.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
|
||||
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.entity.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper;
|
||||
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.resources.utils.HeaderUtility;
|
||||
|
@ -259,7 +262,7 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
return map;
|
||||
}
|
||||
|
||||
private void createRelation(OrientGraph orientGraph, Vertex resource, JsonNode relationArray,
|
||||
private void createRelations(OrientGraph orientGraph, Vertex resource, JsonNode relationArray,
|
||||
@SuppressWarnings("rawtypes") Class<? extends Relation> relation) throws FacetNotFoundException,
|
||||
ResourceNotFoundException, ResourceRegistryException {
|
||||
|
||||
|
@ -418,7 +421,7 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
return vertex;
|
||||
|
||||
} catch (Exception e) {
|
||||
if (orientGraph != null && !deferredCommit) {
|
||||
if (orientGraph != null) {
|
||||
orientGraph.rollback();
|
||||
}
|
||||
throw new ResourceRegistryException("Error Creating " + entityType
|
||||
|
@ -838,13 +841,13 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
String property = lowerCaseFirstCharacter(ConsistsOf.NAME);
|
||||
if (jsonNode.has(property)) {
|
||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||
createRelation(orientGraph, resource, jsonNodeArray, ConsistsOf.class);
|
||||
createRelations(orientGraph, resource, jsonNodeArray, ConsistsOf.class);
|
||||
}
|
||||
|
||||
property = lowerCaseFirstCharacter(IsRelatedTo.NAME);
|
||||
if (jsonNode.has(property)) {
|
||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||
createRelation(orientGraph, resource, jsonNodeArray, IsRelatedTo.class);
|
||||
createRelations(orientGraph, resource, jsonNodeArray, IsRelatedTo.class);
|
||||
}
|
||||
|
||||
orientGraph.commit();
|
||||
|
@ -935,4 +938,58 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected <E extends Entity> boolean addEntityToContext(Class<E> clz,
|
||||
UUID uuid) throws FacetNotFoundException,
|
||||
ResourceNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
|
||||
OrientGraph orientGraph = null;
|
||||
|
||||
try {
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
|
||||
Vertex vertex = getEntity(orientGraph, uuid, null, clz);
|
||||
|
||||
UUID contextUUID = ContextUtility.addToActualContext(orientGraph, vertex);
|
||||
|
||||
if (Resource.class.isAssignableFrom(clz)) {
|
||||
Iterable<Vertex> facets = vertex.getVertices(Direction.OUT,
|
||||
ConsistsOf.NAME);
|
||||
for (Vertex facet : facets) {
|
||||
ContextUtility.addToActualContext(orientGraph, facet);
|
||||
}
|
||||
}
|
||||
|
||||
orientGraph.commit();
|
||||
logger.info("{} with UUID {} successfully added to actual Context with UUID {}", clz.getSimpleName(),
|
||||
uuid, contextUUID);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
if (orientGraph != null) {
|
||||
orientGraph.rollback();
|
||||
}
|
||||
throw new ContextException(e.getMessage());
|
||||
} finally {
|
||||
if (orientGraph != null) {
|
||||
orientGraph.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addResourceToContext(UUID uuid)
|
||||
throws ResourceNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
return addEntityToContext(Resource.class, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFacetToContext(UUID uuid) throws FacetNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return addEntityToContext(Facet.class, uuid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ public abstract class ContextUtility {
|
|||
}
|
||||
|
||||
public static Vertex getActualContextVertex() throws ContextNotFoundException, ContextException{
|
||||
OrientGraphNoTx orientGraphNoTx = null;
|
||||
try {
|
||||
String scope = getCurrentScope();
|
||||
if(scope==null){
|
||||
|
@ -98,13 +99,18 @@ public abstract class ContextUtility {
|
|||
.getSecurityContextFactory(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.READER);
|
||||
return ContextUtility.getContextVertexByFullName(
|
||||
factory.getTx(), scope);
|
||||
|
||||
orientGraphNoTx = factory.getNoTx();
|
||||
return ContextUtility.getContextVertexByFullName(orientGraphNoTx, scope);
|
||||
} catch (ContextNotFoundException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new ContextException(
|
||||
"Unable to restrive Context Vertex for current Context", e);
|
||||
} finally{
|
||||
if(orientGraphNoTx!=null){
|
||||
orientGraphNoTx.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +183,7 @@ public abstract class ContextUtility {
|
|||
}
|
||||
}
|
||||
|
||||
public static Vertex getContextVertexByFullName(OrientGraph orientGraph,
|
||||
public static Vertex getContextVertexByFullName(OrientGraphNoTx orientGraphNoTx,
|
||||
String fullName) throws ContextNotFoundException {
|
||||
|
||||
logger.trace("Going to get {} {} from full name '{}'", Context.NAME, Vertex.class.getSimpleName(), fullName);
|
||||
|
@ -193,7 +199,7 @@ public abstract class ContextUtility {
|
|||
;
|
||||
OSQLSynchQuery<Vertex> osqlSynchQuery = new OSQLSynchQuery<Vertex>(
|
||||
select);
|
||||
Iterable<Vertex> vertexes = orientGraph.command(osqlSynchQuery)
|
||||
Iterable<Vertex> vertexes = orientGraphNoTx.command(osqlSynchQuery)
|
||||
.execute();
|
||||
|
||||
if (vertexes == null || !vertexes.iterator().hasNext()) {
|
||||
|
|
|
@ -3,12 +3,9 @@ package org.gcube.informationsystem.resourceregistry;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
|
||||
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.entity.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class ContextManagerFactory implements Factory<ContextManagement> {
|
||||
|
@ -52,23 +49,6 @@ public class ContextManagerFactory implements Factory<ContextManagement> {
|
|||
return "{}";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addResourceToContext(UUID uuid)
|
||||
throws ResourceNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addFacetToContext(UUID uuid)
|
||||
throws FacetNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.UUID;
|
|||
|
||||
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
@ -104,6 +105,23 @@ public class EntityManagementFactory implements Factory<EntityManagement> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addResourceToContext(UUID uuid)
|
||||
throws ResourceNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addFacetToContext(UUID uuid)
|
||||
throws FacetNotFoundException, ContextNotFoundException,
|
||||
ResourceRegistryException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -245,14 +245,14 @@ public class ContextManagementImplTest {
|
|||
* contextManagementImpl.delete(gcube);
|
||||
*/
|
||||
|
||||
logger.debug("The DB should be now clean");
|
||||
//logger.debug("The DB should be now clean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDevContext() throws ContextNotFoundException,
|
||||
public void removeContext() throws ContextNotFoundException,
|
||||
ContextException, InternalException {
|
||||
contextManagementImpl.delete(UUID
|
||||
.fromString("4c39472d-3ee8-4da3-8a4f-53d06af4fd4b"));
|
||||
.fromString(""));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,20 @@
|
|||
package org.gcube.informationsystem.resourceregistry.resources.impl;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.impl.entity.facet.AccessPointFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.ContactFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.EventFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.LicenseFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.NetworkingFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.ServiceStateFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
|
||||
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
|
||||
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
|
||||
|
@ -22,9 +29,13 @@ import org.gcube.informationsystem.model.embedded.Header;
|
|||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.Facet;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.entity.facet.AccessPointFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.EventFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.LicenseFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.NetworkingFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.ServiceStateFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
|
||||
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
||||
|
@ -53,6 +64,45 @@ public class EntityManagementImplTest {
|
|||
entityManagementImpl = new EntityManagementImpl();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEService() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devNext");
|
||||
|
||||
EService eService = new EServiceImpl();
|
||||
|
||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||
softwareFacet.setGroup("InformationSystem");
|
||||
softwareFacet.setName("resource-registry");
|
||||
softwareFacet.setVersion("1.1.0");
|
||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService, softwareFacet, null);
|
||||
eService.addFacet(isIdentifiedBy);
|
||||
|
||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
||||
accessPointFacet.setEndpoint(new URI("http://localhost"));
|
||||
accessPointFacet.setEntryName("port1");
|
||||
eService.addFacet(accessPointFacet);
|
||||
|
||||
EventFacet eventFacet = new EventFacetImpl();
|
||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
||||
eventFacet.setValue("Created");
|
||||
eService.addFacet(eventFacet);
|
||||
|
||||
ServiceStateFacet serviceStateFacet = new ServiceStateFacetImpl();
|
||||
serviceStateFacet.setValue("ready");
|
||||
eService.addFacet(serviceStateFacet);
|
||||
|
||||
LicenseFacet licenseFacet = new LicenseFacetImpl();
|
||||
licenseFacet.setName("EUPL");
|
||||
licenseFacet.setTextURL(new URL("https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
||||
eService.addFacet(licenseFacet);
|
||||
|
||||
String json = entityManagementImpl.createResource(EService.NAME, Entities.marshal(eService));
|
||||
logger.debug("Created : {}", json);
|
||||
eService = Entities.unmarshal(EService.class, json);
|
||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateReadDeleteFacet() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devNext");
|
||||
|
@ -388,4 +438,5 @@ public class EntityManagementImplTest {
|
|||
//entityManagementImpl.deleteResource(resourceUUID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.gcube.informationsystem.impl.relation.consistsof.HasVolatileMemoryImp
|
|||
import org.gcube.informationsystem.impl.relation.isrelatedto.HostsImpl;
|
||||
import org.gcube.informationsystem.impl.utils.Entities;
|
||||
import org.gcube.informationsystem.model.entity.Facet;
|
||||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.entity.facet.AccessPointFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
||||
import org.gcube.informationsystem.model.entity.facet.EventFacet;
|
||||
|
@ -57,17 +56,15 @@ public class MultiContextTest {
|
|||
private static Logger logger = LoggerFactory
|
||||
.getLogger(EntityManagementImplTest.class);
|
||||
|
||||
protected ContextManagementImpl contextManagementImpl;
|
||||
protected EntityManagementImpl entityManagementImpl;
|
||||
|
||||
public MultiContextTest() {
|
||||
entityManagementImpl = new EntityManagementImpl();
|
||||
contextManagementImpl = new ContextManagementImpl();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateHostingNode() throws Exception {
|
||||
public void testCreateEServiceHostingNode() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devNext");
|
||||
|
||||
EService eService = new EServiceImpl();
|
||||
|
@ -76,7 +73,7 @@ public class MultiContextTest {
|
|||
softwareFacet.setGroup("InformationSystem");
|
||||
softwareFacet.setName("resource-registry");
|
||||
softwareFacet.setVersion("1.1.0");
|
||||
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService, softwareFacet, null);
|
||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService, softwareFacet, null);
|
||||
eService.addFacet(isIdentifiedBy);
|
||||
|
||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
||||
|
@ -93,7 +90,6 @@ public class MultiContextTest {
|
|||
serviceStateFacet.setValue("ready");
|
||||
eService.addFacet(serviceStateFacet);
|
||||
|
||||
|
||||
LicenseFacet licenseFacet = new LicenseFacetImpl();
|
||||
licenseFacet.setName("EUPL");
|
||||
licenseFacet.setTextURL(new URL("https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
||||
|
@ -105,6 +101,8 @@ public class MultiContextTest {
|
|||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||
|
||||
|
||||
|
||||
|
||||
/* ----- */
|
||||
|
||||
HostingNode hostingNode = new HostingNodeImpl();
|
||||
|
@ -116,8 +114,8 @@ public class MultiContextTest {
|
|||
networkingFacet.setMask("255.255.248.0");
|
||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||
|
||||
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
|
||||
hostingNode.addFacet(isIdentifiedBy);
|
||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(hostingNode, networkingFacet, null);
|
||||
hostingNode.addFacet(isIdentifiedByHNNF);
|
||||
|
||||
|
||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
||||
|
@ -146,28 +144,24 @@ public class MultiContextTest {
|
|||
new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(hostingNode, disk, null);
|
||||
hostingNode.addFacet(hasPersistentMemory);
|
||||
|
||||
|
||||
|
||||
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
|
||||
hostingNode.attachResource(hosts);
|
||||
|
||||
|
||||
json = entityManagementImpl.createResource(HostingNode.NAME, Entities.marshal(hostingNode));
|
||||
hostingNode = Entities.unmarshal(HostingNode.class, json);
|
||||
logger.debug("Created : {}", json);
|
||||
|
||||
String hnJson = entityManagementImpl.createResource(HostingNode.NAME, Entities.marshal(hostingNode));
|
||||
logger.debug("Created : {}", hnJson);
|
||||
hostingNode = Entities.unmarshal(HostingNode.class, hnJson);
|
||||
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
||||
|
||||
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
contextManagementImpl.addResourceToContext(hostingNode.getHeader().getUUID());
|
||||
|
||||
entityManagementImpl.addResourceToContext(hostingNode.getHeader().getUUID());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTest() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException{
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
contextManagementImpl.addResourceToContext(UUID.fromString("36799dbc-e0df-463d-9895-861cc19a9442"));
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
entityManagementImpl.addResourceToContext(UUID.fromString("75583599-c082-4b89-84ab-125e64d768c4"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
|
||||
<logger name="org.gcube" level="INFO" />
|
||||
<logger name="org.gcube.informationsystem" level="INFO" />
|
||||
<logger name="org.gcube.informationsystem.resourceregistry.context" level="TRACE" />
|
||||
<logger name="org.gcube.informationsystem.resourceregistry.resources.utils" level="TRACE" />
|
||||
<logger name="org.gcube.informationsystem" level="DEBUG" />
|
||||
<logger name="org.gcube.informationsystem.resourceregistry.context" level="INFO" />
|
||||
<logger name="org.gcube.informationsystem.resourceregistry.resources.utils" level="INFO" />
|
||||
<logger name="org.gcube.informationsystem.impl.utils.discovery" level="ERROR" />
|
||||
|
||||
<root level="WARN">
|
||||
|
|
Loading…
Reference in New Issue