Compare commits

..

No commits in common. "44a54c91508805daaa9c5aaf621c1369566ff41c" and "f328250842f49f33f29b2d6415f1b25664a703ee" have entirely different histories.

28 changed files with 310 additions and 617 deletions

View File

@ -4,6 +4,9 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
<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="output" path="bin"/>
</classpath>

View File

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

12
README
View File

@ -1,13 +1,9 @@
The gCube System - ISRegistry
------------------------------------------------------------
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).
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.
Authors
@ -22,7 +18,7 @@ Authors
Version and Release Date
------------------------
v. 2.1.3 (05-04-2012)
v. 2.0.0 (07-02-2011)
Description

View File

@ -59,8 +59,6 @@ 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 -->
@ -75,8 +73,6 @@ 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}" />
@ -94,7 +90,6 @@ 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 -->
@ -106,9 +101,6 @@ 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" />
@ -152,11 +144,7 @@ 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}">
<fileset dir="${container.schema.dir}" casesensitive="yes">
@ -474,39 +462,10 @@ 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">

View File

@ -1,21 +1,4 @@
<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>

View File

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

View File

@ -84,8 +84,7 @@
<xsd:element name="uniqueID" 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="changeTime" type="xsd:dateTime" nillable="true"/>
<xsd:element name="invocationScope" type="xsd:string" nillable="true"/>
<xsd:element name="changeTime" type="xsd:dateTime" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
@ -97,7 +96,11 @@
<xsd:element name="Service" 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="gLiteSE" type="tns:RegistryProperty"/>
@ -113,9 +116,6 @@
<xsd:element name="MetadataCollection" type="tns:RegistryProperty"/>
<xsd:element name="GenericResource" type="tns:RegistryProperty"/>
<xsd:element name="RuntimeResource" type="tns:RegistryProperty"/>
<xsd:element name="RegistryFactoryResourceProperties">
<xsd:complexType>
@ -124,6 +124,8 @@
<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"/>
@ -132,7 +134,6 @@
<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>

View File

@ -11,12 +11,9 @@ 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.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;
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;
@ -46,11 +43,10 @@ public class ServiceContext extends GCUBEServiceContext {
protected GCUBEProducer<RegistryTopic, GCUBEResource> topicProducer;
@SuppressWarnings("rawtypes")
@SuppressWarnings("unchecked")
protected class NotificationResourceScheduler extends GCUBEScheduledHandler {
@SuppressWarnings("unchecked")
public NotificationResourceScheduler(long interval, Mode mode) {
super(interval, mode);
}
@ -109,10 +105,6 @@ 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());
}

View File

@ -10,10 +10,8 @@ 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.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.postprocessing.purging.AvailablePurgers;
import org.gcube.informationsystem.registry.impl.postprocessing.purging.Purger;
import org.gcube.informationsystem.registry.impl.state.Definitions.OperationType;
import org.gcube.informationsystem.registry.impl.state.Definitions.ResourceMappings;
@ -25,25 +23,13 @@ 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(), ServiceContext.getContext().getScope());
Calendar.getInstance(), writer.toString());
}
/**
*
@ -71,29 +57,18 @@ 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, ServiceContext.getContext().getScope());
RegistryFactory.updateCounterInfo(id, ResourceMappings.valueOf(type),OperationType.destroy, Calendar.getInstance(), null);
}
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(), ServiceContext.getContext().getScope());
OperationType.update, Calendar.getInstance(), writer.toString());
}
}

View File

@ -11,6 +11,7 @@ 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;
@ -182,15 +183,13 @@ public class RegistryFactory extends GCUBEPortType {
*/
protected static synchronized void updateCounterInfo(String ID,
ResourceMappings resType, OperationType opType, Calendar updateTime,
String profile, GCUBEScope scope) throws Exception {
String profile) 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()) {

View File

@ -4,16 +4,27 @@ 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;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,21 +0,0 @@
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

@ -1,42 +0,0 @@
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

@ -1,42 +0,0 @@
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

@ -1,15 +0,0 @@
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,7 +8,6 @@ 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;
/**
@ -23,7 +22,6 @@ 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);}},
@ -33,7 +31,7 @@ public class Definitions {
gLiteCE() {public GCUBEResource getResourceImplementation() throws Exception {return null;}},
gLiteSite() {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);}};
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
* each instance of the IS-Registry service.
*
* @author Manuele Simi (CNR)
* @author Andrea Manzi, Manuele Simi (CNR)
*
*/
public class RegistryFactoryResource extends GCUBEWSResource {
@ -23,8 +23,10 @@ public class RegistryFactoryResource extends GCUBEWSResource {
protected static final String CollectionRP="Collection";
protected static final String RuntimeResourceRP="RuntimeResource";
protected static final String CSRP="CS";
protected static final String CSInstanceRP="CSInstance";
protected static final String GHNRP="GHN";
protected static final String gLiteSERP="gLiteSE";
@ -49,7 +51,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
ExternalRunningInstanceRP,
ServiceRP,
CollectionRP,
RuntimeResourceRP,
CSRP,
CSInstanceRP,
GHNRP,
gLiteSERP,
gLiteCERP,
@ -164,7 +167,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setCollection (RegistryProperty property) {
this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property);
this.getResourcePropertySet().get(CollectionRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -179,27 +184,53 @@ public class RegistryFactoryResource extends GCUBEWSResource {
/**
* Default Setter for the RP RuntimeResource
* Default Setter for the RP CS
*
* @param property The RegistryProperty
*
*/
public void setRuntimeResource (RegistryProperty property) {
this.getResourcePropertySet().get(RuntimeResourceRP).clear();
this.getResourcePropertySet().get(RuntimeResourceRP).add(property);
public void setCS (RegistryProperty property) {
this.getResourcePropertySet().get(CSRP).clear();
this.getResourcePropertySet().get(CSRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
* Default getter for the RP RuntimeResource
* Default getter for the RP CS
*
* @return The RegistryProperty
*
*/
public RegistryProperty getRuntimeResource () {
return (RegistryProperty) this.getResourcePropertySet().get(RuntimeResourceRP).get(0);
public RegistryProperty getCS () {
return (RegistryProperty) this.getResourcePropertySet().get(CSRP).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
@ -233,6 +264,7 @@ 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);
}
/**
@ -254,7 +286,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setGLiteCE (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteCERP).clear();
this.getResourcePropertySet().get(gLiteCERP).add(property);
this.getResourcePropertySet().get(gLiteCERP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -277,7 +311,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setGLiteSite (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteSiteRP).clear();
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
this.getResourcePropertySet().get(gLiteSiteRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -299,7 +335,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setGLiteService (RegistryProperty property) {
this.getResourcePropertySet().get(gLiteServiceRP).clear();
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
this.getResourcePropertySet().get(gLiteServiceRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -320,7 +358,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setVRE (RegistryProperty property) {
this.getResourcePropertySet().get(VRERP).clear();
this.getResourcePropertySet().get(VRERP).add(property);
this.getResourcePropertySet().get(VRERP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -330,6 +370,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public RegistryProperty getVRE () {
return (RegistryProperty) this.getResourcePropertySet().get(gLiteServiceRP).get(0);
}
@ -341,7 +382,9 @@ public class RegistryFactoryResource extends GCUBEWSResource {
*/
public void setMetadataCollection (RegistryProperty property) {
this.getResourcePropertySet().get(MetadataCollectionRP).clear();
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
this.getResourcePropertySet().get(MetadataCollectionRP).add(property);
//this.getPersistenceDelegate().store(this);
}
/**
@ -356,6 +399,7 @@ public class RegistryFactoryResource extends GCUBEWSResource {
}
/**
* Default Setter for the RP Generic
*
@ -379,13 +423,26 @@ 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);
@ -398,9 +455,12 @@ public class RegistryFactoryResource extends GCUBEWSResource {
this.getResourcePropertySet().get(CollectionRP).clear();
this.getResourcePropertySet().get(CollectionRP).add(property);
this.getResourcePropertySet().get(RuntimeResourceRP).clear();
this.getResourcePropertySet().get(RuntimeResourceRP).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(GHNRP).clear();
this.getResourcePropertySet().get(GHNRP).add(property);
@ -424,7 +484,8 @@ public class RegistryFactoryResource extends GCUBEWSResource {
this.getResourcePropertySet().get(GenericResourceRP).clear();
this.getResourcePropertySet().get(GenericResourceRP).add(property);
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.testsuite.security;
package org.gcube.informationsystem.registry.stubs.testsuite;
import java.io.FileReader;
import java.io.StringWriter;
@ -13,68 +13,86 @@ 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.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;
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;
/**
* Tester for Registration.create() operation
* {@link GCUBEResource} registration tester
*
* @author Manuele Simi (CNR-ISTI)
*
*/
public class SecureRegistryRegistrationTest {
public class RegistryRegistrationTest {
/**
*
* @param args
* parameters:
* <ul>
* <li>registration portType URI
* <li>factory 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 {
for (String param : args) System.out.println("param "+ param);
if (args.length != 5) {
if (args.length != 4) {
printUsage();
}
String identity = args [4];
for (String param : args) System.out.println("param "+ param);
GCUBEResource resource = getResource(args[2], new FileReader(args[1]));
// get the scope and the factory URI
GCUBEScope scope = GCUBEScope.getScope(args[2]);
EndpointReferenceType factoryEPR = new EndpointReferenceType();
try {
factoryEPR.setAddress(new Address(args[0]));
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());
registration.create(message);
System.out.println("Resource successfully registered");
} 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 {
StringWriter writer = new StringWriter();
resource.store(writer);
message.setProfile(writer.toString());
message.setType(resource.getType());
System.out.println(registryFactoryPortType.createResource(message));
} catch (Exception e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
}
}
@ -121,8 +139,10 @@ public class SecureRegistryRegistrationTest {
* Prints tester usage syntax
*/
static void printUsage() {
System.out.println("RegistryRegistrationTest <registration URI> <resource file> <resource type> <caller scope> <identity>");
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.out
.println("RegistryRegistrationTest <factory 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,51 @@
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

@ -0,0 +1,55 @@
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

@ -1,110 +0,0 @@
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

@ -1,62 +0,0 @@
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

@ -1,78 +0,0 @@
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,41 +0,0 @@
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;
}
}