Compare commits

...

10 Commits

Author SHA1 Message Date
Lucio Lelii 44a54c9150 added field invocationScope to the Registry Factory property
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@60418 82a268e6-3cf1-43bd-a215-b396298e98cf
2012-10-24 15:47:54 +00:00
Manuele Simi e592963fa2 cleaning up the project
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@54294 82a268e6-3cf1-43bd-a215-b396298e98cf
2012-05-05 21:25:38 +00:00
Manuele Simi 0a659ececd Updating README for IS-Registry
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@54293 82a268e6-3cf1-43bd-a215-b396298e98cf
2012-05-05 21:23:26 +00:00
Manuele Simi cba4b9239e WS-Topic for Runtime Resources added
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@53135 82a268e6-3cf1-43bd-a215-b396298e98cf
2012-04-05 16:27:19 +00:00
Manuele Simi dbe11e0cdb IS-Registry test-suite modified for supporting the recursive registration of entire folders of resources
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@48372 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-11-10 16:55:48 +00:00
Manuele Simi 28985c6293 Merging from branch 2.1.x
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@46755 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-10-20 20:53:23 +00:00
Manuele Simi 3f3787da1e Updating secure test-suite
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@44101 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-08-02 14:38:51 +00:00
Manuele Simi c2615afce3 Decoupling the testsuite from the stubs, introducing dedicated ant tasks and adding a secure client for resource registration
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@43034 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-07-22 02:57:52 +00:00
Manuele Simi 4babb8014f Updating changelog for 2.1 release
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@36601 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-03-25 16:10:22 +00:00
Manuele Simi a68073786e Updaters for gHNs and RIs
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@36550 82a268e6-3cf1-43bd-a215-b396298e98cf
2011-03-24 14:52:20 +00:00
28 changed files with 615 additions and 308 deletions

View File

@ -4,9 +4,6 @@
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="src" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIBS"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
<classpathentry kind="lib" path="/Dependencies/ISREGISTRY/org.gcube.informationsystem.registry.stubs.jar"/>
<classpathentry kind="lib" path="/Dependencies/ISCollector/org.gcube.informationsystem.collector.stubs.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/GCF.1.1.0"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>Registry</name> <name>Registry.trunk</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

12
README
View File

@ -1,9 +1,13 @@
The gCube System - ISRegistry The gCube System - ISRegistry
------------------------------------------------------------ ------------------------------------------------------------
This work is partially funded by the European Commission in the This work has been partially supported by the following European projects:
context of the D4Science project (www.d4science.eu), under the 1st DILIGENT (FP6-2003-IST-2),
call of FP7 IST priority. D4Science (FP7-INFRA-2007-1.2.2),
D4Science-II (FP7-INFRA-2008-1.2.2), i
Marine (FP7-INFRASTRUCTURES-2011-2), and
EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).
Authors Authors
@ -18,7 +22,7 @@ Authors
Version and Release Date Version and Release Date
------------------------ ------------------------
v. 2.0.0 (07-02-2011) v. 2.1.3 (05-04-2012)
Description Description

View File

@ -59,6 +59,8 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
<property name="etc.dir.name" value="etc" /> <property name="etc.dir.name" value="etc" />
<property name="etc.dir" value="${service.dir}/${etc.dir.name}" /> <property name="etc.dir" value="${service.dir}/${etc.dir.name}" />
<property name="source.dir" value="${service.dir}/src" /> <property name="source.dir" value="${service.dir}/src" />
<property name="testsuite.dir" value="${service.dir}/test" />
<!-- load input properties --> <!-- load input properties -->
@ -73,6 +75,8 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
<property name="garfile" value="${garname}.gar"/> <property name="garfile" value="${garname}.gar"/>
<property name="jarfile" value="${package}.jar" /> <property name="jarfile" value="${package}.jar" />
<property name="jarfile.stubs" value="${package}.stubs.jar" /> <property name="jarfile.stubs" value="${package}.stubs.jar" />
<property name="jarfile.testsuite" value="${package}.testsuite.jar" />
<if name="etics.build" value="true"> <if name="etics.build" value="true">
<property name="build.location" location="${service.dir}" /> <property name="build.location" location="${service.dir}" />
@ -90,6 +94,7 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
<property name="stubs.package" value="${package}.${stubs.dir.name}"/> <property name="stubs.package" value="${package}.${stubs.dir.name}"/>
<property name="stubs.dir.name" value="stubs" /> <!-- auxiliary stub classes --> <property name="stubs.dir.name" value="stubs" /> <!-- auxiliary stub classes -->
<property name="stubs.dir" value="${source.dir}/${package.dir}/${stubs.dir.name}" /> <property name="stubs.dir" value="${source.dir}/${package.dir}/${stubs.dir.name}" />
<available file="${stubs.dir}" property="stubs.dir.present"/> <available file="${stubs.dir}" property="stubs.dir.present"/>
<!-- temporary build locations --> <!-- temporary build locations -->
@ -101,6 +106,9 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
<property name="build.stubs.dir" location="${build.dir}/stubs-${package}" /> <property name="build.stubs.dir" location="${build.dir}/stubs-${package}" />
<property name="build.stubs.src.dir" location="${build.stubs.dir}/src" /> <property name="build.stubs.src.dir" location="${build.stubs.dir}/src" />
<property name="build.stubs.class.dir" location="${build.stubs.dir}/classes" /> <property name="build.stubs.class.dir" location="${build.stubs.dir}/classes" />
<property name="build.testsuite.dir" location="${build.dir}/testsuite-${package}" />
<property name="build.testsuite.src.dir" location="${build.testsuite.dir}/test" />
<property name="build.testsuite.class.dir" location="${build.testsuite.dir}/classes" />
<!-- misc defaults --> <!-- misc defaults -->
<property name="java.debug" value="on" /> <property name="java.debug" value="on" />
@ -144,7 +152,11 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
<mkdir dir="${build.stubs.dir}" /> <mkdir dir="${build.stubs.dir}" />
<mkdir dir="${build.stubs.src.dir}" /> <mkdir dir="${build.stubs.src.dir}" />
<mkdir dir="${build.stubs.class.dir}"/> <mkdir dir="${build.stubs.class.dir}"/>
<mkdir dir="${build.testsuite.dir}" />
<mkdir dir="${build.testsuite.src.dir}" />
<mkdir dir="${build.testsuite.class.dir}"/>
<!-- Populates schema folder --> <!-- Populates schema folder -->
<copy toDir="${build.schema.dir}"> <copy toDir="${build.schema.dir}">
<fileset dir="${container.schema.dir}" casesensitive="yes"> <fileset dir="${container.schema.dir}" casesensitive="yes">
@ -462,10 +474,39 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
</copy> </copy>
</target> </target>
<target name="buildTestsuite" depends="init" description="testsuite">
<copy toDir="${build.testsuite.src.dir}/" overwrite="true">
<fileset dir="${testsuite.dir}" casesensitive="yes">
<exclude name="**/*.class" />
</fileset>
</copy>
<javac srcdir="${build.testsuite.src.dir}" destdir="${build.testsuite.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}" description="compile testsuite classes">
<include name="**/*.java" />
<classpath>
<fileset dir="${container.dir}/lib">
<include name="*.jar" />
<exclude name="${jarfile.testsuite}" />
<exclude name="${jarfile}" />
</fileset>
<fileset dir="${lib.location}">
<include name="**/*.jar" />
<exclude name="**/${jarfile.testsuite}" />
<exclude name="**/${jarfile}" />
</fileset>
</classpath>
</javac>
</target>
<target name="jarStubs" depends="buildStubs" description="jar stub classes"> <target name="jarStubs" depends="buildStubs" description="jar stub classes">
<jar destfile="${build.lib.dir}/${jarfile.stubs}" basedir="${build.stubs.class.dir}" /> <jar destfile="${build.lib.dir}/${jarfile.stubs}" basedir="${build.stubs.class.dir}" />
</target> </target>
<target name="jarTestSuite" depends="buildTestsuite" description="jar testsuite classes">
<jar destfile="${build.lib.dir}/${jarfile.testsuite}" basedir="${build.testsuite.class.dir}" />
</target>
<target name="testsuite" depends="jarTestSuite" description="generates and jars testsuite"/>
<target name="deployStubs" depends="jarStubs" description="deploy stub jar"> <target name="deployStubs" depends="jarStubs" description="deploy stub jar">
<copy file="${build.lib.dir}/${jarfile.stubs}" toDir="${lib.location}"/> <copy file="${build.lib.dir}/${jarfile.stubs}" toDir="${lib.location}"/>
<if name="etics.build" value="false"> <if name="etics.build" value="false">

View File

@ -1,4 +1,21 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.information-system.registry.2-1-4" date="2012-10-24">
<Change>Adding new field in the factory property for the caller scope</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.2-1-3" date="2012-04-05">
<Change>Adding WS-Topic for the new Runtime Resource</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.2-1-2" date="2011-10-06">
<Change>Adding mapping for the new Runtime Resource</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.2-1-1" date="2011-07-11">
<Change>WS-Resources of a to-be-removed RI are deleted synchronously and bulky</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.2-1-0" date="2011-03-25">
<Change>Adding pre/post processing mechanisms for configurable resource manipulation</Change>
<Change>Removing the old and unused Registry portType</Change>
</Changeset>
<Changeset component="org.gcube.information-system.registry.2-0-0" date="2011-02-07"> <Changeset component="org.gcube.information-system.registry.2-0-0" date="2011-02-07">
<Change>Porting on the new XMLCollectionAccess portType exposed by the IS-Collector</Change> <Change>Porting on the new XMLCollectionAccess portType exposed by the IS-Collector</Change>
<Change>New ResourceRegistration portType</Change> <Change>New ResourceRegistration portType</Change>

View File

@ -3,7 +3,7 @@
<ID/> <ID/>
<Type>Service</Type> <Type>Service</Type>
<Profile> <Profile>
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description> <Description>Registry service for gCube Resources</Description>
<Class>InformationSystem</Class> <Class>InformationSystem</Class>
<Name>IS-Registry</Name> <Name>IS-Registry</Name>
<Version>1.0.0</Version> <Version>1.0.0</Version>
@ -16,9 +16,9 @@
</Dependencies> </Dependencies>
<Packages> <Packages>
<Main> <Main>
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description> <Description>IS-Registry: validate, register and unregister gCube resources to/from the IS. It exposes WS-Topics for notifications about gCube resources' lifecycle</Description>
<Name>IS-Registry-service</Name> <Name>IS-Registry-service</Name>
<Version>2.1.0</Version> <Version>2.1.4</Version>
<Mandatory level="VO"/> <Mandatory level="VO"/>
<Shareable level="VO"/> <Shareable level="VO"/>
<GHNRequirements> <GHNRequirements>
@ -32,7 +32,7 @@
<Version>1.0.0</Version> <Version>1.0.0</Version>
</Service> </Service>
<Package>IS-Registry-stubs</Package> <Package>IS-Registry-stubs</Package>
<Version>2.1.0</Version> <Version>2.1.4</Version>
<Scope level="GHN"/> <Scope level="GHN"/>
<Optional>false</Optional> <Optional>false</Optional>
</Dependency> </Dependency>
@ -50,9 +50,9 @@
</PortType> </PortType>
</Main> </Main>
<Software> <Software>
<Description>IS-Registry: validate, register and unregister GCUBE resources to/from the IS. It also publishes Topics for notifications about GCUBE resource events</Description> <Description>Stub classes for interfacing the IS-Registry</Description>
<Name>IS-Registry-stubs</Name> <Name>IS-Registry-stubs</Name>
<Version>2.1.0</Version> <Version>2.1.4</Version>
<MultiVersion value="true"/> <MultiVersion value="true"/>
<Mandatory level="GHN"/> <Mandatory level="GHN"/>
<Shareable level="VO"/> <Shareable level="VO"/>

View File

@ -84,7 +84,8 @@
<xsd:element name="uniqueID" type="xsd:string" nillable="true"/> <xsd:element name="uniqueID" type="xsd:string" nillable="true"/>
<xsd:element name="profile" type="xsd:string" nillable="true"/> <xsd:element name="profile" type="xsd:string" nillable="true"/>
<xsd:element name="operationType" type="xsd:string" nillable="true"/> <xsd:element name="operationType" type="xsd:string" nillable="true"/>
<xsd:element name="changeTime" type="xsd:dateTime" nillable="true"/> <xsd:element name="changeTime" type="xsd:dateTime" nillable="true"/>
<xsd:element name="invocationScope" type="xsd:string" nillable="true"/>
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
@ -96,11 +97,7 @@
<xsd:element name="Service" type="tns:RegistryProperty"/> <xsd:element name="Service" type="tns:RegistryProperty"/>
<xsd:element name="Collection" type="tns:RegistryProperty"/> <xsd:element name="Collection" type="tns:RegistryProperty"/>
<xsd:element name="CS" type="tns:RegistryProperty"/>
<xsd:element name="CSInstance" type="tns:RegistryProperty"/>
<xsd:element name="GHN" type="tns:RegistryProperty"/> <xsd:element name="GHN" type="tns:RegistryProperty"/>
<xsd:element name="gLiteSE" type="tns:RegistryProperty"/> <xsd:element name="gLiteSE" type="tns:RegistryProperty"/>
@ -116,6 +113,9 @@
<xsd:element name="MetadataCollection" type="tns:RegistryProperty"/> <xsd:element name="MetadataCollection" type="tns:RegistryProperty"/>
<xsd:element name="GenericResource" type="tns:RegistryProperty"/> <xsd:element name="GenericResource" type="tns:RegistryProperty"/>
<xsd:element name="RuntimeResource" type="tns:RegistryProperty"/>
<xsd:element name="RegistryFactoryResourceProperties"> <xsd:element name="RegistryFactoryResourceProperties">
<xsd:complexType> <xsd:complexType>
@ -124,8 +124,6 @@
<xsd:element ref="tns:ExternalRunningInstance" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:ExternalRunningInstance" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:Service" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:Service" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:Collection" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:Collection" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:CS" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:CSInstance" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:GHN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:GHN" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:gLiteSE" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:gLiteSE" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:gLiteCE" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:gLiteCE" minOccurs="1" maxOccurs="1"/>
@ -134,6 +132,7 @@
<xsd:element ref="tns:VRE" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:VRE" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:MetadataCollection" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:MetadataCollection" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:GenericResource" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:GenericResource" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:RuntimeResource" minOccurs="1" maxOccurs="1"/>
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>

View File

@ -11,9 +11,12 @@ import org.gcube.common.core.utils.events.GCUBEProducer;
import org.gcube.common.core.utils.events.GCUBETopic; import org.gcube.common.core.utils.events.GCUBETopic;
import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler; import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler;
import org.gcube.informationsystem.registry.impl.local.LocalProfileConsumerImpl; import org.gcube.informationsystem.registry.impl.local.LocalProfileConsumerImpl;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers; import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.GHNPurger; import org.gcube.informationsystem.registry.impl.postprocessing.remove.GHNPurger;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.RIPurger; import org.gcube.informationsystem.registry.impl.postprocessing.remove.RIPurger;
import org.gcube.informationsystem.registry.impl.postprocessing.update.AvailableUpdaters;
import org.gcube.informationsystem.registry.impl.postprocessing.update.GHNUpdater;
import org.gcube.informationsystem.registry.impl.postprocessing.update.RIUpdater;
@ -43,10 +46,11 @@ public class ServiceContext extends GCUBEServiceContext {
protected GCUBEProducer<RegistryTopic, GCUBEResource> topicProducer; protected GCUBEProducer<RegistryTopic, GCUBEResource> topicProducer;
@SuppressWarnings("unchecked") @SuppressWarnings("rawtypes")
protected class NotificationResourceScheduler extends GCUBEScheduledHandler { protected class NotificationResourceScheduler extends GCUBEScheduledHandler {
@SuppressWarnings("unchecked")
public NotificationResourceScheduler(long interval, Mode mode) { public NotificationResourceScheduler(long interval, Mode mode) {
super(interval, mode); super(interval, mode);
} }
@ -105,6 +109,10 @@ public class ServiceContext extends GCUBEServiceContext {
//register purgers for GCUBEResources //register purgers for GCUBEResources
AvailablePurgers.register(new GHNPurger()); AvailablePurgers.register(new GHNPurger());
AvailablePurgers.register(new RIPurger()); AvailablePurgers.register(new RIPurger());
//register updaers for GCUBEResources
AvailableUpdaters.register(new GHNUpdater());
AvailableUpdaters.register(new RIUpdater());
} }

View File

@ -10,8 +10,10 @@ import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic;
import org.gcube.informationsystem.registry.impl.local.LocalNotifier; import org.gcube.informationsystem.registry.impl.local.LocalNotifier;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers; import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.Purger; import org.gcube.informationsystem.registry.impl.postprocessing.remove.Purger;
import org.gcube.informationsystem.registry.impl.postprocessing.update.AvailableUpdaters;
import org.gcube.informationsystem.registry.impl.postprocessing.update.Updater;
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType; import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings; import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
@ -23,13 +25,25 @@ public class LocalResourceRegistration {
ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class); ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext()); publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
logger.debug("Resource " + resource.getID() + " successfully created"); logger.debug("Resource " + resource.getID() + " successfully created");
logger.trace("Looking for updater for "+ resource.getType());
Updater<?> updater = AvailableUpdaters.getPurger(resource.getType());
if (updater != null) {
try {
logger.debug("Applying updater for " + resource.getType());
updater.update(resource.getClass().cast(resource), ServiceContext.getContext().getScope());
} catch (Exception e) {
logger.error("Error while updating the profiles related to the resource", e);
}
} else
logger.trace("No updater found");
//let the notifiers know //let the notifiers know
LocalNotifier.notifyEvent(resource, RegistryTopic.CREATE); LocalNotifier.notifyEvent(resource, RegistryTopic.CREATE);
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
resource.store(writer); resource.store(writer);
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf( RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(
resource.getType()), OperationType.create, resource.getType()), OperationType.create,
Calendar.getInstance(), writer.toString()); Calendar.getInstance(), writer.toString(), ServiceContext.getContext().getScope());
} }
/** /**
* *
@ -57,18 +71,29 @@ public class LocalResourceRegistration {
GCUBEResource resource = ResourceMappings.valueOf(type).getResourceImplementation(); GCUBEResource resource = ResourceMappings.valueOf(type).getResourceImplementation();
resource.setID(id); resource.setID(id);
LocalNotifier.notifyEvent(resource, RegistryTopic.REMOVE); LocalNotifier.notifyEvent(resource, RegistryTopic.REMOVE);
RegistryFactory.updateCounterInfo(id, ResourceMappings.valueOf(type),OperationType.destroy, Calendar.getInstance(), null); RegistryFactory.updateCounterInfo(id, ResourceMappings.valueOf(type),OperationType.destroy, Calendar.getInstance(), null, ServiceContext.getContext().getScope());
} }
public void update(GCUBEResource resource) throws Exception { public void update(GCUBEResource resource) throws Exception {
ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class); ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext()); publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
logger.debug("Resource " + resource.getID() + " successfully updated"); logger.debug("Resource " + resource.getID() + " successfully updated");
logger.trace("Looking for updater for "+ resource.getType());
Updater<?> updater = AvailableUpdaters.getPurger(resource.getType());
if (updater != null) {
try {
logger.debug("Applying updater for " + resource.getType());
updater.update(resource.getClass().cast(resource), ServiceContext.getContext().getScope());
} catch (Exception e) {
logger.error("Error while updating the profiles related to the resource", e);
}
} else
logger.trace("No updater found");
LocalNotifier.notifyEvent(resource, RegistryTopic.UPDATE); LocalNotifier.notifyEvent(resource, RegistryTopic.UPDATE);
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
resource.store(writer); resource.store(writer);
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(resource.getType()), RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(resource.getType()),
OperationType.update, Calendar.getInstance(), writer.toString()); OperationType.update, Calendar.getInstance(), writer.toString(), ServiceContext.getContext().getScope());
} }
} }

View File

@ -11,7 +11,6 @@ import org.gcube.common.core.resources.GCUBEResource;
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.informationsystem.registry.impl.contexts.FactoryContext; import org.gcube.informationsystem.registry.impl.contexts.FactoryContext;
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource; import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType; import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
@ -183,13 +182,15 @@ public class RegistryFactory extends GCUBEPortType {
*/ */
protected static synchronized void updateCounterInfo(String ID, protected static synchronized void updateCounterInfo(String ID,
ResourceMappings resType, OperationType opType, Calendar updateTime, ResourceMappings resType, OperationType opType, Calendar updateTime,
String profile) throws Exception { String profile, GCUBEScope scope) throws Exception {
//return; //return;
RegistryProperty property = new RegistryProperty(); RegistryProperty property = new RegistryProperty();
property.setUniqueID(ID); property.setUniqueID(ID);
property.setProfile(profile); property.setProfile(profile);
property.setOperationType(opType.name()); property.setOperationType(opType.name());
property.setChangeTime(updateTime); property.setChangeTime(updateTime);
property.setInvocationScope(scope.toString());
// select the type of the resource to update // select the type of the resource to update
logger.trace("Notifying about resource " + ID +", event: " + opType); logger.trace("Notifying about resource " + ID +", event: " + opType);
for (Method method : getResource().getClass().getDeclaredMethods()) { for (Method method : getResource().getClass().getDeclaredMethods()) {

View File

@ -4,27 +4,16 @@ import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.Calendar;
import org.apache.axis.components.uuid.UUIDGen; import org.apache.axis.components.uuid.UUIDGen;
import org.apache.axis.components.uuid.UUIDGenFactory; import org.apache.axis.components.uuid.UUIDGenFactory;
import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
import org.gcube.common.core.informationsystem.publisher.ISResourcePublisher;
import org.gcube.common.core.porttypes.GCUBEPortType; import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource; import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext; import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext.RegistryTopic;
import org.gcube.informationsystem.registry.impl.local.LocalNotifier;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.GHNPurger;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.Purger;
import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterManager; import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterManager;
import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterExecutor.InvalidFilterException; import org.gcube.informationsystem.registry.impl.preprocessing.filters.FilterExecutor.InvalidFilterException;
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings; import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateFault; import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateFault;
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage; import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.impl.postprocessing.purging; package org.gcube.informationsystem.registry.impl.postprocessing.remove;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.impl.postprocessing.purging; package org.gcube.informationsystem.registry.impl.postprocessing.remove;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.HashSet; import java.util.HashSet;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.impl.postprocessing.purging; package org.gcube.informationsystem.registry.impl.postprocessing.remove;
import java.util.Set; import java.util.Set;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.impl.postprocessing.purging; package org.gcube.informationsystem.registry.impl.postprocessing.remove;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;

View File

@ -0,0 +1,21 @@
package org.gcube.informationsystem.registry.impl.postprocessing.update;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.core.utils.logging.GCUBELog;
public class AvailableUpdaters {
private static Map<String, Updater<?>> updaters = new HashMap<String, Updater<?>>();
private static GCUBELog logger = new GCUBELog(AvailableUpdaters.class);
public static void register(Updater<?> updater) {
updaters.put(updater.getName(), updater);
logger.debug ("Updater " + updater.getName() + " registered");
}
public static Updater<?> getPurger(String updaterName) {
return updaters.get(updaterName);
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.informationsystem.registry.impl.postprocessing.update;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.remove.Purger;
public class GHNUpdater implements Updater<GCUBEHostingNode> {
protected final GCUBELog logger = new GCUBELog(GHNUpdater.class);
@Override
public void update(GCUBEResource resource, GCUBEScope scope) {
if (! (resource instanceof GCUBEHostingNode))
return;
GCUBEHostingNode node = (GCUBEHostingNode) resource;
logger.trace("The gHN is currently in status " + node.getNodeDescription().getStatus().toString());
if ((node.getNodeDescription().getStatus() == GHNContext.Status.DOWN)
||(node.getNodeDescription().getStatus() == GHNContext.Status.FAILED)) {
logger.trace("Looking for purger for "+ GCUBEHostingNode.TYPE);
Purger<?> purger = AvailablePurgers.getPurger(GCUBEHostingNode.TYPE);
if (purger != null) {
try {
logger.debug("Applying purger for " + GCUBEHostingNode.TYPE);
purger.purge(node.getID(), scope);
} catch (Exception e) {
logger.error("Error while removing the profiles related to the resource", e);
}
} else
logger.trace("No purger found");
}
}
@Override
public String getName() {
return GCUBEHostingNode.TYPE;
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.informationsystem.registry.impl.postprocessing.update;
import org.gcube.common.core.contexts.GCUBEServiceContext;
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.utils.logging.GCUBELog;
import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.remove.Purger;
public class RIUpdater implements Updater<GCUBERunningInstance> {
protected final GCUBELog logger = new GCUBELog(RIUpdater.class);
@Override
public void update(GCUBEResource resource, GCUBEScope scope) {
if (! (resource instanceof GCUBERunningInstance))
return;
GCUBERunningInstance ri = (GCUBERunningInstance) resource;
logger.trace("The Running Instance is currently in state " + ri.getDeploymentData().getState());
if ((ri.getDeploymentData().getState().equals(GCUBEServiceContext.Status.DOWN.toString()))
||(ri.getDeploymentData().getState().equals(GCUBEServiceContext.Status.FAILED.toString()))) {
logger.trace("Looking for purger for "+ GCUBERunningInstance.TYPE);
Purger<?> purger = AvailablePurgers.getPurger(GCUBERunningInstance.TYPE);
if (purger != null) {
try {
logger.debug("Applying purger for " + GCUBERunningInstance.TYPE);
purger.purge(ri.getID(), scope);
} catch (Exception e) {
logger.error("Error while removing the profiles related to the resource", e);
}
} else
logger.trace("No purger found");
}
}
@Override
public String getName() {
return GCUBERunningInstance.TYPE;
}
}

View File

@ -0,0 +1,15 @@
package org.gcube.informationsystem.registry.impl.postprocessing.update;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.scope.GCUBEScope;
public interface Updater <RESOURCE extends GCUBEResource> {
public void update(GCUBEResource resource, GCUBEScope scope);
/**
* Gets the type of resource managed by the purgerE
* @return the type
*/
public String getName();
}

View File

@ -8,6 +8,7 @@ import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBEMCollection; 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.GCUBERunningInstance; import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBERuntimeResource;
import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.resources.GCUBEService;
/** /**
@ -22,6 +23,7 @@ public class Definitions {
/** The Resource Types */ /** The Resource Types */
public static enum ResourceMappings { public static enum ResourceMappings {
RuntimeResource() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBERuntimeResource.class);}},
RunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBERunningInstance.class);}}, RunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBERunningInstance.class);}},
ExternalRunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEExternalRunningInstance.class);}}, ExternalRunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEExternalRunningInstance.class);}},
Service() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEService.class);}}, Service() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEService.class);}},
@ -31,7 +33,7 @@ public class Definitions {
gLiteCE() {public GCUBEResource getResourceImplementation() throws Exception {return null;}}, gLiteCE() {public GCUBEResource getResourceImplementation() throws Exception {return null;}},
gLiteSite() {public GCUBEResource getResourceImplementation()throws Exception {return null;}}, gLiteSite() {public GCUBEResource getResourceImplementation()throws Exception {return null;}},
gLiteService() {public GCUBEResource getResourceImplementation() throws Exception {return null;}}, gLiteService() {public GCUBEResource getResourceImplementation() throws Exception {return null;}},
GenericResource() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEGenericResource.class);}}, GenericResource() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEGenericResource.class);}},
MetadataCollection() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEMCollection.class);}}; MetadataCollection() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEMCollection.class);}};
abstract public GCUBEResource getResourceImplementation() throws Exception; abstract public GCUBEResource getResourceImplementation() throws Exception;

View File

@ -12,7 +12,7 @@ import org.globus.wsrf.ResourceException;
* a GCUBEResource profile is created/removed/updated. A single instance of this class is created within * a GCUBEResource profile is created/removed/updated. A single instance of this class is created within
* each instance of the IS-Registry service. * each instance of the IS-Registry service.
* *
* @author Andrea Manzi, Manuele Simi (CNR) * @author Manuele Simi (CNR)
* *
*/ */
public class RegistryFactoryResource extends GCUBEWSResource { public class RegistryFactoryResource extends GCUBEWSResource {
@ -23,10 +23,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
protected static final String CollectionRP="Collection"; protected static final String CollectionRP="Collection";
protected static final String CSRP="CS"; protected static final String RuntimeResourceRP="RuntimeResource";
protected static final String CSInstanceRP="CSInstance";
protected static final String GHNRP="GHN"; protected static final String GHNRP="GHN";
protected static final String gLiteSERP="gLiteSE"; protected static final String gLiteSERP="gLiteSE";
@ -51,8 +49,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
ExternalRunningInstanceRP, ExternalRunningInstanceRP,
ServiceRP, ServiceRP,
CollectionRP, CollectionRP,
CSRP, RuntimeResourceRP,
CSInstanceRP,
GHNRP, GHNRP,
gLiteSERP, gLiteSERP,
gLiteCERP, gLiteCERP,
@ -167,9 +164,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setCollection (RegistryProperty property) { public void setCollection (RegistryProperty property) {
this.getResourcePropertySet().get(CollectionRP).clear(); this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property); this.getResourcePropertySet().get(CollectionRP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -184,53 +179,27 @@ public class RegistryFactoryResource extends GCUBEWSResource {
/** /**
* Default Setter for the RP CS * Default Setter for the RP RuntimeResource
* *
* @param property The RegistryProperty * @param property The RegistryProperty
* *
*/ */
public void setCS (RegistryProperty property) { public void setRuntimeResource (RegistryProperty property) {
this.getResourcePropertySet().get(CSRP).clear(); this.getResourcePropertySet().get(RuntimeResourceRP).clear();
this.getResourcePropertySet().get(CSRP).add(property); this.getResourcePropertySet().get(RuntimeResourceRP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
* Default getter for the RP CS * Default getter for the RP RuntimeResource
* *
* @return The RegistryProperty * @return The RegistryProperty
* *
*/ */
public RegistryProperty getCS () { public RegistryProperty getRuntimeResource () {
return (RegistryProperty) this.getResourcePropertySet().get(CSRP).get(0); return (RegistryProperty) this.getResourcePropertySet().get(RuntimeResourceRP).get(0);
} }
/**
* Default Setter for the RP CSInstance
*
* @param property The RegistryProperty
*
*/
public void setCSInstance (RegistryProperty property) {
this.getResourcePropertySet().get(CSInstanceRP).clear();
this.getResourcePropertySet().get(CSInstanceRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
* Default getter for the RP CSInstance
*
* @return The RegistryProperty
*
*/
public RegistryProperty getCSInstance () {
return (RegistryProperty) this.getResourcePropertySet().get(CSInstanceRP).get(0);
}
/** /**
* Default Setter for the RP ghn * Default Setter for the RP ghn
@ -264,7 +233,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
public void setGLiteSE (RegistryProperty property) { public void setGLiteSE (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteSERP).clear(); this.getResourcePropertySet().get(gLiteSERP).clear();
this.getResourcePropertySet().get(gLiteSERP).add(property); this.getResourcePropertySet().get(gLiteSERP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -286,9 +254,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setGLiteCE (RegistryProperty property) { public void setGLiteCE (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteCERP).clear(); this.getResourcePropertySet().get(gLiteCERP).clear();
this.getResourcePropertySet().get(gLiteCERP).add(property); this.getResourcePropertySet().get(gLiteCERP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -311,9 +277,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setGLiteSite (RegistryProperty property) { public void setGLiteSite (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteSiteRP).clear(); this.getResourcePropertySet().get(gLiteSiteRP).clear();
this.getResourcePropertySet().get(gLiteSiteRP).add(property); this.getResourcePropertySet().get(gLiteSiteRP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -335,9 +299,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setGLiteService (RegistryProperty property) { public void setGLiteService (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteServiceRP).clear(); this.getResourcePropertySet().get(gLiteServiceRP).clear();
this.getResourcePropertySet().get(gLiteServiceRP).add(property); this.getResourcePropertySet().get(gLiteServiceRP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -358,9 +320,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setVRE (RegistryProperty property) { public void setVRE (RegistryProperty property) {
this.getResourcePropertySet().get(VRERP).clear(); this.getResourcePropertySet().get(VRERP).clear();
this.getResourcePropertySet().get(VRERP).add(property); this.getResourcePropertySet().get(VRERP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -370,7 +330,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public RegistryProperty getVRE () { public RegistryProperty getVRE () {
return (RegistryProperty) this.getResourcePropertySet().get(gLiteServiceRP).get(0); return (RegistryProperty) this.getResourcePropertySet().get(gLiteServiceRP).get(0);
} }
@ -382,9 +341,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/ */
public void setMetadataCollection (RegistryProperty property) { public void setMetadataCollection (RegistryProperty property) {
this.getResourcePropertySet().get(MetadataCollectionRP).clear(); this.getResourcePropertySet().get(MetadataCollectionRP).clear();
this.getResourcePropertySet().get(MetadataCollectionRP).add(property); this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
//this.getPersistenceDelegate().store(this);
} }
/** /**
@ -399,7 +356,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
} }
/** /**
* Default Setter for the RP Generic * Default Setter for the RP Generic
* *
@ -423,26 +379,13 @@ public class RegistryFactoryResource extends GCUBEWSResource {
} }
/**
* Sets an empty resource for each RP for notification purposes
*/
private void initialiseRPs() { private void initialiseRPs() {
RegistryProperty property = new RegistryProperty(); RegistryProperty property = new RegistryProperty();
/*for (Method method :this.getClass().getDeclaredMethods()) {
if (method.getName().contains("set")) {
try {
method.invoke(this,property);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
break;
}
}*/
this.getResourcePropertySet().get(RunningInstanceRP).clear(); this.getResourcePropertySet().get(RunningInstanceRP).clear();
this.getResourcePropertySet().get(RunningInstanceRP).add(property); this.getResourcePropertySet().get(RunningInstanceRP).add(property);
@ -455,12 +398,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
this.getResourcePropertySet().get(CollectionRP).clear(); this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property); this.getResourcePropertySet().get(CollectionRP).add(property);
this.getResourcePropertySet().get(CSRP).clear(); this.getResourcePropertySet().get(RuntimeResourceRP).clear();
this.getResourcePropertySet().get(CSRP).add(property); this.getResourcePropertySet().get(RuntimeResourceRP).add(property);
this.getResourcePropertySet().get(CSInstanceRP).clear();
this.getResourcePropertySet().get(CSInstanceRP).add(property);
this.getResourcePropertySet().get(GHNRP).clear(); this.getResourcePropertySet().get(GHNRP).clear();
this.getResourcePropertySet().get(GHNRP).add(property); this.getResourcePropertySet().get(GHNRP).add(property);
@ -484,8 +424,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
this.getResourcePropertySet().get(GenericResourceRP).clear(); this.getResourcePropertySet().get(GenericResourceRP).clear();
this.getResourcePropertySet().get(GenericResourceRP).add(property); this.getResourcePropertySet().get(GenericResourceRP).add(property);
} }
} }

View File

@ -1,51 +0,0 @@
package org.gcube.informationsystem.registry.stubs.testsuite;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
public class RegistryRemoveTest {
public static void main(String[] args) throws Exception {
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return true;
}
};
EndpointReferenceType factoryEPR = new EndpointReferenceType();
RegistryFactoryPortType registryFactoryPortType = null;
try {
factoryEPR.setAddress(new Address(args[0]));
registryFactoryPortType = registryLocator
.getRegistryFactoryPortTypePort(factoryEPR);
} catch (Exception e) {
e.printStackTrace();
}
RemoveResourceMessage message = new RemoveResourceMessage();
// managerSec.useCredentials(cred);
registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
registryFactoryPortType, GCUBEScope.getScope(args[2]),
managerSec);
try {
message.setType(args[3]);
message.setUniqueID(args[1]);
registryFactoryPortType.removeResource(message);
System.out.println("Profile with ID " + args[1] + "has been succesfully removed");
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,55 +0,0 @@
package org.gcube.informationsystem.registry.stubs.testsuite;
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.GCUBERemotePortTypeContext;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
public class RegistryUpdateTest {
public static void main (String[]args ) throws Exception {
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}};
FileReader fis = new FileReader (args[1]);
// load the resource
GCUBEResource resource = RegistryRegistrationTest.getResource(args[3], new FileReader(args[1]));
EndpointReferenceType factoryEPR = new EndpointReferenceType();
resource.load(fis);
RegistryFactoryPortType registryFactoryPortType= null;
try {
factoryEPR.setAddress(new Address(args[0]));
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
}catch(Exception e){
e.printStackTrace();
}
UpdateResourceMessage message = new UpdateResourceMessage();
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[2]),managerSec);
try {
StringWriter writer =new StringWriter();
resource.store(writer);
message.setXmlProfile(writer.toString());
message.setUniqueID(resource.getID());
message.setType(args[3]);
registryFactoryPortType.updateResource(message);
System.out.println("Profile has been updated");
} catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,110 @@
package org.gcube.informationsystem.registry.testsuite;
import java.io.File;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
/**
* Tester for Registration.create() operation
*
* @author Manuele Simi (CNR-ISTI)
*
*/
public class RegistryRegistrationTest {
/**
*
* @param args
* parameters:
* <ul>
* <li>registration portType URI
* <li>resource file
* <li>resource type
* <li>caller scope
* </ul>
* @throws Exception
* if the registration fails
*/
public static void main(String[] args) throws Exception {
if (args.length != 4) {
printUsage();
}
for (String param : args) System.out.println("param "+ param);
// get the scope and the REGITRATION URI
GCUBEScope scope = GCUBEScope.getScope(args[2]);
//create the porttype
EndpointReferenceType factoryEPR = new EndpointReferenceType();
ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
}
};
ResourceRegistrationPortType registration = null;
try {
factoryEPR.setAddress(new Address(args[0]));
registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
registration = GCUBERemotePortTypeContext.getProxy(registration, scope, managerSec);
} catch (Exception e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
}
File param = new File(args[1]);
if (param.isDirectory())
registerDirectory(registration,args[3],param);
else {
try {
Resource resource = new Resource(param, args[3]);
resource.register(registration);
} catch (Exception e) {
System.err.print("Unable to register " + param.getAbsolutePath());
e.printStackTrace();
}
}
}
/**
* Registers all the resources in a directory, recursively if needed
* @param registration
* @param resourceType
* @param dirToProcess
*/
static void registerDirectory(ResourceRegistrationPortType registration, String resourceType, File dirToProcess) {
for (File f : dirToProcess.listFiles()) {
if (f.isDirectory())
registerDirectory(registration,resourceType,f);
else
try {
Resource resource = new Resource(f, resourceType);
resource.register(registration);
} catch (Exception e) {
System.err.print("Unable to register " + f.getAbsolutePath());
e.printStackTrace();
}
}
}
/**
* Prints tester usage syntax
*/
static void printUsage() {
System.out.println("RegistryRegistrationTest <registration URI> <resource file> <caller scope> <resource type>");
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.exit(1);
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.informationsystem.registry.testsuite;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.resourceregistration.RemoveMessage;
import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
/**
*
* Tester for Registration.remove() operation
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class RegistryRemoveTest {
public static void main(String[] args) throws Exception {
for (String param : args) System.out.println("param "+ param);
// get the scope and the registration URI
GCUBEScope scope = GCUBEScope.getScope(args[2]);
EndpointReferenceType factoryEPR = new EndpointReferenceType();
try {
factoryEPR.setAddress(new Address(args[0]));
} catch (Exception e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
}
ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
}
};
// load the resource
try {
ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
RemoveMessage message = new RemoveMessage();
registration = GCUBERemotePortTypeContext.getProxy(registration, scope, managerSec);
message.setType(args[3]);
message.setUniqueID(args[1]);
registration.remove(message);
System.out.println("Profile with ID " + args[1] + "has been succesfully removed");
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,78 @@
package org.gcube.informationsystem.registry.testsuite;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.StringWriter;
import org.gcube.common.core.contexts.GHNContext;
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.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBERuntimeResource;
import org.gcube.common.core.resources.GCUBEService;
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
public class Resource {
private GCUBEResource resource;
private File source;
protected Resource (File resource, String type) throws FileNotFoundException,Exception {
this.source = resource;
this.resource = this.load(type, new FileReader(resource));
}
/**
* Registers the resource in the given portType
* @param registration
* @param resourceType
* @param fileToRegister
* @throws Exception
*/
protected void register(ResourceRegistrationPortType registration) throws Exception {
CreateMessage message = new CreateMessage();
StringWriter writer = new StringWriter();
resource.store(writer);
message.setProfile(writer.toString());
message.setType(resource.getType());
registration.create(message);
System.out.println("Resource "+ this.source.getAbsolutePath() +" successuflly registered: " + this.resource.getID());
}
/**
* Loads the specific GCUBEResource class
*
* @param type the resource type
* @param file the file representation of the profile
* @return the resource class
* @throws Exception
* if the loading fails
*/
private GCUBEResource load(String type, FileReader file) throws Exception {
if (type.compareTo("Service") == 0) {
GCUBEService service = GHNContext.getImplementation(GCUBEService.class);
service.load(file);
return (GCUBEResource) service;
} else if (type.compareTo("RunningInstance") == 0) {
GCUBERunningInstance instance = GHNContext.getImplementation(GCUBERunningInstance.class);
instance.load(file);
return (GCUBEResource) instance;
} else if (type.compareTo("GHN") == 0) {
GCUBEHostingNode node = GHNContext.getImplementation(GCUBEHostingNode.class);
node.load(file);
return (GCUBEResource) node;
} else if (type.compareTo("GenericResource") == 0) {
GCUBEGenericResource generic = GHNContext.getImplementation(GCUBEGenericResource.class);
generic.load(file);
return (GCUBEResource) generic;
} else if (type.compareTo("RuntimeResource") == 0) {
GCUBERuntimeResource rt = GHNContext.getImplementation(GCUBERuntimeResource.class);
rt.load(file);
return (GCUBEResource) rt;
}
throw new Exception(type + " is an invalid resource type");
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.stubs.testsuite; package org.gcube.informationsystem.registry.testsuite.security;
import java.io.FileReader; import java.io.FileReader;
import java.io.StringWriter; import java.io.StringWriter;
@ -13,87 +13,69 @@ import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl; import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage; import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType; import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator; import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
/** /**
* {@link GCUBEResource} registration tester * Tester for Registration.create() operation
* *
* @author Manuele Simi (CNR-ISTI) * @author Manuele Simi (CNR-ISTI)
* *
*/ */
public class RegistryRegistrationTest { public class SecureRegistryRegistrationTest {
/** /**
* *
* @param args * @param args
* parameters: * parameters:
* <ul> * <ul>
* <li>factory URI * <li>registration portType URI
* <li>resource file * <li>resource file
* <li>resource type * <li>resource type
* <li>caller scope * <li>caller scope
* * <li>identity
* </ul>
* @throws Exception * @throws Exception
* if the registration fails * if the registration fails
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args.length != 4) { for (String param : args) System.out.println("param "+ param);
if (args.length != 5) {
printUsage(); printUsage();
} }
for (String param : args) System.out.println("param "+ param);
// get the scope and the factory URI
GCUBEScope scope = GCUBEScope.getScope(args[2]);
String identity = args [4];
GCUBEResource resource = getResource(args[2], new FileReader(args[1]));
EndpointReferenceType factoryEPR = new EndpointReferenceType(); EndpointReferenceType factoryEPR = new EndpointReferenceType();
try { try {
factoryEPR.setAddress(new Address(args[0])); factoryEPR.setAddress(new Address(args[0]));
} catch (Exception e) { ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
e.printStackTrace(); ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
Runtime.getRuntime().exit(1); GCUBESecurityManager securityManager = Utils.generateAndConfigureDefaultSecurityManager(identity, true);
} securityManager.setSecurity(registration, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
registration = GCUBERemotePortTypeContext.getProxy(registration, GCUBEScope.getScope(args[3]), securityManager);
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator(); CreateMessage message = new CreateMessage();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
}
};
// load the resource
GCUBEResource resource = getResource(args[3], new FileReader(args[1]));
RegistryFactoryPortType registryFactoryPortType = null;
try {
registryFactoryPortType = registryLocator
.getRegistryFactoryPortTypePort(factoryEPR);
} catch (Exception e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
}
CreateResourceMessage message = new CreateResourceMessage();
registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
registryFactoryPortType, scope, managerSec);
try {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
resource.store(writer); resource.store(writer);
message.setProfile(writer.toString()); message.setProfile(writer.toString());
message.setType(resource.getType()); message.setType(resource.getType());
System.out.println(registryFactoryPortType.createResource(message)); registration.create(message);
System.out.println("Resource successfully registered");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Runtime.getRuntime().exit(1); Runtime.getRuntime().exit(1);
} }
} }
/** /**
@ -139,10 +121,8 @@ public class RegistryRegistrationTest {
* Prints tester usage syntax * Prints tester usage syntax
*/ */
static void printUsage() { static void printUsage() {
System.out System.out.println("RegistryRegistrationTest <registration URI> <resource file> <resource type> <caller scope> <identity>");
.println("RegistryRegistrationTest <factory URI> <resource file> <caller scope> <resource type>"); System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.out
.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.exit(1); System.exit(1);
} }
} }

View File

@ -0,0 +1,41 @@
package org.gcube.informationsystem.registry.testsuite.security;
import org.gcube.common.core.security.GCUBEClientSecurityManager;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.common.core.security.context.SecurityContextFactory;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
public class Utils {
public static GCUBESecurityManager generateAndConfigureDefaultSecurityManager (String identity, final boolean isSecurityEnabled)
{
GCUBEClientLog logger = new GCUBEClientLog(Utils.class);
GCUBESecurityManager securityManager = null;
if (isSecurityEnabled)
{
try {
securityManager = SecurityContextFactory.getInstance().getSecurityContext().getDefaultSecurityManager();
logger.debug("Identity = "+identity);
((GCUBEClientSecurityManager) securityManager).setDefaultIdentityParameter(identity);
} catch (Exception e) {
logger.error("Unable to generate default security manager: trying without security...",e);
securityManager = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {return isSecurityEnabled;}
};
}
}
else
{
securityManager = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {return isSecurityEnabled;}
};
}
return securityManager;
}
}