This commit is contained in:
Andrea Manzi 2008-03-20 18:19:36 +00:00
parent ae73f7b809
commit 058fb3af46
4 changed files with 128 additions and 8 deletions

View File

@ -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 {
publisher.removeWSResource(this);
publisher.removeWSResource(this,GHNContext.getContext().getDefaultScope());
} catch (ISPublisherException e) {
e.printStackTrace();
}

View File

@ -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.ISMalformedQueryException;
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.GCUBEMCollection;
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.utils.logging.GCUBELog;
import org.gcube.common.is.publisher.impl.GCUBEPublisher;
@ -103,7 +113,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
public String createResource(CreateResourceMessage inputMessage) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault {
GCUBEResource resource = null;
GCUBEResource resource = null;
logSecurityInfo("createResource");
String profile = inputMessage.getProfile();
@ -114,10 +125,10 @@ public class RegistryFactory extends GCUBEStartupPortType{
throw new RemoteException(msg);
}
try {
resource.load ( new StringReader(profile));
resource.getType();
resource = this.getResourceClass(inputMessage.getType());
resource.load(new StringReader(profile));
//the parse Profile class allows to extract from profiles information about type/DL/UniqueID
//in order to distiguish among different Resource Type
@ -137,7 +148,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
}
catch (Exception ex)
{
logger.error("Error trying to loading profile");
logger.error("Error trying to load profile");
ex.printStackTrace();
throw new SchemaValidationFault();
}
@ -223,7 +234,8 @@ public class RegistryFactory extends GCUBEStartupPortType{
}
try {
resource.load(new StringReader(xmlProfile));
resource = this.getResourceClass(mess.getType());
resource.load(new StringReader(xmlProfile));
}
catch (Exception e) {
@ -456,7 +468,7 @@ public class RegistryFactory extends GCUBEStartupPortType{
private RegistryFactoryResource getResource() throws RemoteException {
Object resource = null;
try {
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("FactoryResource"));
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey("RegistryResource"));
//resource= ResourceContext.getResourceContext().getResource();
} catch (Exception e) {
logger.error(" Unable to access resource", e);
@ -466,6 +478,44 @@ public class RegistryFactory extends GCUBEStartupPortType{
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 removeScopeInProfile(RemoveScopeInProfileMessage message)throws GCUBEFault{return null;}

View File

@ -4,6 +4,8 @@ import java.util.ArrayList;
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.informationsystem.registry.impl.util.RegistrationThread;
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
@ -100,6 +102,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
e.printStackTrace();
logger.error("Error on Registration Thread",e);
}
GHNContext.getImplementation(ISPublisher.class).registerWSResource(this,GHNContext.getContext().getDefaultScope());
} catch (Exception e) {
logger.error("Error on Initialization of Resource",e);

View File

@ -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);
}
}