git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@38 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ae73f7b809
commit
058fb3af46
|
@ -87,6 +87,14 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +177,7 @@ public class ProfileResource extends GCUBEWSResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
publisher.removeWSResource(this);
|
publisher.removeWSResource(this,GHNContext.getContext().getDefaultScope());
|
||||||
} catch (ISPublisherException e) {
|
} catch (ISPublisherException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,18 @@ import org.gcube.common.core.is.ISException;
|
||||||
import org.gcube.common.core.is.client.ISClient.ISInvalidQueryException;
|
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.ISClient.ISMalformedQueryException;
|
||||||
import org.gcube.common.core.porttypes.GCUBEStartupPortType;
|
import org.gcube.common.core.porttypes.GCUBEStartupPortType;
|
||||||
|
import org.gcube.common.core.resources.GCUBECS;
|
||||||
|
import org.gcube.common.core.resources.GCUBECSInstance;
|
||||||
|
import org.gcube.common.core.resources.GCUBECollection;
|
||||||
|
import org.gcube.common.core.resources.GCUBEExternalRunningInstance;
|
||||||
|
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||||
|
import org.gcube.common.core.resources.GCUBEMCollection;
|
||||||
import org.gcube.common.core.resources.GCUBEResource;
|
import org.gcube.common.core.resources.GCUBEResource;
|
||||||
|
import org.gcube.common.core.resources.GCUBEService;
|
||||||
|
import org.gcube.common.core.resources.GCUBETransformationProgram;
|
||||||
|
import org.gcube.common.core.resources.GCUBEVRE;
|
||||||
|
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
||||||
import org.gcube.common.core.scope.GCUBEScope;
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.common.is.publisher.impl.GCUBEPublisher;
|
import org.gcube.common.is.publisher.impl.GCUBEPublisher;
|
||||||
|
@ -103,6 +113,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
|
|
||||||
public String createResource(CreateResourceMessage inputMessage) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault {
|
public String createResource(CreateResourceMessage inputMessage) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault {
|
||||||
|
|
||||||
|
|
||||||
GCUBEResource resource = null;
|
GCUBEResource resource = null;
|
||||||
|
|
||||||
logSecurityInfo("createResource");
|
logSecurityInfo("createResource");
|
||||||
|
@ -114,10 +125,10 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
throw new RemoteException(msg);
|
throw new RemoteException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
resource = this.getResourceClass(inputMessage.getType());
|
||||||
resource.load(new StringReader(profile));
|
resource.load(new StringReader(profile));
|
||||||
resource.getType();
|
|
||||||
//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/DL/UniqueID
|
||||||
//in order to distiguish among different Resource Type
|
//in order to distiguish among different Resource Type
|
||||||
|
|
||||||
|
@ -137,7 +148,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.error("Error trying to loading profile");
|
logger.error("Error trying to load profile");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw new SchemaValidationFault();
|
throw new SchemaValidationFault();
|
||||||
}
|
}
|
||||||
|
@ -223,6 +234,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
resource = this.getResourceClass(mess.getType());
|
||||||
resource.load(new StringReader(xmlProfile));
|
resource.load(new StringReader(xmlProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,7 +468,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
private RegistryFactoryResource getResource() throws RemoteException {
|
private RegistryFactoryResource getResource() throws RemoteException {
|
||||||
Object resource = null;
|
Object resource = null;
|
||||||
try {
|
try {
|
||||||
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("FactoryResource"));
|
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("RegistryResource"));
|
||||||
//resource= ResourceContext.getResourceContext().getResource();
|
//resource= ResourceContext.getResourceContext().getResource();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(" Unable to access resource", e);
|
logger.error(" Unable to access resource", e);
|
||||||
|
@ -466,6 +478,44 @@ public class RegistryFactory extends GCUBEStartupPortType{
|
||||||
return factoryResource;
|
return factoryResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GCUBEResource getResourceClass(String type) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
switch (ResourceType.valueOf(type)){
|
||||||
|
case ExternalRunningInstance:return GHNContext.getImplementation(GCUBEExternalRunningInstance.class);
|
||||||
|
case Service: return GHNContext.getImplementation(GCUBEService.class);
|
||||||
|
case Collection: return GHNContext.getImplementation(GCUBECollection.class);
|
||||||
|
case CS: return GHNContext.getImplementation(GCUBECS.class);
|
||||||
|
case CSInstance: return GHNContext.getImplementation(GCUBECSInstance.class);
|
||||||
|
case GHN: return GHNContext.getImplementation(GCUBEHostingNode.class);
|
||||||
|
case VRE: return GHNContext.getImplementation(GCUBEVRE.class);
|
||||||
|
case TransformationProgram: return GHNContext.getImplementation(GCUBETransformationProgram.class);
|
||||||
|
case MetadataCollection: return GHNContext.getImplementation(GCUBECollection.class);
|
||||||
|
case Generic: return GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ResourceType {
|
||||||
|
ExternalRunningInstance,
|
||||||
|
Service,
|
||||||
|
Collection,
|
||||||
|
CS,
|
||||||
|
CSInstance,
|
||||||
|
GHN,
|
||||||
|
gLiteSE,
|
||||||
|
gLiteCE,
|
||||||
|
gLiteSite,
|
||||||
|
gLiteService,
|
||||||
|
VRE,
|
||||||
|
Generic,
|
||||||
|
TransformationProgram,
|
||||||
|
MetadataCollection
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
|
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
|
||||||
|
|
||||||
public String removeScopeInProfile(RemoveScopeInProfileMessage message)throws GCUBEFault{return null;}
|
public String removeScopeInProfile(RemoveScopeInProfileMessage message)throws GCUBEFault{return null;}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
|
import org.gcube.common.core.is.publisher.ISPublisher;
|
||||||
import org.gcube.common.core.state.GCUBEWSResource;
|
import org.gcube.common.core.state.GCUBEWSResource;
|
||||||
import org.gcube.informationsystem.registry.impl.util.RegistrationThread;
|
import org.gcube.informationsystem.registry.impl.util.RegistrationThread;
|
||||||
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
|
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
|
||||||
|
@ -100,6 +102,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("Error on Registration Thread",e);
|
logger.error("Error on Registration Thread",e);
|
||||||
}
|
}
|
||||||
|
GHNContext.getImplementation(ISPublisher.class).registerWSResource(this,GHNContext.getContext().getDefaultScope());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on Initialization of Resource",e);
|
logger.error("Error on Initialization of Resource",e);
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package org.gcube.informationsystem.registry.test;
|
||||||
|
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
import org.apache.axis.message.addressing.Address;
|
||||||
|
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||||
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
|
import org.gcube.common.core.resources.GCUBEService;
|
||||||
|
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||||
|
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
||||||
|
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
|
||||||
|
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
||||||
|
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
||||||
|
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||||
|
|
||||||
|
public class RegistryTest {
|
||||||
|
|
||||||
|
public static void main (String[]args ) throws Exception {
|
||||||
|
|
||||||
|
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
|
||||||
|
|
||||||
|
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}};
|
||||||
|
|
||||||
|
ExtendedGSSCredential cred =org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]);
|
||||||
|
|
||||||
|
FileReader fis = new FileReader (args[1]);
|
||||||
|
// GHNContext.getImplementation(GCUBEService.class);
|
||||||
|
GCUBEService resource =GHNContext.getImplementation(GCUBEService.class);
|
||||||
|
EndpointReferenceType factoryEPR = new EndpointReferenceType();
|
||||||
|
resource.load(fis);
|
||||||
|
//resource.store(fir);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RegistryFactoryPortType registryFactoryPortType= null;
|
||||||
|
try {
|
||||||
|
factoryEPR.setAddress(new Address(args[0]));
|
||||||
|
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
CreateResourceMessage message = new CreateResourceMessage();
|
||||||
|
String profile ="";
|
||||||
|
managerSec.useCredentials(cred);
|
||||||
|
managerSec.setSecurity(registryFactoryPortType, GCUBESecurityManager.AuthMode.INTEGRITY, GCUBESecurityManager.DelegationMode.NONE);
|
||||||
|
try {
|
||||||
|
StringWriter writer =new StringWriter();
|
||||||
|
resource.store(writer);
|
||||||
|
message.setProfile(writer.toString());
|
||||||
|
message.setType(resource.getType());
|
||||||
|
profile =registryFactoryPortType.createResource(message);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println(profile);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue