From f197ceeaafc129e628026bdb9827da379e243ec6 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Tue, 4 Nov 2008 17:42:02 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@6036 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../registry/impl/Registry.java | 8 ------- .../registry/impl/RegistryFactory.java | 22 ++++++++----------- .../impl/contexts/ProfileContext.java | 2 +- .../impl/contexts/ServiceContext.java | 4 ++-- .../registry/impl/state/ProfileResource.java | 8 +++---- .../impl/state/RegistryFactoryResource.java | 14 ------------ .../impl/util/RegistrationThread.java | 5 ----- .../registry/impl/util/RegistryUtil.java | 4 ++-- 8 files changed, 17 insertions(+), 50 deletions(-) diff --git a/src/org/gcube/informationsystem/registry/impl/Registry.java b/src/org/gcube/informationsystem/registry/impl/Registry.java index e65a177..66c39cd 100644 --- a/src/org/gcube/informationsystem/registry/impl/Registry.java +++ b/src/org/gcube/informationsystem/registry/impl/Registry.java @@ -1,18 +1,10 @@ package org.gcube.informationsystem.registry.impl; -import java.io.StringWriter; - -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - import org.apache.axis.utils.XMLUtils; import org.gcube.common.core.faults.GCUBEFault; import org.gcube.informationsystem.registry.impl.contexts.ProfileContext; import org.gcube.informationsystem.registry.impl.state.ProfileResource; import org.gcube.informationsystem.registry.stubs.GetProfileString; -import org.globus.wsrf.ResourceException; /** diff --git a/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java index bc90e16..e6fb17c 100644 --- a/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java +++ b/src/org/gcube/informationsystem/registry/impl/RegistryFactory.java @@ -13,12 +13,9 @@ import java.util.Collections; import java.util.List; import org.apache.axis.components.uuid.UUIDGen; import org.apache.axis.components.uuid.UUIDGenFactory; -import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.faults.GCUBEFault; -import org.gcube.common.core.resources.GCUBEGenericResource; import org.gcube.common.core.resources.GCUBEHostingNode; import org.gcube.common.core.resources.GCUBEResource; -import org.gcube.common.core.resources.impl.kxml.GCUBEResourceImpl; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.state.GCUBEWSResourceKey; import org.gcube.common.core.utils.events.GCUBEEvent; @@ -78,7 +75,7 @@ public class RegistryFactory{ /** * Map of registration to Notification */ - public static List notificationMap = Collections.synchronizedList(new ArrayList()); + public static final List notificationMap = Collections.synchronizedList(new ArrayList()); /** the key used to label the Factory Resource */ public static final String NOTIFICATOR_RESOURCE_KEY = "RegistryResource"; @@ -116,6 +113,7 @@ public class RegistryFactory{ * @throws RemoteException * @throws ProfileAlreadyRegisteredFault */ + @SuppressWarnings("unchecked") public String createResource(CreateResourceMessage mess) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault { GCUBEResource resource=null; @@ -136,12 +134,7 @@ public class RegistryFactory{ resource=ResourceType.valueOf(mess.getType()).getResourceClass(); resource.load(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(profile.getBytes("UTF-8")), "UTF-8"))); - - if (mess.getType().compareTo(GCUBEGenericResource.TYPE)==0){ - System.out.println("profile:" +profile); - System.out.println("------------"); - System.out.println(((GCUBEGenericResource) resource).getBody()); - } + //the parse Profile class allows to extract from profiles information about type/SCOPE/UniqueID //in order to distinguish among different Resource Type //Adding scopes to Profile @@ -269,6 +262,7 @@ public class RegistryFactory{ * @return RemoveResourceResponse * @throws RemoteException Exceptions */ + @SuppressWarnings("unchecked") public RemoveResourceResponse removeResource (RemoveResourceMessage inputMessage) throws RemoteException,GCUBEFault{ logSecurityInfo("removeResource"); logger.info("RemoveResource operation invoked"); @@ -303,7 +297,9 @@ public class RegistryFactory{ if (type.compareTo(GCUBEHostingNode.TYPE) == 0) RegistryUtil.unregisterRIRelatedToGHN(ID,this); } catch (Exception e) { - logger.error("Error removing profile related to this GHNID for ID ", e); + logger.error("Error removing profile related to this GHNID for ID ", e); + System.out.println("error removing RI related to GHN"); + e.printStackTrace(); } if (this.isResourceCreated(ID)){ @@ -318,9 +314,9 @@ public class RegistryFactory{ throw new RemoteException(); } try { - + GCUBEEvent event = new GCUBEEvent(); - GCUBEResource resource =GHNContext.getImplementation(GCUBEResource.class); + GCUBEResource resource =ResourceType.valueOf(type).getResourceClass(); resource.setID(ID); event.setPayload(resource); ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.REMOVE, event); diff --git a/src/org/gcube/informationsystem/registry/impl/contexts/ProfileContext.java b/src/org/gcube/informationsystem/registry/impl/contexts/ProfileContext.java index 05b036e..7f94a5c 100644 --- a/src/org/gcube/informationsystem/registry/impl/contexts/ProfileContext.java +++ b/src/org/gcube/informationsystem/registry/impl/contexts/ProfileContext.java @@ -15,7 +15,7 @@ public class ProfileContext extends GCUBEStatefulPortTypeContext{ private ProfileContext(){} - protected static ProfileContext cache = new ProfileContext(); + protected static final ProfileContext cache = new ProfileContext(); public static ProfileContext getContext() { diff --git a/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java b/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java index 0f505bc..6b13ddf 100644 --- a/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java +++ b/src/org/gcube/informationsystem/registry/impl/contexts/ServiceContext.java @@ -15,7 +15,6 @@ import org.gcube.common.core.resources.GCUBEHostingNode; import org.gcube.common.core.resources.GCUBEResource; import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.common.core.state.GCUBETopicList; import org.gcube.common.core.utils.events.GCUBEProducer; import org.gcube.common.core.utils.events.GCUBETopic; import org.gcube.common.core.utils.handlers.GCUBEHandler; @@ -35,7 +34,7 @@ public class ServiceContext extends GCUBEServiceContext { public static final String JNDI_NAME = "gcube/informationsystem/registry"; - protected static ServiceContext cache = new ServiceContext(); + protected static final ServiceContext cache = new ServiceContext(); protected ISClient client = null; @@ -89,6 +88,7 @@ public class ServiceContext extends GCUBEServiceContext { return topicProducer; } + @SuppressWarnings("unchecked") @Override protected void onReady() throws Exception { diff --git a/src/org/gcube/informationsystem/registry/impl/state/ProfileResource.java b/src/org/gcube/informationsystem/registry/impl/state/ProfileResource.java index 5d024f5..4d99f53 100644 --- a/src/org/gcube/informationsystem/registry/impl/state/ProfileResource.java +++ b/src/org/gcube/informationsystem/registry/impl/state/ProfileResource.java @@ -8,8 +8,6 @@ import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; - -import org.apache.axis.utils.XMLUtils; import org.gcube.common.core.informationsystem.notifier.ISNotifier; import org.gcube.common.core.informationsystem.publisher.ISPublisher; import org.gcube.common.core.informationsystem.publisher.ISPublisherException; @@ -24,7 +22,6 @@ import org.gcube.informationsystem.registry.impl.RegistryFactory; import org.gcube.informationsystem.registry.impl.contexts.ProfileContext; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext; import org.globus.wsrf.ResourceException; -import org.globus.wsrf.Topic; import org.globus.wsrf.impl.SimpleTopic; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -75,7 +72,7 @@ public class ProfileResource extends GCUBEWSResource { try { resource.store(writer); - System.out.println("create Profile "+ writer.toString()); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); @@ -158,7 +155,7 @@ public class ProfileResource extends GCUBEWSResource { * @return the Resource QName */ private QName generateQName() { - return new QName(ProfileContext.getContext().getNamespace(), NotificationProfileRP.toString()+this.getID().getValue()); + return new QName(ProfileContext.getContext().getNamespace(), NotificationProfileRP+this.getID().getValue()); } public GCUBEResource getGCubeResource() { @@ -207,6 +204,7 @@ public class ProfileResource extends GCUBEWSResource { } + @SuppressWarnings("unchecked") public void updateResource(GCUBEResource resource) throws Exception{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/src/org/gcube/informationsystem/registry/impl/state/RegistryFactoryResource.java b/src/org/gcube/informationsystem/registry/impl/state/RegistryFactoryResource.java index 402fb3d..7ea06cc 100644 --- a/src/org/gcube/informationsystem/registry/impl/state/RegistryFactoryResource.java +++ b/src/org/gcube/informationsystem/registry/impl/state/RegistryFactoryResource.java @@ -125,7 +125,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RI property * */ - @SuppressWarnings("unchecked") public void setRunningInstance (RegistryProperty property) { this.getResourcePropertySet().get(RunningInstanceRP).clear(); this.getResourcePropertySet().get(RunningInstanceRP).add(property); @@ -150,7 +149,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setExternalRunningInstance (RegistryProperty property) { this.getResourcePropertySet().get(ExternalRunningInstanceRP).clear(); this.getResourcePropertySet().get(ExternalRunningInstanceRP).add(property); @@ -177,7 +175,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * */ - @SuppressWarnings("unchecked") public void setService (RegistryProperty property) { this.getResourcePropertySet().get(ServiceRP).clear(); this.getResourcePropertySet().get(ServiceRP).add(property); @@ -203,7 +200,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setCollection (RegistryProperty property) { this.getResourcePropertySet().get(CollectionRP).clear(); this.getResourcePropertySet().get(CollectionRP).add(property); @@ -228,7 +224,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setCS (RegistryProperty property) { this.getResourcePropertySet().get(CSRP).clear(); this.getResourcePropertySet().get(CSRP).add(property); @@ -253,7 +248,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setCSInstance (RegistryProperty property) { this.getResourcePropertySet().get(CSInstanceRP).clear(); this.getResourcePropertySet().get(CSInstanceRP).add(property); @@ -279,7 +273,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGHN (RegistryProperty property) { this.getResourcePropertySet().get(GHNRP).clear(); this.getResourcePropertySet().get(GHNRP).add(property); @@ -303,7 +296,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGLiteSE (RegistryProperty property) { this.getResourcePropertySet().get(gLiteSERP).clear(); this.getResourcePropertySet().get(gLiteSERP).add(property); @@ -327,7 +319,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGLiteCE (RegistryProperty property) { this.getResourcePropertySet().get(gLiteCERP).clear(); this.getResourcePropertySet().get(gLiteCERP).add(property); @@ -353,7 +344,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGLiteSite (RegistryProperty property) { this.getResourcePropertySet().get(gLiteSiteRP).clear(); this.getResourcePropertySet().get(gLiteSiteRP).add(property); @@ -378,7 +368,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGLiteService (RegistryProperty property) { this.getResourcePropertySet().get(gLiteServiceRP).clear(); this.getResourcePropertySet().get(gLiteServiceRP).add(property); @@ -402,7 +391,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setVRE (RegistryProperty property) { this.getResourcePropertySet().get(VRERP).clear(); this.getResourcePropertySet().get(VRERP).add(property); @@ -427,7 +415,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setMetadataCollection (RegistryProperty property) { this.getResourcePropertySet().get(MetadataCollectionRP).clear(); this.getResourcePropertySet().get(MetadataCollectionRP).add(property); @@ -454,7 +441,6 @@ public class RegistryFactoryResource extends GCUBEWSResource { * @param property The RegistryProperty * */ - @SuppressWarnings("unchecked") public void setGenericResource (RegistryProperty property) { this.getResourcePropertySet().get(GenericResourceRP).clear(); this.getResourcePropertySet().get(GenericResourceRP).add(property); diff --git a/src/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java b/src/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java index 67a15bf..9978fa0 100644 --- a/src/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java +++ b/src/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java @@ -1,12 +1,7 @@ package org.gcube.informationsystem.registry.impl.util; -import java.util.ArrayList; import java.util.List; - -import javax.xml.namespace.QName; - import org.gcube.common.core.informationsystem.notifier.ISNotifier; -import org.gcube.common.core.informationsystem.publisher.ISPublisher; import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBELog; diff --git a/src/org/gcube/informationsystem/registry/impl/util/RegistryUtil.java b/src/org/gcube/informationsystem/registry/impl/util/RegistryUtil.java index c778d0a..2b533d0 100644 --- a/src/org/gcube/informationsystem/registry/impl/util/RegistryUtil.java +++ b/src/org/gcube/informationsystem/registry/impl/util/RegistryUtil.java @@ -67,7 +67,7 @@ public class RegistryUtil { if (client==null) client = GHNContext.getImplementation(ISClient.class); RemoveResourceMessage message = null; GCUBEGenericQuery query = client.getQuery("RIOnGHN"); - query.addParameters(new QueryParameter("ID", GHNContext.getContext().getGHNID())); + query.addParameters(new QueryParameter("ID", id)); //query to IS on order to retrieve the RI deployed on the GHN; List resources = client.execute(query, ServiceContext.getContext().getScope()); @@ -82,6 +82,6 @@ public class RegistryUtil { } catch (RemoteException rme) {} } - } + } } }