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.
|
||||
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
|
||||
|
||||
- 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
|
||||
|
||||
- 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>
|
||||
<artifactId>share-updates</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.7.2-SNAPSHOT</version>
|
||||
<version>2.8.0-SNAPSHOT</version>
|
||||
<name>gCube Share Updates Portlet</name>
|
||||
<description>
|
||||
gCube Share Updates for exchanging updates with other users of VREs.
|
||||
|
@ -75,6 +75,10 @@
|
|||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
|
@ -167,16 +171,6 @@
|
|||
<artifactId>commons-io</artifactId>
|
||||
<scope>compile</scope>
|
||||
</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>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
|
|
|
@ -3,17 +3,14 @@ package org.gcube.portlets.user.shareupdates.server;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
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.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.LoggerFactory;
|
||||
|
||||
|
@ -59,44 +56,37 @@ public class UploadToWorkspaceThread implements Runnable {
|
|||
public void run() {
|
||||
try {
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
|
||||
|
||||
Workspace ws = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(username).getWorkspace();
|
||||
|
||||
|
||||
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
_log.info("Trying to get VRE folder for scope="+currScope);
|
||||
FolderContainer vreFolder = shc.openVREFolder();
|
||||
|
||||
_log.info("File to upload="+fileabsolutePathOnServer);
|
||||
File file = new File(fileabsolutePathOnServer);
|
||||
InputStream fileData = new FileInputStream(file);
|
||||
|
||||
_log.info("Trying to get Group folder for scope="+currScope);
|
||||
WorkspaceSharedFolder folder = ws.getVREFolderByScope(currScope);
|
||||
|
||||
Workspace ownerWS = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(folder.getOwner().getPortalLogin()).getWorkspace();
|
||||
|
||||
WorkspaceFolder attachment = null;
|
||||
try{
|
||||
attachment = (WorkspaceFolder) ownerWS.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
|
||||
} catch (ItemNotFoundException e) {
|
||||
_log.info(ATTACHMENT_FOLDER + " Workspace Folder does not exists, creating it for "+currScope);
|
||||
attachment = ownerWS.createFolder(ATTACHMENT_FOLDER, "Folder created automatically by the System", folder.getId());
|
||||
attachment.setACL(folder.getUsers(), ACLType.WRITE_OWNER);
|
||||
|
||||
|
||||
FolderContainer attachmentFolder = null;
|
||||
try {
|
||||
OpenResolver oRes = vreFolder.openByRelativePath(ATTACHMENT_FOLDER);
|
||||
attachmentFolder = oRes.asFolder();
|
||||
} catch (InvalidItemException e) {
|
||||
_log.info(ATTACHMENT_FOLDER + " in VRE Folder does not exists, creating it for "+currScope);
|
||||
vreFolder.newFolder(ATTACHMENT_FOLDER,"Folder created automatically by the System");
|
||||
}
|
||||
|
||||
WorkspaceFolder theFolderToWriteIn = (WorkspaceFolder) ws.getItemByPath(folder.getPath() + "/" + ATTACHMENT_FOLDER);
|
||||
String itemName = WorkspaceUtil.getUniqueName(fileName, theFolderToWriteIn);
|
||||
FolderItem item = WorkspaceUtil.createExternalFile(theFolderToWriteIn, itemName, "File shared by " + fullName + "("+username+")", null, fileData);
|
||||
|
||||
_log.debug("Uploaded " + item.getName() + " - Returned Workspace id=" + item.getId());
|
||||
ScopeProvider.instance.set(currScope);
|
||||
|
||||
String itemName = getUniqueName(fileName);
|
||||
FileContainer uploadedFile = attachmentFolder.uploadFile(fileData, itemName, "File shared by " + fullName + "("+username+")");
|
||||
_log.debug("Uploaded " + uploadedFile.get().getName() + " - Returned Workspace id=" + uploadedFile.getId());
|
||||
}
|
||||
catch (Exception e) {
|
||||
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