copied from private svn
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@164746 82a268e6-3cf1-43bd-a215-b396298e98cfmaster
commit
0172ad559f
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ws-synchronized-module-library</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="ws-synchronized-module-library">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/test/java"/>
|
||||
<property name="java-output-path" value="/ws-synchronized-module-library/target/classes"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.appclient" version="6.0"/>
|
||||
</faceted-project>
|
@ -0,0 +1,2 @@
|
||||
disabled=06target
|
||||
eclipse.preferences.version=1
|
@ -0,0 +1 @@
|
||||
${gcube.license}
|
@ -0,0 +1,60 @@
|
||||
The gCube System - ${name}
|
||||
--------------------------------------------------
|
||||
|
||||
${description}
|
||||
|
||||
|
||||
${gcube.description}
|
||||
|
||||
${gcube.funding}
|
||||
|
||||
|
||||
Version
|
||||
--------------------------------------------------
|
||||
|
||||
${version} (${buildDate})
|
||||
|
||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||
|
||||
|
||||
Authors
|
||||
--------------------------------------------------
|
||||
|
||||
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
Download information
|
||||
--------------------------------------------------
|
||||
|
||||
Source code is available from SVN:
|
||||
${scm.url}
|
||||
|
||||
Binaries can be downloaded from the gCube website:
|
||||
${gcube.website}
|
||||
|
||||
|
||||
Installation
|
||||
--------------------------------------------------
|
||||
|
||||
|
||||
Documentation
|
||||
--------------------------------------------------
|
||||
|
||||
Documentation is available on-line in the gCube Wiki:
|
||||
${gcube.wikiRoot}
|
||||
|
||||
Support
|
||||
--------------------------------------------------
|
||||
|
||||
Bugs and support requests can be reported in the gCube issue tracking tool:
|
||||
${gcube.issueTracking}
|
||||
|
||||
|
||||
Licensing
|
||||
--------------------------------------------------
|
||||
|
||||
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
@ -0,0 +1,6 @@
|
||||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portal.ws-synchronized-module-library.0-0-"
|
||||
date="2018-02-14">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
@ -0,0 +1,32 @@
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<baseDirectory>/</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README</include>
|
||||
<include>LICENSE</include>
|
||||
<include>changelog.xml</include>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/${build.finalName}.${project.packaging}</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
|
||||
</files>
|
||||
</assembly>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID></ID>
|
||||
<Type>Library</Type>
|
||||
<Profile>
|
||||
<Description>${description}</Description>
|
||||
<Class>PortalLbrary</Class>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>${artifactId}</Name>
|
||||
<Version>${version}</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>${groupId}</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<version>${version}</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>${build.finalName}.jar</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>ws-synchronized-module-library</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ws-synchronized-module-library</name>
|
||||
|
||||
<description>
|
||||
ws-synchronized-module-library is used to get synchronized item of gCube Workspace from several repository
|
||||
</description>
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.spatial-data</groupId>
|
||||
<artifactId>ws-thredds</artifactId>
|
||||
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- FWS -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- END FWS -->
|
||||
|
||||
<!-- HOME LIBRARY -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGER -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<finalName>${artifactId}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>servicearchive</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portal.wssynclibrary;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface DoCheckSyncItem.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 8, 2018
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public interface DoCheckSyncItem<T> {
|
||||
|
||||
|
||||
/**
|
||||
* Check item synched.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the t
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
T checkItemSynched(String itemId) throws ItemNotSynched, Exception;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.gcube.portal.wssynclibrary;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface DoConnectRepository.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
*/
|
||||
public interface DoConnectRepository {
|
||||
|
||||
/**
|
||||
* Inits the repository.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
Boolean initRepository();
|
||||
|
||||
/**
|
||||
* Shutdown repository.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
Boolean shutDownRepository();
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package org.gcube.portal.wssynclibrary;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface DoSyncItem.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
* @param <O> the generic type
|
||||
*/
|
||||
public interface DoSyncItem<O> {
|
||||
|
||||
/**
|
||||
* Do sync.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the t
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
O doSync(String itemId) throws ItemNotSynched, Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the sync status.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the sync status
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
O monitorSyncStatus(String itemId) throws ItemNotSynched, Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the sync.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return true, if successful
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
Boolean removeSync(String itemId) throws ItemNotSynched, Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Stop sync.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return true, if successful
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
Boolean stopSync(String itemId) throws ItemNotSynched, Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Register callback for id.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
void registerCallbackForId(String itemId) throws Exception;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='wssynclibrary'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
@ -0,0 +1,32 @@
|
||||
package org.gcube.portal.wssynclibrary.shared;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ItemNotSynched.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 8, 2018
|
||||
*/
|
||||
public class ItemNotSynched extends Exception {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = 3965350221961538838L;
|
||||
|
||||
/**
|
||||
* Instantiates a new item not synched.
|
||||
*/
|
||||
public ItemNotSynched() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new item not synched.
|
||||
*
|
||||
* @param arg0 the arg 0
|
||||
*/
|
||||
public ItemNotSynched(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Enum Status.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 16, 2018
|
||||
*/
|
||||
public enum Status implements Serializable{
|
||||
INITIALIZING("INITIALIZING"), // initial status
|
||||
ONGOING("ONGOING"), // synch in progress
|
||||
WARNINGS("WARNINGS"), // errors occurred
|
||||
STOPPED("STOPPED"), // STOP received, waiting for request to finish
|
||||
COMPLETED("COMPLETED");
|
||||
|
||||
/**
|
||||
* Instantiates a new status.
|
||||
*/
|
||||
Status(){}
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new status.
|
||||
*
|
||||
* @param label the label
|
||||
*/
|
||||
Status(String label){
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Enum Sync_Status.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 20, 2018
|
||||
*/
|
||||
public enum Sync_Status implements Serializable {
|
||||
|
||||
UP_TO_DATE("No need to sync"),
|
||||
OUTDATED_WS("Workspace version is obsolete, need to sync"),
|
||||
OUTDATED_REMOTE("Remote version is obsolete, need to sync");
|
||||
|
||||
String decription;
|
||||
|
||||
/**
|
||||
* Instantiates a new sync status.
|
||||
*/
|
||||
private Sync_Status() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sync status.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
Sync_Status(String description){
|
||||
this.decription = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the decription.
|
||||
*
|
||||
* @return the decription
|
||||
*/
|
||||
public String getDecription() {
|
||||
return decription;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ThProcessDescriptor.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 8, 2018
|
||||
*/
|
||||
public class ThProcessDescriptor implements Serializable{
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -3357273914885205346L;
|
||||
|
||||
/** The folder id. */
|
||||
private String folderId;
|
||||
|
||||
/** The folder path. */
|
||||
private String folderPath;
|
||||
|
||||
/** The launch time. */
|
||||
private long launchTime;
|
||||
|
||||
/** The process id. */
|
||||
private String processId;
|
||||
|
||||
/** The synch configuration. */
|
||||
private ThSynchFolderConfiguration synchConfiguration;
|
||||
|
||||
|
||||
public ThProcessDescriptor() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public ThProcessDescriptor(String folderId, String folderPath, long launchTime, String processId,
|
||||
ThSynchFolderConfiguration synchConfiguration) {
|
||||
super();
|
||||
this.folderId = folderId;
|
||||
this.folderPath = folderPath;
|
||||
this.launchTime = launchTime;
|
||||
this.processId = processId;
|
||||
this.synchConfiguration = synchConfiguration;
|
||||
}
|
||||
|
||||
|
||||
public String getFolderId() {
|
||||
return folderId;
|
||||
}
|
||||
|
||||
|
||||
public void setFolderId(String folderId) {
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
|
||||
public String getFolderPath() {
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
|
||||
public void setFolderPath(String folderPath) {
|
||||
this.folderPath = folderPath;
|
||||
}
|
||||
|
||||
|
||||
public long getLaunchTime() {
|
||||
return launchTime;
|
||||
}
|
||||
|
||||
|
||||
public void setLaunchTime(long launchTime) {
|
||||
this.launchTime = launchTime;
|
||||
}
|
||||
|
||||
|
||||
public String getProcessId() {
|
||||
return processId;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessId(String processId) {
|
||||
this.processId = processId;
|
||||
}
|
||||
|
||||
|
||||
public ThSynchFolderConfiguration getSynchConfiguration() {
|
||||
return synchConfiguration;
|
||||
}
|
||||
|
||||
|
||||
public void setSynchConfiguration(ThSynchFolderConfiguration synchConfiguration) {
|
||||
this.synchConfiguration = synchConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ThProcessDescriptor [folderId=");
|
||||
builder.append(folderId);
|
||||
builder.append(", folderPath=");
|
||||
builder.append(folderPath);
|
||||
builder.append(", launchTime=");
|
||||
builder.append(launchTime);
|
||||
builder.append(", processId=");
|
||||
builder.append(processId);
|
||||
builder.append(", synchConfiguration=");
|
||||
builder.append(synchConfiguration);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class ThProcessStatus implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -432977518148737956L;
|
||||
private Long queuedTransfers;
|
||||
private Long servedTransfers;
|
||||
private Long errorCount;
|
||||
private Status status;
|
||||
|
||||
private float percentCompleted = 0;
|
||||
|
||||
private String logBuilder;
|
||||
|
||||
private String currentMessage="Waiting to start..";
|
||||
|
||||
public ThProcessStatus() {
|
||||
}
|
||||
|
||||
public ThProcessStatus(Long queuedTransfers, Long servedTransfers, Long errorCount, Status status,
|
||||
String log, String currentMessage, float percentCompleted) {
|
||||
super();
|
||||
this.queuedTransfers = queuedTransfers;
|
||||
this.servedTransfers = servedTransfers;
|
||||
this.errorCount = errorCount;
|
||||
this.status = status;
|
||||
this.logBuilder = log;
|
||||
this.currentMessage = currentMessage;
|
||||
this.percentCompleted = percentCompleted;
|
||||
}
|
||||
|
||||
public Long getQueuedTransfers() {
|
||||
return queuedTransfers;
|
||||
}
|
||||
|
||||
public void setQueuedTransfers(Long queuedTransfers) {
|
||||
this.queuedTransfers = queuedTransfers;
|
||||
}
|
||||
|
||||
public Long getServedTransfers() {
|
||||
return servedTransfers;
|
||||
}
|
||||
|
||||
public void setServedTransfers(Long servedTransfers) {
|
||||
this.servedTransfers = servedTransfers;
|
||||
}
|
||||
|
||||
public Long getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
public void setErrorCount(Long errorCount) {
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getLogBuilder() {
|
||||
return logBuilder;
|
||||
}
|
||||
|
||||
public void setLogBuilder(String logBuilder) {
|
||||
this.logBuilder = logBuilder;
|
||||
}
|
||||
|
||||
public String getCurrentMessage() {
|
||||
return currentMessage;
|
||||
}
|
||||
|
||||
public void setCurrentMessage(String currentMessage) {
|
||||
this.currentMessage = currentMessage;
|
||||
}
|
||||
|
||||
public float getPercentCompleted() {
|
||||
return percentCompleted;
|
||||
}
|
||||
|
||||
public void setPercentCompleted(float percentCompleted) {
|
||||
this.percentCompleted = percentCompleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ThProcessStatus [queuedTransfers=");
|
||||
builder.append(queuedTransfers);
|
||||
builder.append(", servedTransfers=");
|
||||
builder.append(servedTransfers);
|
||||
builder.append(", errorCount=");
|
||||
builder.append(errorCount);
|
||||
builder.append(", status=");
|
||||
builder.append(status);
|
||||
builder.append(", percentCompleted=");
|
||||
builder.append(percentCompleted);
|
||||
builder.append(", logBuilder=");
|
||||
builder.append(logBuilder);
|
||||
builder.append(", currentMessage=");
|
||||
builder.append(currentMessage);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,176 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The Class ThSyncFolderDescriptor.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 8, 2018
|
||||
*/
|
||||
public class ThSyncFolderDescriptor implements Serializable{
|
||||
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = 4134777763175272691L;
|
||||
|
||||
/** The folder id. */
|
||||
private String folderId;
|
||||
|
||||
/** The folder path. */
|
||||
private String folderPath;
|
||||
|
||||
/** The configuration. */
|
||||
private ThSynchFolderConfiguration configuration;
|
||||
|
||||
/** The is locked. */
|
||||
private boolean isLocked=false;
|
||||
|
||||
|
||||
/** The local process descriptor. */
|
||||
private ThProcessDescriptor localProcessDescriptor=null;
|
||||
|
||||
/**
|
||||
* Instantiates a new s sync folder descriptor.
|
||||
*/
|
||||
public ThSyncFolderDescriptor() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new s sync folder descriptor.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param folderPath the folder path
|
||||
* @param configuration the configuration
|
||||
* @param isLocked the is locked
|
||||
* @param localProcessDescriptor the local process descriptor
|
||||
*/
|
||||
public ThSyncFolderDescriptor(String folderId, String folderPath, ThSynchFolderConfiguration configuration,
|
||||
boolean isLocked, ThProcessDescriptor localProcessDescriptor) {
|
||||
super();
|
||||
this.folderId = folderId;
|
||||
this.folderPath = folderPath;
|
||||
this.configuration = configuration;
|
||||
this.isLocked = isLocked;
|
||||
this.localProcessDescriptor = localProcessDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folder id.
|
||||
*
|
||||
* @return the folder id
|
||||
*/
|
||||
public String getFolderId() {
|
||||
return folderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the folder id.
|
||||
*
|
||||
* @param folderId the new folder id
|
||||
*/
|
||||
public void setFolderId(String folderId) {
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folder path.
|
||||
*
|
||||
* @return the folder path
|
||||
*/
|
||||
public String getFolderPath() {
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the folder path.
|
||||
*
|
||||
* @param folderPath the new folder path
|
||||
*/
|
||||
public void setFolderPath(String folderPath) {
|
||||
this.folderPath = folderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
public ThSynchFolderConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration.
|
||||
*
|
||||
* @param configuration the new configuration
|
||||
*/
|
||||
public void setConfiguration(ThSynchFolderConfiguration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is locked.
|
||||
*
|
||||
* @return true, if is locked
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locked.
|
||||
*
|
||||
* @param isLocked the new locked
|
||||
*/
|
||||
public void setLocked(boolean isLocked) {
|
||||
this.isLocked = isLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local process descriptor.
|
||||
*
|
||||
* @return the local process descriptor
|
||||
*/
|
||||
public ThProcessDescriptor getLocalProcessDescriptor() {
|
||||
return localProcessDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the local process descriptor.
|
||||
*
|
||||
* @param localProcessDescriptor the new local process descriptor
|
||||
*/
|
||||
public void setLocalProcessDescriptor(ThProcessDescriptor localProcessDescriptor) {
|
||||
this.localProcessDescriptor = localProcessDescriptor;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ThSyncFolderDescriptor [folderId=");
|
||||
builder.append(folderId);
|
||||
builder.append(", folderPath=");
|
||||
builder.append(folderPath);
|
||||
builder.append(", configuration=");
|
||||
builder.append(configuration);
|
||||
builder.append(", isLocked=");
|
||||
builder.append(isLocked);
|
||||
builder.append(", localProcessDescriptor=");
|
||||
builder.append(localProcessDescriptor);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ThSyncStatus.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
*/
|
||||
public class ThSyncStatus implements Serializable{
|
||||
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -5071064482243232229L;
|
||||
|
||||
/** The descriptor. */
|
||||
private ThProcessDescriptor descriptor;
|
||||
|
||||
/** The status. */
|
||||
private ThProcessStatus status;
|
||||
|
||||
/**
|
||||
* Instantiates a new th sync status.
|
||||
*/
|
||||
public ThSyncStatus() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new th sync status.
|
||||
*
|
||||
* @param descriptor the descriptor
|
||||
* @param status the status
|
||||
*/
|
||||
public ThSyncStatus(ThProcessDescriptor descriptor, ThProcessStatus status) {
|
||||
super();
|
||||
this.descriptor = descriptor;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the descriptor.
|
||||
*
|
||||
* @return the descriptor
|
||||
*/
|
||||
public ThProcessDescriptor getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the descriptor.
|
||||
*
|
||||
* @param descriptor the new descriptor
|
||||
*/
|
||||
public void setDescriptor(ThProcessDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the process status.
|
||||
*
|
||||
* @return the process status
|
||||
*/
|
||||
public ThProcessStatus getProcessStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status.
|
||||
*
|
||||
* @param status the new status
|
||||
*/
|
||||
public void setStatus(ThProcessStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ThSyncStatus [descriptor=");
|
||||
builder.append(descriptor);
|
||||
builder.append(", status=");
|
||||
builder.append(status);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
package org.gcube.portal.wssynclibrary.shared.thredds;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ThSynchFolderConfiguration.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 8, 2018
|
||||
*/
|
||||
public class ThSynchFolderConfiguration implements Serializable{
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -5807533629170443212L;
|
||||
|
||||
/** The remote path. */
|
||||
private String remotePath;
|
||||
|
||||
/** The filter. */
|
||||
private String filter;
|
||||
|
||||
/** The target token. */
|
||||
private String targetToken;
|
||||
|
||||
/** The to create catalog name. */
|
||||
private String toCreateCatalogName;
|
||||
|
||||
/** The remote persistence. */
|
||||
private String remotePersistence="thredds";
|
||||
|
||||
|
||||
public ThSynchFolderConfiguration() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ThSynchFolderConfiguration(String remotePath, String filter, String targetToken, String toCreateCatalogName,
|
||||
String remotePersistence) {
|
||||
super();
|
||||
this.remotePath = remotePath;
|
||||
this.filter = filter;
|
||||
this.targetToken = targetToken;
|
||||
this.toCreateCatalogName = toCreateCatalogName;
|
||||
this.remotePersistence = remotePersistence;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setRemotePath(String remotePath) {
|
||||
this.remotePath = remotePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getTargetToken() {
|
||||
return targetToken;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setTargetToken(String targetToken) {
|
||||
this.targetToken = targetToken;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getToCreateCatalogName() {
|
||||
return toCreateCatalogName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setToCreateCatalogName(String toCreateCatalogName) {
|
||||
this.toCreateCatalogName = toCreateCatalogName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getRemotePersistence() {
|
||||
return remotePersistence;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setRemotePersistence(String remotePersistence) {
|
||||
this.remotePersistence = remotePersistence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ThSynchFolderConfiguration [remotePath=");
|
||||
builder.append(remotePath);
|
||||
builder.append(", filter=");
|
||||
builder.append(filter);
|
||||
builder.append(", targetToken=");
|
||||
builder.append(targetToken!=null && targetToken.length()>3?targetToken.substring(0,targetToken.length()-3):"");
|
||||
builder.append(", toCreateCatalogName=");
|
||||
builder.append(toCreateCatalogName);
|
||||
builder.append(", remotePersistence=");
|
||||
builder.append(remotePersistence);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
package org.gcube.portal.wssynclibrary.thredds;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThProcessDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThProcessStatus;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessDescriptor;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessStatus;
|
||||
import org.gcube.usecases.ws.thredds.model.SyncFolderDescriptor;
|
||||
import org.gcube.usecases.ws.thredds.model.SynchFolderConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ThreddsConverter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
*/
|
||||
public class ThreddsConverter {
|
||||
|
||||
public static final String THREDDS_FILTER_NC_NCML_ASC = "*.nc,*.ncml,*.asc";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ThreddsConverter.class);
|
||||
|
||||
/** The to S sync folder descriptor. */
|
||||
public static Function<SyncFolderDescriptor, ThSyncFolderDescriptor> toThSyncFolderDescriptor = new Function<SyncFolderDescriptor, ThSyncFolderDescriptor>() {
|
||||
|
||||
public ThSyncFolderDescriptor apply(SyncFolderDescriptor t) {
|
||||
ThSyncFolderDescriptor mySync = new ThSyncFolderDescriptor();
|
||||
if(t==null) {
|
||||
logger.info("Input "+SyncFolderDescriptor.class.getSimpleName()+" is null, returning empty "+ThSyncFolderDescriptor.class.getSimpleName());
|
||||
return mySync;
|
||||
}
|
||||
|
||||
mySync.setFolderId(t.getFolderId());
|
||||
mySync.setFolderPath(t.getFolderPath());
|
||||
mySync.setLocked(t.isLocked());
|
||||
ThProcessDescriptor localProcessDescriptor = toThProcessDescriptor.apply(t.getLocalProcessDescriptor());
|
||||
mySync.setLocalProcessDescriptor(localProcessDescriptor);
|
||||
ThSynchFolderConfiguration configuration = toThSynchFolderConfiguration.apply(t.getConfiguration());
|
||||
mySync.setConfiguration(configuration);
|
||||
|
||||
return mySync;
|
||||
}
|
||||
};
|
||||
|
||||
/** The to S sync folder descriptor. */
|
||||
public static Function<ThSyncFolderDescriptor, SyncFolderDescriptor> toSyncFolderDescriptor = new Function<ThSyncFolderDescriptor, SyncFolderDescriptor>() {
|
||||
|
||||
public SyncFolderDescriptor apply(ThSyncFolderDescriptor t) {
|
||||
|
||||
if(t==null) {
|
||||
logger.warn("Input "+ThSyncFolderDescriptor.class.getSimpleName()+" is null, returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
SynchFolderConfiguration configuration = toSynchFolderConfiguration.apply(t.getConfiguration());
|
||||
return new SyncFolderDescriptor(t.getFolderId(), t.getFolderPath(), configuration);
|
||||
}
|
||||
};
|
||||
|
||||
/** The to synch folder configuration. */
|
||||
public static Function<ThSynchFolderConfiguration, SynchFolderConfiguration> toSynchFolderConfiguration = new Function<ThSynchFolderConfiguration, SynchFolderConfiguration>() {
|
||||
|
||||
public SynchFolderConfiguration apply(ThSynchFolderConfiguration t) {
|
||||
|
||||
if(t==null) {
|
||||
logger.warn("Input "+ThSynchFolderConfiguration.class.getSimpleName()+" is null, returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
String filter = t.getFilter()!=null && !t.getFilter().isEmpty()?t.getFilter():THREDDS_FILTER_NC_NCML_ASC;
|
||||
|
||||
return new SynchFolderConfiguration(t.getRemotePath(), filter, t.getTargetToken(), t.getToCreateCatalogName());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** The to S synch folder configuration. */
|
||||
public static Function<SynchFolderConfiguration, ThSynchFolderConfiguration> toThSynchFolderConfiguration = new Function<SynchFolderConfiguration, ThSynchFolderConfiguration>() {
|
||||
|
||||
public ThSynchFolderConfiguration apply(SynchFolderConfiguration t) {
|
||||
ThSynchFolderConfiguration mySync = new ThSynchFolderConfiguration();
|
||||
if(t==null) {
|
||||
logger.info("Input "+SynchFolderConfiguration.class.getSimpleName()+" is null, returning empty "+ThSynchFolderConfiguration.class.getSimpleName());
|
||||
return mySync;
|
||||
}
|
||||
mySync.setFilter(t.getFilter());
|
||||
mySync.setRemotePath(t.getRemotePath());
|
||||
mySync.setRemotePersistence(t.getRemotePersistence());
|
||||
mySync.setTargetToken(t.getTargetToken());
|
||||
mySync.setToCreateCatalogName(t.getToCreateCatalogName());
|
||||
return mySync;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** The to S sync folder descriptor. */
|
||||
public static Function<ProcessDescriptor, ThProcessDescriptor> toThProcessDescriptor = new Function<ProcessDescriptor, ThProcessDescriptor>() {
|
||||
|
||||
public ThProcessDescriptor apply(ProcessDescriptor t) {
|
||||
ThProcessDescriptor mySync = new ThProcessDescriptor();
|
||||
if(t==null) {
|
||||
logger.info("Input "+ProcessDescriptor.class.getSimpleName()+" is null, returning empty "+ThProcessDescriptor.class.getSimpleName());
|
||||
return mySync;
|
||||
}
|
||||
|
||||
mySync.setFolderId(t.getFolderId());
|
||||
mySync.setFolderPath(t.getFolderPath());
|
||||
mySync.setProcessId(t.getProcessId());
|
||||
ThSynchFolderConfiguration fc = toThSynchFolderConfiguration.apply(t.getSynchConfiguration());
|
||||
mySync.setSynchConfiguration(fc);
|
||||
return mySync;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** The to th process status. */
|
||||
public static Function<ProcessStatus, ThProcessStatus> toThProcessStatus = new Function<ProcessStatus, ThProcessStatus>() {
|
||||
|
||||
public ThProcessStatus apply(ProcessStatus t) {
|
||||
ThProcessStatus mySync = new ThProcessStatus();
|
||||
if(t==null) {
|
||||
logger.info("Input "+ProcessStatus.class.getSimpleName()+" is null, returning empty "+ThProcessStatus.class.getSimpleName());
|
||||
return mySync;
|
||||
}
|
||||
|
||||
mySync.setCurrentMessage(t.getCurrentMessage());
|
||||
mySync.setPercentCompleted(t.getPercent());
|
||||
|
||||
if(t.getErrorCount()!=null)
|
||||
mySync.setErrorCount(t.getErrorCount().get());
|
||||
if(t.getLogBuilder()!=null)
|
||||
mySync.setLogBuilder(t.getLogBuilder().toString());
|
||||
if(t.getQueuedTransfers()!=null)
|
||||
mySync.setQueuedTransfers(t.getQueuedTransfers().get());
|
||||
if(t.getServedTransfers()!=null)
|
||||
mySync.setServedTransfers(t.getServedTransfers().get());
|
||||
|
||||
if(t.getStatus()!=null) {
|
||||
|
||||
switch (t.getStatus()) {
|
||||
case COMPLETED:
|
||||
mySync.setStatus(Status.COMPLETED);
|
||||
break;
|
||||
case INITIALIZING:
|
||||
mySync.setStatus(Status.INITIALIZING);
|
||||
break;
|
||||
case ONGOING:
|
||||
mySync.setStatus(Status.ONGOING);
|
||||
break;
|
||||
case WARNINGS:
|
||||
mySync.setStatus(Status.WARNINGS);
|
||||
break;
|
||||
case STOPPED:
|
||||
mySync.setStatus(Status.STOPPED);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//mySync.setStatus(t.getStatus());
|
||||
return mySync;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,392 @@
|
||||
package org.gcube.portal.wssynclibrary.thredds;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Properties;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThProcessDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThProcessStatus;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration;
|
||||
import org.gcube.usecases.ws.thredds.SyncEngine;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessDescriptor;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessStatus;
|
||||
import org.gcube.usecases.ws.thredds.faults.InternalException;
|
||||
import org.gcube.usecases.ws.thredds.faults.ProcessNotFoundException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceInteractionException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceLockedException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
|
||||
import org.gcube.usecases.ws.thredds.model.SyncFolderDescriptor;
|
||||
import org.gcube.usecases.ws.thredds.model.SyncOperationCallBack;
|
||||
import org.gcube.usecases.ws.thredds.model.SynchFolderConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class WorkspaceThreddsSynchronize.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
*/
|
||||
public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronizedRepository<ThSyncStatus, ThSyncFolderDescriptor>{
|
||||
|
||||
/** The logger. */
|
||||
private static Logger logger = LoggerFactory.getLogger(WorkspaceThreddsSynchronize.class);
|
||||
|
||||
/** The engine. */
|
||||
private SyncEngine engine=null;
|
||||
|
||||
/** The instance. */
|
||||
private static WorkspaceThreddsSynchronize instance = null;
|
||||
|
||||
public static final String WS_SYNCH_SYNCH_STATUS = "WS-SYNCH.SYNCH-STATUS";
|
||||
|
||||
/** The map call back. */
|
||||
// Fully synchronized HashMap
|
||||
private Map<String, ThSyncStatus> mapCallBack = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace thredds synchronize.
|
||||
*/
|
||||
private WorkspaceThreddsSynchronize() {
|
||||
// GET ENGINE : SINGLETON INSTANCE
|
||||
engine = SyncEngine.get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the single instance of WorkspaceThreddsSynchronize.
|
||||
*
|
||||
* @return single instance of WorkspaceThreddsSynchronize
|
||||
*/
|
||||
public static WorkspaceThreddsSynchronize getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new WorkspaceThreddsSynchronize();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
//setSynchronizedFolder(config, folder.getId());
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#isItemSynchronized(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ThSyncFolderDescriptor checkItemSynched(String itemId) throws ItemNotSynched, Exception {
|
||||
logger.debug("Perfoming checkItemSynched for id: "+itemId);
|
||||
try {
|
||||
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
|
||||
SyncFolderDescriptor desc = engine.check(itemId, false);
|
||||
|
||||
logger.debug("The item id: "+itemId +" is synched");
|
||||
ThSyncFolderDescriptor descr = ThreddsConverter.toThSyncFolderDescriptor.apply(desc);
|
||||
logger.trace("CheckItemSynched for id: "+itemId+" returning descriptor: "+descr);
|
||||
return descr;
|
||||
|
||||
}catch(WorkspaceNotSynchedException e) {
|
||||
String err = "The item id: "+itemId +" is not synched";
|
||||
logger.trace(err);
|
||||
throw new ItemNotSynched("The item id: "+itemId +" is not synched");
|
||||
// System.out.println("Folder not synched, configurin it..");
|
||||
//engine.setSynchronizedFolder(config, folder.getId());
|
||||
}catch(WorkspaceLockedException e) {
|
||||
logger.warn("Workspace locked, going to force unlock..");
|
||||
engine.forceUnlock(itemId);
|
||||
//System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
|
||||
//engine.forceUnlock(folder.getId());
|
||||
|
||||
//TODO???
|
||||
return null;
|
||||
//???
|
||||
} catch (WorkspaceInteractionException | InternalException e) {
|
||||
logger.error("Error: ",e);
|
||||
if(e instanceof WorkspaceInteractionException)
|
||||
throw new Exception("Sorry, an error occurred during check syncronization due to WS interection for the itemId: "+itemId);
|
||||
else if(e instanceof InternalException)
|
||||
throw new Exception("Sorry, an Internal Exception occurred during check syncronization for the itemId: "+itemId);
|
||||
|
||||
throw new Exception("Sorry, an error occurred server side during chck syncronization for the itemId: "+itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the synchronized folder.
|
||||
*
|
||||
* @param thConfig the th config
|
||||
* @param itemId the item id
|
||||
* @return the th sync folder descriptor
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ThSyncFolderDescriptor setSynchronizedFolder(ThSynchFolderConfiguration thConfig, String itemId) throws Exception {
|
||||
SynchFolderConfiguration config = ThreddsConverter.toSynchFolderConfiguration.apply(thConfig);
|
||||
|
||||
if(thConfig.getRemotePath()==null || thConfig.getRemotePath().isEmpty())
|
||||
throw new Exception("A valid remote path must be provided");
|
||||
|
||||
if(thConfig.getToCreateCatalogName()==null || thConfig.getToCreateCatalogName().isEmpty())
|
||||
throw new Exception("A valid Catalogue Name must be provided");
|
||||
|
||||
if(thConfig.getTargetToken()==null || thConfig.getTargetToken().isEmpty())
|
||||
throw new Exception("A valid Target Token must be provided");
|
||||
|
||||
try {
|
||||
engine.setSynchronizedFolder(config, itemId);
|
||||
} catch (WorkspaceInteractionException | InternalException e) {
|
||||
logger.error("Error on setSynchronizedFolder for config: "+thConfig);
|
||||
logger.error("Using itemId: "+itemId,e);
|
||||
throw new Exception("Error on setSynchronizedFolder");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#doSynchronization(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ThSyncStatus doSync(String itemId) throws Exception {
|
||||
|
||||
try {
|
||||
// INVOKE SYNCHRONIZATION ON FOLDER
|
||||
ProcessDescriptor descriptor = engine.doSync(itemId);
|
||||
|
||||
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
||||
|
||||
if(synStatus==null) {
|
||||
|
||||
registerCallbackForId(itemId);
|
||||
descriptor = engine.getProcessDescriptorByFolderId(itemId);
|
||||
ProcessStatus status = engine.getProcessStatusByFolderId(itemId);
|
||||
updateMapCallback(itemId, status, descriptor);
|
||||
}
|
||||
|
||||
logger.debug("DoSync returning status: "+synStatus);
|
||||
return synStatus;
|
||||
|
||||
} catch (WorkspaceInteractionException | InternalException | ProcessNotFoundException e) {
|
||||
logger.error("Error: ",e);
|
||||
|
||||
if(e instanceof WorkspaceInteractionException)
|
||||
throw new Exception("Sorry, an error occurred during syncronization due to WS interection for the itemId: "+itemId);
|
||||
else if(e instanceof InternalException)
|
||||
throw new Exception("Sorry, an Internal Exception occurred during syncronization for the itemId: "+itemId);
|
||||
|
||||
throw new Exception("Sorry, an error occurred server side during syncronization for the itemId: "+itemId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.DoSyncItem#getSyncStatus(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ThSyncStatus monitorSyncStatus(String itemId) throws ItemNotSynched, Exception {
|
||||
|
||||
|
||||
try {
|
||||
//ThSyncFolderDescriptor descr = checkItemSynched(itemId);
|
||||
|
||||
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
||||
|
||||
|
||||
if(synStatus==null) {
|
||||
logger.info("The sync is not on-going...,returning process status null");
|
||||
// String err = "The item id: "+itemId +" is not cached as synched";
|
||||
// throw new ItemNotSynched(err);
|
||||
return new ThSyncStatus(null, null);
|
||||
}
|
||||
|
||||
if(synStatus.getProcessStatus()!=null) {
|
||||
if(synStatus.getProcessStatus().getStatus()!=null) {
|
||||
if(synStatus.getProcessStatus().getStatus().equals(Status.COMPLETED)) {
|
||||
//TODO NOW?
|
||||
mapCallBack.put(itemId, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.trace("MonitorSyncStatus for item: "+itemId+" returning: "+synStatus);
|
||||
return synStatus;
|
||||
|
||||
// } catch (ItemNotSynched e) {
|
||||
// String err = "The item id: "+itemId +" is not synched repository side";
|
||||
// throw new ItemNotSynched(err);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Sorry, an error occurred during syncronization for itemId: "+itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#removeSync(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Boolean removeSync(String itemId) {
|
||||
return null;
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#stopSync(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Boolean stopSync(String itemId) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#initRepository()
|
||||
*/
|
||||
@Override
|
||||
public Boolean initRepository() {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#shutDownRepository()
|
||||
*/
|
||||
@Override
|
||||
public Boolean shutDownRepository() {
|
||||
try {
|
||||
engine.shutDown();
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronizedRepository#decribeSyncRepository()
|
||||
*/
|
||||
@Override
|
||||
public String decribeSyncRepository() {
|
||||
return "Sync repository for Thredds";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the synched status from item property.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param username the username
|
||||
* @return the synched status from item property
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Sync_Status getSynchedStatusFromItemProperty(String folderId, String username) throws ItemNotSynched, Exception{
|
||||
|
||||
if(folderId==null)
|
||||
throw new Exception("Invalid pareter itemId is null");
|
||||
|
||||
String scope = ScopeProvider.instance.get();
|
||||
if(scope == null || scope.isEmpty())
|
||||
throw new Exception("You must set a valid scope into ScopeProvider instance");
|
||||
|
||||
WorkspaceFolder folder = null;
|
||||
|
||||
try {
|
||||
|
||||
logger.debug("Scope provider instancied at: "+scope);
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(username);
|
||||
folder = (WorkspaceFolder) workspace.getItem(folderId);
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("Error HL side: "+folderId, e);
|
||||
throw new Exception("Sorry an error occurred getting HL item for id: "+folderId);
|
||||
}
|
||||
|
||||
if(folder==null)
|
||||
throw new Exception("Sorry an error occurred getting HL item for id: "+folderId);
|
||||
|
||||
Properties properties = folder.getProperties();
|
||||
|
||||
if(properties==null || properties.getProperties()==null || properties.getProperties().size()==0) {
|
||||
throw new ItemNotSynched("No properties to read");
|
||||
}
|
||||
|
||||
String wsSyncStatus = properties.getProperties().get(WS_SYNCH_SYNCH_STATUS);
|
||||
logger.info("Folder id: "+folder.getId()+" has current: "+WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus);
|
||||
try {
|
||||
return Sync_Status.valueOf(wsSyncStatus);
|
||||
}catch (Exception e) {
|
||||
logger.warn(wsSyncStatus + "is not value of "+Sync_Status.values());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register callback for id.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public void registerCallbackForId(String itemId) throws Exception{
|
||||
|
||||
try {
|
||||
|
||||
SyncOperationCallBack callback = new SyncOperationCallBack() {
|
||||
|
||||
@Override
|
||||
public void onStep(ProcessStatus status, ProcessDescriptor descriptor) {
|
||||
logger.debug("ON STEP : "+status+" "+descriptor);
|
||||
logger.debug("LOG : \n"+ status.getLogBuilder().toString());
|
||||
if(status.getStatus().equals(ProcessStatus.Status.COMPLETED)) {
|
||||
//mapCallBack.remove(itemId);
|
||||
}
|
||||
updateMapCallback(itemId, status, descriptor);
|
||||
}
|
||||
};
|
||||
|
||||
// REGISTER CALLBACK TO MONITOR PROGRESS
|
||||
logger.debug("Registering callback on itemId: "+itemId);
|
||||
engine.registerCallBack(itemId, callback);
|
||||
}catch (ProcessNotFoundException e) {
|
||||
logger.error("Register callback exception: ",e);
|
||||
throw new Exception("No Process found for item id: "+itemId+ ", refresh an try again");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update map callback.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param status the status
|
||||
* @param descriptor the descriptor
|
||||
*/
|
||||
private void updateMapCallback(String itemId, ProcessStatus status, ProcessDescriptor descriptor) {
|
||||
ThProcessDescriptor thDesc = ThreddsConverter.toThProcessDescriptor.apply(descriptor);
|
||||
ThProcessStatus thStatus = ThreddsConverter.toThProcessStatus.apply(status);
|
||||
mapCallBack.put(itemId, new ThSyncStatus(thDesc, thStatus));
|
||||
logger.debug("Update map for "+itemId +" with new "+thStatus);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package org.gcube.portal.wssynclibrary.thredds;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.DoCheckSyncItem;
|
||||
import org.gcube.portal.wssynclibrary.DoConnectRepository;
|
||||
import org.gcube.portal.wssynclibrary.DoSyncItem;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface WorkspaceThreddsSynchronizedRepository.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 14, 2018
|
||||
* @param <O> the generic type
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public interface WorkspaceThreddsSynchronizedRepository<O, T> extends DoSyncItem<O>, DoCheckSyncItem<T>, DoConnectRepository {
|
||||
|
||||
|
||||
/**
|
||||
* Decribe sync repository.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String decribeSyncRepository();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application-client version="6" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_6.xsd">
|
||||
<display-name>A Java EE 6 Application Client</display-name>
|
||||
</application-client>
|
@ -0,0 +1,131 @@
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.usecases.ws.thredds.SyncEngine;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessDescriptor;
|
||||
import org.gcube.usecases.ws.thredds.engine.impl.ProcessStatus;
|
||||
import org.gcube.usecases.ws.thredds.faults.InternalException;
|
||||
import org.gcube.usecases.ws.thredds.faults.ProcessNotFoundException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceInteractionException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceLockedException;
|
||||
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
|
||||
import org.gcube.usecases.ws.thredds.model.SyncOperationCallBack;
|
||||
import org.gcube.usecases.ws.thredds.model.SynchFolderConfiguration;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class TestWsThreddsEngine.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 7, 2018
|
||||
*/
|
||||
public class TestWsThreddsEngine {
|
||||
|
||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
||||
public static String TEST_USER = "francesco.mangiacrapa";
|
||||
|
||||
public static String TEST_FOLDER_ID = "";
|
||||
|
||||
public static void main(String[] args) throws ProcessNotFoundException, InternalErrorException, WorkspaceInteractionException, InternalException, WorkspaceFolderNotFoundException, ItemNotFoundException, InsufficientPrivilegesException, ItemAlreadyExistException, HomeNotFoundException, UserNotFoundException, MalformedURLException, IOException {
|
||||
|
||||
// GET ENGINE : SINGLETON INSTANCE
|
||||
SyncEngine engine=SyncEngine.get();
|
||||
|
||||
|
||||
|
||||
Workspace ws = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(TEST_USER)
|
||||
.getWorkspace();
|
||||
|
||||
|
||||
//TEST INFO...
|
||||
//TestCommons.setScope();
|
||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
WorkspaceFolder folder=(WorkspaceFolder) ws.getItem(TEST_FOLDER_ID);
|
||||
|
||||
// FOLDER CONFIGURATION BEAN
|
||||
//SynchFolderConfiguration config=TestCommons.getSynchConfig();
|
||||
|
||||
String filter = "";
|
||||
String remotePersistence = "";
|
||||
String remotePath = "";
|
||||
String targetToken = "";
|
||||
SynchFolderConfiguration config = new SynchFolderConfiguration(remotePath, filter, targetToken, remotePersistence);
|
||||
|
||||
try {
|
||||
//try to clean it up, first..
|
||||
System.out.println("Cleaning it up..");
|
||||
engine.unsetSynchronizedFolder(folder.getId(), false);
|
||||
}catch(WorkspaceNotSynchedException e) {
|
||||
// it was already cleared
|
||||
}catch(WorkspaceLockedException e) {
|
||||
engine.forceUnlock(folder.getId());
|
||||
engine.unsetSynchronizedFolder(folder.getId(), false);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
|
||||
engine.check(folder.getId(), false);
|
||||
}catch(WorkspaceNotSynchedException e) {
|
||||
System.out.println("Folder not synched, configurin it..");
|
||||
engine.setSynchronizedFolder(config, folder.getId());
|
||||
}catch(WorkspaceLockedException e) {
|
||||
System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
|
||||
engine.forceUnlock(folder.getId());
|
||||
}
|
||||
|
||||
// INVOKE SYNCHRONIZATION ON FOLDER
|
||||
ProcessDescriptor descriptor=engine.doSync(folder.getId());
|
||||
|
||||
System.out.println("Obtained descriptor : "+descriptor);
|
||||
|
||||
|
||||
SyncOperationCallBack syncCall = new SyncOperationCallBack() {
|
||||
|
||||
@Override
|
||||
public void onStep(ProcessStatus status, ProcessDescriptor descriptor) {
|
||||
System.out.println("ON STEP : "+status+" "+descriptor);
|
||||
System.out.println("LOG : \n"+ status.getLogBuilder().toString());
|
||||
if(status.getStatus().equals(ProcessStatus.Status.COMPLETED)) {
|
||||
|
||||
//COMPLETED FARE REMOVE DALLA MAPPA
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// REGISTER CALLBACK TO MONITOR PROGRESS
|
||||
engine.registerCallBack(folder.getId(), syncCall);
|
||||
|
||||
|
||||
engine.check(folder.getId(), true);
|
||||
|
||||
|
||||
// INVOKE WHEN PORTAL SHUTS DOWN TO FREE RESOURCES AND STOP SYNC PROCESSES
|
||||
engine.shutDown();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue