Merged from Branch
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/is-exporter-se-plugin@152669 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
20eb34ed77
commit
2c221bd88f
|
@ -22,7 +22,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE xml>
|
<!DOCTYPE xml>
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.informationsystem.is-exporter-se-plugin.1.0.0" date="${buildDate}">
|
<Changeset component="org.gcube.informationsystem.is-exporter-se-plugin.1.1.0" date="${buildDate}">
|
||||||
|
<Change>Removed List and Set usage as workaround fo OrientDB bug #9021</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.informationsystem.is-exporter-se-plugin.1.0.0" date="2017-06-07">
|
||||||
<Change>First Release</Change>
|
<Change>First Release</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
68
pom.xml
68
pom.xml
|
@ -7,7 +7,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.information-system</groupId>
|
<groupId>org.gcube.information-system</groupId>
|
||||||
<artifactId>is-exporter-se-plugin</artifactId>
|
<artifactId>is-exporter-se-plugin</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<name>IS Exporter</name>
|
<name>IS Exporter</name>
|
||||||
<description>Exports GenericReosurce and ServiceEndpoint from gCoreIS to Resource Registry</description>
|
<description>Exports GenericReosurce and ServiceEndpoint from gCoreIS to Resource Registry</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -55,12 +55,6 @@
|
||||||
<version>[1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.core</groupId>
|
|
||||||
<artifactId>common-scope</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources</groupId>
|
<groupId>org.gcube.resources</groupId>
|
||||||
<artifactId>common-gcore-resources</artifactId>
|
<artifactId>common-gcore-resources</artifactId>
|
||||||
|
@ -76,7 +70,21 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>authorization-client</artifactId>
|
<artifactId>authorization-client</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-encryption</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-scope-maps</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.information-system</groupId>
|
<groupId>org.gcube.information-system</groupId>
|
||||||
<artifactId>information-system-model</artifactId>
|
<artifactId>information-system-model</artifactId>
|
||||||
|
@ -96,6 +104,27 @@
|
||||||
<artifactId>resource-registry-publisher</artifactId>
|
<artifactId>resource-registry-publisher</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>home-library-jcr</artifactId>
|
<artifactId>home-library-jcr</artifactId>
|
||||||
|
@ -113,6 +142,26 @@
|
||||||
<artifactId>home-library</artifactId>
|
<artifactId>home-library</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-scope</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-authorization</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency -->
|
||||||
|
|
||||||
|
<!-- dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-gcore-stubs</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency -->
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -129,6 +178,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test dependencies -->
|
<!-- Test dependencies -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -142,11 +192,7 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -21,6 +21,9 @@ public class ISExporterPlugin extends Plugin<ISExporterPluginDeclaration> {
|
||||||
*/
|
*/
|
||||||
private static Logger logger = LoggerFactory.getLogger(ISExporterPlugin.class);
|
private static Logger logger = LoggerFactory.getLogger(ISExporterPlugin.class);
|
||||||
|
|
||||||
|
public static final String FILTERED_REPORT = "FILTERED_REPORT";
|
||||||
|
|
||||||
|
|
||||||
public ISExporterPlugin(ISExporterPluginDeclaration pluginDeclaration) {
|
public ISExporterPlugin(ISExporterPluginDeclaration pluginDeclaration) {
|
||||||
super(pluginDeclaration);
|
super(pluginDeclaration);
|
||||||
logger.debug("contructor");
|
logger.debug("contructor");
|
||||||
|
@ -32,16 +35,26 @@ public class ISExporterPlugin extends Plugin<ISExporterPluginDeclaration> {
|
||||||
String token = SecurityTokenProvider.instance.get();
|
String token = SecurityTokenProvider.instance.get();
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||||
String scope = authorizationEntry.getContext();
|
String scope = authorizationEntry.getContext();
|
||||||
logger.debug("Launching {} execution on scope {}",
|
logger.info("Launching {} execution on scope {}",
|
||||||
ISExporterPluginDeclaration.NAME, scope);
|
ISExporterPluginDeclaration.NAME, scope);
|
||||||
|
|
||||||
GenericResourceExporter genericResourceExporter = new GenericResourceExporter();
|
boolean filteredReport = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
filteredReport = (boolean) inputs.getOrDefault(FILTERED_REPORT, false);
|
||||||
|
}catch (Exception e) {
|
||||||
|
filteredReport = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("Failure Report are filtered (e.g. Failing UUID are not shown to avoid to produce to much uneeded reports)");
|
||||||
|
|
||||||
|
GenericResourceExporter genericResourceExporter = new GenericResourceExporter(filteredReport);
|
||||||
genericResourceExporter.export();
|
genericResourceExporter.export();
|
||||||
|
|
||||||
ServiceEndpointExporter serviceEndpointExporter = new ServiceEndpointExporter();
|
ServiceEndpointExporter serviceEndpointExporter = new ServiceEndpointExporter(filteredReport);
|
||||||
serviceEndpointExporter.export();
|
serviceEndpointExporter.export();
|
||||||
|
|
||||||
logger.debug("{} execution finished", ISExporterPluginDeclaration.NAME);
|
logger.info("{} execution finished", ISExporterPluginDeclaration.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**{@inheritDoc}*/
|
/**{@inheritDoc}*/
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.informationsystem.exporter.mapper;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -17,16 +16,7 @@ import java.util.UUID;
|
||||||
import org.gcube.common.authorization.client.Constants;
|
import org.gcube.common.authorization.client.Constants;
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.homelibrary.home.Home;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeManager;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeManagerFactory;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.informationsystem.exporter.ISExporterPluginDeclaration;
|
|
||||||
import org.gcube.informationsystem.exporter.mapper.exception.CreateException;
|
import org.gcube.informationsystem.exporter.mapper.exception.CreateException;
|
||||||
import org.gcube.informationsystem.exporter.mapper.exception.UpdateException;
|
import org.gcube.informationsystem.exporter.mapper.exception.UpdateException;
|
||||||
import org.gcube.informationsystem.impl.utils.ISMapper;
|
import org.gcube.informationsystem.impl.utils.ISMapper;
|
||||||
|
@ -72,8 +62,9 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
public static final String CREATE = "create";
|
public static final String CREATE = "create";
|
||||||
public static final String UPDATE = "update";
|
public static final String UPDATE = "update";
|
||||||
|
|
||||||
protected Class<GR> grClass;
|
protected final Class<GR> grClass;
|
||||||
protected Class<R> rClass;
|
protected final Class<R> rClass;
|
||||||
|
protected final boolean filteredReport;
|
||||||
|
|
||||||
public static final String UTF8 = "UTF-8";
|
public static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
|
@ -98,14 +89,16 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getFile(Class<?> grClass, String contextFullName, String dateString) {
|
public File getFile(Class<?> grClass, String contextFullName, String dateString) {
|
||||||
return new File(contextFullName.replace("/", "_") + "-" + grClass.getSimpleName() + "-" + dateString + "-exporter.json");
|
return new File(contextFullName.replace("/", "_") + "-" + grClass.getSimpleName() + "-" + dateString
|
||||||
|
+ "-exporter.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GCoreResourceMapper(Class<GR> grClass, Class<R> rClass){
|
protected GCoreResourceMapper(Class<GR> grClass, Class<R> rClass, boolean filteredReport) {
|
||||||
this.grClass = grClass;
|
this.grClass = grClass;
|
||||||
this.rClass = rClass;
|
this.rClass = rClass;
|
||||||
this.resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
this.resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
|
||||||
this.resourceRegistryClient = ResourceRegistryClientFactory.create();
|
this.resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
|
this.filteredReport = filteredReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<GR> getAll() {
|
protected List<GR> getAll() {
|
||||||
|
@ -142,11 +135,13 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
} catch (ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
update = false;
|
update = false;
|
||||||
} catch (ResourceAvailableInAnotherContextException e) {
|
} catch (ResourceAvailableInAnotherContextException e) {
|
||||||
// This code should never be reached because this should be fixed in map function
|
// This code should never be reached because this should be fixed in
|
||||||
|
// map function
|
||||||
resourceRegistryPublisher.addResourceToContext(uuid);
|
resourceRegistryPublisher.addResourceToContext(uuid);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}catch (Exception ee) {}
|
} catch (Exception ee) {
|
||||||
|
}
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,50 +177,44 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
return Constants.authorizationService().get(token).getClientInfo().getId();
|
return Constants.authorizationService().get(token).getClientInfo().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
/*
|
||||||
protected Home getHome(HomeManager manager) throws Exception{
|
*
|
||||||
Home home = null;
|
* @SuppressWarnings("deprecation") protected Home getHome(HomeManager
|
||||||
String scope = ScopeProvider.instance.get();
|
* manager) throws Exception{ Home home = null; String scope =
|
||||||
if(scope!=null){
|
* ScopeProvider.instance.get(); if(scope!=null){ home =
|
||||||
home = manager.getHome(getUsername());
|
* manager.getHome(getUsername()); }else{ home = manager.getHome(); } return
|
||||||
}else{
|
* home; }
|
||||||
home = manager.getHome();
|
*
|
||||||
}
|
* protected WorkspaceFolder getExporterFolder(Workspace ws) throws
|
||||||
return home;
|
* Exception { WorkspaceFolder root = ws.getRoot();
|
||||||
}
|
*
|
||||||
|
* WorkspaceFolder exporterFolder = null;
|
||||||
protected WorkspaceFolder getExporterFolder(Workspace ws) throws Exception {
|
* if(!ws.exists(ISExporterPluginDeclaration.NAME, root.getId())){ String
|
||||||
WorkspaceFolder root = ws.getRoot();
|
* folderDescription = String.
|
||||||
|
* format("The folder is used by %s plugin to store informations regarding failures exporting old GCore Resource to new Resource Registry"
|
||||||
WorkspaceFolder exporterFolder = null;
|
* , ISExporterPluginDeclaration.NAME); exporterFolder =
|
||||||
if(!ws.exists(ISExporterPluginDeclaration.NAME, root.getId())){
|
* ws.createFolder(ISExporterPluginDeclaration.NAME, folderDescription,
|
||||||
String folderDescription = String.format("The folder is used by %s plugin to store informations regarding failures exporting old GCore Resource to new Resource Registry", ISExporterPluginDeclaration.NAME);
|
* root.getId()); }else{ exporterFolder = (WorkspaceFolder)
|
||||||
exporterFolder = ws.createFolder(ISExporterPluginDeclaration.NAME, folderDescription, root.getId());
|
* ws.find(ISExporterPluginDeclaration.NAME, root.getId()); } return
|
||||||
}else{
|
* exporterFolder; }
|
||||||
exporterFolder = (WorkspaceFolder) ws.find(ISExporterPluginDeclaration.NAME, root.getId());
|
*
|
||||||
}
|
* public static final String APPLICATION_JSON_MIMETYPE =
|
||||||
return exporterFolder;
|
* "application/json";
|
||||||
}
|
*
|
||||||
|
* private static final String FOLDER_DESCRIPTION =
|
||||||
public static final String APPLICATION_JSON_MIMETYPE = "application/json";
|
* "Failures Report Folder for " + ISExporterPluginDeclaration.NAME;
|
||||||
|
*
|
||||||
private static final String FOLDER_DESCRIPTION = "Failures Report Folder for " + ISExporterPluginDeclaration.NAME;
|
* protected FolderItem publishFileToWorkspace(File file) throws Exception {
|
||||||
|
* HomeManagerFactory factory = HomeLibrary.getHomeManagerFactory();
|
||||||
protected FolderItem publishFileToWorkspace(File file) throws Exception {
|
* HomeManager manager = factory.getHomeManager(); Home home =
|
||||||
HomeManagerFactory factory = HomeLibrary.getHomeManagerFactory();
|
* getHome(manager); Workspace ws = home.getWorkspace(); WorkspaceFolder
|
||||||
HomeManager manager = factory.getHomeManager();
|
* exporterFolder = getExporterFolder(ws); FileInputStream fileInputStream =
|
||||||
Home home = getHome(manager);
|
* new FileInputStream(file);
|
||||||
Workspace ws = home.getWorkspace();
|
*
|
||||||
WorkspaceFolder exporterFolder = getExporterFolder(ws);
|
* FolderItem folderItem = WorkspaceUtil.createExternalFile( exporterFolder,
|
||||||
FileInputStream fileInputStream = new FileInputStream(file);
|
* file.getName(), FOLDER_DESCRIPTION, APPLICATION_JSON_MIMETYPE,
|
||||||
|
* fileInputStream); return folderItem; }
|
||||||
FolderItem folderItem = WorkspaceUtil.createExternalFile(
|
*/
|
||||||
exporterFolder, file.getName(),
|
|
||||||
FOLDER_DESCRIPTION,
|
|
||||||
APPLICATION_JSON_MIMETYPE,
|
|
||||||
fileInputStream);
|
|
||||||
return folderItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract R map(GR gr) throws Exception;
|
protected abstract R map(GR gr) throws Exception;
|
||||||
|
|
||||||
|
@ -233,13 +222,14 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
String contextName = getCurrentContextName();
|
String contextName = getCurrentContextName();
|
||||||
|
|
||||||
if (failed.size() == 0) {
|
if (failed.size() == 0) {
|
||||||
logger.debug("No needs to create an empty report besause there were no exporting failures on {}", contextName);
|
logger.debug("No needs to create an empty report besause there were no exporting failures on {}",
|
||||||
|
contextName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("-------------------------------------------------------");
|
logger.warn("-------------------------------------------------------");
|
||||||
logger.warn("{} : {} of {} ({} failures) {}s were exported as {}s", contextName,
|
logger.warn("{} : {} of {} ({} failures) {}s were exported as {}s", contextName, allSize - failed.size(),
|
||||||
allSize-failed.size(), allSize, failed.size(), grClass.getSimpleName(), rClass.getSimpleName());
|
allSize, failed.size(), grClass.getSimpleName(), rClass.getSimpleName());
|
||||||
logger.warn("-------------------------------------------------------\n\n");
|
logger.warn("-------------------------------------------------------\n\n");
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
@ -255,12 +245,25 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
|
|
||||||
for (GR gr : failed) {
|
for (GR gr : failed) {
|
||||||
logger.trace("-------------------------------------------------------");
|
logger.trace("-------------------------------------------------------");
|
||||||
|
|
||||||
|
if (filteredReport) {
|
||||||
|
try {
|
||||||
|
UUID.fromString(gr.id());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.debug(
|
||||||
|
"{} with has id {} which is not a valid UUID. The reports are filtered and such an error is not reported.",
|
||||||
|
gr.getClass().getSimpleName(), gr.id());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
R r = null;
|
R r = null;
|
||||||
try {
|
try {
|
||||||
r = map(gr);
|
r = map(gr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addNodeToArray(mappingArrayNode, objectMapper, gr, e);
|
addNodeToArray(mappingArrayNode, objectMapper, gr, e);
|
||||||
logger.trace("Error exporting {}. The problem was on mapping {} with UUID {}", gr, grClass.getSimpleName(), gr.id());
|
logger.trace("Error exporting {}. The problem was on mapping {} with UUID {}", gr,
|
||||||
|
grClass.getSimpleName(), gr.id());
|
||||||
logger.trace("-------------------------------------------------------\n");
|
logger.trace("-------------------------------------------------------\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +275,8 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
logger.error("This MUST BE A BUG. Please Investigate");
|
logger.error("This MUST BE A BUG. Please Investigate");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.getMessage().contains("com.orientechnologies.orient.server.distributed.task.ODistributedOperationException")){
|
if (e.getMessage().contains(
|
||||||
|
"com.orientechnologies.orient.server.distributed.task.ODistributedOperationException")) {
|
||||||
logger.error("This is an OrientDB distributed Issue");
|
logger.error("This is an OrientDB distributed Issue");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +290,8 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.trace("Error exporting {}. The problem was on publishing {} as {}", gr, rClass.getSimpleName(), ISMapper.marshal(r));
|
logger.trace("Error exporting {}. The problem was on publishing {} as {}", gr,
|
||||||
|
rClass.getSimpleName(), ISMapper.marshal(r));
|
||||||
} catch (JsonProcessingException e1) {
|
} catch (JsonProcessingException e1) {
|
||||||
logger.trace("", e1);
|
logger.trace("", e1);
|
||||||
}
|
}
|
||||||
|
@ -294,6 +299,13 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
logger.trace("-------------------------------------------------------\n");
|
logger.trace("-------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(filteredReport){
|
||||||
|
if(mappingArrayNode.size()==0 && publishingArrayNode.size()==0){
|
||||||
|
logger.debug("No need to produce JSON reports because alla the errors where filtered as requested by the input parameters.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String json = objectMapper.writeValueAsString(objectNode);
|
String json = objectMapper.writeValueAsString(objectNode);
|
||||||
|
|
||||||
|
@ -309,13 +321,12 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
/*
|
||||||
publishFileToWorkspace(file);
|
* try { publishFileToWorkspace(file); file.delete(); }catch
|
||||||
file.delete();
|
* (Exception e) {
|
||||||
}catch (Exception e) {
|
* logger.error("Error while saving file {} on Workspace",
|
||||||
logger.error("Error while saving file {} on Workspace", file.getName(), e);
|
* file.getName(), e); // TODO Use the Social Notification }
|
||||||
// TODO Use the Social Notification
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error exporting JSON error result", e);
|
logger.error("Error exporting JSON error result", e);
|
||||||
|
@ -340,11 +351,9 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
List<GR> all = getAll();
|
List<GR> all = getAll();
|
||||||
|
|
||||||
logger.debug("-------------------------------------------------------");
|
logger.debug("-------------------------------------------------------");
|
||||||
logger.debug("Going to export {} {}s as {}s",
|
logger.debug("Going to export {} {}s as {}s", all.size(), grClass.getSimpleName(), rClass.getSimpleName());
|
||||||
all.size(), grClass.getSimpleName(), rClass.getSimpleName());
|
|
||||||
logger.debug("-------------------------------------------------------");
|
logger.debug("-------------------------------------------------------");
|
||||||
|
|
||||||
|
|
||||||
List<GR> failed = new ArrayList<>();
|
List<GR> failed = new ArrayList<>();
|
||||||
|
|
||||||
for (GR gr : all) {
|
for (GR gr : all) {
|
||||||
|
@ -360,8 +369,4 @@ public abstract class GCoreResourceMapper<GR extends org.gcube.common.resources.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class GenericResourceExporter extends GCoreResourceMapper<GenericResource
|
||||||
public static final String FIXED_VERSION = "1.0.0";
|
public static final String FIXED_VERSION = "1.0.0";
|
||||||
public static final String FULL_BODY = "FULL_BODY";
|
public static final String FULL_BODY = "FULL_BODY";
|
||||||
|
|
||||||
public GenericResourceExporter(){
|
public GenericResourceExporter(Boolean filteredReport){
|
||||||
super(GenericResource.class, Configuration.class);
|
super(GenericResource.class, Configuration.class, filteredReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.gcube.informationsystem.exporter.mapper;
|
package org.gcube.informationsystem.exporter.mapper;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -21,6 +20,7 @@ import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
|
||||||
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
|
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
|
||||||
import org.gcube.informationsystem.impl.relation.ConsistsOfImpl;
|
import org.gcube.informationsystem.impl.relation.ConsistsOfImpl;
|
||||||
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
|
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
|
||||||
|
import org.gcube.informationsystem.impl.utils.ISMapper;
|
||||||
import org.gcube.informationsystem.model.embedded.Header;
|
import org.gcube.informationsystem.model.embedded.Header;
|
||||||
import org.gcube.informationsystem.model.embedded.ValueSchema;
|
import org.gcube.informationsystem.model.embedded.ValueSchema;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
|
@ -37,6 +37,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resour
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
public class ServiceEndpointExporter extends GCoreResourceMapper<ServiceEndpoint, EService> {
|
public class ServiceEndpointExporter extends GCoreResourceMapper<ServiceEndpoint, EService> {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ServiceEndpointExporter.class);
|
private static Logger logger = LoggerFactory.getLogger(ServiceEndpointExporter.class);
|
||||||
|
@ -51,25 +54,23 @@ public class ServiceEndpointExporter extends GCoreResourceMapper<ServiceEndpoint
|
||||||
public static final String USERNAME = "USERNAME";
|
public static final String USERNAME = "USERNAME";
|
||||||
public static final String PASSWORD = "PASSWORD";
|
public static final String PASSWORD = "PASSWORD";
|
||||||
public static final String USERNAME_PASSWORD_SCHEMA_STRING;
|
public static final String USERNAME_PASSWORD_SCHEMA_STRING;
|
||||||
//public static final URI USERNAME_PASSWORD_SCHEMA;
|
|
||||||
|
|
||||||
public static final String NAME = "NAME";
|
public static final String NAME = "name";
|
||||||
public static final String ENCRYPTED = "ENCRYPTED";
|
public static final String VALUE = "value";
|
||||||
public static final String VALUE = "VALUE";
|
public static final String ENCRYPTED = "encrypted";
|
||||||
public static final String PROPERTY_SCHEMA_STRING;
|
|
||||||
public static final URI PROPERTY_SCHEMA;
|
public static final String ARRAY = "ARRAY";
|
||||||
|
public static final String PROPERTIES = "PROPERTIES";
|
||||||
|
|
||||||
|
|
||||||
public static final String NOT_URI_ENDPOINT = "NOT_URI_ENDPOINT";
|
public static final String NOT_URI_ENDPOINT = "NOT_URI_ENDPOINT";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
USERNAME_PASSWORD_SCHEMA_STRING = String.format("%s:%s", USERNAME, PASSWORD);
|
USERNAME_PASSWORD_SCHEMA_STRING = String.format("%s:%s", USERNAME, PASSWORD);
|
||||||
//USERNAME_PASSWORD_SCHEMA = URI.create(USERNAME_PASSWORD_SCHEMA_STRING);
|
|
||||||
PROPERTY_SCHEMA_STRING = String.format("%s:%s:%s", NAME, ENCRYPTED, VALUE);
|
|
||||||
PROPERTY_SCHEMA = URI.create(PROPERTY_SCHEMA_STRING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceEndpointExporter(){
|
public ServiceEndpointExporter(boolean filteredReport){
|
||||||
super(ServiceEndpoint.class, EService.class);
|
super(ServiceEndpoint.class, EService.class, filteredReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -274,23 +275,22 @@ public class ServiceEndpointExporter extends GCoreResourceMapper<ServiceEndpoint
|
||||||
}
|
}
|
||||||
/* ----- */
|
/* ----- */
|
||||||
|
|
||||||
|
Group<Property> properties = accessPoint.properties();
|
||||||
|
if(properties!=null && properties.size()>0){
|
||||||
|
ObjectNode propertiesObjectNode = ISMapper.getObjectMapper().createObjectNode();
|
||||||
|
ArrayNode arrayNode = propertiesObjectNode.putArray(ARRAY);
|
||||||
|
|
||||||
List<ValueSchema> properties = new ArrayList<>();
|
for(Property property : properties){
|
||||||
|
ObjectNode objectNode = ISMapper.getObjectMapper().createObjectNode();
|
||||||
for(Property property : accessPoint.properties()){
|
objectNode.put(NAME, property.name());
|
||||||
ValueSchema valueSchema = new ValueSchemaImpl();
|
objectNode.put(VALUE, property.value());
|
||||||
String propertyValue = PROPERTY_SCHEMA.toString();
|
objectNode.put(ENCRYPTED, Boolean.toString(property.isEncrypted()));
|
||||||
propertyValue = propertyValue.replace(NAME, property.name());
|
|
||||||
propertyValue = propertyValue.replace(ENCRYPTED, Boolean.toString(property.isEncrypted()));
|
|
||||||
propertyValue = propertyValue.replace(VALUE, property.value());
|
|
||||||
|
|
||||||
valueSchema.setValue(propertyValue);
|
|
||||||
valueSchema.setSchema(PROPERTY_SCHEMA);
|
|
||||||
|
|
||||||
properties.add(valueSchema);
|
|
||||||
|
|
||||||
|
arrayNode.add(objectNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
accessPointFacets[i].setAdditionalProperty(PROPERTIES, propertiesObjectNode);
|
||||||
}
|
}
|
||||||
//accessPointFacets[i].setProperties(properties);
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
org.gcube.informationsystem.exporter.ISExporterPluginDeclaration
|
|
@ -1,5 +1,8 @@
|
||||||
package org.gcube.informationsystem.exporter;
|
package org.gcube.informationsystem.exporter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
import org.gcube.informationsystem.exporter.mapper.GenericResourceExporterTest;
|
import org.gcube.informationsystem.exporter.mapper.GenericResourceExporterTest;
|
||||||
import org.gcube.informationsystem.exporter.mapper.ServiceEndpointExporterTest;
|
import org.gcube.informationsystem.exporter.mapper.ServiceEndpointExporterTest;
|
||||||
|
@ -25,13 +28,15 @@ public class ISExporterPluginTest {
|
||||||
logger.info("\n\n\n-------------------------------------------------------------------------");
|
logger.info("\n\n\n-------------------------------------------------------------------------");
|
||||||
ScopedTest.setContext(token);
|
ScopedTest.setContext(token);
|
||||||
ISExporterPlugin isExporterPlugin = new ISExporterPlugin(new ISExporterPluginDeclaration());
|
ISExporterPlugin isExporterPlugin = new ISExporterPlugin(new ISExporterPluginDeclaration());
|
||||||
isExporterPlugin.launch(null);
|
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||||
|
inputs.put(ISExporterPlugin.FILTERED_REPORT, true);
|
||||||
|
isExporterPlugin.launch(inputs);
|
||||||
logger.info("\n\n\n");
|
logger.info("\n\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void delAllExported() throws ObjectNotFound, Exception{
|
public void removeExported() throws ObjectNotFound, Exception{
|
||||||
String[] tokens = {
|
String[] tokens = {
|
||||||
ScopedTest.GCUBE,
|
ScopedTest.GCUBE,
|
||||||
ScopedTest.GCUBE_DEVSEC,
|
ScopedTest.GCUBE_DEVSEC,
|
||||||
|
@ -44,10 +49,10 @@ public class ISExporterPluginTest {
|
||||||
ScopedTest.setContext(token);
|
ScopedTest.setContext(token);
|
||||||
|
|
||||||
GenericResourceExporterTest genericResourceExporterTest = new GenericResourceExporterTest();
|
GenericResourceExporterTest genericResourceExporterTest = new GenericResourceExporterTest();
|
||||||
genericResourceExporterTest.del();
|
genericResourceExporterTest.removeExported();
|
||||||
|
|
||||||
ServiceEndpointExporterTest serviceEndpointExporterTest = new ServiceEndpointExporterTest();
|
ServiceEndpointExporterTest serviceEndpointExporterTest = new ServiceEndpointExporterTest();
|
||||||
serviceEndpointExporterTest.del();
|
serviceEndpointExporterTest.removeExported();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,14 @@ public class GCoreResourceMapperTest extends ScopedTest {
|
||||||
for(String token : tokens){
|
for(String token : tokens){
|
||||||
logger.info("\n\n\n-------------------------------------------------------------------------");
|
logger.info("\n\n\n-------------------------------------------------------------------------");
|
||||||
ScopedTest.setContext(token);
|
ScopedTest.setContext(token);
|
||||||
GenericResourceExporter gre = new GenericResourceExporter();
|
GenericResourceExporter gre = new GenericResourceExporter(false);
|
||||||
File file = getFile(gre);
|
File file = getFile(gre);
|
||||||
|
logger.info("\n\n\n {}", file);
|
||||||
|
/*
|
||||||
gre.publishFileToWorkspace(file);
|
gre.publishFileToWorkspace(file);
|
||||||
logger.info("\n\n\n");
|
logger.info("\n\n\n");
|
||||||
file.delete();
|
file.delete();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
import org.gcube.common.resources.gcore.GenericResource;
|
import org.gcube.common.resources.gcore.GenericResource;
|
||||||
import org.gcube.informationsystem.exporter.ScopedTest;
|
import org.gcube.informationsystem.exporter.ScopedTest;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
import org.gcube.informationsystem.model.entity.resource.Configuration;
|
import org.gcube.informationsystem.model.entity.resource.Configuration;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||||
|
@ -29,12 +29,11 @@ public class GenericResourceExporterTest extends ScopedTest{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void export() {
|
public void export() {
|
||||||
GenericResourceExporter gre = new GenericResourceExporter();
|
GenericResourceExporter gre = new GenericResourceExporter(false);
|
||||||
gre.export();
|
gre.export();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeExported() throws ObjectNotFound, Exception {
|
||||||
public void del() throws ResourceRegistryException{
|
|
||||||
ResourceRegistryClient client = ResourceRegistryClientFactory.create();
|
ResourceRegistryClient client = ResourceRegistryClientFactory.create();
|
||||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||||
|
|
||||||
|
@ -42,8 +41,7 @@ public class GenericResourceExporterTest extends ScopedTest{
|
||||||
List<Configuration> configurations = (List<Configuration>) client.getInstances(Configuration.NAME, false);
|
List<Configuration> configurations = (List<Configuration>) client.getInstances(Configuration.NAME, false);
|
||||||
List<Configuration> failed = new ArrayList<>();
|
List<Configuration> failed = new ArrayList<>();
|
||||||
|
|
||||||
logger.debug("Going to delete {} {}s",
|
logger.debug("Going to delete {} {}s", configurations.size(), Configuration.NAME);
|
||||||
configurations.size(), Configuration.NAME);
|
|
||||||
|
|
||||||
int excluded = 0;
|
int excluded = 0;
|
||||||
|
|
||||||
|
@ -62,13 +60,15 @@ public class GenericResourceExporterTest extends ScopedTest{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("{} of {} ({} failures) {}s were deleted. {} {}s were excluded because there was not exported from gCore IS.",
|
logger.debug(
|
||||||
configurations.size()-failed.size()-excluded, configurations.size(), failed.size(), Configuration.NAME, excluded, Configuration.NAME);
|
"{} of {} ({} failures) {}s were deleted. {} {}s were excluded because there was not exported from gCore IS.",
|
||||||
|
configurations.size() - failed.size() - excluded, configurations.size(), failed.size(),
|
||||||
|
Configuration.NAME, excluded, Configuration.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void investigateSingleResource() throws Exception {
|
public void investigateSingleResource() throws Exception {
|
||||||
ScopedTest.setContext(ScopedTest.GCUBE);
|
//ScopedTest.setContext(ScopedTest.GCUBE_DEVSEC);
|
||||||
|
|
||||||
UUID uuid = UUID.fromString("");
|
UUID uuid = UUID.fromString("");
|
||||||
|
|
||||||
|
@ -82,30 +82,9 @@ public class GenericResourceExporterTest extends ScopedTest{
|
||||||
DiscoveryClient<GenericResource> client = ICFactory.clientFor(GenericResource.class);
|
DiscoveryClient<GenericResource> client = ICFactory.clientFor(GenericResource.class);
|
||||||
List<GenericResource> seList = client.submit(query);
|
List<GenericResource> seList = client.submit(query);
|
||||||
|
|
||||||
GenericResourceExporter see = new GenericResourceExporter();
|
GenericResourceExporter see = new GenericResourceExporter(false);
|
||||||
see.mapAndPublish(seList.get(0));
|
see.mapAndPublish(seList.get(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
|
||||||
public void addToAllScopes() throws Exception {
|
|
||||||
|
|
||||||
UUID uuid = UUID.fromString("");
|
|
||||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
|
||||||
|
|
||||||
String[] tokens = {
|
|
||||||
ScopedTest.GCUBE,
|
|
||||||
ScopedTest.GCUBE_DEVSEC,
|
|
||||||
ScopedTest.GCUBE_DEVSEC_DEVVRE,
|
|
||||||
ScopedTest.GCUBE_DEVNEXT,
|
|
||||||
ScopedTest.GCUBE_DEVNEXT_NEXTNEXT
|
|
||||||
};
|
|
||||||
|
|
||||||
for(String token : tokens){
|
|
||||||
ScopedTest.setContext(token);
|
|
||||||
publisher.addResourceToContext(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||||
import org.gcube.informationsystem.exporter.ScopedTest;
|
import org.gcube.informationsystem.exporter.ScopedTest;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
import org.gcube.informationsystem.model.entity.resource.EService;
|
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||||
|
@ -29,15 +29,14 @@ public class ServiceEndpointExporterTest extends ScopedTest{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void export(){
|
public void export(){
|
||||||
ServiceEndpointExporter see = new ServiceEndpointExporter();
|
ServiceEndpointExporter see = new ServiceEndpointExporter(false);
|
||||||
see.export();
|
see.export();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void del() throws ResourceRegistryException{
|
public void removeExported() throws ObjectNotFound, Exception{
|
||||||
ResourceRegistryClient client = ResourceRegistryClientFactory.create();
|
ResourceRegistryClient client = ResourceRegistryClientFactory.create();
|
||||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<EService> eServices = (List<EService>) client.getInstances(EService.NAME, false);
|
List<EService> eServices = (List<EService>) client.getInstances(EService.NAME, false);
|
||||||
List<EService> failed = new ArrayList<>();
|
List<EService> failed = new ArrayList<>();
|
||||||
|
@ -65,11 +64,13 @@ public class ServiceEndpointExporterTest extends ScopedTest{
|
||||||
eServices.size()-failed.size()-excluded, eServices.size(), failed.size(), EService.NAME, excluded, EService.NAME);
|
eServices.size()-failed.size()-excluded, eServices.size(), failed.size(), EService.NAME, excluded, EService.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void investigateSingleResource() throws Exception {
|
public void investigateSingleResource() throws Exception {
|
||||||
UUID uuid = UUID.fromString("66a674a2-8319-43b4-86c1-bd092bc7c490");
|
// ScopedTest.setContext(GCUBE);
|
||||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
|
||||||
publisher.addResourceToContext(uuid);
|
UUID uuid = UUID.fromString("");
|
||||||
|
//ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||||
|
//publisher.deleteResource(uuid);
|
||||||
//ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
//ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ public class ServiceEndpointExporterTest extends ScopedTest{
|
||||||
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
|
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
|
||||||
List<ServiceEndpoint> seList = client.submit(query);
|
List<ServiceEndpoint> seList = client.submit(query);
|
||||||
|
|
||||||
ServiceEndpointExporter see = new ServiceEndpointExporter();
|
ServiceEndpointExporter see = new ServiceEndpointExporter(false);
|
||||||
see.notifyFailures(seList.size(), seList);
|
see.notifyFailures(seList.size(), seList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue