updated plugin

This commit is contained in:
Francesco Mangiacrapa 2024-01-19 14:36:43 +01:00
parent bcb4b5d6e0
commit e724da933e
5 changed files with 116 additions and 79 deletions

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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="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="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ckan-plugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -3,16 +3,18 @@
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>
<artifactId>catalogue-binding-plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>gCube CMS - Catalogue Binding Plugin</name>
<parent>
<groupId>org.gcube.application.cms</groupId>
<artifactId>gcube-cms-suite</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</parent>
<artifactId>catalogue-binding-plugins</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>gCube CMS - Catalogue Binding Plugin</name>
<properties>
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
@ -27,13 +29,13 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>${gcube-smartgears-bom-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>${gcube-smartgears-bom-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>cms-plugin-framework</artifactId>
<version>${plugin-framework-version}</version>
@ -49,8 +51,8 @@
<groupId>org.gcube.application.cms</groupId>
<artifactId>cms-plugin-framework</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>org.gcube.application.cms</groupId>
<artifactId>default-lc-managers</artifactId>
<scope>provided</scope>

View File

@ -41,8 +41,11 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CatalogueBindingPlugin extends AbstractPlugin implements EventListenerPluginInterface {
public static final PluginDescriptor DESCRIPTOR = new PluginDescriptor(CatalogueBindingPlugin.PLUGIN_ID,
CatalogueBindingPlugin.PLUGIN_TYPE);
public static final String SUBSCRIBE_EVENTS_CONFIG = "subscribeEvents";
public static final String PLUGIN_ID = "Catalogue-Binding-Plugin";
public static final String PLUGIN_TYPE = "EventListener";
public static final PluginDescriptor DESCRIPTOR = new PluginDescriptor(PLUGIN_ID, PLUGIN_TYPE);
static {
DESCRIPTOR.setVersion(new Semver("1.0.0"));
@ -59,73 +62,12 @@ public class CatalogueBindingPlugin extends AbstractPlugin implements EventListe
return DESCRIPTOR;
}
/**
* Inits the in context.
*
* @return the initialization report
* @throws InitializationException the initialization exception
*/
@Override
@Synchronized
public InitializationReport initInContext() throws InitializationException {
InitializationReport report = new InitializationReport();
try {
String context = UserUtils.getCurrent().getContext();
if (getCatalogueBindingMapPerContext() == null) {
log.info("Initializing in " + context);
catalogueBindingMap.put(context, new EventsSubscribed());
}
report.setStatus(Report.Status.OK);
report.putMessage("Initialized " + DESCRIPTOR.getId() + " in the " + context);
} catch (Exception e) {
InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
log.error("initInContext error: {} ", exc);
throw exc;
}
return report;
}
public static final String SUBSCRIBE_EVENTS_CONFIG = "subscribeEvents";
public static final String PLUGIN_ID = "Catalogue-Binding-Plugin";
public static final String PLUGIN_TYPE = "EventListener";
/**
* Instantiates a new materialization config.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 17, 2024
*/
/**
* Instantiates a new subscribe events config.
*/
/**
* Instantiates a new subscribe events config.
*/
@Data
public static class SubscribeEventsConfig {
public class SubscribeEventsConfig {
private String event;
}
protected Map<String, EventsSubscribed> catalogueBindingMap = null;
/**
* Gets the catalogue binding map per context.
*
* @return the catalogue binding map per context
*/
protected EventsSubscribed getCatalogueBindingMapPerContext() {
String context = UserUtils.getCurrent().getContext();
log.debug("Getting {} from cache map for context {}", CatalogueBindingPlugin.PLUGIN_ID, context);
if (catalogueBindingMap == null)
catalogueBindingMap = new LinkedHashMap<String, EventsSubscribed>();
return catalogueBindingMap.get(context);
}
/**
* Inits the.
*
@ -211,6 +153,48 @@ public class CatalogueBindingPlugin extends AbstractPlugin implements EventListe
}
/**
* Inits the in context.
*
* @return the initialization report
* @throws InitializationException the initialization exception
*/
@Override
@Synchronized
public InitializationReport initInContext() throws InitializationException {
InitializationReport report = new InitializationReport();
try {
String context = UserUtils.getCurrent().getContext();
if (getCatalogueBindingMapPerContext() == null) {
log.info("Initializing in " + context);
catalogueBindingMap.put(context, new EventsSubscribed());
}
report.setStatus(Report.Status.OK);
report.putMessage("Initialized " + DESCRIPTOR.getId() + " in the " + context);
} catch (Exception e) {
InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
log.error("initInContext error: {} ", exc);
throw exc;
}
return report;
}
protected Map<String, EventsSubscribed> catalogueBindingMap = null;
/**
* Gets the catalogue binding map per context.
*
* @return the catalogue binding map per context
*/
protected EventsSubscribed getCatalogueBindingMapPerContext() {
String context = UserUtils.getCurrent().getContext();
log.debug("Getting {} from cache map for context {}", CatalogueBindingPlugin.PLUGIN_ID, context);
if (catalogueBindingMap == null)
catalogueBindingMap = new LinkedHashMap<String, EventsSubscribed>();
return catalogueBindingMap.get(context);
}
/**
* Read events subscribed from configuration in the UCD.
*

View File

@ -29,7 +29,7 @@ public class PluginsReflections {
log.debug("Evaluating class {}",pluginClass);
if(!pluginClass.isInterface() && !Modifier.isAbstract(pluginClass.getModifiers())){
try {
log.debug("\nFound implementation {} ",pluginClass);
log.debug("Found implementation {} ",pluginClass);
Plugin plugin = pluginClass.newInstance();
log.debug("Loading {} description : {}", plugin, plugin.getDescriptor());