removed Home Library dependency
This commit is contained in:
parent
55f8373ad5
commit
5e51079370
|
@ -4,12 +4,14 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [v2.7.2-SNAPSHOT] -2021-03-25
|
## [v2.8.0-SNAPSHOT] -2021-03-25
|
||||||
|
|
||||||
- Ported to git
|
- Ported to git
|
||||||
|
|
||||||
- Fix Bug #21023 attached documents in Posts do not open in Chrome
|
- Fix Bug #21023 attached documents in Posts do not open in Chrome
|
||||||
|
|
||||||
|
- Remove HomeLibrary dependency and replace with storage hub one
|
||||||
|
|
||||||
## [v2.7.1] -2020-04-28
|
## [v2.7.1] -2020-04-28
|
||||||
|
|
||||||
- Feature #18992 Reconsider the alert message raised when writing a post containing more than one link
|
- Feature #18992 Reconsider the alert message raised when writing a post containing more than one link
|
||||||
|
|
16
pom.xml
16
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>share-updates</artifactId>
|
<artifactId>share-updates</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.7.2-SNAPSHOT</version>
|
<version>2.8.0-SNAPSHOT</version>
|
||||||
<name>gCube Share Updates Portlet</name>
|
<name>gCube Share Updates Portlet</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Share Updates for exchanging updates with other users of VREs.
|
gCube Share Updates for exchanging updates with other users of VREs.
|
||||||
|
@ -75,6 +75,10 @@
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>social-networking-library</artifactId>
|
||||||
|
@ -167,16 +171,6 @@
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.common</groupId>
|
|
||||||
<artifactId>home-library-jcr</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
<artifactId>usermanagement-core</artifactId>
|
<artifactId>usermanagement-core</artifactId>
|
||||||
|
|
|
@ -3,17 +3,14 @@ package org.gcube.portlets.user.shareupdates.server;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
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.WorkspaceSharedFolder;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.model.exceptions.InvalidItemException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -59,44 +56,37 @@ public class UploadToWorkspaceThread implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
String currScope = ScopeProvider.instance.get();
|
String currScope = ScopeProvider.instance.get();
|
||||||
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
|
|
||||||
|
|
||||||
Workspace ws = HomeLibrary
|
|
||||||
.getHomeManagerFactory()
|
StorageHubClient shc = new StorageHubClient();
|
||||||
.getHomeManager()
|
_log.info("Trying to get VRE folder for scope="+currScope);
|
||||||
.getHome(username).getWorkspace();
|
FolderContainer vreFolder = shc.openVREFolder();
|
||||||
|
|
||||||
_log.info("File to upload="+fileabsolutePathOnServer);
|
_log.info("File to upload="+fileabsolutePathOnServer);
|
||||||
File file = new File(fileabsolutePathOnServer);
|
File file = new File(fileabsolutePathOnServer);
|
||||||
InputStream fileData = new FileInputStream(file);
|
InputStream fileData = new FileInputStream(file);
|
||||||
|
|
||||||
_log.info("Trying to get Group folder for scope="+currScope);
|
|
||||||
WorkspaceSharedFolder folder = ws.getVREFolderByScope(currScope);
|
|
||||||
|
|
||||||
Workspace ownerWS = HomeLibrary
|
FolderContainer attachmentFolder = null;
|
||||||
.getHomeManagerFactory()
|
|
||||||
.getHomeManager()
|
|
||||||
.getHome(folder.getOwner().getPortalLogin()).getWorkspace();
|
|
||||||
|
|
||||||
WorkspaceFolder attachment = null;
|
|
||||||
try {
|
try {
|
||||||
attachment = (WorkspaceFolder) ownerWS.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
|
OpenResolver oRes = vreFolder.openByRelativePath(ATTACHMENT_FOLDER);
|
||||||
} catch (ItemNotFoundException e) {
|
attachmentFolder = oRes.asFolder();
|
||||||
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it for "+currScope);
|
} catch (InvalidItemException e) {
|
||||||
attachment = ownerWS.createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System", folder.getId());
|
_log.info(ATTACHMENT_FOLDER + " in VRE Folder does not exists, creating it for "+currScope);
|
||||||
attachment.setACL(folder.getUsers(), ACLType.WRITE_OWNER);
|
vreFolder.newFolder(ATTACHMENT_FOLDER,"Folder created automatically by the System");
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceFolder theFolderToWriteIn = (WorkspaceFolder) ws.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
|
String itemName = getUniqueName(fileName);
|
||||||
String itemName = WorkspaceUtil.getUniqueName(fileName, theFolderToWriteIn);
|
FileContainer uploadedFile = attachmentFolder.uploadFile(fileData, itemName, "File shared by " + fullName + "("+username+")");
|
||||||
FolderItem item = WorkspaceUtil.createExternalFile(theFolderToWriteIn, itemName, "File shared by " + fullName + "("+username+")", null, fileData);
|
_log.debug("Uploaded " + uploadedFile.get().getName() + " - Returned Workspace id=" + uploadedFile.getId());
|
||||||
|
|
||||||
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" + item.getId());
|
|
||||||
ScopeProvider.instance.set(currScope);
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
_log.error("Something wrong while uploading " + fileName + " in Workspace " + e.getMessage());
|
_log.error("Something wrong while uploading " + fileName + " in Workspace VRE Folder " + ATTACHMENT_FOLDER + ": "+ e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getUniqueName(String filename) {
|
||||||
|
return UUID.randomUUID().toString().substring(0, 8) + "_" + filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue