ref 8819: Extend The Algorithms Importer to Manage Many Processes as Black Boxes

https://support.d4science.org/issues/8819

Updated the support for Processes as Black Boxes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@151117 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-17 16:39:42 +00:00
parent 002a0dc151
commit 0cab752a72
23 changed files with 711 additions and 115 deletions

View File

@ -0,0 +1,70 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.MonitorDeployOperationEvent.MonitorDeployOperationEventHandler;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import com.google.gwt.user.client.Timer;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class MonitorDeployOperation {
private Timer monitor = null;
private MonitorDeployOperationEventHandler handler;
public MonitorDeployOperation() {
monitor = new Timer() {
public void run() {
executeCommand();
}
};
}
private void stopMonitor() {
if (monitor.isRunning()) {
monitor.cancel();
}
}
private void executeCommand() {
MonitorDeployOperationEvent event = new MonitorDeployOperationEvent();
handler.onMonitor(event);
}
public void addHandler(MonitorDeployOperationEventHandler handler) {
this.handler = handler;
}
public void start() {
startSchedule();
}
private void startSchedule() {
// Execute the timer to expire 2 seconds in the future
monitor.schedule(Constants.CLIENT_MONITOR_PERIODMILLIS);
}
public void repeat() {
monitor.schedule(Constants.CLIENT_MONITOR_PERIODMILLIS);
}
public void stop() {
stopMonitor();
}
}

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class MonitorDeployOperationEvent
extends GwtEvent<MonitorDeployOperationEvent.MonitorDeployOperationEventHandler> {
public static Type<MonitorDeployOperationEventHandler> TYPE = new Type<MonitorDeployOperationEventHandler>();
public interface MonitorDeployOperationEventHandler extends EventHandler {
void onMonitor(MonitorDeployOperationEvent event);
}
public interface HasMonitorDeployOperationEventHandler extends HasHandlers {
public HandlerRegistration addMonitorDeployOperationEventHandler(MonitorDeployOperationEventHandler handler);
}
public MonitorDeployOperationEvent() {
}
@Override
protected void dispatch(MonitorDeployOperationEventHandler handler) {
handler.onMonitor(this);
}
@Override
public Type<MonitorDeployOperationEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<MonitorDeployOperationEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, MonitorDeployOperationEvent event) {
source.fireEvent(event);
}
@Override
public String toString() {
return "MonitorDeployOperationEvent []";
}
}

View File

@ -9,6 +9,9 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewCod
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.WorkAreaEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.MonitorDeployOperation;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.MonitorDeployOperationEvent;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.MonitorDeployOperationEvent.MonitorDeployOperationEventHandler;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
@ -548,17 +551,13 @@ public class ProjectManager {
});
}
public void setBinaryCode(final InputData inputData,final ItemDescription itemDescription) {
public void setBinaryCode(final InputData inputData, final ItemDescription itemDescription) {
if (project != null) {
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null
&& (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox
||project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit)) {
saveInputDataForBinarySet(inputData,itemDescription);
|| project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit)) {
saveInputDataForBinarySet(inputData, itemDescription);
}
} else {
@ -643,27 +642,26 @@ public class ProjectManager {
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete", "Would you like to delete this resource?");
mb.addDialogHideHandler(new DialogHideHandler() {
@Override
public void onDialogHide(DialogHideEvent event) {
switch (event.getHideButton()) {
case NO:
break;
case YES:
deleteItemOnServer(itemDescription, false);
break;
default:
break;
}
}
});
mb.setWidth(300);
mb.show();
@Override
public void onDialogHide(DialogHideEvent event) {
switch (event.getHideButton()) {
case NO:
break;
case YES:
deleteItemOnServer(itemDescription, false);
break;
default:
break;
}
}
});mb.setWidth(300);mb.show();
}
}
private void deleteItemOnServer(ItemDescription itemDescription, final boolean mainCode) {
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
@ -778,9 +776,10 @@ public class ProjectManager {
}
// TODO
private void softwarePublishOnServer() {
final StatAlgoImporterMonitor monitor = new StatAlgoImporterMonitor();
StatAlgoImporterServiceAsync.INSTANCE.publishSoftware(new AsyncCallback<Void>() {
StatAlgoImporterServiceAsync.INSTANCE.publishSoftware(new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
monitor.hide();
@ -793,15 +792,121 @@ public class ProjectManager {
}
}
public void onSuccess(Void result) {
monitor.hide();
UtilsGXT3.info("Publish", "The software has been published!");
fireProjectStatusSoftwarePublishEvent();
public void onSuccess(String operationId) {
Log.debug("Publish result: " + operationId);
if (saiDescriptor != null && saiDescriptor.getPoolManagerConfig() != null
&& saiDescriptor.getPoolManagerConfig().isEnable()) {
if (operationId != null && !operationId.isEmpty()) {
monitorOperationDeployStatus(operationId, monitor);
} else {
monitor.hide();
Log.info(
"Publish, the software has been published, but no autodeploy on server is enable so some time is required for installation by administrators!");
UtilsGXT3.info("Publish", "The software has been published!");
fireProjectStatusSoftwarePublishEvent();
}
} else {
monitor.hide();
UtilsGXT3.info("Publish", "The software has been published!");
fireProjectStatusSoftwarePublishEvent();
}
}
});
}
// TODO
private void monitorOperationDeployStatus(final String operationId, final StatAlgoImporterMonitor monitor) {
final MonitorDeployOperation monitorDeployOperation = new MonitorDeployOperation();
MonitorDeployOperationEventHandler handler = new MonitorDeployOperationEventHandler() {
@Override
public void onMonitor(MonitorDeployOperationEvent event) {
StatAlgoImporterServiceAsync.INSTANCE.getDeployOperationStatus(operationId, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
monitorDeployOperation.stop();
monitor.hide();
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
fireProjectStatusExplorerRefreshEvent();
}
}
public void onSuccess(String deployOperationStatus) {
Log.debug("Deploy Operation Status: " + deployOperationStatus);
if(deployOperationStatus==null){
monitorDeployOperation.repeat();
}
switch(deployOperationStatus){
case "COMPLETED":
monitorDeployOperation.stop();
monitor.hide();
UtilsGXT3.info("Publish", "The software has been published!");
fireProjectStatusSoftwarePublishEvent();
break;
case "FAILED":
monitorDeployOperation.stop();
retrieveOperationDeployLogs(operationId, monitor);
break;
case "INPROGRESS":
monitorDeployOperation.repeat();
break;
default:
monitorDeployOperation.repeat();
break;
}
}
});
}
};
monitorDeployOperation.addHandler(handler);
monitorDeployOperation.start();
}
private void retrieveOperationDeployLogs(final String operationId, final StatAlgoImporterMonitor monitor) {
StatAlgoImporterServiceAsync.INSTANCE.getDeployOperationLogs(operationId, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
monitor.hide();
if (caught instanceof StatAlgoImporterSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
fireProjectStatusExplorerRefreshEvent();
}
}
public void onSuccess(String logs) {
Log.debug("Deploy Operation Logs: " + logs);
monitor.hide();
UtilsGXT3.alert("Error", "Error deploying the algorithm: "+logs);
fireProjectStatusExplorerRefreshEvent();
}
});
}
public void startProjectManager() {
retrieveSAIDescriptor(null);
}

View File

@ -78,8 +78,12 @@ public interface StatAlgoImporterService extends RemoteService {
public Project setNewCode(ItemDescription itemDescription, String code) throws StatAlgoImporterServiceException;
public void publishSoftware() throws StatAlgoImporterServiceException;
public String publishSoftware() throws StatAlgoImporterServiceException;
public String getDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException;
public String getDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException;
public void repackageSoftware() throws StatAlgoImporterServiceException;

View File

@ -60,10 +60,14 @@ public interface StatAlgoImporterServiceAsync {
void restoreUISession(String value, AsyncCallback<Project> asyncCallback);
void publishSoftware(AsyncCallback<Void> asyncCallback);
void publishSoftware(AsyncCallback<String> asyncCallback);
void repackageSoftware(AsyncCallback<Void> asyncCallback);
void getDeployOperationStatus(String operationId, AsyncCallback<String> callback);
void getDeployOperationLogs(String operationId, AsyncCallback<String> callback);

View File

@ -15,6 +15,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFil
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.SAIDescriptor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
@ -204,7 +205,23 @@ public class SessionUtil {
return recipients;
}
//
public static SAIDescriptor getSAIDescriptor(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws Exception {
SessionOp<SAIDescriptor> sessionOp = new SessionOp<>();
SAIDescriptor saiDescriptor = sessionOp.get(httpRequest, serviceCredentials,
SessionConstants.SAI_DESCRIPTOR, SAIDescriptor.class);
return saiDescriptor;
}
public static void setSAIDescriptor(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
SAIDescriptor saiDescriptor) {
SessionOp<SAIDescriptor> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials, SessionConstants.SAI_DESCRIPTOR, saiDescriptor);
}
//
public static FileUploadMonitor getFileUploadMonitor(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws Exception {

View File

@ -15,8 +15,10 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeRea
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectBuilder;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectDeploy;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.BuildSAIDescriptor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.poolmanager.DataMinerPoolManager;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.CodeSave;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.DeploySave;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.ProjectArchiver;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
@ -128,6 +130,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getSAIDescriptor()");
SAIDescriptor saiDescriptor = BuildSAIDescriptor.build(serviceCredentials.getScope());
SessionUtil.setSAIDescriptor(httpRequest, serviceCredentials, saiDescriptor);
return saiDescriptor;
} catch (StatAlgoImporterServiceException e) {
@ -285,14 +288,15 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
logger.debug("openProjectOnWorkspace()");
Project project = ProjectArchiver.readProject(newProjectFolder, serviceCredentials);
if(project!=null){
if(project.getProjectConfig()==null){
project.setProjectConfig(new ProjectConfig(ProjectLanguageType.R.getId(), new ProjectSupportREdit()));
} else{
if (project != null) {
if (project.getProjectConfig() == null) {
project.setProjectConfig(
new ProjectConfig(ProjectLanguageType.R.getId(), new ProjectSupportREdit()));
} else {
}
}
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
return project;
@ -583,8 +587,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
}
@Override
public Project setNewCode(ItemDescription fileDescription, String code)
throws StatAlgoImporterServiceException {
public Project setNewCode(ItemDescription fileDescription, String code) throws StatAlgoImporterServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
@ -596,8 +599,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportREdit) {
CodeSave codeSave = new CodeSave();
ItemDescription mainCodeItemDescription = codeSave.saveNew(serviceCredentials,
fileDescription, code, project.getProjectFolder().getFolder().getId());
ItemDescription mainCodeItemDescription = codeSave.saveNew(serviceCredentials, fileDescription,
code, project.getProjectFolder().getFolder().getId());
MainCode mainCode = new MainCode(mainCodeItemDescription);
project.setMainCode(mainCode);
project.setInputData(null);
@ -608,7 +611,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) {
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project
.getProjectConfig().getProjectSupport();
CodeSave codeSave = new CodeSave();
ItemDescription binaryCodeItemDescription = codeSave.saveNew(serviceCredentials,
fileDescription, code, project.getProjectFolder().getFolder().getId());
@ -622,7 +625,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
} else {
throw new StatAlgoImporterServiceException("Error in project configuration!");
}
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
return project;
} else {
@ -650,7 +653,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
if (project != null) {
project.setInputData(inputData);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
SAIDescriptor saiDescriptor = SessionUtil.getSAIDescriptor(httpRequest, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials,saiDescriptor);
project = projectBuilder.buildTarget();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);
@ -692,7 +696,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
}
@Override
public void publishSoftware() throws StatAlgoImporterServiceException {
public String publishSoftware() throws StatAlgoImporterServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
@ -700,18 +704,31 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
ArrayList<Recipient> recipients = SessionUtil.getRecipients(httpRequest.getServletContext());
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) {
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
SAIDescriptor saiDescriptor = SessionUtil.getSAIDescriptor(httpRequest, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials, saiDescriptor);
project = projectBuilder.buildDeploy();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);
ProjectDeploy projectDeploy=new ProjectDeploy(httpRequest, serviceCredentials, project, recipients);
projectDeploy.deploy();
ProjectDeploy projectDeploy = new ProjectDeploy(httpRequest, serviceCredentials, project, recipients);
DeploySave deploySave = projectDeploy.deploy();
if (saiDescriptor != null && saiDescriptor.getPoolManagerConfig() != null
&& saiDescriptor.getPoolManagerConfig().isEnable()) {
logger.info("Deploy On PoolManager");
logger.debug("CodeJarAdminCopy for PoolManager: " + deploySave.getCodeJarAdminCopy());
DataMinerPoolManager poolManager = new DataMinerPoolManager(serviceCredentials);
String operationId = poolManager.deployAlgorithm(deploySave.getInfoData(),
deploySave.getCodeJarAdminCopy());
logger.info("Deploy operationId: " + operationId);
return operationId;
} else {
logger.info("Deploy On PoolManager disabled");
return null;
}
} else {
throw new StatAlgoImporterServiceException(
"The software was not created correctly try to recreate it!");
}
return;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
throw e;
@ -731,7 +748,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
logger.debug("RepackageSoftware()");
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) {
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials);
SAIDescriptor saiDescriptor = SessionUtil.getSAIDescriptor(httpRequest, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials,saiDescriptor);
project = projectBuilder.buildRepackage();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);
@ -741,7 +759,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
return;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
logger.error("repackageSoftware(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("repackageSoftware(): " + e.getLocalizedMessage(), e);
@ -751,4 +769,46 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
}
@Override
public String getDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getDeployOperationStatus(): OperationId=" + operationId);
DataMinerPoolManager poolManager = new DataMinerPoolManager(serviceCredentials);
String deployOperationStatus = poolManager.getDeployOperationStatus(operationId);
logger.debug("Deploy Operation Status: " + deployOperationStatus);
return deployOperationStatus;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
throw e;
} catch (Throwable e) {
logger.error("getDeployOperationStatus(): " + e.getLocalizedMessage(), e);
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
@Override
public String getDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getDeployOperationLogs(): OperationId=" + operationId);
DataMinerPoolManager poolManager = new DataMinerPoolManager(serviceCredentials);
String deployOperationLogsLink = poolManager.getDeployOperationLogsLink(operationId);
logger.debug("Deploy Operation Logs Link: " + deployOperationLogsLink);
return deployOperationLogsLink;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
throw e;
} catch (Throwable e) {
logger.error("getDeployOperationLogs(): " + e.getLocalizedMessage(), e);
e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
}

View File

@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
public class GeneralPurposeScriptProducer {
private static final Logger logger = LoggerFactory.getLogger(GeneralPurposeScriptProducer.class);
public static final String REMOTE_TEMPLATE_FILE = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R";
private String remoteTemplateFile;
// name,type,default
@ -36,6 +36,10 @@ public class GeneralPurposeScriptProducer {
}
}
public GeneralPurposeScriptProducer(String remoteTemplateFile){
this.remoteTemplateFile=remoteTemplateFile;
}
public String URLReader(String urlToTemplate) throws Exception {
URL remoteFile = new URL(urlToTemplate);
BufferedReader in = new BufferedReader(new InputStreamReader(remoteFile.openStream()));
@ -68,7 +72,7 @@ public class GeneralPurposeScriptProducer {
String processInvocation = generateExternalProcessInvokation(mainSoftwareName, input);
String outputDeclaration = generateOutputStrings(output);
String fileExistenceChecks = generateFileExistenceCheck(output);
String script = URLReader(REMOTE_TEMPLATE_FILE);
String script = URLReader(remoteTemplateFile);
script = script.replace("#INPUT_DECLARATION#", inputDeclaration);
script = script.replace("#PROCESS_COMPOSITION#", processInvocation);

View File

@ -33,8 +33,9 @@ public class MainGenerator {
private static final Logger logger = LoggerFactory.getLogger(MainGenerator.class);
private static final String R_MIMETYPE = "text/plain";
private static final String R_DESCRIPTION = "R script for ";
public void createMain(ServiceCredentials serviceCredentials, Project project)
public void createMain(ServiceCredentials serviceCredentials, Project project, String remoteTemplateFile)
throws StatAlgoImporterServiceException {
logger.debug("Project: " + project);
@ -52,7 +53,7 @@ public class MainGenerator {
logger.debug("Language: " + project.getProjectConfig().getLanguage());
logger.debug("Binary software: " + binarySoftware);
GeneralPurposeScriptProducer s = new GeneralPurposeScriptProducer();
GeneralPurposeScriptProducer s = new GeneralPurposeScriptProducer(remoteTemplateFile);
List<GeneralPurposeScriptProducer.Triple> input = new ArrayList<>();
List<GeneralPurposeScriptProducer.Triple> output = new ArrayList<>();

View File

@ -21,6 +21,8 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.blackbox.MainGenerator;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.SAIDescriptor;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectCompile;
@ -77,12 +79,14 @@ public class ProjectBuilder {
private Project project;
private String backupFolderId;
private ServiceCredentials serviceCredentials;
private SAIDescriptor saiDescriptor;
private Path algorithmJava;
private Path infoTXT;
public ProjectBuilder(Project project, ServiceCredentials serviceCredentials) {
public ProjectBuilder(Project project, ServiceCredentials serviceCredentials, SAIDescriptor saiDescriptor) {
this.project = project;
this.serviceCredentials = serviceCredentials;
this.saiDescriptor = saiDescriptor;
}
public Project buildTarget() throws StatAlgoImporterServiceException {
@ -134,8 +138,8 @@ public class ProjectBuilder {
private void createMainCodeIfRequest() throws StatAlgoImporterServiceException {
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null
&& (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox||
project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit)) {
&& (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox
|| project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit)) {
if (project.getMainCode() != null && project.getMainCode().getItemDescription() != null) {
ItemDescription mainCodeItemDescription = project.getMainCode().getItemDescription();
if (mainCodeItemDescription.getId() != null && !mainCodeItemDescription.getId().isEmpty()) {
@ -144,7 +148,12 @@ public class ProjectBuilder {
}
}
MainGenerator mainGenerator = new MainGenerator();
mainGenerator.createMain(serviceCredentials, project);
if (saiDescriptor != null && saiDescriptor.getRemoteTemplateFile() != null
&& !saiDescriptor.getRemoteTemplateFile().isEmpty()) {
mainGenerator.createMain(serviceCredentials, project, saiDescriptor.getRemoteTemplateFile());
} else {
mainGenerator.createMain(serviceCredentials, project, Constants.REMOTE_TEMPLATE_FILE);
}
}
}
@ -418,8 +427,8 @@ public class ProjectBuilder {
}
} else {
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) {
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project.getProjectConfig()
.getProjectSupport();
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project
.getProjectConfig().getProjectSupport();
if (projectSupportBashEdit.getBinaryItem() == null) {
throw new StatAlgoImporterServiceException("Attention No Code Set");

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.poolmanager.DataMinerPoolManager;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.AlgorithmNotification;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.DeploySave;
@ -38,21 +37,16 @@ public class ProjectDeploy {
}
public void deploy() throws StatAlgoImporterServiceException{
InfoGenerator infoGenerator=new InfoGenerator(project, serviceCredentials);
InfoData infoData=infoGenerator.readInfo();
public DeploySave deploy() throws StatAlgoImporterServiceException {
logger.debug("ProjectDeploy deploy()");
InfoGenerator infoGenerator = new InfoGenerator(project, serviceCredentials);
InfoData infoData = infoGenerator.readInfo();
logger.debug("Deploy Save");
DeploySave deploySave=new DeploySave(serviceCredentials, project, infoData);
DeploySave deploySave = new DeploySave(serviceCredentials, project, infoData);
deploySave.save();
logger.debug("Send notify");
sendNotify(deploySave.getInfoText());
logger.debug("CodeJarAdminCopy for PoolManager: "+deploySave.getCodeJarAdminCopy());
DataMinerPoolManager poolManager=new DataMinerPoolManager(serviceCredentials);
String operationId=poolManager.deployAlgorithm(infoData, deploySave.getCodeJarAdminCopy());
logger.debug("Deploy operationId: "+operationId);
String deployStatus=poolManager.monitorAlgorithmDeploy(operationId);
logger.debug("Deploy status: "+deployStatus);
return deploySave;
}
private void sendNotify(String body) {

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server.is;
import java.util.ArrayList;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.PoolManagerConfig;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.ProjectLanguageType;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.ProjectSetup;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.ProjectSupportType;
@ -26,26 +27,34 @@ public class BuildSAIDescriptor {
if (Constants.DEBUG_MODE) {
logger.info("Debug Mode");
PoolManagerConfig poolManagerConfig = new PoolManagerConfig(false);
ArrayList<ProjectSetup> availableProjectConfigurations = new ArrayList<>();
ProjectSetup r = new ProjectSetup(ProjectLanguageType.R.getId(), ProjectSupportType.REDIT);
availableProjectConfigurations.add(r);
ProjectSetup rBlackBox = new ProjectSetup(ProjectLanguageType.R_BLACKBOX.getId(), ProjectSupportType.BLACKBOX);
ProjectSetup rBlackBox = new ProjectSetup(ProjectLanguageType.R_BLACKBOX.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(rBlackBox);
ProjectSetup java = new ProjectSetup(ProjectLanguageType.JAVA.getId(), ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(java);
ProjectSetup knimeWorkflow = new ProjectSetup(ProjectLanguageType.KNIME_WORKFLOW.getId(), ProjectSupportType.BLACKBOX);
ProjectSetup knimeWorkflow = new ProjectSetup(ProjectLanguageType.KNIME_WORKFLOW.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(knimeWorkflow);
ProjectSetup linuxCompiled = new ProjectSetup(ProjectLanguageType.LINUX_COMPILED.getId(), ProjectSupportType.BLACKBOX);
ProjectSetup linuxCompiled = new ProjectSetup(ProjectLanguageType.LINUX_COMPILED.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(linuxCompiled);
ProjectSetup octave = new ProjectSetup(ProjectLanguageType.OCTAVE.getId(), ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(octave);
ProjectSetup python = new ProjectSetup(ProjectLanguageType.PYTHON.getId(), ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(python);
ProjectSetup windowsCompiled = new ProjectSetup(ProjectLanguageType.WINDOWS_COMPILED.getId(), ProjectSupportType.BLACKBOX);
ProjectSetup windowsCompiled = new ProjectSetup(ProjectLanguageType.WINDOWS_COMPILED.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(windowsCompiled);
ProjectSetup preInstalled = new ProjectSetup(ProjectLanguageType.PRE_INSTALLED.getId(), ProjectSupportType.BASHEDIT);
ProjectSetup preInstalled = new ProjectSetup(ProjectLanguageType.PRE_INSTALLED.getId(),
ProjectSupportType.BASHEDIT);
availableProjectConfigurations.add(preInstalled);
saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
saiDescriptor = new SAIDescriptor(poolManagerConfig, Constants.REMOTE_TEMPLATE_FILE,
availableProjectConfigurations);
} else {
logger.info("Production Mode");
SAIDescriptorJAXB saiDescriptorJAXB = null;
@ -54,27 +63,77 @@ public class BuildSAIDescriptor {
} catch (StatAlgoImporterServiceException e) {
logger.info(e.getLocalizedMessage());
}
PoolManagerConfig poolManagerConfig;
String remoteTemplateFile;
ArrayList<ProjectSetup> availableProjectConfigurations = new ArrayList<>();
logger.debug("SAIDescriptorJAXB: " + saiDescriptorJAXB);
if (saiDescriptorJAXB != null && saiDescriptorJAXB.getAvailableprojectconfiguration() != null
&& !saiDescriptorJAXB.getAvailableprojectconfiguration().isEmpty()) {
ProjectSupportType type;
for (AvailableProjectConfigJAXB availableProjectConfigJAXB : saiDescriptorJAXB
.getAvailableprojectconfiguration()) {
type = ProjectSupportType.valueFromLabel(availableProjectConfigJAXB.getSupport());
if (type != null) {
availableProjectConfigurations
.add(new ProjectSetup(availableProjectConfigJAXB.getLanguage(), type));
}
if (saiDescriptorJAXB != null) {
if (saiDescriptorJAXB.getPoolmanager() != null) {
PoolManagerJAXB poolManagerJAXB = saiDescriptorJAXB.getPoolmanager();
poolManagerConfig = new PoolManagerConfig(poolManagerJAXB.isEnable());
} else {
logger.info("PoolManager disabled for scope: " + scope);
poolManagerConfig = new PoolManagerConfig(false);
}
if(saiDescriptorJAXB.getRemotetemplatefile()!=null&&!saiDescriptorJAXB.getRemotetemplatefile().isEmpty()){
remoteTemplateFile = saiDescriptorJAXB.getRemotetemplatefile();
} else {
remoteTemplateFile = Constants.REMOTE_TEMPLATE_FILE;
}
if (saiDescriptorJAXB.getAvailableprojectconfiguration() != null
&& !saiDescriptorJAXB.getAvailableprojectconfiguration().isEmpty()) {
ProjectSupportType type;
for (AvailableProjectConfigJAXB availableProjectConfigJAXB : saiDescriptorJAXB
.getAvailableprojectconfiguration()) {
type = ProjectSupportType.valueFromLabel(availableProjectConfigJAXB.getSupport());
if (type != null) {
availableProjectConfigurations
.add(new ProjectSetup(availableProjectConfigJAXB.getLanguage(), type));
}
}
} else {
logger.info("Available Project Configuration use default configuration, scope: " + scope);
ProjectSetup r = new ProjectSetup(ProjectLanguageType.R.getId(), ProjectSupportType.REDIT);
availableProjectConfigurations.add(r);
ProjectSetup rBlackBox = new ProjectSetup(ProjectLanguageType.R_BLACKBOX.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(rBlackBox);
ProjectSetup java = new ProjectSetup(ProjectLanguageType.JAVA.getId(), ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(java);
ProjectSetup knimeWorkflow = new ProjectSetup(ProjectLanguageType.KNIME_WORKFLOW.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(knimeWorkflow);
ProjectSetup linuxCompiled = new ProjectSetup(ProjectLanguageType.LINUX_COMPILED.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(linuxCompiled);
ProjectSetup octave = new ProjectSetup(ProjectLanguageType.OCTAVE.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(octave);
ProjectSetup python = new ProjectSetup(ProjectLanguageType.PYTHON.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(python);
ProjectSetup windowsCompiled = new ProjectSetup(ProjectLanguageType.WINDOWS_COMPILED.getId(),
ProjectSupportType.BLACKBOX);
availableProjectConfigurations.add(windowsCompiled);
ProjectSetup preInstalled = new ProjectSetup(ProjectLanguageType.PRE_INSTALLED.getId(),
ProjectSupportType.BASHEDIT);
availableProjectConfigurations.add(preInstalled);
}
} else {
logger.info("Production Mode Default");
logger.info("SAIDescriptorJAXB use default configuration for scope: " + scope);
poolManagerConfig = new PoolManagerConfig(false);
remoteTemplateFile = Constants.REMOTE_TEMPLATE_FILE;
ProjectSetup r = new ProjectSetup(ProjectLanguageType.R.getId(), ProjectSupportType.REDIT);
availableProjectConfigurations.add(r);
ProjectSetup rBlackBox = new ProjectSetup(ProjectLanguageType.R_BLACKBOX.getId(),
@ -101,7 +160,7 @@ public class BuildSAIDescriptor {
}
saiDescriptor = new SAIDescriptor(availableProjectConfigurations);
saiDescriptor = new SAIDescriptor(poolManagerConfig, remoteTemplateFile, availableProjectConfigurations);
}

View File

@ -0,0 +1,35 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.server.is;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Giancarlo Panichi
*
*
*/
@XmlRootElement(name = "poolmanager")
@XmlAccessorType(XmlAccessType.FIELD)
public class PoolManagerJAXB {
@XmlElement(name = "enable")
private boolean enable;
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
@Override
public String toString() {
return "PoolManagerJAXB [enable=" + enable + "]";
}
}

View File

@ -19,9 +19,31 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class SAIDescriptorJAXB {
@XmlElement(name = "poolmanager")
private PoolManagerJAXB poolmanager;
@XmlElement(name = "remotetemplatefile")
private String remotetemplatefile;
@XmlElement(name = "availableprojectconfiguration")
private List<AvailableProjectConfigJAXB> availableprojectconfiguration = new ArrayList<>();
public PoolManagerJAXB getPoolmanager() {
return poolmanager;
}
public void setPoolmanager(PoolManagerJAXB poolmanager) {
this.poolmanager = poolmanager;
}
public String getRemotetemplatefile() {
return remotetemplatefile;
}
public void setRemotetemplatefile(String remotetemplatefile) {
this.remotetemplatefile = remotetemplatefile;
}
public List<AvailableProjectConfigJAXB> getAvailableprojectconfiguration() {
return availableprojectconfiguration;
}
@ -32,7 +54,8 @@ public class SAIDescriptorJAXB {
@Override
public String toString() {
return "SAIDescriptorJAXB [availableprojectconfiguration=" + availableprojectconfiguration + "]";
return "SAIDescriptorJAXB [poolmanager=" + poolmanager + ", remotetemplatefile=" + remotetemplatefile
+ ", availableprojectconfiguration=" + availableprojectconfiguration + "]";
}
}

View File

@ -26,27 +26,35 @@ public class DataMinerPoolManager {
private static Logger logger = LoggerFactory.getLogger(DataMinerPoolManager.class);
private String serverUrl;
private ServiceCredentials serviceCredentials;
public DataMinerPoolManager(ServiceCredentials serviceCredentials) throws StatAlgoImporterServiceException {
this.serviceCredentials=serviceCredentials;
this.serviceCredentials = serviceCredentials;
serverUrl = InformationSystemUtils.retrieveDataMinerPoolManager(serviceCredentials.getScope());
}
public String deployAlgorithm(InfoData infoData,
ItemDescription codeJarAdminCopy) throws StatAlgoImporterServiceException {
String operationId = sendRequest(infoData, codeJarAdminCopy, serverUrl);
public String deployAlgorithm(InfoData infoData, ItemDescription codeJarAdminCopy)
throws StatAlgoImporterServiceException {
String operationId = sendRequest(infoData, codeJarAdminCopy);
return operationId;
}
public String monitorAlgorithmDeploy(String operationId) throws StatAlgoImporterServiceException {
String deployStatus = deployStatus(serverUrl, operationId);
public String getDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException {
String logs = retrieveDeployOperationLogs(operationId);
return logs;
}
public String getDeployOperationLogsLink(String operationId) throws StatAlgoImporterServiceException {
String logsLink = retrieveDeployOperationLogsLink(operationId);
return logsLink;
}
public String getDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException {
String deployStatus = retrieveDeployOperationStatus(operationId);
return deployStatus;
}
private String sendRequest(InfoData infoData,
ItemDescription codeJarAdminCopy, String serverUrl) throws StatAlgoImporterServiceException {
private String sendRequest(InfoData infoData, ItemDescription codeJarAdminCopy)
throws StatAlgoImporterServiceException {
logger.info("Send request to DataMinerPoolManager: " + serverUrl);
/*
* http://node2-d-d4s.d4science.org:8080/dataminer-pool-manager-2.0.0-
@ -103,18 +111,17 @@ public class DataMinerPoolManager {
}
}
private String deployStatus(String serverUrl, String operationId)
throws StatAlgoImporterServiceException {
private String retrieveDeployOperationStatus(String operationId) throws StatAlgoImporterServiceException {
logger.info("Send monitor request to DataMinerPoolManager: " + serverUrl);
/*
*
* http://node2-d-d4s.d4science.org:8080/dataminer-pool-manager-2.0.0-
* SNAPSHOT/api/log?
* gcube-token=708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548
* &logUrl=426c8e35-a624-4710-b612-c90929c32c27
* SNAPSHOT/api/monitor? gcube-token=.... &logUrl=opId
*
*/
try {
String requestUrl = serverUrl + "/log?gcube-token=" + serviceCredentials.getToken() + "&logUrl="
String requestUrl = serverUrl + "/monitor?gcube-token=" + serviceCredentials.getToken() + "&logUrl="
+ operationId;
logger.debug("DataMinerPoolManager monitor request=" + requestUrl);
@ -152,4 +159,65 @@ public class DataMinerPoolManager {
}
private String retrieveDeployOperationLogs(String operationId) throws StatAlgoImporterServiceException {
logger.info("Send logs info request to DataMinerPoolManager: " + serverUrl);
/*
* http://node2-d-d4s.d4science.org:8080/dataminer-pool-manager-2.0.0-
* SNAPSHOT/api/log?
* gcube-token=708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548
* &logUrl=426c8e35-a624-4710-b612-c90929c32c27
*/
try {
String requestUrl = serverUrl + "/log?gcube-token=" + serviceCredentials.getToken() + "&logUrl="
+ operationId;
logger.debug("DataMinerPoolManager logs request=" + requestUrl);
URL urlObj = new URL(requestUrl);
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
InputStream is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null;
StringBuffer operationStatus = new StringBuffer();
logger.info("DataMinerPoolManager response: ");
while ((line = reader.readLine()) != null) {
logger.info(line);
operationStatus.append(line);
}
return operationStatus.toString();
} catch (MalformedURLException e) {
logger.error("DataMinerPoolManager problem retrieving operation logs URL seems to be invalid: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(
"DataMinerPoolManager problem retrieving operation logs URL seems to be invalid: "
+ e.getLocalizedMessage(),
e);
} catch (IOException e) {
logger.error("DataMinerPoolManager problem retrieving operation logs: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(
"DataMinerPoolManager problem retrieving operation logs: " + e.getLocalizedMessage(), e);
} catch (Throwable e) {
logger.error("DataMinerPoolManager error occured retrieving operation logs: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(
"DataMinerPoolManager error occured retrieving operation logs: " + e.getLocalizedMessage(), e);
}
}
private String retrieveDeployOperationLogsLink(String operationId) throws StatAlgoImporterServiceException {
logger.info("Retrieve deploy operation logs link for: [operationId="+operationId+", server=" + serverUrl+"]");
String requestUrl = serverUrl + "/log?gcube-token=" + serviceCredentials.getToken() + "&logUrl=" + operationId;
logger.debug("DataMinerPoolManager monitor request=" + requestUrl);
return requestUrl;
}
}

View File

@ -122,6 +122,11 @@ public class DeploySave {
return codeJarAdminCopy;
}
public InfoData getInfoData() {
return infoData;
}
}

View File

@ -42,5 +42,8 @@ public class Constants {
public static final String PRE_INSTALLED = "Pre-Installed";
public static final String REMOTE_TEMPLATE_FILE = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R";
// DataMiner Pool Manager
public static final int CLIENT_MONITOR_PERIODMILLIS = 2000;
}

View File

@ -0,0 +1,38 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class PoolManagerConfig implements Serializable {
private static final long serialVersionUID = 5010071163308091807L;
private boolean enable;
public PoolManagerConfig() {
}
public PoolManagerConfig(boolean enable) {
super();
this.enable = enable;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
@Override
public String toString() {
return "PoolManagerConfig [enable=" + enable + "]";
}
}

View File

@ -12,18 +12,39 @@ import java.util.ArrayList;
public class SAIDescriptor implements Serializable {
private static final long serialVersionUID = 8083363401840308985L;
private PoolManagerConfig poolManagerConfig;
private String remoteTemplateFile;
private ArrayList<ProjectSetup> availableProjectConfigurations;
public SAIDescriptor() {
super();
}
public SAIDescriptor(ArrayList<ProjectSetup> availableProjectConfigurations) {
public SAIDescriptor(PoolManagerConfig poolManagerConfig, String remoteTemplateFile,
ArrayList<ProjectSetup> availableProjectConfigurations) {
super();
this.poolManagerConfig = poolManagerConfig;
this.remoteTemplateFile = remoteTemplateFile;
this.availableProjectConfigurations = availableProjectConfigurations;
}
public PoolManagerConfig getPoolManagerConfig() {
return poolManagerConfig;
}
public void setPoolManagerConfig(PoolManagerConfig poolManagerConfig) {
this.poolManagerConfig = poolManagerConfig;
}
public String getRemoteTemplateFile() {
return remoteTemplateFile;
}
public void setRemoteTemplateFile(String remoteTemplateFile) {
this.remoteTemplateFile = remoteTemplateFile;
}
public ArrayList<ProjectSetup> getAvailableProjectConfigurations() {
return availableProjectConfigurations;
}
@ -34,7 +55,8 @@ public class SAIDescriptor implements Serializable {
@Override
public String toString() {
return "SAIDescriptor [availableProjectConfigurations=" + availableProjectConfigurations + "]";
return "SAIDescriptor [poolManagerConfig=" + poolManagerConfig + ", remoteTemplateFile=" + remoteTemplateFile
+ ", availableProjectConfigurations=" + availableProjectConfigurations + "]";
}
}

View File

@ -8,6 +8,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session;
*/
public class SessionConstants {
public static final String SAI_DESCRIPTOR="SAI_DESCRIPTOR";
public static final String FILE_UPLOAD_MONITOR="FILE_UPLOAD_MONITOR";
public static final String IMPORT_CODE_FILE_UPLOAD_SESSION = "IMPORT_CODE_FILE_UPLOAD_SESSION";
public static final String PROJECT = "PROJECT";

View File

@ -2,5 +2,4 @@
{ "user":"gianpaolo.coro", "surname":"Coro", "name":"Gianpaolo"},
{ "user":"scarponi", "surname":"Scarponi", "name":"Paolo"},
{ "user":"lucio.lelii", "surname":"Lelii", "name":"Lucio"},
{ "user":"statistical.manager", "surname":"Manager", "name":"Statistical"},
{ "user":"roberto.cirillo", "surname":"Cirillo", "name":"Roberto"} ] }

View File

@ -8,6 +8,7 @@ import java.util.List;
import javax.xml.bind.JAXBContext;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.AvailableProjectConfigJAXB;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.PoolManagerJAXB;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.SAIDescriptorJAXB;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.ProjectLanguageType;
@ -34,6 +35,14 @@ public class ISResourceTest extends TestCase {
StringWriter sw = new StringWriter();
SAIDescriptorJAXB saiDescriptor = new SAIDescriptorJAXB();
PoolManagerJAXB poolManagerJAXB=new PoolManagerJAXB();
poolManagerJAXB.setEnable(true);
saiDescriptor.setPoolmanager(poolManagerJAXB);
saiDescriptor.setRemotetemplatefile(Constants.REMOTE_TEMPLATE_FILE);
List<AvailableProjectConfigJAXB> list = new ArrayList<>();
AvailableProjectConfigJAXB a1 = new AvailableProjectConfigJAXB();
a1.setLanguage(ProjectLanguageType.R.getId());
@ -48,11 +57,14 @@ public class ISResourceTest extends TestCase {
a1.setSupport(ProjectSupportType.BLACKBOX.getId());
list.add(a1);
saiDescriptor.setAvailableprojectconfiguration(list);
jaxbContext.createMarshaller().marshal(saiDescriptor, sw);
logger.debug(sw.toString());
SAIDescriptorJAXB descr = (SAIDescriptorJAXB) jaxbContext.createUnmarshaller()
.unmarshal(new StringReader(sw.toString()));
logger.debug("SAIDescriptor: " + descr);
assertTrue("Success", true);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);

View File

@ -31,3 +31,9 @@ java.lang.ClassCastException: org.gcube.portlets.user.statisticalalgorithmsimpor
2017-06-14 14:42:05 DEBUG ISResourceTest:51 - SAIDescriptor: SAIDescriptorJAXB [availableprojectconfiguration=[AvailableProjectConfigJAXB [language=R, support=REditor], AvailableProjectConfigJAXB [language=Linux, support=BlackBox], AvailableProjectConfigJAXB [language=Octave, support=BlackBox]]]
2017-06-14 14:47:07 DEBUG ISResourceTest:48 - <?xml version="1.0" encoding="UTF-8" standalone="yes"?><saidescriptor><availableprojectconfiguration><language>R</language><support>REditor</support></availableprojectconfiguration><availableprojectconfiguration><language>Linux</language><support>BlackBox</support></availableprojectconfiguration><availableprojectconfiguration><language>Octave</language><support>BlackBox</support></availableprojectconfiguration></saidescriptor>
2017-06-14 14:47:07 DEBUG ISResourceTest:51 - SAIDescriptor: SAIDescriptorJAXB [availableprojectconfiguration=[AvailableProjectConfigJAXB [language=R, support=REditor], AvailableProjectConfigJAXB [language=Linux, support=BlackBox], AvailableProjectConfigJAXB [language=Octave, support=BlackBox]]]
2017-07-17 12:50:38 DEBUG ISResourceTest:59 - <?xml version="1.0" encoding="UTF-8" standalone="yes"?><saidescriptor><poolmanager><enable>true</enable></poolmanager><availableprojectconfiguration><language>R</language><support>REdit</support></availableprojectconfiguration><availableprojectconfiguration><language>Linux-compiled</language><support>BlackBox</support></availableprojectconfiguration><availableprojectconfiguration><language>Octave</language><support>BlackBox</support></availableprojectconfiguration></saidescriptor>
2017-07-17 12:50:39 DEBUG ISResourceTest:63 - SAIDescriptor: SAIDescriptorJAXB [poolmanager=PoolManagerJAXB [enable=true], availableprojectconfiguration=[AvailableProjectConfigJAXB [language=R, support=REdit], AvailableProjectConfigJAXB [language=Linux-compiled, support=BlackBox], AvailableProjectConfigJAXB [language=Octave, support=BlackBox]]]
2017-07-17 12:51:01 DEBUG ISResourceTest:59 - <?xml version="1.0" encoding="UTF-8" standalone="yes"?><saidescriptor><poolmanager><enable>true</enable></poolmanager><availableprojectconfiguration><language>R</language><support>REdit</support></availableprojectconfiguration><availableprojectconfiguration><language>Linux-compiled</language><support>BlackBox</support></availableprojectconfiguration><availableprojectconfiguration><language>Octave</language><support>BlackBox</support></availableprojectconfiguration></saidescriptor>
2017-07-17 12:51:01 DEBUG ISResourceTest:63 - SAIDescriptor: SAIDescriptorJAXB [poolmanager=PoolManagerJAXB [enable=true], availableprojectconfiguration=[AvailableProjectConfigJAXB [language=R, support=REdit], AvailableProjectConfigJAXB [language=Linux-compiled, support=BlackBox], AvailableProjectConfigJAXB [language=Octave, support=BlackBox]]]
2017-07-17 18:29:07 DEBUG ISResourceTest:62 - <?xml version="1.0" encoding="UTF-8" standalone="yes"?><saidescriptor><poolmanager><enable>true</enable></poolmanager><remotetemplatefile>http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R</remotetemplatefile><availableprojectconfiguration><language>R</language><support>REdit</support></availableprojectconfiguration><availableprojectconfiguration><language>Linux-compiled</language><support>BlackBox</support></availableprojectconfiguration><availableprojectconfiguration><language>Octave</language><support>BlackBox</support></availableprojectconfiguration></saidescriptor>
2017-07-17 18:29:07 DEBUG ISResourceTest:66 - SAIDescriptor: SAIDescriptorJAXB [poolmanager=PoolManagerJAXB [enable=true], remotetemplatefile=http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R, availableprojectconfiguration=[AvailableProjectConfigJAXB [language=R, support=REdit], AvailableProjectConfigJAXB [language=Linux-compiled, support=BlackBox], AvailableProjectConfigJAXB [language=Octave, support=BlackBox]]]