ref 11724: SAI - Update to StorageHUB
https://support.d4science.org/issues/11724 Updated to StorageHub git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@169580 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c336d5d8d2
commit
82b6a37aec
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.11.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.12.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.11.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.12.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -45,5 +45,5 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.11.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.12.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="${groupId}.${artifactId}.1-12-0" date="2018-07-01">
|
||||
<Change>Updated to StorageHub [ticket #11724]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${groupId}.${artifactId}.1-11-0" date="2018-06-01">
|
||||
<Change>Added Status control in Algorithm Generator [ticket #11750]</Change>
|
||||
<Change>Added System parameters support [ticket #11768]</Change>
|
||||
|
|
20
pom.xml
20
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>statistical-algorithms-importer</artifactId>
|
||||
<version>1.11.0-SNAPSHOT</version>
|
||||
<version>1.12.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
|
@ -94,6 +94,13 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- StorageHub -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -233,6 +240,13 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- StorageHub -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -313,14 +327,14 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-explorer</artifactId>
|
||||
<version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Workspace Uploader -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-uploader</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- GitHub Connector -->
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.St
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.MainCode;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBashEdit;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBlackBox;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportREdit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -44,23 +45,22 @@ public class CodeReader {
|
|||
logCode();
|
||||
return code;
|
||||
}
|
||||
|
||||
private void logCode(){
|
||||
|
||||
private void logCode() {
|
||||
if (code != null) {
|
||||
for (CodeData codeData : code) {
|
||||
logger.debug("" + codeData.getId() + " " + codeData.getCodeLine());
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
logger.debug("no code!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void retrieveCode() throws StatAlgoImporterServiceException {
|
||||
if (project != null) {
|
||||
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null) {
|
||||
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportREdit) {
|
||||
|
||||
logger.debug("Project Support REdit");
|
||||
MainCode mainCode = project.getMainCode();
|
||||
if (mainCode == null || mainCode.getItemDescription() == null
|
||||
|| mainCode.getItemDescription().getId() == null
|
||||
|
@ -72,6 +72,7 @@ public class CodeReader {
|
|||
}
|
||||
} else {
|
||||
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) {
|
||||
logger.debug("Project Support BashEdit");
|
||||
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project
|
||||
.getProjectConfig().getProjectSupport();
|
||||
if (projectSupportBashEdit == null || projectSupportBashEdit.getBinaryItem() == null
|
||||
|
@ -82,9 +83,21 @@ public class CodeReader {
|
|||
String itemId = projectSupportBashEdit.getBinaryItem().getId();
|
||||
readCodeFromItem(itemId);
|
||||
}
|
||||
|
||||
} else {
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* Check how if open a project after another already open if we write this code we create a lock
|
||||
* this create a lock on workspace when we save the project
|
||||
*
|
||||
* if (project.getProjectConfig().getProjectSupport()
|
||||
* instanceof ProjectSupportBlackBox) {
|
||||
*
|
||||
* logger.debug("Project Support BlackBox"); code = new
|
||||
* ArrayList<>(); } else {
|
||||
*/
|
||||
throw new StatAlgoImporterServiceException("Error reading code!");
|
||||
// }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -16,10 +16,13 @@ import org.gcube.common.homelibrary.home.HomeLibrary;
|
|||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
||||
import org.gcube.common.homelibrary.jcr.workspace.JCRWorkspaceSharedFolder;
|
||||
import org.gcube.common.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -50,21 +53,12 @@ public class FilesStorage {
|
|||
* exception
|
||||
*/
|
||||
public String getPublicLink(String user, String itemId) throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
|
||||
try {
|
||||
logger.info("Get public link: [user=" + user + ", itemId=" + itemId + "]");
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException("Attention this is a folder!");
|
||||
}
|
||||
|
||||
if (workSpaceItem instanceof FolderItem) {
|
||||
return workSpaceItem.getPublicLink(false);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("Attention no public link for this item!");
|
||||
}
|
||||
logger.debug("getPublicLink: [user=" + user + ", itemId=" + itemId + "]");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
URL url = shc.open(itemId).asFile().getPublicLink();
|
||||
return url.toString();
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Get public link: " + e.getLocalizedMessage(), e);
|
||||
|
@ -156,12 +150,13 @@ public class FilesStorage {
|
|||
* exception
|
||||
*/
|
||||
public void deleteItemOnFolder(String user, String itemId) throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
logger.info("Delete item on folder: [user=" + user + ", itemId=" + itemId + "]");
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
logger.debug("Delete Item: [User=" + user + ", ItemId=" + itemId+"]");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
OpenResolver openResolver = shc.open(itemId);
|
||||
|
||||
ws.removeItems(itemId);
|
||||
ItemContainer<Item> itemContainer = openResolver.asItem();
|
||||
itemContainer.delete();
|
||||
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
|
@ -187,7 +182,6 @@ public class FilesStorage {
|
|||
Workspace ws;
|
||||
try {
|
||||
logger.info("Delete folder: [user=" + user + ", parentId=" + parentId + ", folderName=" + folderName + "]");
|
||||
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(parentId);
|
||||
|
@ -861,7 +855,6 @@ public class FilesStorage {
|
|||
Workspace ws;
|
||||
try {
|
||||
logger.info("Get shared info: [user=" + user + ", itemId=" + itemId + "]");
|
||||
|
||||
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
|
@ -869,7 +862,7 @@ public class FilesStorage {
|
|||
if (!workspaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException("Attention this is not a folder!");
|
||||
}
|
||||
|
||||
|
||||
List<String> shared = new ArrayList<String>();
|
||||
if (workspaceItem.isShared()) {
|
||||
JCRWorkspaceSharedFolder sharedFolder = (JCRWorkspaceSharedFolder) workspaceItem;
|
||||
|
@ -880,21 +873,19 @@ public class FilesStorage {
|
|||
if (owner != null && !owner.isEmpty()) {
|
||||
shared.add(owner);
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return shared;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Get shared info: " + e.getLocalizedMessage(), e);
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),e);
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue