git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@45 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
274f44e39a
commit
a176507fff
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="src/" kind="src" path=""/>
|
||||
<classpathentry excluding="src/|build/" kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/CONTAINERLIB"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/GCUBE_CORE"/>
|
||||
<classpathentry kind="lib" path="/home/andrea/gcube/information-system/gCubeIS/SERVICELIBS/GCUBE_ISREGISTRY/org.gcube.informationsystem.registry.stubs.jar"/>
|
||||
<classpathentry kind="lib" path="SERVICELIBS/GCUBE_ISREGISTRY/org.gcube.informationsystem.registry.stubs.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
name = Registry
|
||||
package = org.gcube.informationsystem.registry
|
||||
package.dir = org/gcube/informationsystem/registry
|
||||
lib.dir = SERVICELIBS/GCUBE_ISREGISTRY
|
||||
|
|
Binary file not shown.
|
@ -86,14 +86,6 @@ public class ProfileResource extends GCUBEWSResource {
|
|||
}
|
||||
}
|
||||
}
|
||||
//Resource Registration
|
||||
try {
|
||||
GHNContext.getImplementation(ISPublisher.class).registerWSResource(this,GHNContext.getContext().getDefaultScope());
|
||||
} catch (ISPublisherException e) {
|
||||
throw new ResourceException(e);
|
||||
} catch (Exception e) {
|
||||
throw new ResourceException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -153,7 +145,7 @@ public class ProfileResource extends GCUBEWSResource {
|
|||
public void remove() throws ResourceException{
|
||||
super.remove();
|
||||
logger.info("Resource " + this.getID()+ " is going to be removed.");
|
||||
this.getPersistenceDelegate().remove(this);
|
||||
|
||||
try {
|
||||
publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||
} catch (Exception e) {
|
||||
|
@ -184,6 +176,10 @@ public class ProfileResource extends GCUBEWSResource {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
protected void removeProfile() throws ResourceException {
|
||||
this.getPersistenceDelegate().remove(this);
|
||||
}
|
||||
|
||||
|
||||
public void updateResource(GCUBEResource resource) throws Exception{
|
||||
|
|
|
@ -10,9 +10,6 @@ import java.util.Calendar;
|
|||
import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.is.ISException;
|
||||
import org.gcube.common.core.is.client.ISClient.ISInvalidQueryException;
|
||||
import org.gcube.common.core.is.client.ISClient.ISMalformedQueryException;
|
||||
import org.gcube.common.core.porttypes.GCUBEStartupPortType;
|
||||
import org.gcube.common.core.resources.GCUBECS;
|
||||
import org.gcube.common.core.resources.GCUBECSInstance;
|
||||
|
@ -47,8 +44,8 @@ import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse;
|
|||
import org.gcube.informationsystem.registry.stubs.UpdateScopeInProfileMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.UpdateStateMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.service.RegistryServiceAddressingLocator;
|
||||
import org.globus.wsrf.ResourceContext;
|
||||
import org.globus.wsrf.ResourceKey;
|
||||
import org.globus.wsrf.security.SecurityManager;
|
||||
import org.oasis.wsrf.lifetime.Destroy;
|
||||
|
||||
|
||||
|
@ -77,11 +74,6 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
public static ArrayList notificationMap = new ArrayList<String>();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected ResourceContext ctxResource = null;
|
||||
|
||||
@Override
|
||||
protected GCUBEServiceContext getServiceContext() {
|
||||
return ServiceContext.getContext();
|
||||
|
@ -110,12 +102,23 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a GCUBEResource
|
||||
*
|
||||
* @param inputMessage
|
||||
* @return
|
||||
* @throws SchemaValidationFault
|
||||
* @throws RemoteException
|
||||
* @throws ProfileAlreadyRegisteredFault
|
||||
*/
|
||||
public String createResource(CreateResourceMessage inputMessage) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault {
|
||||
|
||||
|
||||
GCUBEResource resource = null;
|
||||
|
||||
logSecurityInfo("createResource");
|
||||
|
||||
String profile = inputMessage.getProfile();
|
||||
|
||||
if (profile == null || profile.compareTo("") == 0) {
|
||||
|
@ -128,7 +131,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
|
||||
resource = this.getResourceClass(inputMessage.getType());
|
||||
resource.load(new StringReader(profile));
|
||||
//the parse Profile class allows to extract from profiles information about type/DL/UniqueID
|
||||
//the parse Profile class allows to extract from profiles information about type/SCOPE/UniqueID
|
||||
//in order to distiguish among different Resource Type
|
||||
|
||||
//Adding scopes to Profile
|
||||
|
@ -235,14 +238,6 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
try {
|
||||
resource = this.getResourceClass(mess.getType());
|
||||
resource.load(new StringReader(xmlProfile));
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
logger.debug("Error parsing profile");
|
||||
throw new RemoteException("Error parsing profile");
|
||||
}
|
||||
|
||||
try{
|
||||
getProfileResource(ID).updateResource(resource);
|
||||
}
|
||||
|
||||
|
@ -277,7 +272,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
GCUBEResource profile= null;
|
||||
|
||||
String ID = inputMessage.getUniqueID();
|
||||
|
||||
String type = inputMessage.getType();
|
||||
|
||||
if (ID == null || ID.compareTo("") ==0) {
|
||||
logger.debug("ID missing ");
|
||||
throw new RemoteException("Error, ID missing");
|
||||
|
@ -288,23 +284,18 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
|
||||
GCUBEResource resource = null;
|
||||
try {
|
||||
resource = RegistryUtil.getProfileFromIS(ID);
|
||||
} catch (ISMalformedQueryException e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
} catch (ISInvalidQueryException e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
} catch (ISException e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
resource = RegistryUtil.getProfileFromIS(ID,this.getResourceClass(type).getClass());
|
||||
} catch (Exception e1) {
|
||||
logger.error("Error gettign profile from IS ");
|
||||
return new RemoveResourceResponse();
|
||||
}
|
||||
|
||||
|
||||
if( resource == null) return new RemoveResourceResponse();
|
||||
|
||||
else {
|
||||
|
||||
logger.debug("Try to remove the resource from the ISIC");
|
||||
logger.debug("Try to remove the resource from the IS-IC");
|
||||
ProfileManager manager;
|
||||
try {
|
||||
manager = new GCUBEPublisher().getProfileManager(null, GHNContext.getContext().getDefaultScope());
|
||||
|
@ -320,10 +311,9 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
try{
|
||||
|
||||
ProfileResource resource = getProfileResource(ID );
|
||||
|
||||
profile.load(new StringReader(resource.getProfile()));
|
||||
//remove profile
|
||||
resource.remove();
|
||||
resource.removeProfile();
|
||||
RegistryServiceAddressingLocator locator = new RegistryServiceAddressingLocator();
|
||||
RegistryPortType portType = locator.getRegistryPortTypePort(resource.getEPR());
|
||||
|
||||
|
@ -332,13 +322,13 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(":Error removing resource for ID "+ e);
|
||||
logger.error("Error removing resource for ID "+ e);
|
||||
throw new RemoteException();
|
||||
}
|
||||
|
||||
try {
|
||||
if (profile.getType().compareTo(GCUBEHostingNode.TYPE) == 0) {
|
||||
unregisterRIRelatedToDHN(profile.getID());
|
||||
RegistryUtil.unregisterRIRelatedToDHN(profile.getID(),this);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -347,6 +337,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
}
|
||||
|
||||
logger.info(" Profile destroyed");
|
||||
|
||||
try {
|
||||
updateCounterInfo(profile,operationType.destroy.name(),Calendar.getInstance());
|
||||
}
|
||||
|
@ -369,8 +360,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
|
||||
logger.info("Security info for method "+ methodName );
|
||||
|
||||
//String identity = SecurityManager.getManager().getCaller();
|
||||
//logger.info("The caller is: " + identity);
|
||||
String identity = SecurityManager.getManager().getCaller();
|
||||
logger.info("The caller is: " + identity);
|
||||
|
||||
}
|
||||
|
||||
|
@ -430,33 +421,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
this.getResource().getPersistenceDelegate().store(this.getResource());
|
||||
|
||||
|
||||
/* String gLueType= prof.getGlueResourceType();
|
||||
if (gLueType.trim().compareTo("GlueSE")==0) {
|
||||
this.getResource().setGLiteSE(property);
|
||||
|
||||
|
||||
}else if (gLueType.trim().compareTo("GlueCE")==0) {
|
||||
this.getResource().setGLiteCE(property);
|
||||
|
||||
}else if(gLueType.trim().compareTo("GlueSite")==0) {
|
||||
|
||||
this.getResource().setGLiteSite(property);
|
||||
|
||||
}else if (gLueType.trim().compareTo("GlueService")==0) {
|
||||
|
||||
this.getResource().setGLiteService(property);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void unregisterRIRelatedToDHN(String id ){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return the resource
|
||||
|
@ -468,7 +434,6 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
Object resource = null;
|
||||
try {
|
||||
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("RegistryResource"));
|
||||
//resource= ResourceContext.getResourceContext().getResource();
|
||||
} catch (Exception e) {
|
||||
logger.error(" Unable to access resource", e);
|
||||
}
|
||||
|
@ -477,6 +442,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
|||
return factoryResource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private GCUBEResource getResourceClass(String type) throws Exception {
|
||||
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public class ServiceContext extends GCUBEServiceContext{
|
|||
}
|
||||
|
||||
if (isICCodeployed) {
|
||||
queryRI.setEntryName( "diligentproject/informationservice/disic/DISICFactoryService");
|
||||
queryRI.setEntryName( "gcube/informationsystem/isic/ISICFactoryService");
|
||||
queryRI.setResourceClass("InformationSystem");
|
||||
queryRI.setResourceName("IS-IC");
|
||||
if (client.execute(queryRI, GHNContext.getContext().getDefaultScope()).size()==0) registerProfile(ISICRIProfile,GCUBERunningInstance.TYPE);
|
||||
|
|
|
@ -1,19 +1,32 @@
|
|||
package org.gcube.informationsystem.registry.impl.util;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.is.ISException;
|
||||
import org.gcube.common.core.is.client.ISClient;
|
||||
import org.gcube.common.core.is.client.ISClient.ISInvalidQueryException;
|
||||
import org.gcube.common.core.is.client.ISClient.ISMalformedQueryException;
|
||||
import org.gcube.common.core.is.client.queries.GCUBERIsOnGHNQuery;
|
||||
import org.gcube.common.core.is.client.queries.GCUBEResourceFromIDQuery;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.informationsystem.registry.impl.core.RegistryFactory;
|
||||
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Andrea Manzi(ISTI_CNR)
|
||||
*
|
||||
*/
|
||||
public class RegistryUtil {
|
||||
|
||||
|
||||
public static ISClient client = null;
|
||||
|
||||
|
||||
public RegistryUtil () {
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
|
@ -21,14 +34,54 @@ public class RegistryUtil {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static GCUBEResource getProfileFromIS(String ID) throws ISMalformedQueryException, ISInvalidQueryException, ISException {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param ID
|
||||
* @param resourceClass
|
||||
* @return
|
||||
* @throws ISMalformedQueryException
|
||||
* @throws ISInvalidQueryException
|
||||
* @throws ISException
|
||||
*/
|
||||
public static GCUBEResource getProfileFromIS(String ID, Class<? extends GCUBEResource> resourceClass) throws ISMalformedQueryException, ISInvalidQueryException, ISException {
|
||||
GCUBEResourceFromIDQuery query =client.getQuery(GCUBEResourceFromIDQuery.class);
|
||||
query.setResourceClass(resourceClass);
|
||||
query.setResourceID(ID);
|
||||
List<GCUBEResource> resource = client.execute(query, GHNContext.getContext().getDefaultScope());
|
||||
if (resource != null) return resource.get(0);
|
||||
else return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* @param service
|
||||
* @throws ISMalformedQueryException
|
||||
* @throws ISInvalidQueryException
|
||||
* @throws ISException
|
||||
* @throws GCUBEFault
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public static void unregisterRIRelatedToDHN(String id ,RegistryFactory service) throws ISMalformedQueryException, ISInvalidQueryException, ISException, GCUBEFault, RemoteException{
|
||||
RemoveResourceMessage message = null;
|
||||
GCUBERIsOnGHNQuery query= client.getQuery(GCUBERIsOnGHNQuery.class);
|
||||
query.setResourceID(id);
|
||||
//query to IS on order to retrieve the RI deployed on the GHN;
|
||||
List<GCUBEResource> resources = client.execute(query, GHNContext.getContext().getDefaultScope());
|
||||
|
||||
if (resources.size() != 0){
|
||||
for (GCUBEResource resource : resources) {
|
||||
message = new RemoveResourceMessage();
|
||||
message.setType(GCUBERunningInstance.TYPE);
|
||||
message.setUniqueID(resource.getID());
|
||||
service.removeResource(message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
<xsd:complexType name="UpdateStateMessage">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="uniqueID" type="xsd:string"/>
|
||||
|
||||
<xsd:element name="state" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
@ -81,6 +80,7 @@
|
|||
<xsd:complexType name="RemoveResourceMessage">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="uniqueID" type="xsd:string" minOccurs="1" maxOccurs="1"/>
|
||||
<xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
|
|
Loading…
Reference in New Issue