Compare commits
10 Commits
f328250842
...
44a54c9150
Author | SHA1 | Date |
---|---|---|
Lucio Lelii | 44a54c9150 | |
Manuele Simi | e592963fa2 | |
Manuele Simi | 0a659ececd | |
Manuele Simi | cba4b9239e | |
Manuele Simi | dbe11e0cdb | |
Manuele Simi | 28985c6293 | |
Manuele Simi | 3f3787da1e | |
Manuele Simi | c2615afce3 | |
Manuele Simi | 4babb8014f | |
Manuele Simi | a68073786e |
|
@ -4,9 +4,6 @@
|
|||
<classpathentry kind="src" path="src"/>
|
||||
<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.USER_LIBRARY/GCORELIBS"/>
|
||||
<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="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
2
.project
2
.project
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Registry</name>
|
||||
<name>Registry.trunk</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
12
README
12
README
|
@ -1,9 +1,13 @@
|
|||
The gCube System - ISRegistry
|
||||
------------------------------------------------------------
|
||||
|
||||
This work is partially funded by the European Commission in the
|
||||
context of the D4Science project (www.d4science.eu), under the 1st
|
||||
call of FP7 IST priority.
|
||||
This work has been partially supported by the following European projects:
|
||||
DILIGENT (FP6-2003-IST-2),
|
||||
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
|
||||
|
@ -18,7 +22,7 @@ Authors
|
|||
|
||||
Version and Release Date
|
||||
------------------------
|
||||
v. 2.0.0 (07-02-2011)
|
||||
v. 2.1.3 (05-04-2012)
|
||||
|
||||
|
||||
Description
|
||||
|
|
41
build.xml
41
build.xml
|
@ -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" value="${service.dir}/${etc.dir.name}" />
|
||||
<property name="source.dir" value="${service.dir}/src" />
|
||||
<property name="testsuite.dir" value="${service.dir}/test" />
|
||||
|
||||
|
||||
|
||||
<!-- 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="jarfile" value="${package}.jar" />
|
||||
<property name="jarfile.stubs" value="${package}.stubs.jar" />
|
||||
<property name="jarfile.testsuite" value="${package}.testsuite.jar" />
|
||||
|
||||
|
||||
<if name="etics.build" value="true">
|
||||
<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.dir.name" value="stubs" /> <!-- auxiliary stub classes -->
|
||||
<property name="stubs.dir" value="${source.dir}/${package.dir}/${stubs.dir.name}" />
|
||||
|
||||
<available file="${stubs.dir}" property="stubs.dir.present"/>
|
||||
|
||||
<!-- 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.src.dir" location="${build.stubs.dir}/src" />
|
||||
<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 -->
|
||||
<property name="java.debug" value="on" />
|
||||
|
@ -144,6 +152,10 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
|
|||
<mkdir dir="${build.stubs.dir}" />
|
||||
<mkdir dir="${build.stubs.src.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 -->
|
||||
<copy toDir="${build.schema.dir}">
|
||||
|
@ -462,10 +474,39 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
|
|||
</copy>
|
||||
</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">
|
||||
<jar destfile="${build.lib.dir}/${jarfile.stubs}" basedir="${build.stubs.class.dir}" />
|
||||
</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">
|
||||
<copy file="${build.lib.dir}/${jarfile.stubs}" toDir="${lib.location}"/>
|
||||
<if name="etics.build" value="false">
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
<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">
|
||||
<Change>Porting on the new XMLCollectionAccess portType exposed by the IS-Collector</Change>
|
||||
<Change>New ResourceRegistration portType</Change>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<ID/>
|
||||
<Type>Service</Type>
|
||||
<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>
|
||||
<Name>IS-Registry</Name>
|
||||
<Version>1.0.0</Version>
|
||||
|
@ -16,9 +16,9 @@
|
|||
</Dependencies>
|
||||
<Packages>
|
||||
<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>
|
||||
<Version>2.1.0</Version>
|
||||
<Version>2.1.4</Version>
|
||||
<Mandatory level="VO"/>
|
||||
<Shareable level="VO"/>
|
||||
<GHNRequirements>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<Version>1.0.0</Version>
|
||||
</Service>
|
||||
<Package>IS-Registry-stubs</Package>
|
||||
<Version>2.1.0</Version>
|
||||
<Version>2.1.4</Version>
|
||||
<Scope level="GHN"/>
|
||||
<Optional>false</Optional>
|
||||
</Dependency>
|
||||
|
@ -50,9 +50,9 @@
|
|||
</PortType>
|
||||
</Main>
|
||||
<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>
|
||||
<Version>2.1.0</Version>
|
||||
<Version>2.1.4</Version>
|
||||
<MultiVersion value="true"/>
|
||||
<Mandatory level="GHN"/>
|
||||
<Shareable level="VO"/>
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<xsd:element name="profile" 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="invocationScope" type="xsd:string" nillable="true"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
|
@ -97,10 +98,6 @@
|
|||
|
||||
<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="gLiteSE" type="tns:RegistryProperty"/>
|
||||
|
@ -117,6 +114,9 @@
|
|||
|
||||
<xsd:element name="GenericResource" type="tns:RegistryProperty"/>
|
||||
|
||||
<xsd:element name="RuntimeResource" type="tns:RegistryProperty"/>
|
||||
|
||||
|
||||
<xsd:element name="RegistryFactoryResourceProperties">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
|
@ -124,8 +124,6 @@
|
|||
<xsd:element ref="tns:ExternalRunningInstance" 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: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:gLiteSE" 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:MetadataCollection" 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:complexType>
|
||||
</xsd:element>
|
||||
|
|
|
@ -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.handlers.GCUBEScheduledHandler;
|
||||
import org.gcube.informationsystem.registry.impl.local.LocalProfileConsumerImpl;
|
||||
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.RIPurger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.remove.GHNPurger;
|
||||
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;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected class NotificationResourceScheduler extends GCUBEScheduledHandler {
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public NotificationResourceScheduler(long interval, Mode mode) {
|
||||
super(interval, mode);
|
||||
}
|
||||
|
@ -105,6 +109,10 @@ public class ServiceContext extends GCUBEServiceContext {
|
|||
//register purgers for GCUBEResources
|
||||
AvailablePurgers.register(new GHNPurger());
|
||||
AvailablePurgers.register(new RIPurger());
|
||||
|
||||
//register updaers for GCUBEResources
|
||||
AvailableUpdaters.register(new GHNUpdater());
|
||||
AvailableUpdaters.register(new RIUpdater());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.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.Purger;
|
||||
import org.gcube.informationsystem.registry.impl.postprocessing.remove.AvailablePurgers;
|
||||
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.ResourceMappings;
|
||||
|
||||
|
@ -23,13 +25,25 @@ public class LocalResourceRegistration {
|
|||
ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
|
||||
publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
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
|
||||
LocalNotifier.notifyEvent(resource, RegistryTopic.CREATE);
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(
|
||||
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();
|
||||
resource.setID(id);
|
||||
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 {
|
||||
ISResourcePublisher publisher = GHNContext.getImplementation(ISResourcePublisher.class);
|
||||
publisher.register(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
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);
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
RegistryFactory.updateCounterInfo(resource.getID(), ResourceMappings.valueOf(resource.getType()),
|
||||
OperationType.update, Calendar.getInstance(), writer.toString());
|
||||
OperationType.update, Calendar.getInstance(), writer.toString(), ServiceContext.getContext().getScope());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ 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.contexts.FactoryContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
||||
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
||||
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
||||
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,
|
||||
ResourceMappings resType, OperationType opType, Calendar updateTime,
|
||||
String profile) throws Exception {
|
||||
String profile, GCUBEScope scope) throws Exception {
|
||||
//return;
|
||||
RegistryProperty property = new RegistryProperty();
|
||||
property.setUniqueID(ID);
|
||||
property.setProfile(profile);
|
||||
property.setOperationType(opType.name());
|
||||
property.setChangeTime(updateTime);
|
||||
property.setInvocationScope(scope.toString());
|
||||
|
||||
// select the type of the resource to update
|
||||
logger.trace("Notifying about resource " + ID +", event: " + opType);
|
||||
for (Method method : getResource().getClass().getDeclaredMethods()) {
|
||||
|
|
|
@ -4,27 +4,16 @@ import java.io.BufferedReader;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.apache.axis.components.uuid.UUIDGen;
|
||||
import org.apache.axis.components.uuid.UUIDGenFactory;
|
||||
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.resources.GCUBEHostingNode;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
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.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.stubs.resourceregistration.CreateFault;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
|
||||
|
|
|
@ -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.Map;
|
|
@ -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.util.HashSet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.impl.postprocessing.purging;
|
||||
package org.gcube.informationsystem.registry.impl.postprocessing.remove;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -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.Set;
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -8,6 +8,7 @@ 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.GCUBERunningInstance;
|
||||
import org.gcube.common.core.resources.GCUBERuntimeResource;
|
||||
import org.gcube.common.core.resources.GCUBEService;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +23,7 @@ public class Definitions {
|
|||
|
||||
/** The Resource Types */
|
||||
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);}},
|
||||
ExternalRunningInstance() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEExternalRunningInstance.class);}},
|
||||
Service() {public GCUBEResource getResourceImplementation() throws Exception {return GHNContext.getImplementation(GCUBEService.class);}},
|
||||
|
|
|
@ -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
|
||||
* each instance of the IS-Registry service.
|
||||
*
|
||||
* @author Andrea Manzi, Manuele Simi (CNR)
|
||||
* @author Manuele Simi (CNR)
|
||||
*
|
||||
*/
|
||||
public class RegistryFactoryResource extends GCUBEWSResource {
|
||||
|
@ -23,9 +23,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
|
||||
protected static final String CollectionRP="Collection";
|
||||
|
||||
protected static final String CSRP="CS";
|
||||
|
||||
protected static final String CSInstanceRP="CSInstance";
|
||||
protected static final String RuntimeResourceRP="RuntimeResource";
|
||||
|
||||
protected static final String GHNRP="GHN";
|
||||
|
||||
|
@ -51,8 +49,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
ExternalRunningInstanceRP,
|
||||
ServiceRP,
|
||||
CollectionRP,
|
||||
CSRP,
|
||||
CSInstanceRP,
|
||||
RuntimeResourceRP,
|
||||
GHNRP,
|
||||
gLiteSERP,
|
||||
gLiteCERP,
|
||||
|
@ -168,8 +165,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setCollection (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(CollectionRP).clear();
|
||||
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
|
||||
*
|
||||
*/
|
||||
public void setCS (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(CSRP).clear();
|
||||
this.getResourcePropertySet().get(CSRP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
|
||||
public void setRuntimeResource (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(RuntimeResourceRP).clear();
|
||||
this.getResourcePropertySet().get(RuntimeResourceRP).add(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default getter for the RP CS
|
||||
* Default getter for the RP RuntimeResource
|
||||
*
|
||||
* @return The RegistryProperty
|
||||
*
|
||||
*/
|
||||
public RegistryProperty getCS () {
|
||||
return (RegistryProperty) this.getResourcePropertySet().get(CSRP).get(0);
|
||||
public RegistryProperty getRuntimeResource () {
|
||||
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
|
||||
|
@ -264,7 +233,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setGLiteSE (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(gLiteSERP).clear();
|
||||
this.getResourcePropertySet().get(gLiteSERP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,8 +255,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setGLiteCE (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(gLiteCERP).clear();
|
||||
this.getResourcePropertySet().get(gLiteCERP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,8 +278,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setGLiteSite (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(gLiteSiteRP).clear();
|
||||
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,8 +300,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setGLiteService (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(gLiteServiceRP).clear();
|
||||
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,8 +321,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setVRE (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(VRERP).clear();
|
||||
this.getResourcePropertySet().get(VRERP).add(property);
|
||||
//this.getPersistenceDelegate().store(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,7 +330,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
*/
|
||||
public RegistryProperty getVRE () {
|
||||
return (RegistryProperty) this.getResourcePropertySet().get(gLiteServiceRP).get(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -383,8 +342,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
public void setMetadataCollection (RegistryProperty property) {
|
||||
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
|
||||
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
|
||||
*
|
||||
|
@ -423,26 +379,13 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an empty resource for each RP for notification purposes
|
||||
*/
|
||||
private void initialiseRPs() {
|
||||
|
||||
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).add(property);
|
||||
|
||||
|
@ -455,11 +398,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
this.getResourcePropertySet().get(CollectionRP).clear();
|
||||
this.getResourcePropertySet().get(CollectionRP).add(property);
|
||||
|
||||
this.getResourcePropertySet().get(CSRP).clear();
|
||||
this.getResourcePropertySet().get(CSRP).add(property);
|
||||
|
||||
this.getResourcePropertySet().get(CSInstanceRP).clear();
|
||||
this.getResourcePropertySet().get(CSInstanceRP).add(property);
|
||||
this.getResourcePropertySet().get(RuntimeResourceRP).clear();
|
||||
this.getResourcePropertySet().get(RuntimeResourceRP).add(property);
|
||||
|
||||
this.getResourcePropertySet().get(GHNRP).clear();
|
||||
this.getResourcePropertySet().get(GHNRP).add(property);
|
||||
|
@ -485,7 +425,6 @@ public class RegistryFactoryResource extends GCUBEWSResource {
|
|||
this.getResourcePropertySet().get(GenericResourceRP).clear();
|
||||
this.getResourcePropertySet().get(GenericResourceRP).add(property);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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.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.GCUBEService;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
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.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
|
||||
import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
|
||||
|
||||
/**
|
||||
* {@link GCUBEResource} registration tester
|
||||
* Tester for Registration.create() operation
|
||||
*
|
||||
* @author Manuele Simi (CNR-ISTI)
|
||||
*
|
||||
*/
|
||||
public class RegistryRegistrationTest {
|
||||
public class SecureRegistryRegistrationTest {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param args
|
||||
* parameters:
|
||||
* <ul>
|
||||
* <li>factory URI
|
||||
* <li>registration portType URI
|
||||
* <li>resource file
|
||||
* <li>resource type
|
||||
* <li>caller scope
|
||||
*
|
||||
* <li>identity
|
||||
* </ul>
|
||||
* @throws Exception
|
||||
* if the registration fails
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
try {
|
||||
factoryEPR.setAddress(new Address(args[0]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runtime.getRuntime().exit(1);
|
||||
}
|
||||
|
||||
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
|
||||
|
||||
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 {
|
||||
ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
|
||||
ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
|
||||
GCUBESecurityManager securityManager = Utils.generateAndConfigureDefaultSecurityManager(identity, true);
|
||||
securityManager.setSecurity(registration, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
|
||||
registration = GCUBERemotePortTypeContext.getProxy(registration, GCUBEScope.getScope(args[3]), securityManager);
|
||||
CreateMessage message = new CreateMessage();
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
message.setProfile(writer.toString());
|
||||
message.setType(resource.getType());
|
||||
System.out.println(registryFactoryPortType.createResource(message));
|
||||
registration.create(message);
|
||||
System.out.println("Resource successfully registered");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runtime.getRuntime().exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,10 +121,8 @@ public class RegistryRegistrationTest {
|
|||
* Prints tester usage syntax
|
||||
*/
|
||||
static void printUsage() {
|
||||
System.out
|
||||
.println("RegistryRegistrationTest <factory URI> <resource file> <caller scope> <resource type>");
|
||||
System.out
|
||||
.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
System.out.println("RegistryRegistrationTest <registration URI> <resource file> <resource type> <caller scope> <identity>");
|
||||
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue