diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java index f4dcb8d..54a9ad3 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java @@ -313,6 +313,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements logger.debug("SetMainCode(): " + itemDescription); Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials); if (project != null) { + FilesStorage filesStorage = new FilesStorage(); + String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId()); + itemDescription.setPublicLink(link); project.setMainCode(new MainCode(itemDescription)); project.setInputData(null); project.setProjectTarget(null); @@ -348,6 +351,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) { ProjectSupportBlackBox projectSupportBlackBox = (ProjectSupportBlackBox) project .getProjectConfig().getProjectSupport(); + FilesStorage filesStorage = new FilesStorage(); + String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId()); + itemDescription.setPublicLink(link); projectSupportBlackBox.setBinaryItem(itemDescription); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); logger.debug("Project: " + project); @@ -355,6 +361,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) { ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project .getProjectConfig().getProjectSupport(); + FilesStorage filesStorage = new FilesStorage(); + String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId()); + itemDescription.setPublicLink(link); projectSupportBashEdit.setBinaryItem(itemDescription); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); logger.debug("Project: " + project); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/GeneralPurposeScriptProducer.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/GeneralPurposeScriptProducer.java index 0149dd5..c6e2fa0 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/GeneralPurposeScriptProducer.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/GeneralPurposeScriptProducer.java @@ -64,9 +64,12 @@ public class GeneralPurposeScriptProducer { String URLtoSoftware) throws Exception { String mainSoftwareName = mainSoftware; - if (URLtoSoftware!=null) { - mainSoftwareName = URLReader(URLtoSoftware); - } + //if (URLtoSoftware!=null) { + // logger.debug("Reading main software from remote URL: "+URLtoSoftware); + // mainSoftwareName = URLReader(URLtoSoftware); + // logger.debug("Main software name: "+mainSoftwareName); + // + //} String inputDeclaration = generateInputStrings(input, softwareType, mainSoftwareName); String processInvocation = generateExternalProcessInvokation(mainSoftwareName, input); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/MainGenerator.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/MainGenerator.java index 5c1f009..c8d3510 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/MainGenerator.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/blackbox/MainGenerator.java @@ -33,7 +33,6 @@ 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, String remoteTemplateFile) throws StatAlgoImporterServiceException { @@ -77,13 +76,20 @@ public class MainGenerator { Path producedScript = null; - if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit){ - producedScript = s.generateScript(input, output, binarySoftware.getName(), - project.getProjectConfig().getLanguage(), binarySoftware.getPublicLink()); - } else { - producedScript = s.generateScript(input, output, binarySoftware.getName(), - project.getProjectConfig().getLanguage()); - } + // if (project.getProjectConfig().getProjectSupport() instanceof + // ProjectSupportBashEdit){ + // logger.debug("Generate Script R with public link: + // "+binarySoftware.getPublicLink()); + // producedScript = s.generateScript(input, output, + // binarySoftware.getName(), + // project.getProjectConfig().getLanguage(), + // binarySoftware.getPublicLink()); + // } else { + + logger.debug("Generate Script R"); + producedScript = s.generateScript(input, output, binarySoftware.getName(), + project.getProjectConfig().getLanguage()); + // } if (producedScript == null || !Files.exists(producedScript)) { String error = "Error creating script: file not exists!"; diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/CodeSave.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/CodeSave.java index 5910d15..fbb1bbc 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/CodeSave.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/storage/CodeSave.java @@ -60,10 +60,10 @@ public class CodeSave { private ItemDescription saveInWorkspace(Path tempFile, ServiceCredentials serviceCredentials, ItemDescription file, String folderId) throws StatAlgoImporterServiceException { FilesStorage filesStorage = new FilesStorage(); - WorkspaceItem mainCodeItem; + WorkspaceItem worksapceItem; try { - mainCodeItem = filesStorage.createItemOnWorkspace(serviceCredentials.getUserName(), + worksapceItem = filesStorage.createItemOnWorkspace(serviceCredentials.getUserName(), Files.newInputStream(tempFile, StandardOpenOption.READ), file.getName(), ALGORITHM_DESCRIPTION, ALGORITHM_MIMETYPE, folderId); } catch (IOException e) { @@ -71,17 +71,18 @@ public class CodeSave { throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e); } - ItemDescription mainCode; + ItemDescription item; try { - mainCode = new ItemDescription(mainCodeItem.getId(), mainCodeItem.getName(), - mainCodeItem.getOwner().getPortalLogin(), mainCodeItem.getPath(), mainCodeItem.getType().name()); + item = new ItemDescription(worksapceItem.getId(), worksapceItem.getName(), + worksapceItem.getOwner().getPortalLogin(), worksapceItem.getPath(), worksapceItem.getType().name()); + item.setPublicLink(worksapceItem.getPublicLink(false)); } catch (InternalErrorException e) { logger.error(e.getLocalizedMessage(),e); throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); } - return mainCode; + return item; }