Initial import.
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@10882 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ead8cde142
commit
d9f15661cd
11
.classpath
11
.classpath
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ehcache"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/gCore"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/dependenciesD4S"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.5.0_16"/>
|
||||
<classpathentry kind="lib" path="C:/Documents and Settings/rena/Desktop/ISCache.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Documents and Settings/rena/Desktop/lo/lib/org.gcube.thumbnailer.stubs.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
.project
17
.project
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>applicationSupportLayerCore</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>
|
|
@ -1,3 +0,0 @@
|
|||
#Mon Sep 22 12:37:04 EEST 2008
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
|
71
build.xml
71
build.xml
|
@ -1,71 +0,0 @@
|
|||
<project default="compile" basedir=".">
|
||||
<property environment="env" />
|
||||
<property name="globus.location" location="${env.GLOBUS_LOCATION}"/>
|
||||
<property name="project.build" value="build"/>
|
||||
<property name="build.classes" value="${project.build}/classes"/>
|
||||
<target name="compile" depends="clean ,setenv" description="Compile project source code">
|
||||
<echo>Compiling project source code</echo>
|
||||
<javac srcdir="."
|
||||
destdir="${build.classes}"
|
||||
classpathref="classpath"
|
||||
debug="on"
|
||||
optimize="off"
|
||||
deprecation="on"/>
|
||||
<!--<copy file="etc/**" toDir="${build.classes}"/> -->
|
||||
</target>
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<jar destfile="ASL-Core.jar" >
|
||||
<fileset dir="${build.classes}">
|
||||
<include name="**/*.class"/>
|
||||
<include name="**/*.xml"/>
|
||||
<include name="**/*.properties"/>
|
||||
</fileset>
|
||||
<fileset dir=".">
|
||||
<include name="**/etc/*.xml"/>
|
||||
<include name="**/etc/*.properties"/>
|
||||
</fileset>
|
||||
|
||||
</jar>
|
||||
</target>
|
||||
<target name="setenv" description="Check for libraries and print out config information">
|
||||
<mkdir dir="${project.build}"/>
|
||||
<mkdir dir="${build.classes}"/>
|
||||
<path id="classpath">
|
||||
<pathelement location="${build.classes}"/>
|
||||
<pathelement path="${java.class.path}"/>
|
||||
<fileset dir="${globus.location}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${ehcache}/">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
</target>
|
||||
<target name="javadoc">
|
||||
<javadoc access="public"
|
||||
author="true"
|
||||
destdir="doc/api"
|
||||
nodeprecated="false"
|
||||
nodeprecatedlist="false"
|
||||
noindex="false"
|
||||
nonavbar="false"
|
||||
notree="false"
|
||||
source="1.5"
|
||||
sourcepath="src"
|
||||
packagenames="org.gcube.application.framework.*"
|
||||
splitindex="true"
|
||||
use="true"
|
||||
version="true"
|
||||
failonerror="false">
|
||||
<classpath>
|
||||
<fileset dir="${globus.location}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="clean" description="Delete classes and existing library">
|
||||
<delete quiet="true" dir="${project.build}"/>
|
||||
</target>
|
||||
</project>
|
538
etc/ehcache.xml
538
etc/ehcache.xml
|
@ -1,538 +0,0 @@
|
|||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
|
||||
|
||||
<!--
|
||||
CacheManager Configuration
|
||||
==========================
|
||||
An ehcache.xml corresponds to a single CacheManager.
|
||||
|
||||
See instructions below or the ehcache schema (ehcache.xsd) on how to configure.
|
||||
|
||||
DiskStore configuration
|
||||
=======================
|
||||
|
||||
Sets the path to the directory where cache files are created.
|
||||
|
||||
If the path is a Java System Property it is replaced by its value in the
|
||||
running VM.
|
||||
|
||||
The following properties are translated:
|
||||
* user.home - User's home directory
|
||||
* user.dir - User's current working directory
|
||||
* java.io.tmpdir - Default temp file path
|
||||
|
||||
Subdirectories can be specified below the property e.g. java.io.tmpdir/one
|
||||
-->
|
||||
<diskStore path="java.io.tmpdir"/>
|
||||
|
||||
<!--
|
||||
CacheManagerEventListener
|
||||
=========================
|
||||
Specifies a CacheManagerEventListenerFactory, be used to create a CacheManagerPeerProvider,
|
||||
which is notified when Caches are added or removed from the CacheManager.
|
||||
|
||||
The attributes of CacheManagerEventListenerFactory are:
|
||||
* class - a fully qualified factory class name
|
||||
* properties - comma separated properties having meaning only to the factory.
|
||||
|
||||
Sets the fully qualified class name to be registered as the CacheManager event listener.
|
||||
|
||||
The events include:
|
||||
* adding a Cache
|
||||
* removing a Cache
|
||||
|
||||
Callbacks to listener methods are synchronous and unsynchronized. It is the responsibility
|
||||
of the implementer to safely handle the potential performance and thread safety issues
|
||||
depending on what their listener is doing.
|
||||
|
||||
If no class is specified, no listener is created. There is no default.
|
||||
-->
|
||||
<cacheManagerEventListenerFactory class="" properties=""/>
|
||||
|
||||
|
||||
<!--
|
||||
CacheManagerPeerProvider
|
||||
========================
|
||||
(Enable for distributed operation)
|
||||
|
||||
Specifies a CacheManagerPeerProviderFactory which will be used to create a
|
||||
CacheManagerPeerProvider, which discovers other CacheManagers in the cluster.
|
||||
|
||||
The attributes of cacheManagerPeerProviderFactory are:
|
||||
* class - a fully qualified factory class name
|
||||
* properties - comma separated properties having meaning only to the factory.
|
||||
|
||||
Ehcache comes with a built-in RMI-based distribution system with two means of discovery of
|
||||
CacheManager peers participating in the cluster:
|
||||
* automatic, using a multicast group. This one automatically discovers peers and detects
|
||||
changes such as peers entering and leaving the group
|
||||
* manual, using manual rmiURL configuration. A hardcoded list of peers is provided at
|
||||
configuration time.
|
||||
|
||||
Configuring Automatic Discovery:
|
||||
Automatic discovery is configured as per the following example:
|
||||
<cacheManagerPeerProviderFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
|
||||
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
|
||||
multicastGroupPort=4446, timeToLive=32"/>
|
||||
|
||||
Valid properties are:
|
||||
* peerDiscovery (mandatory) - specify "automatic"
|
||||
* multicastGroupAddress (mandatory) - specify a valid multicast group address
|
||||
* multicastGroupPort (mandatory) - specify a dedicated port for the multicast heartbeat
|
||||
traffic
|
||||
* timeToLive - specify a value between 0 and 255 which determines how far the packets will
|
||||
propagate.
|
||||
|
||||
By convention, the restrictions are:
|
||||
0 - the same host
|
||||
1 - the same subnet
|
||||
32 - the same site
|
||||
64 - the same region
|
||||
128 - the same continent
|
||||
255 - unrestricted
|
||||
|
||||
Configuring Manual Discovery:
|
||||
Manual discovery is configured as per the following example:
|
||||
<cacheManagerPeerProviderFactory class=
|
||||
"net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
|
||||
properties="peerDiscovery=manual,
|
||||
rmiUrls=//server1:40000/sampleCache1|//server2:40000/sampleCache1
|
||||
| //server1:40000/sampleCache2|//server2:40000/sampleCache2"
|
||||
propertySeparator="," />
|
||||
|
||||
Valid properties are:
|
||||
* peerDiscovery (mandatory) - specify "manual"
|
||||
* rmiUrls (mandatory) - specify a pipe separated list of rmiUrls, in the form
|
||||
//hostname:port
|
||||
|
||||
The hostname is the hostname of the remote CacheManager peer. The port is the listening
|
||||
port of the RMICacheManagerPeerListener of the remote CacheManager peer.
|
||||
|
||||
-->
|
||||
<cacheManagerPeerProviderFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
|
||||
properties="peerDiscovery=automatic,
|
||||
multicastGroupAddress=230.0.0.1,
|
||||
multicastGroupPort=4446, timeToLive=1"
|
||||
propertySeparator=","
|
||||
/>
|
||||
|
||||
|
||||
<!--
|
||||
CacheManagerPeerListener
|
||||
========================
|
||||
(Enable for distributed operation)
|
||||
|
||||
Specifies a CacheManagerPeerListenerFactory which will be used to create a
|
||||
CacheManagerPeerListener, which
|
||||
listens for messages from cache replicators participating in the cluster.
|
||||
|
||||
The attributes of cacheManagerPeerListenerFactory are:
|
||||
class - a fully qualified factory class name
|
||||
properties - comma separated properties having meaning only to the factory.
|
||||
|
||||
Ehcache comes with a built-in RMI-based distribution system. The listener component is
|
||||
RMICacheManagerPeerListener which is configured using
|
||||
RMICacheManagerPeerListenerFactory. It is configured as per the following example:
|
||||
|
||||
<cacheManagerPeerListenerFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
|
||||
properties="hostName=fully_qualified_hostname_or_ip,
|
||||
port=40001,
|
||||
socketTimeoutMillis=120000"
|
||||
propertySeparator="," />
|
||||
|
||||
All properties are optional. They are:
|
||||
* hostName - the hostName of the host the listener is running on. Specify
|
||||
where the host is multihomed and you want to control the interface over which cluster
|
||||
messages are received. Defaults to the host name of the default interface if not
|
||||
specified.
|
||||
* port - the port the listener listens on. This defaults to a free port if not specified.
|
||||
* socketTimeoutMillis - the number of ms client sockets will stay open when sending
|
||||
messages to the listener. This should be long enough for the slowest message.
|
||||
If not specified it defaults 120000ms.
|
||||
|
||||
-->
|
||||
<cacheManagerPeerListenerFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>
|
||||
|
||||
|
||||
<!--
|
||||
Cache configuration
|
||||
===================
|
||||
|
||||
The following attributes are required.
|
||||
|
||||
name:
|
||||
Sets the name of the cache. This is used to identify the cache. It must be unique.
|
||||
|
||||
maxElementsInMemory:
|
||||
Sets the maximum number of objects that will be created in memory
|
||||
|
||||
maxElementsOnDisk:
|
||||
Sets the maximum number of objects that will be maintained in the DiskStore
|
||||
The default value is zero, meaning unlimited.
|
||||
|
||||
eternal:
|
||||
Sets whether elements are eternal. If eternal, timeouts are ignored and the
|
||||
element is never expired.
|
||||
|
||||
overflowToDisk:
|
||||
Sets whether elements can overflow to disk when the memory store
|
||||
has reached the maxInMemory limit.
|
||||
|
||||
The following attributes and elements are optional.
|
||||
|
||||
timeToIdleSeconds:
|
||||
Sets the time to idle for an element before it expires.
|
||||
i.e. The maximum amount of time between accesses before an element expires
|
||||
Is only used if the element is not eternal.
|
||||
Optional attribute. A value of 0 means that an Element can idle for infinity.
|
||||
The default value is 0.
|
||||
|
||||
timeToLiveSeconds:
|
||||
Sets the time to live for an element before it expires.
|
||||
i.e. The maximum time between creation time and when an element expires.
|
||||
Is only used if the element is not eternal.
|
||||
Optional attribute. A value of 0 means that and Element can live for infinity.
|
||||
The default value is 0.
|
||||
|
||||
diskPersistent:
|
||||
Whether the disk store persists between restarts of the Virtual Machine.
|
||||
The default value is false.
|
||||
|
||||
diskExpiryThreadIntervalSeconds:
|
||||
The number of seconds between runs of the disk expiry thread. The default value
|
||||
is 120 seconds.
|
||||
|
||||
diskSpoolBufferSizeMB:
|
||||
This is the size to allocate the DiskStore for a spool buffer. Writes are made
|
||||
to this area and then asynchronously written to disk. The default size is 30MB.
|
||||
Each spool buffer is used only by its cache. If you get OutOfMemory errors consider
|
||||
lowering this value. To improve DiskStore performance consider increasing it. Trace level
|
||||
logging in the DiskStore will show if put back ups are occurring.
|
||||
|
||||
memoryStoreEvictionPolicy:
|
||||
Policy would be enforced upon reaching the maxElementsInMemory limit. Default
|
||||
policy is Least Recently Used (specified as LRU). Other policies available -
|
||||
First In First Out (specified as FIFO) and Less Frequently Used
|
||||
(specified as LFU)
|
||||
|
||||
Cache elements can also contain sub elements which take the same format of a factory class
|
||||
and properties. Defined sub-elements are:
|
||||
|
||||
* cacheEventListenerFactory - Enables registration of listeners for cache events, such as
|
||||
put, remove, update, and expire.
|
||||
|
||||
* bootstrapCacheLoaderFactory - Specifies a BootstrapCacheLoader, which is called by a
|
||||
cache on initialisation to prepopulate itself.
|
||||
|
||||
* cacheExtensionFactory - Specifies a CacheExtension, a generic mechansim to tie a class
|
||||
which holds a reference to a cache to the cache lifecycle.
|
||||
|
||||
* cacheExceptionHandlerFactory - Specifies a CacheExceptionHandler, which is called when
|
||||
cache exceptions occur.
|
||||
|
||||
* cacheLoaderFactory - Specifies a CacheLoader, which can be used both asynchronously and
|
||||
synchronously to load objects into a cache.
|
||||
|
||||
RMI Cache Replication
|
||||
|
||||
Each cache that will be distributed needs to set a cache event listener which replicates
|
||||
messages to the other CacheManager peers. For the built-in RMI implementation this is done
|
||||
by adding a cacheEventListenerFactory element of type RMICacheReplicatorFactory to each
|
||||
distributed cache's configuration as per the following example:
|
||||
|
||||
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
|
||||
properties="replicateAsynchronously=true,
|
||||
replicatePuts=true,
|
||||
replicateUpdates=true,
|
||||
replicateUpdatesViaCopy=true,
|
||||
replicateRemovals=true
|
||||
asynchronousReplicationIntervalMillis=<number of milliseconds"
|
||||
propertySeparator="," />
|
||||
|
||||
The RMICacheReplicatorFactory recognises the following properties:
|
||||
|
||||
* replicatePuts=true|false - whether new elements placed in a cache are
|
||||
replicated to others. Defaults to true.
|
||||
|
||||
* replicateUpdates=true|false - whether new elements which override an
|
||||
element already existing with the same key are replicated. Defaults to true.
|
||||
|
||||
* replicateRemovals=true - whether element removals are replicated. Defaults to true.
|
||||
|
||||
* replicateAsynchronously=true | false - whether replications are
|
||||
asynchronous (true) or synchronous (false). Defaults to true.
|
||||
|
||||
* replicateUpdatesViaCopy=true | false - whether the new elements are
|
||||
copied to other caches (true), or whether a remove message is sent. Defaults to true.
|
||||
|
||||
* asynchronousReplicationIntervalMillis=<number of milliseconds> - The asynchronous
|
||||
replicator runs at a set interval of milliseconds. The default is 1000. The minimum
|
||||
is 10. This property is only applicable if replicateAsynchronously=true
|
||||
|
||||
|
||||
Cluster Bootstrapping
|
||||
|
||||
The RMIBootstrapCacheLoader bootstraps caches in clusters where RMICacheReplicators are
|
||||
used. It is configured as per the following example:
|
||||
|
||||
<bootstrapCacheLoaderFactory
|
||||
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
|
||||
properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
|
||||
propertySeparator="," />
|
||||
|
||||
The RMIBootstrapCacheLoaderFactory recognises the following optional properties:
|
||||
|
||||
* bootstrapAsynchronously=true|false - whether the bootstrap happens in the background
|
||||
after the cache has started. If false, bootstrapping must complete before the cache is
|
||||
made available. The default value is true.
|
||||
|
||||
* maximumChunkSizeBytes=<integer> - Caches can potentially be very large, larger than the
|
||||
memory limits of the VM. This property allows the bootstraper to fetched elements in
|
||||
chunks. The default chunk size is 5000000 (5MB).
|
||||
|
||||
|
||||
Cache Exception Handling
|
||||
|
||||
By default, most cache operations will propagate a runtime CacheException on failure. An
|
||||
interceptor, using a dynamic proxy, may be configured so that a CacheExceptionHandler can
|
||||
be configured to intercept Exceptions. Errors are not intercepted.
|
||||
|
||||
It is configured as per the following example:
|
||||
|
||||
<cacheExceptionHandlerFactory class="com.example.ExampleExceptionHandlerFactory"
|
||||
properties="logLevel=FINE"/>
|
||||
|
||||
Caches with ExceptionHandling configured are not of type Cache, but are of type Ehcache only,
|
||||
and are not available using CacheManager.getCache(), but using CacheManager.getEhcache().
|
||||
|
||||
|
||||
Cache Loader
|
||||
|
||||
A default CacheLoader may be set which loads objects into the cache through asynchronous and
|
||||
synchronous methods on Cache. This is different to the bootstrap cache loader, which is used
|
||||
only in distributed caching.
|
||||
|
||||
It is configured as per the following example:
|
||||
|
||||
<cacheLoaderFactory class="com.example.ExampleCacheLoaderFactory"
|
||||
properties="type=int,startCounter=10"/>
|
||||
|
||||
Cache Extension
|
||||
|
||||
CacheExtensions are a general purpose mechanism to allow generic extensions to a Cache.
|
||||
CacheExtensions are tied into the Cache lifecycle.
|
||||
|
||||
CacheExtensions are created using the CacheExtensionFactory which has a
|
||||
<code>createCacheCacheExtension()</code> method which takes as a parameter a
|
||||
Cache and properties. It can thus call back into any public method on Cache, including, of
|
||||
course, the load methods.
|
||||
|
||||
Extensions are added as per the following example:
|
||||
|
||||
<cacheExtensionFactory class="com.example.FileWatchingCacheRefresherExtensionFactory"
|
||||
properties="refreshIntervalMillis=18000, loaderTimeout=3000,
|
||||
flushPeriod=whatever, someOtherProperty=someValue ..."/>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<!--
|
||||
Mandatory Default Cache configuration. These settings will be applied to caches
|
||||
created programmtically using CacheManager.add(String cacheName).
|
||||
|
||||
The defaultCache has an implicit name "default" which is a reserved cache name.
|
||||
-->
|
||||
<defaultCache
|
||||
maxElementsInMemory="10000"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="120"
|
||||
timeToLiveSeconds="120"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="30"
|
||||
maxElementsOnDisk="10000000"
|
||||
diskPersistent="false"
|
||||
diskExpiryThreadIntervalSeconds="120"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Sample caches. Following are some example caches. Remove these before use.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Sample cache named sampleCache1
|
||||
This cache contains a maximum in memory of 10000 elements, and will expire
|
||||
an element if it is idle for more than 5 minutes and lives for more than
|
||||
10 minutes.
|
||||
|
||||
If there are more than 10000 elements it will overflow to the
|
||||
disk cache, which in this configuration will go to wherever java.io.tmp is
|
||||
defined on your system. On a standard Linux system this will be /tmp"
|
||||
-->
|
||||
<cache name="profiles"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="genericResources"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="searchConfiguration"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="collections"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="content"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="thumbnail"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="schemata"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache name="metadata"
|
||||
maxElementsInMemory="10000"
|
||||
maxElementsOnDisk="1000"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
diskSpoolBufferSizeMB="20"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Sample cache named sampleCache2
|
||||
This cache has a maximum of 1000 elements in memory. There is no overflow to disk, so 1000
|
||||
is also the maximum cache size. Note that when a cache is eternal, timeToLive and
|
||||
timeToIdle are not used and do not need to be specified.
|
||||
-->
|
||||
<cache name="sampleCache2"
|
||||
maxElementsInMemory="1000"
|
||||
eternal="true"
|
||||
overflowToDisk="false"
|
||||
memoryStoreEvictionPolicy="FIFO"
|
||||
/>
|
||||
|
||||
|
||||
<!--
|
||||
Sample cache named sampleCache3. This cache overflows to disk. The disk store is
|
||||
persistent between cache and VM restarts. The disk expiry thread interval is set to 10
|
||||
minutes, overriding the default of 2 minutes.
|
||||
-->
|
||||
<cache name="sampleCache3"
|
||||
maxElementsInMemory="500"
|
||||
eternal="false"
|
||||
overflowToDisk="true"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
diskPersistent="true"
|
||||
diskExpiryThreadIntervalSeconds="1"
|
||||
memoryStoreEvictionPolicy="LFU"
|
||||
/>
|
||||
|
||||
|
||||
<!--
|
||||
Sample distributed cache named sampleDistributedCache1.
|
||||
This cache replicates using defaults.
|
||||
It also bootstraps from the cluster, using default properties.
|
||||
-->
|
||||
<cache name="sampleDistributedCache1"
|
||||
maxElementsInMemory="10"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="100"
|
||||
timeToLiveSeconds="100"
|
||||
overflowToDisk="false">
|
||||
<cacheEventListenerFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
|
||||
<bootstrapCacheLoaderFactory
|
||||
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
|
||||
</cache>
|
||||
|
||||
|
||||
<!--
|
||||
Sample distributed cache named sampleDistributedCache2.
|
||||
This cache replicates using specific properties.
|
||||
It only replicates updates and does so synchronously via copy
|
||||
-->
|
||||
<cache name="sampleDistributedCache2"
|
||||
maxElementsInMemory="10"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="100"
|
||||
timeToLiveSeconds="100"
|
||||
overflowToDisk="false">
|
||||
<cacheEventListenerFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
|
||||
properties="replicateAsynchronously=false, replicatePuts=false,
|
||||
replicateUpdates=true, replicateUpdatesViaCopy=true,
|
||||
replicateRemovals=false"/>
|
||||
</cache>
|
||||
|
||||
<!--
|
||||
Sample distributed cache named sampleDistributedCache3.
|
||||
This cache replicates using defaults except that the asynchronous replication
|
||||
interval is set to 200ms.
|
||||
-->
|
||||
<cache name="sampleDistributedCache3"
|
||||
maxElementsInMemory="10"
|
||||
eternal="false"
|
||||
timeToIdleSeconds="100"
|
||||
timeToLiveSeconds="100"
|
||||
overflowToDisk="false">
|
||||
<cacheEventListenerFactory
|
||||
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
|
||||
properties="asynchronousReplicationIntervalMillis=200"/>
|
||||
</cache>
|
||||
</ehcache>
|
|
@ -1 +0,0 @@
|
|||
sharedDir=${catalina.home}/shared/d4s
|
|
@ -1,18 +0,0 @@
|
|||
MYPROXY_HOST=grids04.eng.it
|
||||
MYPROXY_PORT=7512
|
||||
PROXIES_DIR=#path to dir where the proxy files will be storeed#
|
||||
HOST_CERT=#myproxy certificate#
|
||||
HOST_KEY=#myproxy key#
|
||||
|
||||
NEW_SERVLET_HOST=dl14.di.uoa.gr #hostname for voms servlet#
|
||||
NEW_SERVLET_PORT=8888 #port where voms servlet is listening#
|
||||
NEW_SERVLET_PATH=/VOMSServlet/VOMSServlet #voms servlet path#
|
||||
NEW_SERVLET_PROTOCOL=http # protocol: http/https#
|
||||
|
||||
KEY_STORE=#path to *.p12 key file#
|
||||
KEY_STORE_TYPE=PKCS12
|
||||
KEY_STORE_PWD=#password for the *.p12 key file#
|
||||
|
||||
TRUST_STORE=#path to trust store file#
|
||||
TRUST_STORE_PWD=#password for the trust store file#
|
||||
TRUST_STORE_TYPE=JKS
|
|
@ -1,124 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache;
|
||||
|
||||
import org.gcube.application.framework.core.cache.factories.CollectionCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.ContentInfoCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.GenericResourceCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.MetadataCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.ProfileCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.SchemaInfoCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.SearchConfigCacheEntryFactory;
|
||||
import org.gcube.application.framework.core.cache.factories.ThumbnailCacheEntryFactory;
|
||||
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.constructs.blocking.SelfPopulatingCache;
|
||||
|
||||
//TODO: Done!!!
|
||||
/**
|
||||
* @author Valia Tsagkalidou
|
||||
*
|
||||
* This class is a singleton that manages the available caches
|
||||
*
|
||||
*/
|
||||
public class CachesManager {
|
||||
protected static CachesManager cacheManager = new CachesManager();
|
||||
protected CacheManager manager;
|
||||
protected Ehcache profileCache;
|
||||
protected Ehcache genericResourceCache;
|
||||
protected Ehcache searchConfigCache;
|
||||
protected Ehcache collectionCache;
|
||||
protected Ehcache contentCache;
|
||||
protected Ehcache thumbnailCache;
|
||||
protected Ehcache schemataCache;
|
||||
protected Ehcache metadataCache;
|
||||
|
||||
/**
|
||||
* The contsructor
|
||||
*/
|
||||
protected CachesManager() {
|
||||
|
||||
manager = CacheManager.create(CachesManager.class.getResource("/etc/ehcache.xml"));
|
||||
|
||||
profileCache = manager.getEhcache("profiles");
|
||||
genericResourceCache = manager.getEhcache("genericResources");
|
||||
searchConfigCache = manager.getEhcache("searchConfiguration");
|
||||
collectionCache = manager.getEhcache("collections");
|
||||
contentCache = manager.getEhcache("content");
|
||||
thumbnailCache = manager.getEhcache("thumbnail");
|
||||
schemataCache = manager.getEhcache("schemata");
|
||||
metadataCache = manager.getEhcache("metadata");
|
||||
|
||||
profileCache = new SelfPopulatingCache(profileCache, new ProfileCacheEntryFactory());
|
||||
genericResourceCache = new SelfPopulatingCache(genericResourceCache, new GenericResourceCacheEntryFactory());
|
||||
searchConfigCache = new SelfPopulatingCache(searchConfigCache, new SearchConfigCacheEntryFactory());
|
||||
collectionCache = new SelfPopulatingCache(collectionCache, new CollectionCacheEntryFactory());
|
||||
contentCache = new SelfPopulatingCache(contentCache, new ContentInfoCacheEntryFactory());
|
||||
thumbnailCache = new SelfPopulatingCache(thumbnailCache, new ThumbnailCacheEntryFactory());
|
||||
schemataCache = new SelfPopulatingCache(schemataCache, new SchemaInfoCacheEntryFactory());
|
||||
metadataCache = new SelfPopulatingCache(metadataCache, new MetadataCacheEntryFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sigleton of CachesManager
|
||||
*/
|
||||
public static CachesManager getInstance() {
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the user profiles
|
||||
*/
|
||||
public Ehcache getProfileCache() {
|
||||
return profileCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the generic resources
|
||||
*/
|
||||
public Ehcache getGenericResourceCache() {
|
||||
return genericResourceCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the search configurations
|
||||
*/
|
||||
public Ehcache getSearchConfigCache() {
|
||||
return searchConfigCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the collections per VRE
|
||||
*/
|
||||
public Ehcache getCollectionCache() {
|
||||
return collectionCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains information about digital objects
|
||||
*/
|
||||
public Ehcache getContentCache() {
|
||||
return contentCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains thumbnails
|
||||
*/
|
||||
public Ehcache getThumbnailCache() {
|
||||
return thumbnailCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the searchable fields for each metadata schema
|
||||
*/
|
||||
public Ehcache getSchemataCache() {
|
||||
return schemataCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache that contains the metadata objects
|
||||
*/
|
||||
public Ehcache getMetadataCache() {
|
||||
return metadataCache;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.HarvestIS;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.HarvestIS.MODE;
|
||||
|
||||
/**
|
||||
* This class manages the running harvester threads.
|
||||
*
|
||||
* @author Giota
|
||||
*
|
||||
*/
|
||||
|
||||
public class HarvestersManager {
|
||||
|
||||
public static final String threadsName = "DISHarvesterThread_";
|
||||
|
||||
/**
|
||||
* Defines the manager's instance
|
||||
*/
|
||||
private static HarvestersManager instance = null;
|
||||
|
||||
protected HashMap<GCUBEScope, ISInfo> isInfos;
|
||||
|
||||
/**
|
||||
* The manager thread runs and every 5 minutes checks if a harvester thread should be terminated because
|
||||
* its credential is not valid anymore
|
||||
*/
|
||||
private HarvestersManager() {
|
||||
//TODO: check it again for the logic.....
|
||||
isInfos = new HashMap<GCUBEScope, ISInfo>();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method starts the manager. If there is already an instance for the manager it uses it.
|
||||
*/
|
||||
synchronized public static HarvestersManager getInstance() {
|
||||
if (instance == null)
|
||||
instance = new HarvestersManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope the GGUBEScope of the IS Info
|
||||
* @return the IS Info for this specific scope
|
||||
*/
|
||||
public ISInfo getISInfo(GCUBEScope scope)
|
||||
{
|
||||
ISInfo isInfo = isInfos.get(scope);
|
||||
if(isInfo == null)
|
||||
{
|
||||
isInfo = new ISInfo();
|
||||
getHarvesterThread(scope, isInfo);
|
||||
isInfos.put(scope, isInfo);
|
||||
}
|
||||
return isInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param isInfo
|
||||
* @return
|
||||
*/
|
||||
protected HarvestIS getHarvesterThread(GCUBEScope scope, ISInfo isInfo) {
|
||||
HarvestIS returnedThread = null;
|
||||
|
||||
/* Harvester not found for the specific DL */
|
||||
/* Create new harvester */
|
||||
Vector<MODE> modes = new Vector<MODE>();
|
||||
modes.add(HarvestIS.MODE.CMS);
|
||||
modes.add(HarvestIS.MODE.MC);
|
||||
modes.add(HarvestIS.MODE.PERSONALIZATION_ADMIN);
|
||||
modes.add(HarvestIS.MODE.PERSONALIZATION_USER);
|
||||
modes.add(HarvestIS.MODE.SEARCHMASTER);
|
||||
modes.add(HarvestIS.MODE.THUMBNAILER);
|
||||
modes.add(HarvestIS.MODE.VREMANAGEMENT);
|
||||
|
||||
try {
|
||||
System.out.println("There is no harvester for the DL: " + scope.getName() + ". Creating a new harvester.");
|
||||
returnedThread = new HarvestIS(isInfo, modes, scope);
|
||||
// new File("/tmp/harvest" + scope.toString()).mkdirs();
|
||||
// returnedThread = new HarvestIS(isInfo, "/tmp/harvest" + scope.toString(), scope);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/* Change the thread's name to the desired name */
|
||||
returnedThread.setName(createThreadsName(scope.getName()));
|
||||
// returnedThread.setDaemon(true);
|
||||
/* Start harvester */
|
||||
returnedThread.start();
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return returnedThread;
|
||||
}
|
||||
|
||||
private static String createThreadsName(String DL) {
|
||||
return threadsName + DL;
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.application.framework.core.security.VOMSAdminManager;
|
||||
import org.gcube.application.framework.core.util.UserCredential;
|
||||
import org.gcube.common.core.security.utils.VOMSAttributesReader;
|
||||
import org.gcube.vomanagement.vomsAdmin.impl.VOMSAdminImpl;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
class ApplicationCredentials {
|
||||
private static ApplicationCredentials applCredentials = new ApplicationCredentials();
|
||||
private HashMap<String, ExtendedGSSCredential> creds;
|
||||
protected static String userDN = "/O=Grid/OU=GlobusTest/OU=simpleCA-gauss.eng.it/OU=eng.it/CN=";
|
||||
protected static String userCA = "/O=Grid/OU=GlobusTest/OU=simpleCA-gauss.eng.it/CN=Globus Simple CA";
|
||||
|
||||
|
||||
/**
|
||||
* The basic constructor
|
||||
*/
|
||||
protected ApplicationCredentials()
|
||||
{
|
||||
creds = new HashMap<String, ExtendedGSSCredential>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sigleton of ApplicationCredentials
|
||||
*/
|
||||
public static ApplicationCredentials getInstance()
|
||||
{
|
||||
return applCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DLname the of the DL for which you want to get the "portal" credential
|
||||
* @return the grid credential
|
||||
*/
|
||||
public ExtendedGSSCredential getCredential(String DLname)
|
||||
{
|
||||
ExtendedGSSCredential cred = creds.get(DLname);
|
||||
if(cred == null)
|
||||
{
|
||||
cred = UserCredential.getCredential("application", DLname);
|
||||
if(cred == null)
|
||||
{
|
||||
//user "application" does not exist on this DL, so we add him and try to get credential again
|
||||
VOMSAdminImpl vomsA;
|
||||
try {
|
||||
vomsA = VOMSAdminManager.getVOMSAdmin();
|
||||
String[] roles = vomsA.listRoles();
|
||||
vomsA.createUser("application", userDN+"application", userCA, "application@gcube.org");
|
||||
vomsA.addMember(DLname, userDN+"application", userCA);
|
||||
vomsA.assignRole(DLname, roles[0], userDN+"application", userCA);
|
||||
}
|
||||
catch (Exception e) {
|
||||
vomsA = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
cred = UserCredential.getCredential("application", DLname);
|
||||
}
|
||||
creds.put(DLname, cred);
|
||||
}
|
||||
else
|
||||
{
|
||||
VOMSAttributesReader vomsReader = null;
|
||||
try {
|
||||
vomsReader = new VOMSAttributesReader(cred);
|
||||
if(vomsReader.getRefreshPeriod() < 60000)
|
||||
{
|
||||
cred = UserCredential.getCredential("application", DLname);
|
||||
creds.put(DLname, cred);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
return cred;
|
||||
}
|
||||
}
|
|
@ -1,438 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.globus.wsrf.ResourceKey;
|
||||
import org.globus.wsrf.impl.SimpleResourceKey;
|
||||
import org.globus.wsrf.utils.AddressingUtils;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import org.apache.axis.message.addressing.AttributedURI;
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.InputSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.commons.model.CollectionInfo;
|
||||
import org.gcube.application.framework.core.commons.model.IndexInfo;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.application.framework.core.vremanagement.model.ISGenericResource;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.CollectionInfo.CollectionAttrs;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.CollectionInfo.TypeValues;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class CollectionCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* Document factory instance
|
||||
*/
|
||||
public static final DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
/**
|
||||
* whether geospatial tab should be available or not
|
||||
*/
|
||||
protected boolean geospatial;
|
||||
//TODO: find a way to return also the geospatial tab boolean variable
|
||||
|
||||
|
||||
/**
|
||||
* @param key a String representing the DL name.
|
||||
* @return List<CollectionInfo>[] an array of Lists containing CollectionInfo objects. Each List contains a Collection group. The First element of the list is the CollectionInfo containing info for the Group (name, description etc). The rest of the objects in the list are the actual collections.
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
|
||||
List<CollectionInfo> collections;
|
||||
String searchConfig = (String) CachesManager.getInstance().getSearchConfigCache().get(key).getValue();
|
||||
if(searchConfig == null || searchConfig.equals(""))
|
||||
return null;
|
||||
collections = parseSearchConfig(searchConfig);
|
||||
return retrieveStaticConfiguration(key.toString(), collections);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param searchConfig the search configuration as it is returned from the SearchMaster
|
||||
* @return a list of CollectionInfo, which represents the currently available collections
|
||||
*/
|
||||
protected List<CollectionInfo> parseSearchConfig(String searchConfig)
|
||||
{
|
||||
|
||||
try {
|
||||
// Interpreting the dynamic configuration
|
||||
System.out.println("******************************");
|
||||
System.out.println(searchConfig);
|
||||
System.out.println("******************************");
|
||||
InputSource colls_in = new InputSource(new StringReader(searchConfig));
|
||||
Document colls_doc;
|
||||
colls_doc = dfactory.newDocumentBuilder().parse(colls_in);
|
||||
NodeList colls_res;
|
||||
colls_res = XPathAPI.selectNodeList(colls_doc, "/SearchConfig/collections/collection["+CollectionAttrs.TYPE+"='"+TypeValues.DATA+"']");
|
||||
// the initParameter "scenario" should be replaced by vdl parameter.
|
||||
// However, currently only one vdl exists and supports both scenarios...
|
||||
int n = colls_res.getLength(),i;
|
||||
List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
|
||||
for (i = 0; i < n; i++)
|
||||
{//Foreach content collection:
|
||||
// Storing the information in local variables.
|
||||
CollectionInfo colInfo = new CollectionInfo();
|
||||
String val;
|
||||
String id = colls_res.item(i).getAttributes().getNamedItem("id").getNodeValue();
|
||||
val = id;
|
||||
String colName = colls_res.item(i).getAttributes().getNamedItem("name").getNodeValue();
|
||||
|
||||
colInfo.setId(id);
|
||||
colInfo.setName(colName);
|
||||
NodeList contentRes = XPathAPI.selectNodeList(colls_doc, "/SearchConfig/collections/collection[@id='"+id+"']/"+CollectionAttrs.ASSOCIATEDWITH);
|
||||
int attrNo = contentRes.getLength();
|
||||
for(int j=0; j<attrNo; j++)
|
||||
{//Foreach metadata collection:
|
||||
try
|
||||
{
|
||||
String metadataID = contentRes.item(j).getFirstChild().getNodeValue();
|
||||
String language = null, schema = null;
|
||||
|
||||
NodeList metaRes = XPathAPI.selectNodeList(colls_doc, "/SearchConfig/collections/collection[@id='"+metadataID+"']/"+"LANGUAGE");
|
||||
if(metaRes == null)
|
||||
continue;
|
||||
language = metaRes.item(0).getFirstChild().getNodeValue();
|
||||
|
||||
metaRes = XPathAPI.selectNodeList(colls_doc, "/SearchConfig/collections/collection[@id='"+metadataID+"']/"+"SCHEMA");
|
||||
if(metaRes != null)
|
||||
schema = metaRes.item(0).getFirstChild().getNodeValue();
|
||||
metaRes = XPathAPI.selectNodeList(colls_doc, "/SearchConfig/collections/collection[@id='"+metadataID+"']/"+"INDEX");
|
||||
IndexInfo indexInformation = new IndexInfo();
|
||||
if(metaRes != null)
|
||||
{
|
||||
System.out.println("schema = " + metaRes);
|
||||
int k, total = metaRes.getLength();
|
||||
for(k=0; k<total; k++)
|
||||
{//Foreach Index:
|
||||
System.out.println(" -- " + metaRes.item(k).getFirstChild().getNodeValue());
|
||||
if(metaRes.item(k).getFirstChild().getNodeValue().equals("FTS"))
|
||||
{
|
||||
indexInformation.setFts(true);
|
||||
System.out.println("id name : "+val);
|
||||
}
|
||||
else if(metaRes.item(k).getFirstChild().getNodeValue().equals("GEO"))
|
||||
{
|
||||
indexInformation.setGeospatial(true);
|
||||
System.out.println("id name : "+val);
|
||||
}
|
||||
else if(metaRes.item(k).getFirstChild().getNodeValue().equals("FEATURE"))
|
||||
{//Ayto mporei na allaxei....
|
||||
indexInformation.setSimilarity(true);
|
||||
System.out.println("id name : "+val);
|
||||
// geoFound = true; //Prepei na allaxei?
|
||||
}
|
||||
}
|
||||
}
|
||||
colInfo.setMetadataCollection(schema, metadataID, language, indexInformation);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}//End of metadata for.
|
||||
collections.add(colInfo);
|
||||
}
|
||||
return collections;
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the static configuration for the collections from the DIS.
|
||||
* @param dl the dl for which it will retrieve the static configuration (generic resource in IS)
|
||||
* @param collections the collection derived from the dynamic configuration (SearchMaster configuration)
|
||||
* @return an array of Lists containing CollectionInfo objects. Each List contains a Collection group. The First element of the list is the CollectionInfo containing info for the Group (name, description etc). The rest of the objects in the list are the actual collections.
|
||||
* @throws Exception an Exception occurred during the procedure
|
||||
*/
|
||||
protected List<CollectionInfo>[] retrieveStaticConfiguration(String dl, List<CollectionInfo> collections) throws Exception
|
||||
{
|
||||
// Reading the static configuration file and initializing the parameters
|
||||
List<CollectionInfo>[] colHierarchy;
|
||||
QueryString query = new QueryString();
|
||||
query.put("dl", dl);
|
||||
query.put("name", SessionConstants.ScenarioSchemaInfo);
|
||||
List<ISGenericResource> scenarioSchemaInfo = (List<ISGenericResource>) CachesManager.getInstance().getGenericResourceCache().get(query).getValue();
|
||||
if(scenarioSchemaInfo == null || scenarioSchemaInfo.size() == 0)
|
||||
{
|
||||
colHierarchy = new ArrayList[0];
|
||||
return colHierarchy;
|
||||
}
|
||||
System.out.println("*************************************");
|
||||
System.out.println(scenarioSchemaInfo.get(0).getBody());
|
||||
System.out.println("*************************************");
|
||||
InputSource in = new InputSource(new StringReader(scenarioSchemaInfo.get(0).getBody()));
|
||||
Document doc = dfactory.newDocumentBuilder().parse(in);
|
||||
|
||||
retrieveCollections(doc, collections);
|
||||
colHierarchy = retrieveCollectionHierarchy(dl, doc, collections);
|
||||
return colHierarchy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the collections.
|
||||
* @param doc document which holds the collections
|
||||
* @param collections the list containing the collections
|
||||
*/
|
||||
protected void retrieveCollections(Document doc, List<CollectionInfo> collections)
|
||||
{
|
||||
int i,n;
|
||||
List<CollectionInfo> availableCollections = new ArrayList<CollectionInfo>();
|
||||
// Reading the collections and storing them in a list only if they are currently available.
|
||||
NodeList res = doc.getElementsByTagName("collection");
|
||||
n = res.getLength();
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
String val = res.item(i).getAttributes().getNamedItem("name").getNodeValue();
|
||||
CollectionInfo colInfo = null;
|
||||
|
||||
colInfo = getCollectionInfo(val, collections);
|
||||
if (colInfo == null)
|
||||
continue;// This collection is not currently available.
|
||||
|
||||
val = res.item(i).getAttributes().getNamedItem("description").getNodeValue();
|
||||
colInfo.setDescription(val);
|
||||
val = res.item(i).getAttributes().getNamedItem("reference").getNodeValue();
|
||||
colInfo.setReference(val);
|
||||
val = res.item(i).getAttributes().getNamedItem("shortname").getNodeValue();
|
||||
colInfo.setShortName(val);
|
||||
availableCollections.add(colInfo);
|
||||
}
|
||||
|
||||
collections.clear();
|
||||
for(CollectionInfo col : availableCollections)
|
||||
{
|
||||
collections.add(col);
|
||||
}
|
||||
|
||||
res = doc.getElementsByTagName("collections");
|
||||
n = res.getLength();
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
CollectionInfo colInfo = new CollectionInfo();
|
||||
|
||||
colInfo.setId("collection_id_"+i);
|
||||
String val;
|
||||
try{
|
||||
val = res.item(i).getAttributes().getNamedItem("name").getNodeValue();
|
||||
colInfo.setName(val);
|
||||
}
|
||||
catch(Exception e){}
|
||||
try{
|
||||
val = res.item(i).getAttributes().getNamedItem("description").getNodeValue();
|
||||
colInfo.setDescription(val);
|
||||
}
|
||||
catch(Exception e){}
|
||||
try{
|
||||
val = res.item(i).getAttributes().getNamedItem("reference").getNodeValue();
|
||||
colInfo.setReference(val);
|
||||
}
|
||||
catch(Exception e){}
|
||||
try{
|
||||
val = res.item(i).getAttributes().getNamedItem("shortname").getNodeValue();
|
||||
colInfo.setShortName(val);
|
||||
}
|
||||
catch(Exception e){}
|
||||
collections.add(colInfo);
|
||||
}
|
||||
System.out.println("***Number of collections:" + collections.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the collection hierarchy. Joins the static and the dynamic search configuration and produces a hierarchical structure containing information about each collection.
|
||||
* @param DLname the dl name of the active DL (VRE)
|
||||
* @param doc document which holds the collections
|
||||
* @param collections the available collections
|
||||
* @return an array of Lists containing CollectionInfo objects. Each List contains a Collection group. The First element of the list is the CollectionInfo containing info for the Group (name, description etc). The rest of the objects in the list are the actual collections.
|
||||
* @throws Exception an Exception occurred during processing
|
||||
*/
|
||||
protected List<CollectionInfo>[] retrieveCollectionHierarchy(String DLname, Document doc, List<CollectionInfo> collections) throws Exception {
|
||||
|
||||
// Retrieving the tree structure of the collection hierarchy
|
||||
NodeList res = XPathAPI.selectNodeList(doc, "//DL");
|
||||
Node geo = res.item(0).getAttributes().getNamedItem("geospatial");
|
||||
if(geo != null && geo.getNodeValue().equals("true"))
|
||||
geospatial = true;
|
||||
res = XPathAPI.selectNodeList(doc, "//collections");
|
||||
int n = res.getLength();
|
||||
System.out.println("***** number of collection groups:" + n + "*******");
|
||||
List<CollectionInfo>[] colHierachy = new List[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
String val = res.item(i).getAttributes().getNamedItem("name").getNodeValue();
|
||||
NodeList res2 = XPathAPI.selectNodeList(doc, "//collections[@name=\"" + val + "\"]/collection");
|
||||
colHierachy[i] = new ArrayList<CollectionInfo>();
|
||||
CollectionInfo colInfo = getCollectionInfo(val, collections);
|
||||
if(colInfo != null)
|
||||
{
|
||||
colHierachy[i].add(colInfo); // Collection Group Name
|
||||
for (int j = 0; j < res2.getLength(); j++)
|
||||
{//for each collection belonging to that group, it stores its name...
|
||||
colInfo = getCollectionInfo(res2.item(j).getAttributes().getNamedItem("name").getNodeValue(), collections);
|
||||
if(colInfo != null)
|
||||
{
|
||||
findBrowseFields(colInfo, GCUBEScope.getScope(DLname));
|
||||
colHierachy[i].add(colInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("***collection group " + i + " contains " + (colHierachy[i].size()-1) + " collections***");
|
||||
}
|
||||
return colHierachy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resultSet the results
|
||||
* @param forwardIndices a HashMap containing EPRs for each collection - field
|
||||
* @throws Exception an exception occurred
|
||||
*/
|
||||
protected void parseEPRResult(String resultSet, HashMap<String, EndpointReferenceType> forwardIndices) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
if(resultSet == null)
|
||||
return;
|
||||
StringReader reader = new StringReader(resultSet);
|
||||
InputSource source = new InputSource(reader);
|
||||
Document domDoc = builder.parse(source);
|
||||
|
||||
String Address = "";
|
||||
String key = "";
|
||||
String namespaceKey = "";
|
||||
String localNameKey = "";
|
||||
String fieldName = "";
|
||||
|
||||
Element root = domDoc.getDocumentElement();
|
||||
NodeList resultSetChilds = root.getElementsByTagName("RESULT");
|
||||
|
||||
for (int numRes = 0; numRes < resultSetChilds.getLength(); numRes++) {
|
||||
boolean keyExist = false;
|
||||
NodeList EPRChild = resultSetChilds.item(numRes).getChildNodes();
|
||||
|
||||
for (int i = 0; i < EPRChild.getLength(); i++) {
|
||||
|
||||
if (EPRChild.item(i) instanceof Element) {
|
||||
Element child = (Element) EPRChild.item(i);
|
||||
|
||||
if (child.getTagName().equals("KeyName")) {
|
||||
fieldName = ((Text) child.getFirstChild()).getNodeValue();
|
||||
} else if (child.getTagName().equals("Source")) {
|
||||
Address = ((Text) child.getFirstChild()).getNodeValue();
|
||||
} else if (child.getTagName().equals("SourceKey")) {
|
||||
Text keyElement = (Text) child.getFirstChild();
|
||||
|
||||
if (keyElement != null) {
|
||||
key = keyElement.getNodeValue();
|
||||
keyExist = true;
|
||||
}
|
||||
} else if (child.getTagName().equals("CompleteSourceKey")
|
||||
&& keyExist) {
|
||||
|
||||
if (child instanceof Element) {
|
||||
Element completeKey = (Element) child;
|
||||
|
||||
NodeList listChild = completeKey.getChildNodes();
|
||||
|
||||
for (int x = 0; x < listChild.getLength(); x++) {
|
||||
|
||||
if (listChild.item(x) instanceof Element) {
|
||||
Element childEl = (Element) listChild
|
||||
.item(x);
|
||||
|
||||
if (childEl != null) {
|
||||
Text keyElement = (Text) childEl
|
||||
.getFirstChild();
|
||||
|
||||
key = (String) keyElement
|
||||
.getNodeValue();
|
||||
// logger.debug("key " +key);
|
||||
namespaceKey = (String) childEl
|
||||
.getNamespaceURI();
|
||||
// logger.debug("ns "+namespaceKey);
|
||||
localNameKey = (String) childEl
|
||||
.getLocalName();
|
||||
// logger.debug("local " +localNameKey);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EndpointReferenceType epr = new EndpointReferenceType();
|
||||
|
||||
if (keyExist) {
|
||||
ResourceKey key_resource = new SimpleResourceKey(new QName(
|
||||
namespaceKey, localNameKey), key);
|
||||
epr = AddressingUtils.createEndpointReference(Address,
|
||||
key_resource);
|
||||
|
||||
} else
|
||||
epr.setAddress(new AttributedURI(Address));
|
||||
forwardIndices.put(fieldName, epr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Browsable fields for the given collection
|
||||
* @param colInfo the CollectionInfo containing info about the current collection
|
||||
* @param scope the GCUBEScope of the active VRE
|
||||
*/
|
||||
private void findBrowseFields(CollectionInfo colInfo, GCUBEScope scope) {
|
||||
|
||||
String where = "$doc//ServiceClass/string() eq 'Index' and $doc//ServiceName/string() eq 'ForwardIndexLookupService' and $doc//CollectionID/string() eq '"+ colInfo.getId() +"'";
|
||||
String query = "for $doc in collection(\"/db/Properties\")//Document where " + where + " return <RESULT>{$doc//KeyName}{$doc/Source}{$doc/SourceKey}{$doc/CompleteSourceKey}</RESULT>";
|
||||
|
||||
try {
|
||||
|
||||
//TODO: change the way i call IS
|
||||
String forwardResults = null;// = DISHLSClient.getGeneralQueryManager(cred, null).queryDISIC(query, cred, null);
|
||||
parseEPRResult(forwardResults, colInfo.getForward());
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param collectionName the name of the collection
|
||||
* @param collections a list containing all the collections
|
||||
* @return the CollectionInfo of the collection with the corresponding name
|
||||
*/
|
||||
protected CollectionInfo getCollectionInfo(String collectionName, List<CollectionInfo> collections)
|
||||
{
|
||||
CollectionInfo colInfo = null;
|
||||
int i, n = collections.size();
|
||||
for(i=0; i< n; i++)
|
||||
{
|
||||
System.out.println("*******" + collections.get(i).getName() + " vs. " + collectionName);
|
||||
if(collections.get(i).getName().equals(collectionName))
|
||||
{
|
||||
colInfo = collections.get(i);
|
||||
System.out.println("***collection found****");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return colInfo;
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.CMSPortType1PortType;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.DocumentDescription;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.GetDocumentParameters;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.service.CMSPortType1ServiceAddressingLocator;
|
||||
import org.gcube.contentmanagement.layerindependent.descriptions.BasicInfoObjectDescription;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class ContentInfoCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* An atomic integer to get the CMS EPRs round-robin
|
||||
*/
|
||||
protected static AtomicInteger cmsId = new AtomicInteger(0);
|
||||
|
||||
|
||||
/**
|
||||
* @param key a QueryString representing pairs of keys and values.
|
||||
* @return a DocumentDescription as it is returned from the CMS. The content is not transfered for storage and efficiency reasons
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
QueryString query = (QueryString) key;
|
||||
DocumentDescription docDescription = null;
|
||||
if(query.containsKey(CacheEntryConstants.dl) && query.containsKey(CacheEntryConstants.oid))
|
||||
{
|
||||
String[] cmsURIs = HarvestersManager.getInstance().getISInfo(GCUBEScope.getScope(query.get(CacheEntryConstants.dl))).getEndPointForCMSService("");
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
GetDocumentParameters docParams = new GetDocumentParameters();
|
||||
docParams.setDocumentID(query.get(CacheEntryConstants.oid));
|
||||
docParams.setTargetFileLocation(BasicInfoObjectDescription.RAW_CONTENT_DO_NOT_TRANSFER);
|
||||
docParams.setUnrollLevels(3);
|
||||
|
||||
for(int i=0; i< cmsURIs.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
serviceEPR.setAddress(new Address(cmsURIs[cmsId.getAndIncrement()%cmsURIs.length]));
|
||||
CMSPortType1ServiceAddressingLocator serviceLocator = new CMSPortType1ServiceAddressingLocator();
|
||||
CMSPortType1PortType cms = serviceLocator.getCMSPortType1PortTypePort(serviceEPR);
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(GCUBEScope.getScope(query.get(CacheEntryConstants.dl)));
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
ExtendedGSSCredential cred = ApplicationCredentials.getInstance().getCredential(query.get(CacheEntryConstants.dl));
|
||||
secManager.useCredentials(cred);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
cms = GCUBERemotePortTypeContext.getProxy(cms, GCUBEScope.getScope(query.get(CacheEntryConstants.dl)), secManager);
|
||||
// Retrieving dynamic configuration. E.g. which collections are
|
||||
// currently available, if a Full text Index is available....
|
||||
docDescription = cms.getDocument(docParams);
|
||||
break;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return docDescription;
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.application.framework.core.vremanagement.model.ISGenericResource;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou
|
||||
*
|
||||
*/
|
||||
public class GenericResourceCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
static ISClient client = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor to initialize the ISClient
|
||||
*/
|
||||
public GenericResourceCacheEntryFactory() {
|
||||
super();
|
||||
if(client == null)
|
||||
{
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param key a QueryString representing pairs of keys and values.
|
||||
* @return a list containing the Generic Resources that correspond to the query
|
||||
*/
|
||||
public List<ISGenericResource> createEntry(Object key) throws Exception {
|
||||
QueryString querySt = (QueryString) key;
|
||||
GCUBEScope scope = GCUBEScope.getScope(querySt.get(CacheEntryConstants.dl));
|
||||
GCUBEGenericResourceQuery query = client.getQuery(GCUBEGenericResourceQuery.class);
|
||||
System.out.println("\n\nquery: " + querySt.toString());
|
||||
if(querySt.containsKey(CacheEntryConstants.id))
|
||||
{
|
||||
query.addAtomicConditions(new AtomicCondition("/ID", querySt.get(CacheEntryConstants.id)));
|
||||
|
||||
}
|
||||
else if(querySt.containsKey(CacheEntryConstants.name) && querySt.get(CacheEntryConstants.name).equals(SessionConstants.ScenarioSchemaInfo))
|
||||
{
|
||||
query.addAtomicConditions(new AtomicCondition("/Profile/Name", querySt.get(CacheEntryConstants.name)));
|
||||
query.addAtomicConditions(new AtomicCondition("/Profile/Body/DL/attribute::name", querySt.get(CacheEntryConstants.dl)));
|
||||
}
|
||||
else if(querySt.containsKey(CacheEntryConstants.name))
|
||||
{
|
||||
query.addAtomicConditions(new AtomicCondition("/Profile/Name", querySt.get(CacheEntryConstants.name)));
|
||||
}
|
||||
|
||||
try{
|
||||
List<GCUBEGenericResource> result = client.execute(query, scope);
|
||||
List<ISGenericResource> res = new ArrayList<ISGenericResource>();
|
||||
System.out.println("size of results: " + result.size());
|
||||
for(GCUBEGenericResource resource : result)
|
||||
{
|
||||
ISGenericResource genResource = new ISGenericResource(resource.getID(), resource.getName(), resource.getDescription(), resource.getBody());
|
||||
res.add(genResource);
|
||||
}
|
||||
return res;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.CreateManagerResponse;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.GetElementItemResponse;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.GetElementsResponse;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.InformationObjectIDList;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.MetadataManagerFactoryPortType;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.MetadataManagerPortType;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.MetadataObjectList;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.service.MetadataManagerFactoryServiceAddressingLocator;
|
||||
import org.gcube.metadatamanagement.metadatamanager.stubs.service.MetadataManagerServiceAddressingLocator;
|
||||
import org.gcube.metadatamanagement.mmlibrary.model.BaseMetadata;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class MetadataCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* An atomic integer to get the CMS EPRs round-robin
|
||||
*/
|
||||
protected static AtomicInteger mcId = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* @param key a QueryString representing pairs of keys and values.
|
||||
* @return the metadata object of the corresponding ID
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
QueryString query = (QueryString) key;
|
||||
|
||||
try {
|
||||
MetadataManagerPortType metaManager = null;
|
||||
String[] mcURIs = HarvestersManager.getInstance().getISInfo(GCUBEScope.getScope(query.get(CacheEntryConstants.dl))).getEndPointForMMFactoryService("");
|
||||
for(int i=0; i < mcURIs.length; i++)
|
||||
{
|
||||
try {
|
||||
MetadataManagerServiceAddressingLocator instanceLocator = new MetadataManagerServiceAddressingLocator();
|
||||
MetadataManagerFactoryPortType mcFactory = null;
|
||||
EndpointReferenceType endpoint = new EndpointReferenceType();
|
||||
endpoint.setAddress(new Address(mcURIs[mcId.getAndIncrement()%mcURIs.length]));
|
||||
MetadataManagerFactoryServiceAddressingLocator mcflocator = new MetadataManagerFactoryServiceAddressingLocator();
|
||||
mcFactory = mcflocator.getMetadataManagerFactoryPortTypePort(endpoint);
|
||||
CreateManagerResponse createResponsefromcollection = mcFactory.createManagerFromCollection(query.get(CacheEntryConstants.metadataColID));
|
||||
EndpointReferenceType instanceEPR = createResponsefromcollection.getEndpointReference();
|
||||
metaManager = instanceLocator.getMetadataManagerPortTypePort(instanceEPR);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(GCUBEScope.getScope(query.get(CacheEntryConstants.dl)));
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(ApplicationCredentials.getInstance().getCredential(CacheEntryConstants.dl));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
metaManager = GCUBERemotePortTypeContext.getProxy(metaManager, GCUBEScope.getScope(CacheEntryConstants.dl), secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String[] oids = new String[1];
|
||||
oids[0] = query.get(CacheEntryConstants.oid);
|
||||
InformationObjectIDList oidsList = new InformationObjectIDList(oids);
|
||||
GetElementsResponse elements = metaManager.getElements(oidsList);
|
||||
GetElementItemResponse element = elements.getGetElementsItemResponse(0);
|
||||
MetadataObjectList moList = element.getMetadataObjectList();
|
||||
String metadataXML = moList.getMetadataObject(0);
|
||||
BaseMetadata metadata = new BaseMetadata();
|
||||
metadata.fromXML(metadataXML);
|
||||
return metadata;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.commons.ProfileService;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.UserProfileAccessFactoryPortType;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.UserProfileAccessPortType;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.service.UserProfileAccessFactoryServiceAddressingLocator;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.service.UserProfileAccessServiceAddressingLocator;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
import org.ietf.jgss.GSSCredential;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*/
|
||||
public class ProfileCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* Document factory instance
|
||||
*/
|
||||
protected static final DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
/**
|
||||
* An atomic integer to get the Profile EPRs round-robin
|
||||
*/
|
||||
protected static AtomicInteger profileId = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* @param key a QueryString representing pairs of keys and values.
|
||||
* @return the user profile as a DOM object (Document)
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
QueryString query = (QueryString) key;
|
||||
String profile = "";
|
||||
if(query.containsKey(CacheEntryConstants.dl) && query.containsKey(CacheEntryConstants.username))
|
||||
{
|
||||
System.out.println("Scope=" + GCUBEScope.getScope(query.get(CacheEntryConstants.dl)));
|
||||
ProfileService profileService = new ProfileService(query.get(CacheEntryConstants.username), GCUBEScope.getScope(query.get(CacheEntryConstants.dl)));
|
||||
ExtendedGSSCredential cred = (new PortalSecurityManager(GCUBEScope.getScope(query.get(CacheEntryConstants.dl))).isSecurityEnabled())?ApplicationCredentials.getInstance().getCredential(CacheEntryConstants.dl):null;
|
||||
for(int i=0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
UserProfileAccessPortType port = profileService.getUserProfileAccess(cred);
|
||||
profile = port.getUserProfile(new VOID()); // this is the profile!!!
|
||||
System.out.println(profile);
|
||||
InputSource profileIn = new InputSource(new ByteArrayInputStream(profile.getBytes()));
|
||||
Document profileDoc = dfactory.newDocumentBuilder().parse(profileIn);
|
||||
return profileDoc;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.application.framework.core.vremanagement.model.ISGenericResource;
|
||||
import org.gcube.application.framework.core.commons.model.SearchField;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class SchemaInfoCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Document factory instance
|
||||
*/
|
||||
public static final DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
/**
|
||||
* @param key a String representing the DL name.
|
||||
* @return a HashMap that contains the Searchable Fields for each metadata schema
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
HashMap<String, List<SearchField>> SchemaHashMap = new HashMap<String, List<SearchField>>();
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, key.toString());
|
||||
query.addParameter(CacheEntryConstants.name, SessionConstants.MetadataSchemaInfo);
|
||||
List<ISGenericResource> genericResources = ((List<ISGenericResource>)CachesManager.getInstance().getGenericResourceCache().get(query).getValue());
|
||||
String schemaInfo = "<Records>";
|
||||
for(ISGenericResource res : genericResources)
|
||||
schemaInfo += "<Record>" + res.getBody() + "</Record>";
|
||||
schemaInfo += "</Records>";
|
||||
retrieveMetadataSchemaInfo(schemaInfo, SchemaHashMap);
|
||||
return SchemaHashMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the metadata schema info from DIS
|
||||
*
|
||||
* @param metaSchemata a serialized xml document containing the schemata together with their searchble fields
|
||||
* @param SchemaHashMap a HashMap that contains the Searchable Fields for each metadata schema to be filled in
|
||||
*/
|
||||
protected void retrieveMetadataSchemaInfo(String metaSchemata, HashMap<String, List<SearchField>> SchemaHashMap) {
|
||||
if(metaSchemata == null || metaSchemata.trim().equals(""))
|
||||
return;
|
||||
try {
|
||||
InputSource metadata_in = new InputSource(new StringReader(metaSchemata));
|
||||
Document doc = dfactory.newDocumentBuilder().parse(metadata_in);
|
||||
NodeList res = doc.getElementsByTagName("Record");
|
||||
|
||||
int n = res.getLength();
|
||||
int i;
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
//for each schema:
|
||||
String schema = null;
|
||||
List<SearchField> metaFields = new ArrayList<SearchField>();
|
||||
schema = res.item(k).getChildNodes().item(0).getNodeName(); // schema name
|
||||
System.out.println("schema=" + schema);
|
||||
NodeList MetaRes = XPathAPI.selectNodeList(res.item(k), "//"+schema+"/option");
|
||||
int mrLength = MetaRes.getLength();
|
||||
for (i = 0; i < mrLength; i++)
|
||||
{ // For each option (criterion):
|
||||
|
||||
try
|
||||
{
|
||||
NodeList res2 = MetaRes.item(i).getChildNodes();
|
||||
int j, m;
|
||||
m = res2.getLength();
|
||||
SearchField option = new SearchField();
|
||||
for (j = 0; j < m; j++)
|
||||
{
|
||||
String name = res2.item(j).getNodeName();
|
||||
if (name.equals("option-name"))
|
||||
{
|
||||
option.name = res2.item(j).getFirstChild().getNodeValue();
|
||||
}
|
||||
else if (name.equals("option-value"))
|
||||
{
|
||||
option.value = res2.item(j).getFirstChild().getNodeValue();
|
||||
}
|
||||
else if (name.equals("option-type"))
|
||||
{
|
||||
option.type = res2.item(j).getFirstChild().getNodeValue();
|
||||
}
|
||||
else if (name.equals("option-sort"))
|
||||
{
|
||||
option.sort = res2.item(j).getFirstChild().getNodeValue();
|
||||
}
|
||||
}
|
||||
metaFields.add(option);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SchemaHashMap.put(schema, metaFields);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
|
||||
import org.gcube.searchservice.searchmasterservice.stubs.SearchMasterPortType;
|
||||
import org.gcube.searchservice.searchmasterservice.stubs.service.SearchMasterServiceAddressingLocator;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*/
|
||||
public class SearchConfigCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* An atomic integer to get the Search EPRs round-robin
|
||||
*/
|
||||
protected static AtomicInteger SMid = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* @param key a String representing the DL name.
|
||||
* @return a String - serialized the search configuration
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(GCUBEScope.getScope(key.toString()));
|
||||
String[] searchMasterURIs = null;
|
||||
for(int count =0; count < 5 ; count++)
|
||||
{
|
||||
searchMasterURIs = disInfo.getEndPointForMasterService();
|
||||
if(searchMasterURIs.length > 0)
|
||||
break;
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
// Creating a client for Search Master.
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
String collections_xml = null;
|
||||
System.out.println(searchMasterURIs.length + " search masters found on IS.");
|
||||
for(int counter = 0; counter < searchMasterURIs.length; counter++)
|
||||
{
|
||||
try
|
||||
{
|
||||
serviceEPR.setAddress(new Address(searchMasterURIs[SMid.getAndIncrement()%searchMasterURIs.length]));
|
||||
SearchMasterServiceAddressingLocator serviceLocator = new SearchMasterServiceAddressingLocator();
|
||||
SearchMasterPortType searchMaster = serviceLocator.getSearchMasterPortTypePort(serviceEPR);
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(GCUBEScope.getScope(key.toString()));
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(ApplicationCredentials.getInstance().getCredential(key.toString()));
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
searchMaster = GCUBERemotePortTypeContext.getProxy(searchMaster, GCUBEScope.getScope(key.toString()), secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Retrieving dynamic configuration. E.g. which collections are
|
||||
// currently available, if a Full text Index is available....
|
||||
collections_xml = searchMaster.retrieveConfiguration("collections");
|
||||
break;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return collections_xml;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package org.gcube.application.framework.core.cache.factories;
|
||||
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class ThumbnailCacheEntryFactory implements CacheEntryFactory {
|
||||
|
||||
/**
|
||||
* @param key a QueryString representing pairs of keys and values.
|
||||
* @return a Stream containing the thumbnail
|
||||
*/
|
||||
public Object createEntry(Object key) throws Exception {
|
||||
// TODO Auto-generated method stub. I must implement this method!
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
package org.gcube.application.framework.core.commons;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.personalization.profileadministration.stubs.ProfileAdministrationPortType;
|
||||
import org.gcube.personalization.profileadministration.stubs.service.ProfileAdministrationServiceAddressingLocator;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.UserProfileAccessFactoryPortType;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.UserProfileAccessPortType;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.service.UserProfileAccessFactoryServiceAddressingLocator;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.service.UserProfileAccessServiceAddressingLocator;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
import org.ietf.jgss.GSSCredential;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class ProfileService {
|
||||
|
||||
protected static AtomicInteger profileId = new AtomicInteger(0);
|
||||
protected String username;
|
||||
protected GCUBEScope scope;
|
||||
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
* @param username the user for each it will get the profile (Resource)
|
||||
* @param scope the scope of the active VRE
|
||||
*/
|
||||
public ProfileService( String username, GCUBEScope scope) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public UserProfileAccessFactoryPortType getUserProfileAccessFactory()
|
||||
{
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(scope);
|
||||
String[] profileURIs;
|
||||
try {
|
||||
profileURIs = disInfo.getEndPointForPersonalizationUPAFactoryService();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
System.out.println("getUserProfileAccessFactory: " + profileURIs.length);
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
UserProfileAccessFactoryPortType upa = null;
|
||||
|
||||
try
|
||||
{
|
||||
serviceEPR.setAddress(new Address(profileURIs[profileId.getAndIncrement()%profileURIs.length]));
|
||||
UserProfileAccessFactoryServiceAddressingLocator upalocator = new UserProfileAccessFactoryServiceAddressingLocator();
|
||||
upa = upalocator.getUserProfileAccessFactoryPortTypePort(serviceEPR);
|
||||
return upa;
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cred
|
||||
* @return
|
||||
*/
|
||||
public UserProfileAccessPortType getUserProfileAccess(ExtendedGSSCredential cred)
|
||||
{
|
||||
UserProfileAccessFactoryPortType upa = getUserProfileAccessFactory();
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(scope);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(cred);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
upa = GCUBERemotePortTypeContext.getProxy(upa, scope, secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
EndpointReferenceType epr = null;
|
||||
try {
|
||||
System.out.println("\n\n\n\n" + username + " scope= " + scope + "\n\n\n\n");
|
||||
epr = upa.createResource(username);
|
||||
} catch (GCUBEFault e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(epr != null)
|
||||
{
|
||||
try {
|
||||
return getUserProfileAccessServicePortType(epr, scope, cred);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param upa
|
||||
* @param cred
|
||||
* @return
|
||||
*/
|
||||
public UserProfileAccessPortType getUserProfileAccess(UserProfileAccessFactoryPortType upa, ExtendedGSSCredential cred)
|
||||
{
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(scope);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(cred);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
upa = GCUBERemotePortTypeContext.getProxy(upa, scope, secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
EndpointReferenceType epr = null;
|
||||
try {
|
||||
epr = upa.createResource(username);
|
||||
} catch (GCUBEFault e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(epr != null)
|
||||
{
|
||||
try {
|
||||
return getUserProfileAccessServicePortType(epr, scope, cred);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the port type of the service User Profile Access.
|
||||
*
|
||||
* @param epr the endpoint reference of a WS resource of this service
|
||||
* @return port for UserProfileAccess service
|
||||
* @throws RemoteException an exception
|
||||
*/
|
||||
private UserProfileAccessPortType getUserProfileAccessServicePortType(EndpointReferenceType epr,GCUBEScope scope, GSSCredential cred) throws RemoteException {
|
||||
UserProfileAccessServiceAddressingLocator instanceLocator = new UserProfileAccessServiceAddressingLocator();
|
||||
UserProfileAccessPortType port = null;
|
||||
try {
|
||||
port = instanceLocator.getUserProfileAccessPortTypePort(epr);
|
||||
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(scope);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(cred);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
port = GCUBERemotePortTypeContext.getProxy(port, scope, secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RemoteException("A service exception was thrown. Failed to get the port type of the service user profile access");
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cred
|
||||
* @return
|
||||
*/
|
||||
public ProfileAdministrationPortType getProfileAdministration(GSSCredential cred)
|
||||
{
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(scope);
|
||||
String[] profileURIs;
|
||||
try {
|
||||
profileURIs = disInfo.getEndPointForPersonalizationPAService();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
ProfileAdministrationPortType pa = null;
|
||||
System.out.println("profile administration services: " + profileURIs.length);
|
||||
try
|
||||
{
|
||||
serviceEPR.setAddress(new Address(profileURIs[profileId.getAndIncrement()%profileURIs.length]));
|
||||
ProfileAdministrationServiceAddressingLocator palocator = new ProfileAdministrationServiceAddressingLocator();
|
||||
pa = palocator.getProfileAdministrationPortTypePort(serviceEPR);
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(scope);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
secManager.useCredentials(cred);
|
||||
}
|
||||
pa = GCUBERemotePortTypeContext.getProxy(pa, scope, secManager);
|
||||
return pa;
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
package org.gcube.application.framework.core.commons.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Collection's information
|
||||
* @author valia, giotak, UoA
|
||||
*
|
||||
*/
|
||||
public class CollectionInfo implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String shortName;
|
||||
protected String description;
|
||||
protected String reference;
|
||||
protected Vector<String> schemata;
|
||||
protected Vector<String> metadataIDs;
|
||||
protected Vector<String> languages;
|
||||
protected Vector<IndexInfo> indices;
|
||||
protected HashMap<String, EndpointReferenceType> forward;
|
||||
|
||||
/**
|
||||
* @return collection's description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
/**
|
||||
* @param description collection's description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
/**
|
||||
* @return collection's ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* @param id collection's ID
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @return collection's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name collection's name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* Constructor of the class
|
||||
*/
|
||||
public CollectionInfo() {
|
||||
id = "";
|
||||
name = "";
|
||||
shortName = "";
|
||||
description = "";
|
||||
reference = "";
|
||||
schemata = new Vector<String>();
|
||||
metadataIDs = new Vector<String>();
|
||||
languages = new Vector<String>();
|
||||
indices = new Vector<IndexInfo>();
|
||||
forward = new HashMap<String, EndpointReferenceType>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i the position of the metadata schema
|
||||
* @return the schema in the specified position.
|
||||
*/
|
||||
public String getSchema(int i) {
|
||||
return schemata.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i the position of the metadata schema
|
||||
* @return metadata's ID
|
||||
*/
|
||||
public String getMetadataID(int i) {
|
||||
return metadataIDs.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i the position of the metadata schema
|
||||
* @return the language for this schema
|
||||
*/
|
||||
public String getLanguage(int i) {
|
||||
return languages.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i the position of the metadata schema
|
||||
* @return an object that contains info about the existence or not of specific indices
|
||||
*/
|
||||
public IndexInfo getIndexInfo(int i) {
|
||||
return indices.get(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the collection's short name
|
||||
*/
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shortName the collection's short name
|
||||
*/
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schema collection's schema name (e.g. dc, tei)
|
||||
* @param metaID the ID of the metadata collection
|
||||
* @param language metadata collection's language
|
||||
* @param index the indices that collection has
|
||||
*/
|
||||
public void setMetadataCollection(String schema, String metaID, String language, IndexInfo index)
|
||||
{
|
||||
this.schemata.add(schema);
|
||||
this.metadataIDs.add(metaID);
|
||||
this.languages.add(language);
|
||||
this.indices.add(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reference to this collection (usually a url)
|
||||
*/
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reference the reference to this collection (usually a url)
|
||||
*/
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schema metadata collection's schema
|
||||
* @return true if this collection has a corresponding metadata collection with this schema, otherwise false.
|
||||
*/
|
||||
public boolean hasSchema(String schema)
|
||||
{
|
||||
return this.schemata.contains(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schema metadata collection's schema
|
||||
* @return true if this collection has a corresponding metadata collection with this schema, otherwise false.
|
||||
*/
|
||||
public int getIndexOfSchema(String schema)
|
||||
{
|
||||
return this.schemata.indexOf(schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of corrsponding metadata collections
|
||||
*/
|
||||
public int getMetadataSize()
|
||||
{
|
||||
return this.metadataIDs.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forward indices stored in a hasmap. The key to the hasmap is collection together with the field, and the value is an EPR to the index.
|
||||
*/
|
||||
public HashMap<String, EndpointReferenceType> getForward() {
|
||||
return forward;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package org.gcube.application.framework.core.commons.model;
|
||||
|
||||
import org.gcube.portlets.session.client.Point;
|
||||
import org.gcube.portlets.session.client.TimeBound;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
//TODO: Done!!!
|
||||
public class GeospatialInfo {
|
||||
|
||||
String relation;
|
||||
|
||||
Point[] bounds;
|
||||
|
||||
TimeBound timeInterval;
|
||||
|
||||
/**
|
||||
* Geospatial info constructor
|
||||
*
|
||||
*/
|
||||
public GeospatialInfo() {
|
||||
this.relation = null;
|
||||
this.bounds = null;
|
||||
this.timeInterval = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param relation
|
||||
* @param bounds
|
||||
* @param timeInterval
|
||||
*/
|
||||
public GeospatialInfo(String relation, Point[] bounds,
|
||||
TimeBound timeInterval) {
|
||||
this.relation = relation;
|
||||
this.bounds = bounds;
|
||||
this.timeInterval = timeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bounds
|
||||
*/
|
||||
public Point[] getBounds() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return relation
|
||||
*/
|
||||
public String getRelation() {
|
||||
return relation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return timeInterval
|
||||
*/
|
||||
public TimeBound getTimeInterval() {
|
||||
return timeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bounds
|
||||
*/
|
||||
public void setBounds(Point[] bounds) {
|
||||
this.bounds = bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param relation
|
||||
*/
|
||||
public void setRelation(String relation) {
|
||||
this.relation = relation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeInterval
|
||||
*/
|
||||
public void setTimeInterval(TimeBound timeInterval) {
|
||||
this.timeInterval = timeInterval;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package org.gcube.application.framework.core.commons.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class IndexInfo implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected boolean fts;
|
||||
protected boolean geospatial;
|
||||
protected boolean similarity;
|
||||
|
||||
/**
|
||||
* The constructor of the class
|
||||
*
|
||||
*/
|
||||
public IndexInfo() {
|
||||
super();
|
||||
fts = false;
|
||||
geospatial = false;
|
||||
similarity = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether an FTS index exists for this collection
|
||||
*/
|
||||
public boolean isFts() {
|
||||
return fts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether a geospatial index exists for this collection
|
||||
*/
|
||||
public boolean isGeospatial() {
|
||||
return geospatial;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether a similarity index exists for this collection
|
||||
*/
|
||||
public boolean isSimilarity() {
|
||||
return similarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value whether a full text index exists
|
||||
* @param fts true or false
|
||||
*/
|
||||
public void setFts(boolean fts) {
|
||||
this.fts = fts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value whether a geo-spatial index exists
|
||||
* @param geospatial true or false
|
||||
*/
|
||||
public void setGeospatial(boolean geospatial) {
|
||||
this.geospatial = geospatial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value whether a similarity index exists
|
||||
* @param similarity true or false
|
||||
*/
|
||||
public void setSimilarity(boolean similarity) {
|
||||
this.similarity = similarity;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.gcube.application.framework.core.commons.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Panagiota Koltsida (NKUA)
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
//TODO: Done!!!
|
||||
public class SearchField implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Name of the criterion
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Value of the criterion
|
||||
*/
|
||||
public String value;
|
||||
|
||||
/**
|
||||
* Type of the criterion
|
||||
*/
|
||||
public String type;
|
||||
|
||||
/**
|
||||
* The x-path to apply for sorting the results
|
||||
*/
|
||||
public String sort;
|
||||
|
||||
public SearchField() {
|
||||
name = "";
|
||||
value = "";
|
||||
type = "";
|
||||
sort = "";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package org.gcube.application.framework.core.content;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.metadatamanagement.mmlibrary.model.BaseMetadata;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou
|
||||
*
|
||||
*/
|
||||
public interface DigitalObjectInfoI {
|
||||
|
||||
/**
|
||||
* @return a Stream containing the object
|
||||
*/
|
||||
public OutputStream getObject();
|
||||
|
||||
/**
|
||||
* @param name the name of the Object
|
||||
* @param collectionName the name of the collection
|
||||
* @return a Stream containing the object
|
||||
*/
|
||||
public OutputStream getObjectByName(String name, String collectionName);
|
||||
|
||||
/**
|
||||
* @param width the maximum width of the thumbnail
|
||||
* @param height the maximum height of the thumbnail
|
||||
* @return a Stream containing the thumbnail
|
||||
*/
|
||||
public byte[] getThumbnail(int width, int height);
|
||||
|
||||
/**
|
||||
* @return a hashmap containing the primary roles together with the corresponding Object Identifier of the related objects
|
||||
*/
|
||||
public HashMap<String,String> getPrimaryRoles();
|
||||
|
||||
/**
|
||||
* @return a hashmap containing the secondary roles together with the corresponding Object Identifier of the related objects
|
||||
*/
|
||||
public HashMap<String,String> getSecondaryRoles();
|
||||
|
||||
/**
|
||||
* @return the available metadata schemata of the corresponding object
|
||||
*/
|
||||
public List<String> getAvailableSchemata();
|
||||
|
||||
/**
|
||||
* @return the metadata
|
||||
*/
|
||||
public String getMetadata(String schema);
|
||||
|
||||
|
||||
/**
|
||||
* @param metadata the metadata object to be updated
|
||||
*/
|
||||
public void updateMetadata(BaseMetadata metadata);
|
||||
|
||||
/**
|
||||
* @return the object's Mime type
|
||||
*/
|
||||
public String getMimeType();
|
||||
|
||||
/**
|
||||
* @return the object's length
|
||||
*/
|
||||
public long getLength();
|
||||
|
||||
/**
|
||||
* @return the object's name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
}
|
|
@ -1,334 +0,0 @@
|
|||
package org.gcube.application.framework.core.content.impl;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.commons.model.CollectionInfo;
|
||||
import org.gcube.application.framework.core.content.DigitalObjectInfoI;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.FindInfo;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.CMSPortType1PortType;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.DocumentDescription;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.DocumentPropertyDescription;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.GetDocumentParameters;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.Hint;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.ReferencedObjectDescription;
|
||||
import org.gcube.contentmanagement.contentlayer.contentmanagementservice.stubs.service.CMSPortType1ServiceAddressingLocator;
|
||||
import org.gcube.contentmanagement.layerindependent.descriptions.BasicInfoObjectDescription;
|
||||
import org.gcube.contentmanagement.layerindependent.descriptions.BasicStorageHints;
|
||||
import org.gcube.metadatamanagement.mmlibrary.model.BaseMetadata;
|
||||
|
||||
public class DigitalObject implements DigitalObjectInfoI {
|
||||
|
||||
/**
|
||||
* the D4Science session
|
||||
*/
|
||||
protected D4ScienceSession session;
|
||||
|
||||
/**
|
||||
* the object identifier to the object for which you want to retrieve info
|
||||
*/
|
||||
protected String oid;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String colID;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected CollectionInfo colInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final static int chunkSize = 1048576;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static AtomicInteger cmsId = new AtomicInteger(0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param session the D4Science session to be used for retrieving information needed
|
||||
* @param oid the object identifier
|
||||
* @param colID the collection identifier
|
||||
*/
|
||||
public DigitalObject(D4ScienceSession session, String oid, String colID) {
|
||||
super();
|
||||
this.session = session;
|
||||
this.oid = oid;
|
||||
this.colID = colID;
|
||||
List<CollectionInfo>[] collections = (List<CollectionInfo>[]) session.getAttribute(SessionConstants.Collections);
|
||||
colInfo = FindInfo.findCollectionInfo(colID, collections);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getAvailableSchemata()
|
||||
*/
|
||||
public List<String> getAvailableSchemata() {
|
||||
List<String> schemata = new ArrayList<String>();
|
||||
for(int i=0; i<colInfo.getMetadataSize(); i++)
|
||||
{
|
||||
schemata.add(colInfo.getSchema(i));
|
||||
}
|
||||
return schemata;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getLength()
|
||||
*/
|
||||
public long getLength() {
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
DocumentDescription docDescription = (DocumentDescription) CachesManager.getInstance().getContentCache().get(query).getValue();
|
||||
|
||||
DocumentPropertyDescription[] properties = docDescription.getProperties();
|
||||
for(int j = 0 ; j < properties.length; j++)
|
||||
{
|
||||
if(properties[j].getName().indexOf("LengthOfRawContent") != -1)
|
||||
{
|
||||
return Long.parseLong(properties[j].getValue());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
//TODO: edw tha prepei na mpei kai i glwssa gia na einai unique...
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getMetadata(java.lang.String)
|
||||
*/
|
||||
public String getMetadata(String schema) {
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
query.addParameter(CacheEntryConstants.metadataColID, colInfo.getMetadataID(colInfo.getIndexOfSchema(schema)));
|
||||
return (String) CachesManager.getInstance().getMetadataCache().get(query).getValue();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getMimeType()
|
||||
*/
|
||||
public String getMimeType() {
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
DocumentDescription docDescription = (DocumentDescription) CachesManager.getInstance().getContentCache().get(query).getValue();
|
||||
return docDescription.getMimeType();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "unknown/unknown";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getObject()
|
||||
*/
|
||||
public OutputStream getObject() {
|
||||
try {
|
||||
String [] cmsURIs = HarvestersManager.getInstance().getISInfo(session.getScope()).getEndPointForCMSService("");
|
||||
boolean excep = true;
|
||||
String cmsAddress;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
for (int i = 0; i < cmsURIs.length && excep; i++) {
|
||||
excep = false;
|
||||
cmsAddress = cmsURIs[cmsId.getAndIncrement()% cmsURIs.length];
|
||||
|
||||
try {
|
||||
System.out.println("CID=" + oid + " cmsAddress=" + cmsAddress);
|
||||
CMSPortType1PortType cms;
|
||||
|
||||
EndpointReferenceType endpoint = new EndpointReferenceType();
|
||||
endpoint.setAddress(new Address(cmsAddress));
|
||||
CMSPortType1ServiceAddressingLocator cmslocator = new CMSPortType1ServiceAddressingLocator();
|
||||
cms = cmslocator.getCMSPortType1PortTypePort(endpoint);
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(session);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(session.getCredential());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
GCUBERemotePortTypeContext.getProxy(cms, session.getScope(), secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (int count = 0;; count++) {
|
||||
// Retrieving content in chunks :-)
|
||||
|
||||
Hint[] hints = new Hint[2];
|
||||
hints[0] = new Hint();
|
||||
hints[0].setName(BasicStorageHints.HINT_NAME_READING_START_OFFSET);
|
||||
hints[0].setValue("" + count * chunkSize);
|
||||
hints[1] = new Hint();
|
||||
hints[1].setName(BasicStorageHints.HINT_NAME_LIMIT_CONTENT_LENGTH_READ);
|
||||
hints[1].setValue("" + chunkSize);
|
||||
|
||||
GetDocumentParameters getDocumentParams = new GetDocumentParameters();
|
||||
getDocumentParams.setDocumentID(oid);
|
||||
getDocumentParams.setTargetFileLocation(BasicInfoObjectDescription.RAW_CONTENT_IN_MESSAGE);
|
||||
getDocumentParams.setHints(hints);
|
||||
// inmessage://
|
||||
try {
|
||||
DocumentDescription document = cms.getDocument(getDocumentParams);
|
||||
byte[] buffer = document.getRawContent();
|
||||
|
||||
if (buffer == null)
|
||||
break;
|
||||
out.write(buffer);
|
||||
out.flush();
|
||||
if (buffer.length < chunkSize)
|
||||
break;
|
||||
buffer = null;
|
||||
if (count % 5 == 0)
|
||||
System.gc();
|
||||
} catch (RemoteException e) {
|
||||
count--;
|
||||
e.printStackTrace();
|
||||
} catch (Throwable e1) {
|
||||
e1.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
excep = true;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getObjectByName(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public FileOutputStream getObjectByName(String name, String collectionName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getPrimaryRoles()
|
||||
*/
|
||||
public HashMap<String, String> getPrimaryRoles() {
|
||||
HashMap<String, String> primRoles = new HashMap<String, String>();
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
DocumentDescription docDescription = (DocumentDescription) CachesManager.getInstance().getContentCache().get(query).getValue();
|
||||
ReferencedObjectDescription[] references = docDescription.getReferences();
|
||||
for(int j = 0 ; j < references.length; j++)
|
||||
{
|
||||
primRoles.put(references[j].getRole(), references[j].getTargetObjectID());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return primRoles;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getSecondaryRoles()
|
||||
*/
|
||||
public HashMap<String, String> getSecondaryRoles() {
|
||||
HashMap<String, String> secRoles = new HashMap<String, String>();
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
DocumentDescription docDescription = (DocumentDescription) CachesManager.getInstance().getContentCache().get(query).getValue();
|
||||
ReferencedObjectDescription[] references = docDescription.getReferences();
|
||||
for(int j = 0 ; j < references.length; j++)
|
||||
{
|
||||
secRoles.put(references[j].getSecondaryRole(), references[j].getTargetObjectID());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return secRoles;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getThumbnail(int, int)
|
||||
*/
|
||||
public byte[] getThumbnail(int width, int height) {
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
query.addParameter(CacheEntryConstants.width, "" + width);
|
||||
query.addParameter(CacheEntryConstants.height, "" + height);
|
||||
return (byte[]) CachesManager.getInstance().getThumbnailCache().get(query).getValue();
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#updateMetadata(org.gcube.metadatamanagement.mmlibrary.model.BaseMetadata)
|
||||
*/
|
||||
public void updateMetadata(BaseMetadata metadata) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.DigitalObjectInfoI#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
try {
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
query.addParameter(CacheEntryConstants.oid, oid);
|
||||
DocumentDescription docDescription = (DocumentDescription) CachesManager.getInstance().getContentCache().get(query).getValue();
|
||||
return docDescription.getName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package org.gcube.application.framework.core.security;
|
||||
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class PortalSecurityManager extends GCUBESecurityManagerImpl {
|
||||
|
||||
public PortalSecurityManager(GCUBEScope scope) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public PortalSecurityManager(D4ScienceSession session) {
|
||||
super();
|
||||
this.scope = session.getScope();
|
||||
}
|
||||
|
||||
GCUBEScope scope;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package org.gcube.application.framework.core.security;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gcube.application.framework.core.util.Settings;
|
||||
import org.gcube.vomanagement.vomsAdmin.impl.VOMSAdminImpl;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class VOMSAdminManager {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static VOMSAdminImpl vomsAdmin= null;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static VOMSAdminImpl getVOMSAdmin()
|
||||
{
|
||||
if(vomsAdmin == null)
|
||||
{
|
||||
try {
|
||||
vomsAdmin = new VOMSAdminImpl(Settings.getInstance().getProperty("sharedDir")+ File.separator + "vomsAPI.properties");
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return vomsAdmin;
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
package org.gcube.application.framework.core.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.application.framework.core.util.UserCredential;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class D4ScienceSession{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private HashMap<String, Object> innerSession;
|
||||
private long lastUsedTime;
|
||||
private String externalSessionID;
|
||||
private String username;
|
||||
private ExtendedGSSCredential credential;
|
||||
private GCUBEScope scope;
|
||||
private HashMap<String, Notifier> notifiers;
|
||||
|
||||
/**
|
||||
* A constructor based on the user and an external ID
|
||||
* @param externalSessionId the external id
|
||||
* @param user the username
|
||||
*/
|
||||
D4ScienceSession(String externalSessionId, String user)
|
||||
{
|
||||
innerSession = new HashMap<String, Object>();
|
||||
notifiers = new HashMap<String, Notifier>();
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
username = user;
|
||||
externalSessionID = externalSessionId;
|
||||
}
|
||||
|
||||
private void initializeAttributes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the session is still valid or not
|
||||
*/
|
||||
public boolean isValid()
|
||||
{
|
||||
if((System.currentTimeMillis() - lastUsedTime) > 1800000) // 30 minutes
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the session is empty or not
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
return innerSession.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the attribute
|
||||
* @return whether the name attribute exists in the session
|
||||
*/
|
||||
public boolean hasAttribute(String name)
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
return innerSession.containsKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a set of all the attributes in the session
|
||||
*/
|
||||
public Set<String> getAttributeNames()
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
return innerSession.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the attribute
|
||||
* @return the value of the named attribute
|
||||
*/
|
||||
public Object getAttribute(String name)
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
return innerSession.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the attribute
|
||||
* @param value the value of the attribute
|
||||
*/
|
||||
public void setAttribute(String name, Object value)
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
innerSession.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the named attribute from the session
|
||||
* @param name the name of the attribute
|
||||
* @return the removed object
|
||||
*/
|
||||
public Object removeAttribute(String name)
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
return innerSession.remove(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the attributes from the session
|
||||
*/
|
||||
public void removeAll()
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
innerSession.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* invalidates the session
|
||||
*/
|
||||
public void invalidate()
|
||||
{
|
||||
lastUsedTime = System.currentTimeMillis() - 2000000; //more than 30 minutes
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the credential
|
||||
*/
|
||||
public ExtendedGSSCredential getCredential() {
|
||||
return credential;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the external session id (passed to the constructor)
|
||||
*/
|
||||
public String getExternalSessionID() {
|
||||
return externalSessionID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scope
|
||||
*/
|
||||
public GCUBEScope getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the scope (VRE)
|
||||
*/
|
||||
public String getScopeName()
|
||||
{
|
||||
return scope.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope the scope name (VRE)
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
lastUsedTime = System.currentTimeMillis();
|
||||
this.scope = GCUBEScope.getScope(scope.trim().toLowerCase());
|
||||
if(new PortalSecurityManager(this.scope).isSecurityEnabled())
|
||||
this.credential = UserCredential.getCredential(username, scope);
|
||||
innerSession.clear();
|
||||
initializeAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param notification the name of the notification to wait for
|
||||
* @throws InterruptedException when the thread is interrupted
|
||||
*/
|
||||
public void waitNotification(String notification) throws InterruptedException
|
||||
{
|
||||
Notifier notifier = notifiers.get(notification);
|
||||
if(notifier == null)
|
||||
{
|
||||
notifier = new Notifier();
|
||||
notifiers.put(notification, notifier);
|
||||
}
|
||||
|
||||
notifier.waitNotification();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param notification the name of the notification to send notification
|
||||
* @throws InterruptedException when the thread is interrupted
|
||||
*/
|
||||
public void notifyAllWaiting(String notification) throws InterruptedException
|
||||
{
|
||||
Notifier notifier = notifiers.get(notification);
|
||||
if(notifier == null)
|
||||
{
|
||||
notifier = new Notifier();
|
||||
notifiers.put(notification, notifier);
|
||||
}
|
||||
|
||||
notifier.notifyAllWaiting();
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package org.gcube.application.framework.core.session;
|
||||
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
class Notifier {
|
||||
|
||||
Semaphore sem;
|
||||
|
||||
Notifier() {
|
||||
sem = new Semaphore(0, true);
|
||||
}
|
||||
|
||||
|
||||
public void waitNotification() throws InterruptedException
|
||||
{
|
||||
sem.acquire();
|
||||
}
|
||||
|
||||
public void notifyAllWaiting() throws InterruptedException
|
||||
{
|
||||
sem.release(sem.getQueueLength());
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package org.gcube.application.framework.core.session;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class SessionManager {
|
||||
|
||||
protected static Thread thread = new CleanSessionThread();
|
||||
protected static SessionManager sessionManager = new SessionManager();
|
||||
protected HashMap<String, D4ScienceSession> sessions;
|
||||
|
||||
protected SessionManager() {
|
||||
sessions = new HashMap<String, D4ScienceSession>();
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static SessionManager getInstance() {
|
||||
return sessionManager;
|
||||
}
|
||||
|
||||
public D4ScienceSession getD4ScienceSession(String externalSessionID, String username)
|
||||
{
|
||||
D4ScienceSession session = sessions.get(externalSessionID + "_" + username);
|
||||
if(session == null || !session.isValid() || !session.getUsername().equals(username))
|
||||
{
|
||||
session = new D4ScienceSession(externalSessionID, username);
|
||||
sessions.put(externalSessionID + "_" + username, session);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
thread.interrupt();
|
||||
thread.join();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
|
||||
protected static class CleanSessionThread extends Thread
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
try {
|
||||
Thread.sleep(600000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
//TODO: cleanup invalid sessions: add locks...
|
||||
Set<String> keys = sessionManager.sessions.keySet();
|
||||
Iterator<String> iter = keys.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
String extSessionID = iter.next();
|
||||
if(!sessionManager.sessions.get(extSessionID).isValid())
|
||||
{
|
||||
sessionManager.sessions.remove(extSessionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class CacheEntryConstants {
|
||||
|
||||
public static final String dl = "dl";
|
||||
|
||||
public static final String oid = "oid";
|
||||
|
||||
public static final String metadataColID = "metadataColID";
|
||||
|
||||
public static final String name = "name";
|
||||
|
||||
public static final String id = "id";
|
||||
|
||||
public static final String username = "username";
|
||||
|
||||
public static final String width = "width";
|
||||
|
||||
public static final String height = "height";
|
||||
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gcube.application.framework.core.commons.model.CollectionInfo;
|
||||
import org.gcube.application.framework.core.commons.model.SearchField;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class FindInfo {
|
||||
|
||||
public static final String ALL = "ALL";
|
||||
public static final String NAME = "NAME";
|
||||
public static final String DESCRIPTION = "DESCRIPTION";
|
||||
|
||||
public static CollectionInfo findCollectionInfo(String colID, List<CollectionInfo>[] collections)
|
||||
{
|
||||
for(int counter=0; counter < collections.length;counter++)
|
||||
{
|
||||
for(int c2=1; c2 < collections[counter].size(); c2++)
|
||||
{
|
||||
if(collections[counter].get(c2).getId().equals(colID))
|
||||
{
|
||||
return collections[counter].get(c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CollectionInfo findCollectionInfoFromMetadata(String metadataColID, List<CollectionInfo>[] collections)
|
||||
{
|
||||
for(int counter=0; counter < collections.length;counter++)
|
||||
{
|
||||
for(int c2=1; c2 < collections[counter].size(); c2++)
|
||||
{
|
||||
for(int c3=0; c3 < collections[counter].get(c2).getMetadataSize(); c3++)
|
||||
{
|
||||
if(collections[counter].get(c2).getMetadataID(c3).equals(metadataColID))
|
||||
{
|
||||
return collections[counter].get(c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static List<CollectionInfo> searchCollectionInfo(String term, String whereToSearch, List<CollectionInfo>[] collections)
|
||||
{
|
||||
term = term.trim().toLowerCase();
|
||||
if(term.startsWith("*"))
|
||||
{
|
||||
term = term.substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
term = "(\\s|\\p{Punct})" + term;
|
||||
}
|
||||
if(term.endsWith("*"))
|
||||
{
|
||||
term = term.substring(0,term.length()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
term = term + "(\\s|\\p{Punct})";
|
||||
}
|
||||
term = term.replaceAll("\\x2A", ".*");
|
||||
term = term.replaceAll("\\x3F", ".");
|
||||
Pattern pattern = Pattern.compile(term);
|
||||
|
||||
boolean name = false, descr = false;
|
||||
if(whereToSearch.equals(FindInfo.ALL))
|
||||
{
|
||||
name = true;
|
||||
descr = true;
|
||||
}
|
||||
else if(whereToSearch.equals(FindInfo.NAME))
|
||||
{
|
||||
name = true;
|
||||
}
|
||||
else if(whereToSearch.equals(FindInfo.DESCRIPTION))
|
||||
{
|
||||
descr = true;
|
||||
}
|
||||
List<CollectionInfo> res = new ArrayList<CollectionInfo>();
|
||||
for(int counter=0; counter < collections.length;counter++)
|
||||
{
|
||||
for(int c2=0; c2 < collections[counter].size(); c2++)
|
||||
{
|
||||
if(name)
|
||||
{
|
||||
if(pattern.matcher(" " + collections[counter].get(c2).getName().toLowerCase() + " ").find())
|
||||
{
|
||||
res.add(collections[counter].get(c2));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(descr)
|
||||
{
|
||||
if(pattern.matcher(" " + collections[counter].get(c2).getDescription().toLowerCase() + " ").find())
|
||||
{
|
||||
res.add(collections[counter].get(c2));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static int findCollectionSchema(String schemaName, CollectionInfo collection)
|
||||
{
|
||||
for(int counter =0; counter < collection.getMetadataSize(); counter++)
|
||||
{
|
||||
if(collection.getSchema(counter).equals(schemaName))
|
||||
{
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int findCriterion(String name, String schemaName, HashMap<String, List<SearchField>> SchemaHashMap)
|
||||
{
|
||||
List<SearchField> schemaCriteria = SchemaHashMap.get(schemaName);
|
||||
for(int counter = 0; counter < schemaCriteria.size(); counter++)
|
||||
{// finding details regarding this criterion
|
||||
if(schemaCriteria.get(counter).name.equals(name))
|
||||
{
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class NotificationConstants {
|
||||
|
||||
public static final String CollectionsStatusChange = "CollectionsStatusChange";
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class QueryString extends HashMap<String, String>{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public QueryString() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void addParameter(String name, String value)
|
||||
{
|
||||
this.put(name, value);
|
||||
}
|
||||
|
||||
public void removeParameter(String name)
|
||||
{
|
||||
this.remove(name);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class SessionConstants {
|
||||
|
||||
public static final String ScenarioSchemaInfo = "ScenarioCollectionInfo";
|
||||
|
||||
public static final String SchemataInfo = "SchemataInfo";
|
||||
|
||||
public static final String MetadataSchemaInfo = "MetadataSchemaInfo";
|
||||
|
||||
public static final String Collections = "Collections";
|
||||
|
||||
public static final String Queries = "Queries";
|
||||
|
||||
public static final String Geospatial = "Geospatial";
|
||||
|
||||
public static final String CollectionsMap = "CollectionsMap";
|
||||
|
||||
public static final String page_no = "page_no";
|
||||
|
||||
public static final String resNo = "resNo";
|
||||
|
||||
public static final String page_total = "page_total";
|
||||
|
||||
public static final String lastRes = "lastRes";
|
||||
|
||||
public static final String isLast = "isLast";
|
||||
|
||||
public static final String out_of_end = "out_of_end";
|
||||
|
||||
public static final String rsClient = "rsClient";
|
||||
|
||||
public static final String theResultObjects = "theResultObjects";
|
||||
|
||||
public static final String theThumbnails = "theThumbnails";
|
||||
|
||||
public static final String startingPoint = "startingPoint";
|
||||
|
||||
public static final String sourcePortlet = "sourcePortlet";
|
||||
|
||||
public static final String rsEPR = "rsEPR";
|
||||
|
||||
public static final String showRank = "showRank";
|
||||
|
||||
public static final String searchException = "searchException";
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static Properties props = new Properties();;
|
||||
static Settings settings = null;
|
||||
|
||||
Settings()
|
||||
{
|
||||
try
|
||||
{
|
||||
props.load(Settings.class.getResourceAsStream("/etc/settings.properties"));
|
||||
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Settings getInstance()
|
||||
{
|
||||
if (settings == null)
|
||||
settings = new Settings();
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the props
|
||||
*/
|
||||
public String getProperty(String key) {
|
||||
String value = props.getProperty(key);
|
||||
if(value.contains("${"))
|
||||
{
|
||||
int start = 0;
|
||||
int i;
|
||||
while((i= value.indexOf("${", start)) != -1)
|
||||
{
|
||||
start = value.indexOf("}", i) +1;
|
||||
String reg = value.substring(i, start);
|
||||
System.out.println(reg);
|
||||
System.out.println(reg.substring(2, reg.length() -1));
|
||||
value = value.replace(reg, (System.getProperty(reg.substring(2, reg.length() -1)) != null)?System.getProperty(reg.substring(2, reg.length() -1)):"");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.xml.serialize.OutputFormat;
|
||||
import org.apache.xml.serialize.XMLSerializer;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class TransformXSLT {
|
||||
/**
|
||||
* Transforms an xml document based on the given xslt
|
||||
* @param xslt the xslt for transforming the xml
|
||||
* @param xml the xml to be transformed
|
||||
* @return a string containing the transformed xml (output of the transformation)
|
||||
*/
|
||||
public static String transform(String xslt, String xml)
|
||||
{
|
||||
Transformer transformer;
|
||||
try
|
||||
{//Retrieve the XSLT from the DIS (generic resource), and create the transformer
|
||||
ByteArrayInputStream xsltStream = new ByteArrayInputStream(xslt.getBytes());
|
||||
TransformerFactory tFactory = TransformerFactory.newInstance();
|
||||
transformer = tFactory.newTransformer(new StreamSource(xsltStream));
|
||||
|
||||
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
Document doc = null;
|
||||
|
||||
doc = dfactory.newDocumentBuilder().parse(xml);
|
||||
// Apply the transformation
|
||||
ByteArrayOutputStream ba_stream = new ByteArrayOutputStream();
|
||||
OutputFormat format = new OutputFormat(doc);
|
||||
format.setIndenting(false);
|
||||
format.setOmitDocumentType(true);
|
||||
format.setOmitXMLDeclaration(true);
|
||||
StringWriter writer = new StringWriter();
|
||||
XMLSerializer serial = new XMLSerializer(writer,format);
|
||||
serial.serialize(doc);
|
||||
transformer.transform(new StreamSource(new ByteArrayInputStream(writer.toString().getBytes())), new StreamResult(ba_stream));
|
||||
//Prepares the object to be returned
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
try {
|
||||
InputStreamReader isr = new InputStreamReader( new ByteArrayInputStream(ba_stream.toByteArray()),
|
||||
"UTF8");
|
||||
Reader in2 = new BufferedReader(isr);
|
||||
int ch;
|
||||
while ((ch = in2.read()) > -1) {
|
||||
buffer.append((char)ch);
|
||||
}
|
||||
in2.close();
|
||||
return buffer.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an xml document based on the given transformer
|
||||
* @param transformer the transformer based on which the transformation will be applied
|
||||
* @param xml the xml document to be transformed
|
||||
* @return a string containing the transformed xml (output of the transformation)
|
||||
*/
|
||||
public static String transform(Transformer transformer, String xml)
|
||||
{
|
||||
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
|
||||
Document doc = null;
|
||||
|
||||
try
|
||||
{
|
||||
doc = dfactory.newDocumentBuilder().parse(xml);
|
||||
ByteArrayOutputStream ba_stream = new ByteArrayOutputStream();
|
||||
OutputFormat format = new OutputFormat(doc);
|
||||
format.setIndenting(false);
|
||||
format.setOmitDocumentType(true);
|
||||
format.setOmitXMLDeclaration(true);
|
||||
StringWriter writer = new StringWriter();
|
||||
XMLSerializer serial = new XMLSerializer(writer,format);
|
||||
serial.serialize(doc);
|
||||
transformer.transform(new StreamSource(new ByteArrayInputStream(writer.toString().getBytes())), new StreamResult(ba_stream));
|
||||
//Prepares the object to be returned
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
try {
|
||||
InputStreamReader isr = new InputStreamReader( new ByteArrayInputStream(ba_stream.toByteArray()),
|
||||
"UTF8");
|
||||
Reader in2 = new BufferedReader(isr);
|
||||
int ch;
|
||||
while ((ch = in2.read()) > -1) {
|
||||
buffer.append((char)ch);
|
||||
}
|
||||
in2.close();
|
||||
return buffer.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package org.gcube.application.framework.core.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gcube.vomanagement.vomsClient.impl.CredentialsManagerImpl;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public class UserCredential {
|
||||
/**
|
||||
* Retrieves credential for users
|
||||
* @param username the user name for which it will retrieve credential
|
||||
* @param DLname DLname
|
||||
* @return the GSS Credential
|
||||
*/
|
||||
public static ExtendedGSSCredential getCredential(String username, String DLname)
|
||||
{
|
||||
CredentialsManagerImpl man = null;
|
||||
try {
|
||||
String sharedDir = Settings.getInstance().getProperty("sharedDir");
|
||||
System.out.println("file " + sharedDir + "/vomsAPI.properties exists: "+ new File(sharedDir + "/vomsAPI.properties").exists());
|
||||
man = new CredentialsManagerImpl(sharedDir + "/vomsAPI.properties");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
ExtendedGSSCredential cred = null;
|
||||
try {
|
||||
//TODO: put a real password there...
|
||||
cred = man.getCredentials(username, "", DLname);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cred;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.gcube.application.framework.core.vremanagement.impl.Pair;
|
||||
import org.gcube.application.framework.core.vremanagement.model.ISGenericResource;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public interface GenericResourceInfoI {
|
||||
|
||||
/**
|
||||
* @param name the name of the generic resource
|
||||
* @return a list containing the generic resources that have as name the given
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceByName(String name) throws RemoteException ;
|
||||
|
||||
/**
|
||||
* @param id the id of the generic resource
|
||||
* @return a list containing the corresponding generic resources
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceByID(String id) throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return a list containing the generic resources that describe which collections are part of the active VRE as well as their hierarchical structure (the name of this generic resource is "ScenarioCollectionInfo")
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceForScenario() throws RemoteException ;
|
||||
|
||||
/**
|
||||
* Updates a generic resource based on it's ID
|
||||
* @param genericResource the generic resource to be updated
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public void updateGenericResourceByID(ISGenericResource genericResource) throws RemoteException;
|
||||
|
||||
/**
|
||||
* Creates a new generic resource
|
||||
* @param genericResource the new generic resource
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public String createGenericResource(ISGenericResource genericResource) throws RemoteException;
|
||||
|
||||
/**
|
||||
* Reomoves an existing generic resource
|
||||
* @param genericResource the generic resource to be removed
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public void removeGenericResource(ISGenericResource genericResource) throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return a list containing pairs of (name, id) of the available generic resources
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<Pair> getAvailableGenericResourceNames() throws RemoteException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param xsltType Presentation or Metadata. The type of the xslt
|
||||
* @return A vector which contains all the generic resources, xslts of this type. The xslts are sorted by the schema.
|
||||
*/
|
||||
public HashMap<String,Vector<String[]>> getAllXslts(String xsltType);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.core.informationsystem.client.RPDocument;
|
||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||
|
||||
/**
|
||||
* @author valia
|
||||
*
|
||||
*/
|
||||
public interface ISInfoI {
|
||||
|
||||
/**
|
||||
* @param query an XQuery to be submitted on IS
|
||||
* @return a list of XMLResults that represent resources form IS (like RIs, Generic Resources, Collections, etc)
|
||||
*/
|
||||
public List<XMLResult> queryIS(String query);
|
||||
|
||||
/**
|
||||
* @param type the of the WSs to be retrieved
|
||||
* @return a list of RPDocuments
|
||||
*/
|
||||
public List<RPDocument> getWS(String type);
|
||||
|
||||
/**
|
||||
* Adds a GHN to the active VRE
|
||||
* @param url the GHN url
|
||||
*/
|
||||
public void addGHNToScope(String url);
|
||||
|
||||
/**
|
||||
* Adds a service to the active VRE
|
||||
* @param url the Running Instance url
|
||||
* @param className the name of the class where the RI will belong
|
||||
* @param name the name of teh service it provides
|
||||
*/
|
||||
public void addRIToScope(String url, String className, String name);
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public interface SoftwareRepositoryI {
|
||||
|
||||
/**
|
||||
* Stores a service archive to the software repository
|
||||
* @param serviceClass the ServiceClass name of the service archive to be stored
|
||||
* @param serviceName the service name of the service archive to be stored
|
||||
* @param serviceVersion the version of the service
|
||||
* @param URL a url to the download the service archive
|
||||
* @param description a description for the service
|
||||
* @param scopes in which scopes to store this service archive
|
||||
* @return a string
|
||||
*/
|
||||
public String store(String serviceClass, String serviceName, String serviceVersion, String URL, String description);
|
||||
|
||||
/**
|
||||
* @return a string
|
||||
*/
|
||||
public String listPending();
|
||||
|
||||
/**
|
||||
* Approves the storage of service archive (SA)
|
||||
* @param serviceID the service ID for the SA to be approved
|
||||
* @return a string
|
||||
*/
|
||||
public String approve(String serviceID);
|
||||
|
||||
/**
|
||||
* @param scope the scope for which it will list the pending requests for storing a SA
|
||||
* @param serviceID the service identifier
|
||||
* @return an Array of strings containing the pending requests
|
||||
*/
|
||||
public String[] listScopedPackages(String scope, String serviceID);
|
||||
|
||||
/**
|
||||
* @param serviceID the service identifier
|
||||
* @return an Array of Strings
|
||||
*/
|
||||
public String[] isDeployable(String serviceID);
|
||||
|
||||
/**
|
||||
* @param packageName the package name of the service archive
|
||||
* @param serviceClass the service class of the service archive
|
||||
* @param serviceName the service name of the service archive
|
||||
* @param serviceVersion the version of the service in the service archive
|
||||
* @param version the version of the service archive
|
||||
* @return a string (probably url)
|
||||
*/
|
||||
public String get(String packageName, String serviceClass, String serviceName, String serviceVersion, String version);
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a VO
|
||||
* @param vo the VO
|
||||
* @return a string
|
||||
*/
|
||||
public String delete(String vo);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.framework.core.vremanagement.impl.Pair;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
|
||||
public interface TransformationProgramI {
|
||||
|
||||
/**
|
||||
* @param id the transformation program id
|
||||
* @return the IS Resource
|
||||
*/
|
||||
public GCUBEGenericResource getTransformationProgram(String id);
|
||||
|
||||
/**
|
||||
* @param tp the transformation program to be added
|
||||
* @return the transformation program id
|
||||
*/
|
||||
public String createTransformationProgram(GCUBEGenericResource tp);
|
||||
|
||||
/**
|
||||
* Updates a transformaion program
|
||||
* @param tp the transformation program to be updated
|
||||
*/
|
||||
public void updateTransformationProgram(GCUBEGenericResource tp);
|
||||
|
||||
/**
|
||||
* Removes a transformation program
|
||||
* @param id the transformation program id
|
||||
*/
|
||||
public void removeTransformationProgram(String id);
|
||||
|
||||
/**
|
||||
* @return a list of pairs containing transformation program names-ids
|
||||
*/
|
||||
public List<Pair> getTransformationProgramNames();
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CheckedRows;
|
||||
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (NKUA)
|
||||
*
|
||||
*/
|
||||
public interface VREGeneratorI {
|
||||
|
||||
public String[] getExistingNamesVREs();
|
||||
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
//TODO: to be changed
|
||||
public String[][] checkVREStatus()
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void deployVRE() throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getCollection() throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getGHNs() throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getVREModel() throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getFunctionality()
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getMetadataRelatedToCollection()
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @return what the vVRE modeler returns
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public String getQuality() throws RemoteException;
|
||||
|
||||
/**
|
||||
* @param collections the collections to be set
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setCollection(String[] collections)
|
||||
throws RemoteException;
|
||||
|
||||
|
||||
/**
|
||||
* @param GHNElements the GHNs
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setGHNs(String[] GHNElements) throws RemoteException;
|
||||
|
||||
|
||||
/**
|
||||
* @param VREName the VRE name
|
||||
* @param VREDescription a description for the VRE
|
||||
* @param VREDesigner the VRE designer
|
||||
* @param VREManager the VRE manager
|
||||
* @param startTime start time
|
||||
* @param endTime end time
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setVREModel(String VREName, String VREDescription, String VREDesigner, String VREManager, long startTime, long endTime) throws RemoteException;
|
||||
|
||||
/**
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setVREtoPendingState()
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @param csIDElement
|
||||
* @param functionalityIDElement
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setFunctionality(String[] csIDElement, String[] functionalityIDElement)
|
||||
throws RemoteException;
|
||||
|
||||
|
||||
/**
|
||||
* @param collectionIDArray an array containing all the collection IDs
|
||||
* @param checkedArray an array containing whether with IDs are checked (probably)
|
||||
* @param mdFormatIDArray an array containing
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setMetadataRelatedToCollection(String[] collectionIDArray, boolean[][] checkedArray, String[] mdFormatIDArray)
|
||||
throws RemoteException;
|
||||
|
||||
|
||||
/**
|
||||
* @param quality the quality
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public void setQuality(String quality) throws RemoteException;
|
||||
|
||||
}
|
|
@ -1,374 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.impl;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.gcube.application.framework.core.cache.CachesManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.application.framework.core.util.CacheEntryConstants;
|
||||
import org.gcube.application.framework.core.util.QueryString;
|
||||
import org.gcube.application.framework.core.util.SessionConstants;
|
||||
import org.gcube.application.framework.core.vremanagement.GenericResourceInfoI;
|
||||
import org.gcube.application.framework.core.vremanagement.model.ISGenericResource;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.QueryParameter;
|
||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
public class GenericResource implements GenericResourceInfoI{
|
||||
|
||||
/**
|
||||
* A static is publisher in order to communicate with IS
|
||||
*/
|
||||
protected static ISPublisher publisher = null;
|
||||
protected static ISClient client = null;
|
||||
|
||||
/**
|
||||
* The D4Science session to be used
|
||||
*/
|
||||
D4ScienceSession session;
|
||||
|
||||
/**
|
||||
* Constructs a GenericReosurce object
|
||||
* @param extrenalSessionID the external session id which is used for the D4ScienceSession (usually the session.getId() of the HttpSession or PortletSession)
|
||||
* @param username the username of the user that called this constructor
|
||||
*/
|
||||
public GenericResource(String extrenalSessionID, String username)
|
||||
{
|
||||
session = SessionManager.getInstance().getD4ScienceSession(extrenalSessionID, username);
|
||||
try {
|
||||
publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(client == null)
|
||||
{
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a GenericReosurce object
|
||||
* @param session the D4Science session to be used for retrieving information needed
|
||||
*/
|
||||
public GenericResource(D4ScienceSession session) {
|
||||
super();
|
||||
this.session = session;
|
||||
try {
|
||||
publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(client == null)
|
||||
{
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the name of the active VRE
|
||||
*/
|
||||
protected String getDLName()
|
||||
{
|
||||
return session.getScopeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query the query to retrieve generic resources from cache
|
||||
* @return a list of generic resources
|
||||
*/
|
||||
protected List<ISGenericResource> getGenericResource(QueryString query)
|
||||
{
|
||||
return (List<ISGenericResource>) (CachesManager.getInstance().getGenericResourceCache().get(query).getValue());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new generic resource
|
||||
* @param genericResource the new generic resource
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public String createGenericResource(ISGenericResource genericResource)
|
||||
throws RemoteException {
|
||||
try {
|
||||
GCUBEGenericResource gCubeRes = GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
gCubeRes.setName(genericResource.getName());
|
||||
gCubeRes.setDescription(genericResource.getDescription());
|
||||
gCubeRes.setBody(genericResource.getBody());
|
||||
|
||||
String Gr = publisher.registerGCUBEResource(gCubeRes, session.getScope(), new PortalSecurityManager(session));
|
||||
Document doc = parseXMLFileToDOM(Gr);
|
||||
XPath xpath = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
return (String) xpath.evaluate("/Resource/ID/text()", doc, XPathConstants.STRING);
|
||||
} catch (XPathExpressionException e) {
|
||||
e.printStackTrace();
|
||||
throw new RemoteException();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates a generic resource based on it's ID
|
||||
* @param genericResource the generic resource to be updated
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public void updateGenericResourceByID(ISGenericResource genericResource)
|
||||
throws RemoteException {
|
||||
try {
|
||||
|
||||
GCUBEGenericResource gCubeRes = GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
gCubeRes.setID(genericResource.getId());
|
||||
gCubeRes.setName(genericResource.getName());
|
||||
gCubeRes.setDescription(genericResource.getDescription());
|
||||
gCubeRes.setBody(genericResource.getBody());
|
||||
publisher.updateGCUBEResource(gCubeRes, session.getScope(), new PortalSecurityManager(session));
|
||||
List<ISGenericResource> genRes = new ArrayList<ISGenericResource>();
|
||||
genRes.add(genericResource);
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.id, genericResource.getId());
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
CachesManager.getInstance().getGenericResourceCache().put(new net.sf.ehcache.Element(query, genRes));
|
||||
|
||||
query.clear();
|
||||
query.put(CacheEntryConstants.name, genericResource.getName().trim());
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(query) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(query))
|
||||
{
|
||||
System.out.println("\n\nObject exists!!!!!\n\n");
|
||||
CachesManager.getInstance().getGenericResourceCache().get(query).setTimeToLive(-1);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return a list containing pairs of (name, id) of the available generic resources
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<Pair> getAvailableGenericResourceNames() throws RemoteException {
|
||||
List<Pair> pairs = new ArrayList<Pair>();
|
||||
String xquery = "for $query in collection(\"/db/Profiles/GenericResource\")//Document/Data/child::*[local-name()='Profile']/Resource order by $query/Profile/Name return <Result>{$query/ID}{$query/Profile/Name}</Result>";
|
||||
GCUBEGenericQuery queryMan;
|
||||
try {
|
||||
queryMan = client.getQuery(GCUBEGenericQuery.class);
|
||||
queryMan.setExpression(xquery);
|
||||
List<XMLResult> res = client.execute(queryMan, session.getScope());
|
||||
String id, name;
|
||||
for(XMLResult xml : res)
|
||||
{
|
||||
id = xml.evaluate("//ID/text()").get(0);
|
||||
name = xml.evaluate("//Name/text()").get(0);
|
||||
System.out.println(id + " " + name);
|
||||
pairs.add(new Pair(name, id));
|
||||
}
|
||||
return pairs;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id the id of the generic resource
|
||||
* @return a list containing the corresponding generic resources
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceByID(String id)
|
||||
throws RemoteException {
|
||||
QueryString query = new QueryString();
|
||||
query.put(CacheEntryConstants.id, id);
|
||||
query.put(CacheEntryConstants.dl, getDLName());
|
||||
return getGenericResource(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param name the name of the generic resource
|
||||
* @return a list containing the generic resources that have as name the given
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceByName(String name)
|
||||
throws RemoteException {
|
||||
QueryString query = new QueryString();
|
||||
query.put(CacheEntryConstants.name, name);
|
||||
query.put(CacheEntryConstants.dl, getDLName());
|
||||
return getGenericResource(query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return a list containing the generic resources that describe which collections are part of the active VRE as well as their hierarchical structure (the name of this generic resource is "ScenarioCollectionInfo")
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public List<ISGenericResource> getGenericResourceForScenario()
|
||||
throws RemoteException {
|
||||
QueryString query = new QueryString();
|
||||
query.put(CacheEntryConstants.name, SessionConstants.ScenarioSchemaInfo);
|
||||
query.put(CacheEntryConstants.dl, getDLName());
|
||||
return getGenericResource(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an existing generic resource
|
||||
* @param genericResource the generic resource to be removed
|
||||
* @throws RemoteException when an error has occurred while communicating with IS
|
||||
*/
|
||||
public void removeGenericResource(ISGenericResource genericResource)
|
||||
throws RemoteException {
|
||||
try {
|
||||
publisher.removeGCUBEResource(genericResource.getId(), GCUBEGenericResource.TYPE, session.getScope(), new PortalSecurityManager(session));
|
||||
|
||||
QueryString query = new QueryString();
|
||||
query.addParameter(CacheEntryConstants.id, genericResource.getId());
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(query) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(query))
|
||||
{
|
||||
genericResource = ((List<ISGenericResource>)CachesManager.getInstance().getGenericResourceCache().get(query).getValue()).get(0);
|
||||
CachesManager.getInstance().getGenericResourceCache().get(query).setTimeToLive(0);
|
||||
}
|
||||
|
||||
query.clear();
|
||||
query.put(CacheEntryConstants.name, genericResource.getName());
|
||||
query.addParameter(CacheEntryConstants.dl, session.getScopeName());
|
||||
if(CachesManager.getInstance().getGenericResourceCache().isElementInMemory(query) || CachesManager.getInstance().getGenericResourceCache().isElementOnDisk(query))
|
||||
{
|
||||
CachesManager.getInstance().getGenericResourceCache().get(query).setTimeToLive(0);
|
||||
}
|
||||
} catch (ISPublisherException e) {
|
||||
e.printStackTrace();
|
||||
throw new RemoteException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the xml and returns it as DOM object
|
||||
* @param XMLdoc the xml as a string
|
||||
* @return xml parsed as a Document
|
||||
*/
|
||||
static Document parseXMLFileToDOM(String XMLdoc) {
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder;
|
||||
try {
|
||||
builder = dbFactory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new InputSource(new StringReader(XMLdoc)));
|
||||
return doc;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param xsltType Presentation or Metadata. The type of the xslt
|
||||
* @return A vector which contains all the generic resources, xslts of this type. The xslts are sorted by the schema.
|
||||
*/
|
||||
public HashMap<String,Vector<String[]>> getAllXslts(String xsltType) {
|
||||
HashMap<String,Vector<String[]>> schemas_xslts = new HashMap<String,Vector<String[]>>();
|
||||
Vector<String[]> xslts = null;
|
||||
|
||||
|
||||
List<String[]> result = null;
|
||||
try {
|
||||
result = retrieveGenericResourcesFromNameParts(xsltType, session.getScope());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i=0; i<result.size(); i++) {
|
||||
String fullName = result.get(i)[0];
|
||||
String id = result.get(i)[1];
|
||||
String tmp = fullName.substring(xsltType.length()+1,fullName.length());
|
||||
String parts[] = tmp.split("_");
|
||||
String schemaName = parts[0];
|
||||
String xsltName = parts[1];
|
||||
xslts = schemas_xslts.get(schemaName);
|
||||
if (xslts == null) {
|
||||
xslts = new Vector<String[]>();
|
||||
schemas_xslts.put(schemaName, xslts);
|
||||
}
|
||||
|
||||
// add the xslt name and id
|
||||
String s[] = new String[2];
|
||||
s[0] = xsltName;
|
||||
s[1] = id;
|
||||
xslts.add(s);
|
||||
}
|
||||
return schemas_xslts;
|
||||
}
|
||||
|
||||
private static List<String[]> retrieveGenericResourcesFromNameParts(String nameParts, GCUBEScope scope) throws Exception {
|
||||
|
||||
String condition = "contains($result/Profile/Name/string(), '" + nameParts + "')";
|
||||
|
||||
GCUBEGenericQuery query = client.getQuery("GCUBEResourceQuery");
|
||||
query.addParameters(new QueryParameter("FILTER", condition),
|
||||
new QueryParameter("TYPE", GCUBEGenericResource.TYPE),
|
||||
new QueryParameter("RESULT", "<Result>{$result/ID}{$result/Profile/Name}</Result>"));
|
||||
|
||||
List<XMLResult> result = client.execute(query, scope);
|
||||
List<String[]> ret = new LinkedList<String[]>();
|
||||
if (result==null || result.size()==0)
|
||||
throw new Exception("No generic resources were found.");
|
||||
|
||||
for(XMLResult r : result){
|
||||
String[] nameAndID = { r.evaluate("//Name/text()").get(0), r.evaluate("//ID/text()").get(0) };
|
||||
ret.add(nameAndID);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.application.framework.core.vremanagement.ISInfoI;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.RPDocument;
|
||||
import org.gcube.common.core.informationsystem.client.XMLResult;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
|
||||
import org.gcube.common.core.informationsystem.client.queries.WSResourceQuery;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
|
||||
import org.gcube.common.core.informationsystem.publisher.ISPublisherException;
|
||||
import org.gcube.common.core.resources.GCUBEExternalRunningInstance;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
||||
import org.gcube.common.core.state.GCUBEResourceHome;
|
||||
import org.gcube.common.vremanagement.ghnmanager.stubs.AddScopeInputParams;
|
||||
import org.gcube.common.vremanagement.ghnmanager.stubs.GHNManagerPortType;
|
||||
import org.gcube.common.vremanagement.ghnmanager.stubs.ScopeRIParams;
|
||||
import org.gcube.common.vremanagement.ghnmanager.stubs.service.GHNManagerServiceAddressingLocator;
|
||||
|
||||
//TODO: done!!!
|
||||
public class ISInfo implements ISInfoI {
|
||||
|
||||
/**
|
||||
* D4ScienceSession to be used
|
||||
*/
|
||||
protected D4ScienceSession session;
|
||||
/**
|
||||
* is client in order to query IS
|
||||
*/
|
||||
protected static ISClient client = null;
|
||||
|
||||
protected static ISPublisher publisher = null;
|
||||
|
||||
/**
|
||||
* Constructs a ISInfo object
|
||||
* @param session the D4Science session to be used for retrieving information needed
|
||||
*/
|
||||
public ISInfo(D4ScienceSession session)
|
||||
{
|
||||
this.session = session;
|
||||
try {
|
||||
publisher = GHNContext.getImplementation(ISPublisher.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(client == null)
|
||||
{
|
||||
try {
|
||||
client = GHNContext.getImplementation(ISClient.class);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.ISInfoI#queryIS(java.lang.String)
|
||||
*/
|
||||
public List<XMLResult> queryIS(String query) {
|
||||
try {
|
||||
GCUBEGenericQuery queryMan = client.getQuery(GCUBEGenericQuery.class);
|
||||
|
||||
queryMan.setExpression(query);
|
||||
System.out.println(session.getScopeName());
|
||||
return client.execute(queryMan, session.getScope());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ArrayList<XMLResult>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.ISInfoI#getWS(java.lang.String)
|
||||
*/
|
||||
public List<RPDocument> getWS(String type)
|
||||
{
|
||||
WSResourceQuery query = null;
|
||||
try {
|
||||
query = client.getQuery(WSResourceQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("/gc:ServiceClass", type));
|
||||
return client.execute(query, session.getScope());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ArrayList<RPDocument>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.ISInfoI#addGHNToScope(java.lang.String)
|
||||
*/
|
||||
public void addGHNToScope(String url) {
|
||||
//TODO: this will probably change...
|
||||
GCUBESecurityManagerImpl managerSec = new PortalSecurityManager(session);
|
||||
|
||||
EndpointReferenceType endpoint = new EndpointReferenceType();
|
||||
try {
|
||||
endpoint.setAddress(new Address(url));
|
||||
GHNManagerServiceAddressingLocator locator = new GHNManagerServiceAddressingLocator();
|
||||
GHNManagerPortType pt = GCUBERemotePortTypeContext.getProxy(locator.getGHNManagerPortTypePort(endpoint),
|
||||
session.getScope(),managerSec);
|
||||
AddScopeInputParams params = new AddScopeInputParams();
|
||||
params.setScope(session.getScopeName());
|
||||
params.setMap(""); //eventually, set here the new Service Map
|
||||
pt.addScope(params);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeGHNToScope(String url) {
|
||||
//TODO: this will probably change...
|
||||
GCUBESecurityManagerImpl managerSec = new PortalSecurityManager(session);
|
||||
|
||||
EndpointReferenceType endpoint = new EndpointReferenceType();
|
||||
try {
|
||||
endpoint.setAddress(new Address(url));
|
||||
GHNManagerServiceAddressingLocator locator = new GHNManagerServiceAddressingLocator();
|
||||
GHNManagerPortType pt = GCUBERemotePortTypeContext.getProxy(locator.getGHNManagerPortTypePort(endpoint),
|
||||
session.getScope(),managerSec);
|
||||
pt.removeScope(session.getScopeName());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.ISInfoI#addRIToScope(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addRIToScope(String url, String className, String name) {
|
||||
//TODO: this will probably change...
|
||||
GCUBESecurityManagerImpl managerSec = new PortalSecurityManager(session);
|
||||
|
||||
EndpointReferenceType endpoint = new EndpointReferenceType();
|
||||
try {
|
||||
endpoint.setAddress(new Address(url));
|
||||
GHNManagerServiceAddressingLocator locator = new GHNManagerServiceAddressingLocator();
|
||||
GHNManagerPortType pt = GCUBERemotePortTypeContext.getProxy(locator.getGHNManagerPortTypePort(endpoint),
|
||||
session.getScope(), managerSec);
|
||||
ScopeRIParams params = new ScopeRIParams();
|
||||
params.setClazz(className);
|
||||
params.setName(name);
|
||||
params.setScope(session.getScopeName());
|
||||
pt.addRIToScope(params);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addExternalRIToVRE(File file)
|
||||
{
|
||||
GCUBEExternalRunningInstance ri = null;
|
||||
try {
|
||||
ri = GHNContext.getImplementation(GCUBEExternalRunningInstance.class);
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
String ret = "";
|
||||
if(file.exists()){
|
||||
try {
|
||||
ri.load(new FileReader(file));
|
||||
} catch (Exception e) {
|
||||
String message = "Error while loading profile for the External Running Instance with id=" + ri.getID() + "\n";
|
||||
System.out.println(message);
|
||||
e.printStackTrace();
|
||||
ret += message;
|
||||
}
|
||||
}else{
|
||||
String message = "An error occur during the approval of the External Running Instance with id=" + ri.getID() + "\n";
|
||||
System.out.println(message);
|
||||
ret += message;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
// TODO Change this
|
||||
|
||||
publisher.registerGCUBEResource(ri, session.getScope(), new PortalSecurityManager(session));
|
||||
} catch (ISPublisherException e) {
|
||||
String message = "Registration error for the External Running Instance with id=" + ri.getID() + "\n";
|
||||
System.out.println(message);
|
||||
e.printStackTrace();
|
||||
ret += message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void removeExternalRIToVRE(String id)
|
||||
{
|
||||
try {
|
||||
// TODO Change this
|
||||
|
||||
publisher.removeGCUBEResource(id, GCUBEExternalRunningInstance.TYPE, session.getScope(), new PortalSecurityManager(session));
|
||||
} catch (ISPublisherException e) {
|
||||
String message = "Registration error for the External Running Instance with id=" +id + "\n";
|
||||
System.out.println(message);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.impl;
|
||||
|
||||
public class Pair {
|
||||
protected String name;
|
||||
protected String value;
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Pair(String name, String value) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.impl;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.application.framework.core.vremanagement.SoftwareRepositoryI;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
import org.gcube.common.core.security.GCUBESecurityManager;
|
||||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.UserProfileAccessFactoryPortType;
|
||||
import org.gcube.personalization.userprofileaccess.stubs.service.UserProfileAccessFactoryServiceAddressingLocator;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.GetMessage;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.ListScopedPackagesMessage;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.ListScopedPackagesMessageScope;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.SoftwareRepositoryPortType;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.Store;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.StoreItem;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.service.SoftwareRepositoryServiceAddressingLocator;
|
||||
|
||||
import com.sun.org.omg.SendingContext.CodeBasePackage.URLSeqHelper;
|
||||
|
||||
/**
|
||||
* @author Valia Tsagkalidou (KNUA)
|
||||
*
|
||||
*/
|
||||
public class SoftwareRepository implements SoftwareRepositoryI{
|
||||
|
||||
/**
|
||||
* the D4Science Session to use
|
||||
*/
|
||||
protected D4ScienceSession session;
|
||||
|
||||
|
||||
/**
|
||||
* An atomic integer to get the Profile EPRs round-robin
|
||||
*/
|
||||
protected static AtomicInteger srId = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* @param session the D4Science Session to use
|
||||
*/
|
||||
public SoftwareRepository(D4ScienceSession session) {
|
||||
super();
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
protected int getSRUrlsSize()
|
||||
{
|
||||
try {
|
||||
return HarvestersManager.getInstance().getISInfo(session.getScope()).getEndPointForSoftwareRepositoryService().length;
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected SoftwareRepositoryPortType getSRPortType()
|
||||
{
|
||||
String[] urls = null;
|
||||
try {
|
||||
urls = HarvestersManager.getInstance().getISInfo(session.getScope()).getEndPointForSoftwareRepositoryService();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
SoftwareRepositoryPortType srPort = null;
|
||||
|
||||
try
|
||||
{
|
||||
serviceEPR.setAddress(new Address(urls[srId.getAndIncrement()%urls.length]));
|
||||
SoftwareRepositoryServiceAddressingLocator srLocator = new SoftwareRepositoryServiceAddressingLocator();
|
||||
srPort = srLocator.getSoftwareRepositoryPortTypePort(serviceEPR);
|
||||
|
||||
GCUBESecurityManager secManager = new PortalSecurityManager(session);
|
||||
if(secManager.isSecurityEnabled())
|
||||
{
|
||||
try {
|
||||
secManager.useCredentials(session.getCredential());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
srPort = GCUBERemotePortTypeContext.getProxy(srPort, session.getScope(), secManager);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return srPort;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public String store(String serviceClass, String serviceName,
|
||||
String serviceVersion, String URL, String description) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
Store storeMsg = new Store();
|
||||
StoreItem[] storeMessage = new StoreItem[1];
|
||||
storeMessage[0].setDescription(description);
|
||||
storeMessage[0].setScopes(scopes);
|
||||
storeMessage[0].setServiceClass(serviceClass);
|
||||
storeMessage[0].setServiceName(serviceName);
|
||||
storeMessage[0].setServiceVersion(serviceVersion);
|
||||
storeMsg.setStoreMessage(storeMessage);
|
||||
try {
|
||||
return srPort.store(storeMsg);
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public String listPending() {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
try {
|
||||
return srPort.listPending(new VOID());
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.SoftwareRepositoryI#approve(java.lang.String)
|
||||
*/
|
||||
public String approve(String id) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
try {
|
||||
return srPort.approve(id);
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.SoftwareRepositoryI#listScopedPackages(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public String[] listScopedPackages(String scope, String serviceID) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
ListScopedPackagesMessage scopePacks = new ListScopedPackagesMessage();
|
||||
scopePacks.setScope(ListScopedPackagesMessageScope.fromString(scope));
|
||||
scopePacks.setServiceID(serviceID);
|
||||
try {
|
||||
srPort.listScopedPackages(scopePacks);
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.SoftwareRepositoryI#isDeployable(java.lang.String)
|
||||
*/
|
||||
public String[] isDeployable(String serviceID) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
try {
|
||||
srPort.isDeployable(serviceID);
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.SoftwareRepositoryI#get(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public String get(String packageName, String serviceClass,
|
||||
String serviceName, String serviceVersion, String version) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
try {
|
||||
GetMessage getMsg = new GetMessage();
|
||||
getMsg.setPackageName(packageName);
|
||||
getMsg.setServiceClass(serviceClass);
|
||||
getMsg.setServiceName(serviceName);
|
||||
getMsg.setServiceVersion(serviceVersion);
|
||||
getMsg.setVersion(version);
|
||||
srPort.get(getMsg );
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.application.framework.SoftwareRepositoryI#delete(java.lang.String)
|
||||
*/
|
||||
public String delete(String vo) {
|
||||
int n = getSRUrlsSize();
|
||||
for(int i=0; i < n ; i++)
|
||||
{
|
||||
SoftwareRepositoryPortType srPort = getSRPortType();
|
||||
String[] scopes = new String[1];
|
||||
scopes[0] = session.getScopeName();
|
||||
try {
|
||||
return srPort.delete(vo);
|
||||
} catch (GCUBEFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,392 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.impl;
|
||||
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.gcube.application.framework.core.cache.HarvestersManager;
|
||||
import org.gcube.application.framework.core.security.PortalSecurityManager;
|
||||
import org.gcube.application.framework.core.session.D4ScienceSession;
|
||||
import org.gcube.application.framework.core.vremanagement.VREGeneratorI;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
||||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.searchservice.searchlibrary.isharvester.ISInfo;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CheckedRows;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.DHNArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.VdlRequest;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator;
|
||||
import org.globus.wsrf.encoding.ObjectDeserializer;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.xml.rpc.ServiceException;
|
||||
|
||||
public class VREGenerator implements VREGeneratorI {
|
||||
|
||||
D4ScienceSession session;
|
||||
ModelerServicePortType modelPortType;
|
||||
GCUBESecurityManagerImpl managerSec;
|
||||
|
||||
protected static AtomicInteger vreId = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
* @param session
|
||||
* @param epr
|
||||
*/
|
||||
public VREGenerator(D4ScienceSession session, String epr) {
|
||||
super();
|
||||
this.session = session;
|
||||
modelPortType = deserializeEPR(epr);
|
||||
managerSec = new PortalSecurityManager(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param session
|
||||
*/
|
||||
public VREGenerator(D4ScienceSession session) {
|
||||
super();
|
||||
this.session = session;
|
||||
managerSec = new PortalSecurityManager(session);
|
||||
modelPortType = null;
|
||||
}
|
||||
|
||||
ModelerServicePortType deserializeEPR(String epr) {
|
||||
StringReader stringReader = new StringReader(epr);
|
||||
InputSource inputSource = new InputSource(stringReader);
|
||||
EndpointReferenceType endpointReferenceType = null;
|
||||
try {
|
||||
endpointReferenceType = (EndpointReferenceType) ObjectDeserializer
|
||||
.deserialize(inputSource, EndpointReferenceType.class);
|
||||
|
||||
ModelerServiceAddressingLocator mSALocator = new ModelerServiceAddressingLocator();
|
||||
modelPortType = GCUBERemotePortTypeContext.getProxy(mSALocator
|
||||
.getModelerServicePortTypePort(endpointReferenceType),
|
||||
session.getScope(), managerSec);
|
||||
return modelPortType;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getAllVREs(D4ScienceSession session) {
|
||||
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
|
||||
session.getScope());
|
||||
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
ModelerFactoryPortType mFPType = null;
|
||||
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
|
||||
PortalSecurityManager manager = new PortalSecurityManager(session);
|
||||
String[] modelerURIs;
|
||||
try {
|
||||
modelerURIs = disInfo.getEndPointForVREModelerService();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
for (int i = 0; i < modelerURIs.length; i++) {
|
||||
try {
|
||||
System.out.println("getModelFactoryPortTypePort(epr)");
|
||||
|
||||
serviceEPR.setAddress(new Address(modelerURIs[vreId
|
||||
.getAndIncrement()
|
||||
% modelerURIs.length]));
|
||||
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
|
||||
.getModelerFactoryPortTypePort(serviceEPR), session
|
||||
.getScope(), manager);
|
||||
return mFPType.getAllDLs(new VOID());
|
||||
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void removeVRE(D4ScienceSession session, String id) {
|
||||
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
|
||||
session.getScope());
|
||||
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
ModelerFactoryPortType mFPType = null;
|
||||
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
|
||||
PortalSecurityManager manager = new PortalSecurityManager(session);
|
||||
String[] modelerURIs;
|
||||
try {
|
||||
modelerURIs = disInfo.getEndPointForVREModelerService();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < modelerURIs.length; i++) {
|
||||
try {
|
||||
System.out.println("getModelFactoryPortTypePort(epr)");
|
||||
|
||||
serviceEPR.setAddress(new Address(modelerURIs[vreId
|
||||
.getAndIncrement()
|
||||
% modelerURIs.length]));
|
||||
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
|
||||
.getModelerFactoryPortTypePort(serviceEPR), session
|
||||
.getScope(), manager);
|
||||
mFPType.removeDL(id);
|
||||
break;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#checkVREStatus()
|
||||
*/
|
||||
public String[][] checkVREStatus() throws RemoteException {
|
||||
// TODO pou vrisketai auti i sunartisi sta stubs?????
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#deployVRE()
|
||||
*/
|
||||
public void deployVRE() throws RemoteException {
|
||||
modelPortType.deployDL(new VOID());
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#getCollection()
|
||||
*/
|
||||
public String getCollection() throws RemoteException {
|
||||
return modelPortType.getCollection(new VOID());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#getGHNs()
|
||||
*/
|
||||
public String getGHNs() throws RemoteException {
|
||||
return modelPortType.getDHNs(new VOID());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#getVREModel()
|
||||
*/
|
||||
public String getVREModel() throws RemoteException {
|
||||
modelPortType.getDLModel(new VOID());
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#getExistingNamesVREs()
|
||||
*/
|
||||
public String[] getExistingNamesVREs() {
|
||||
// return getModelPortType().get(new VOID());
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#getFunctionality()
|
||||
*/
|
||||
public String getFunctionality() throws RemoteException {
|
||||
return modelPortType.getFunctionality(new VOID());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#getMetadataRelatedToCollection
|
||||
* ()
|
||||
*/
|
||||
public String getMetadataRelatedToCollection() throws RemoteException {
|
||||
return modelPortType.getMetadataRelatedToCollection(new VOID());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.application.framework.VVREGeneratorI#getQuality()
|
||||
*/
|
||||
public String getQuality() throws RemoteException {
|
||||
return modelPortType.getQuality(new VOID());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#setCollection(java.lang
|
||||
* .String[])
|
||||
*/
|
||||
public void setCollection(String[] collections) throws RemoteException {
|
||||
modelPortType.setCollection(new CollectionArray(collections));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#setGHNs(java.lang.String
|
||||
* [])
|
||||
*/
|
||||
public void setGHNs(String[] GHNElements) throws RemoteException {
|
||||
modelPortType.setDHNs(new DHNArray(GHNElements));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#setVREModel(java.lang.
|
||||
* String, java.lang.String, java.lang.String, java.lang.String, long, long)
|
||||
*/
|
||||
public void setVREModel(String VREName, String VREDescription,
|
||||
String VREDesigner, String VREManager, long startTime, long endTime)
|
||||
throws RemoteException {
|
||||
VdlRequest vdlReq = new VdlRequest();
|
||||
vdlReq.setDLDescription(VREDescription);
|
||||
vdlReq.setDLDesigner(VREDesigner);
|
||||
vdlReq.setDLManager(VREManager);
|
||||
vdlReq.setDLName(VREName);
|
||||
vdlReq.setStartTime(startTime);
|
||||
vdlReq.setEndTime(endTime);
|
||||
modelPortType.setDLModel(vdlReq);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.gcube.application.framework.VVREGeneratorI#setVREtoPendingState()
|
||||
*/
|
||||
public void setVREtoPendingState() throws RemoteException {
|
||||
modelPortType.setDLtoPendingState(new VOID());
|
||||
}
|
||||
|
||||
public void setFunctionality(String[] csIDElement,
|
||||
String[] functionalityIDElement) throws RemoteException {
|
||||
FunctionalityIDArray functArray = new FunctionalityIDArray();
|
||||
functArray.setCsIDElement(csIDElement);
|
||||
functArray.setFunctionalityIDElement(functionalityIDElement);
|
||||
modelPortType.setFunctionality(functArray);
|
||||
}
|
||||
|
||||
public void setMetadataRelatedToCollection(String[] collectionIDArray,
|
||||
boolean[][] checkedArray, String[] mdFormatIDArray)
|
||||
throws RemoteException {
|
||||
SetMDFormatArgs mdFormat = new SetMDFormatArgs();
|
||||
int numRows = checkedArray.length;
|
||||
CheckedRows[] checkedRows = new CheckedRows[numRows];
|
||||
|
||||
for (int i = 0; i < numRows; i++) {
|
||||
CheckedRows row = new CheckedRows(checkedArray[i]);
|
||||
checkedRows[i] = row;
|
||||
}
|
||||
mdFormat.setCheckedArray(checkedRows);
|
||||
mdFormat.setCollectionIDArray(collectionIDArray);
|
||||
mdFormat.setMdFormatIDArray(mdFormatIDArray);
|
||||
modelPortType.setMetadataRelatedToCollection(mdFormat);
|
||||
}
|
||||
|
||||
public void setQuality(String quality) throws RemoteException {
|
||||
modelPortType.setQuality(quality);
|
||||
}
|
||||
|
||||
private void getModelPortType() {
|
||||
System.out.println("--- Get ModelPortType ---");
|
||||
|
||||
ISInfo disInfo = HarvestersManager.getInstance().getISInfo(
|
||||
session.getScope());
|
||||
|
||||
EndpointReferenceType serviceEPR = new EndpointReferenceType();
|
||||
ModelerFactoryPortType mFPType = null;
|
||||
|
||||
EndpointReferenceType VREEndpointReferenceType;
|
||||
if (modelPortType == null) {
|
||||
|
||||
System.out.println("VREEndpointReferenceType==null");
|
||||
ModelerFactoryServiceAddressingLocator mFSLocator = new ModelerFactoryServiceAddressingLocator();
|
||||
|
||||
String[] modelerURIs;
|
||||
try {
|
||||
modelerURIs = disInfo.getEndPointForVREModelerService();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < modelerURIs.length; i++) {
|
||||
try {
|
||||
System.out.println("getModelFactoryPortTypePort(epr)");
|
||||
|
||||
serviceEPR.setAddress(new Address(modelerURIs[vreId
|
||||
.getAndIncrement()
|
||||
% modelerURIs.length]));
|
||||
mFPType = GCUBERemotePortTypeContext.getProxy(mFSLocator
|
||||
.getModelerFactoryPortTypePort(serviceEPR), session
|
||||
.getScope(), managerSec);
|
||||
VREEndpointReferenceType = mFPType
|
||||
.createResource(new VOID());
|
||||
mFPType.getAllDLs(new VOID());
|
||||
ModelerServiceAddressingLocator mSALocator = new ModelerServiceAddressingLocator();
|
||||
modelPortType = GCUBERemotePortTypeContext
|
||||
.getProxy(
|
||||
mSALocator
|
||||
.getModelerServicePortTypePort(VREEndpointReferenceType),
|
||||
session.getScope(), managerSec);
|
||||
// Attaching Credential to port type
|
||||
System.out.println("Attaching Credential to port type");
|
||||
break;
|
||||
} catch (ServiceException e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("modelPortType!=null");
|
||||
System.out.println(modelPortType.toString());
|
||||
}
|
||||
|
||||
System.out.println("--- Get ModelPortType done ---");
|
||||
}
|
||||
|
||||
public String getDLepr() {
|
||||
return modelPortType.toString();
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package org.gcube.application.framework.core.vremanagement.model;
|
||||
|
||||
public class ISGenericResource {
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String body;
|
||||
|
||||
|
||||
public ISGenericResource() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public ISGenericResource(String id, String name, String description,
|
||||
String body) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
/**
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
/**
|
||||
* @param body the body to set
|
||||
*/
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue