56 lines
1.7 KiB
Java
56 lines
1.7 KiB
Java
|
package org.gcube.informationsystem.exporter;
|
||
|
|
||
|
import java.util.Map;
|
||
|
|
||
|
import org.gcube.common.authorization.client.Constants;
|
||
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||
|
import org.gcube.informationsystem.exporter.mapper.GenericResourceExporter;
|
||
|
import org.gcube.informationsystem.exporter.mapper.ServiceEndpointExporter;
|
||
|
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||
|
import org.slf4j.Logger;
|
||
|
import org.slf4j.LoggerFactory;
|
||
|
|
||
|
/**
|
||
|
* @author Luca Frosini (ISTI - CNR)
|
||
|
*/
|
||
|
public class ISExporterPlugin extends Plugin<ISExporterPluginDeclaration> {
|
||
|
|
||
|
/**
|
||
|
* Logger
|
||
|
*/
|
||
|
private static Logger logger = LoggerFactory.getLogger(ISExporterPlugin.class);
|
||
|
|
||
|
public ISExporterPlugin(ISExporterPluginDeclaration pluginDeclaration) {
|
||
|
super(pluginDeclaration);
|
||
|
logger.debug("contructor");
|
||
|
}
|
||
|
|
||
|
/**{@inheritDoc}*/
|
||
|
@Override
|
||
|
public void launch(Map<String, Object> inputs) throws Exception {
|
||
|
String token = SecurityTokenProvider.instance.get();
|
||
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||
|
String scope = authorizationEntry.getContext();
|
||
|
logger.debug("Launching {} execution on scope {}",
|
||
|
ISExporterPluginDeclaration.NAME, scope);
|
||
|
|
||
|
GenericResourceExporter genericResourceExporter = new GenericResourceExporter();
|
||
|
genericResourceExporter.export();
|
||
|
|
||
|
ServiceEndpointExporter serviceEndpointExporter = new ServiceEndpointExporter();
|
||
|
serviceEndpointExporter.export();
|
||
|
|
||
|
logger.debug("{} execution finished", ISExporterPluginDeclaration.NAME);
|
||
|
}
|
||
|
|
||
|
/**{@inheritDoc}*/
|
||
|
@Override
|
||
|
protected void onStop() throws Exception {
|
||
|
logger.debug("onStop()");
|
||
|
|
||
|
Thread.currentThread().interrupt();
|
||
|
}
|
||
|
|
||
|
}
|