Compare commits

...

14 Commits

12 changed files with 89 additions and 374 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/share-updates-2.7.1/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/share-updates-2.8.1-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/share-updates-2.7.1/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/share-updates-2.8.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -34,5 +34,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/share-updates-2.7.1/WEB-INF/classes"/>
<classpathentry kind="output" path="target/share-updates-2.8.1-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,24 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="share-updates">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="social-util-library-1.7.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-util-library/social-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/>
</wb-module>
<wb-module deploy-name="share-updates">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="social-util-library-1.7.3.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/social-util-library/social-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/>
</wb-module>
</project-modules>

View File

@ -4,15 +4,21 @@
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.1] -2022-06-15
- Fixed soem deps
## [v2.8.0] -2021-04-02
- 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
- Feature #18992 Reconsider the alert message raised when writing a post containing more than one link
## [v2.7.0] - 2019-03-29
@ -20,7 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v2.6.2] - 2019-01-04
- Incident #13096, mentioning in some VRE may not work
- Incident #13096 mentioning in some VRE may not work
## [v2.6.1] - 2018-04-12

View File

@ -20,30 +20,21 @@ See [Releases](https://code-repo.d4science.org/gCubeSystem/share-updates/release
## Authors
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Costantino Perciante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
* **Costantino Perciante**
## Maintainers
* **Massimiliano Assante** - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
* **Massimiliano Assante** ([ORCID](https://orcid.org/0000-0002-3761-1492)) - [ISTI-CNR Infrascience Group](https://www.isti.cnr.it/People/M.Assante)
## License
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
## About the gCube Framework
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
open-source software toolkit used for building and operating Hybrid Data
Infrastructures enabling the dynamic deployment of Virtual Research Environments
by favouring the realisation of reuse oriented policies.
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- DILIGENT (grant no. 004260);
- the Seventh Framework Programme for research, technological development and demonstration
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
- the H2020 research and innovation programme
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md)

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/share-updates/src/test/java/org/gcube/portlets/user/shareupdates/client/GwtTestShareUpdates.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.shareupdates.client.GwtTestShareUpdates"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="share-updates"/>
</launchConfiguration>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gwt.eclipse.core.launch.gwtJUnit">
<stringAttribute key="com.google.gwt.eclipse.core.LOG_LEVEL" value="INFO"/>
<booleanAttribute key="com.google.gwt.eclipse.core.NOT_HEADLESS" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.OUT_DIR" value="www-test"/>
<booleanAttribute key="com.google.gwt.eclipse.core.STANDARDS_MODE" value="false"/>
<stringAttribute key="com.google.gwt.eclipse.core.STYLE" value="OBFUSCATED"/>
<stringAttribute key="com.google.gwt.eclipse.core.WEB_MODE" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/share-updates/src/test/java/org/gcube/portlets/user/shareupdates/client/GwtTestShareUpdates.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.gcube.portlets.user.shareupdates.client.GwtTestShareUpdates"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="share-updates"/>
</launchConfiguration>

View File

@ -1,178 +0,0 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.shareupdates.2-7-1"
date="2020-04-28">
<Change>Feature #18992, Reconsider the alert message raised when writing a post containing more than one link</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-7-0"
date="2019-03-29">
<Change>Revised social networking library mechanism for http links, mentions and hashtags recognition, Task #13207</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-6-2"
date="2019-01-04">
<Change>Incident #13096, mentioning in some VRE may not work</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-6-1"
date="2018-04-12">
<Change>Removed previous jquery js load script</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-6-0"
date="2018-02-07">
<Change>restyled checkbox for notifications</Change>
<Change>Removed deprecated TIBCO Pagebus library and replaces with
Liferay's IPC Client Side
</Change>
<Change>Enhanced efficiency when retrieving mentioned users or groups
in posts
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-5-0"
date="2017-12-07">
<Change>drop down menu replaced with checkbox for notifications, see
Task #9971
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-4-0"
date="2017-05-03">
<Change>Ported to Java8</Change>
<Change>Fix for bug #7630</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-3-1"
date="2017-04-12">
<Change>Fixes an issue where the sharing of posts in any VRE would not
generate any notification in some cases, Incident #7553
</Change>
<Change>Fix for Bug #8063, Share Updates links are truncated in some
cases
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-3-0"
date="2017-02-20">
<Change>Updated method for using ftp server</Change>
<Change>Minor fix when VREs' teams are notified</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-1-0"
date="2016-09-29">
<Change>updated opengraph checkURL for getting images in case of HTTP
redirect permanently is encountered
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.2-0-0"
date="2016-06-29">
<Change>Updated to Liferay 6.2.5</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-9-2"
date="2016-02-29">
<Change>Minor bug fixes</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-9-0"
date="2016-01-22">
<Change>Multi-attachment upload is now supported</Change>
<Change>Drag and drop mechanism added for attachments</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-8-2"
date="2015-12-21">
<Change>Restyled to optimize vertical space</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-8-0"
date="2015-07-06">
<Change>made notification to members option configurable as default,
see Feature #121
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-7-0"
date="2015-05-27">
<Change>Integrated gwt-bootstrap and revised css</Change>
<Change>ported to GWT 2.7.0</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-1"
date="2014-12-13">
<Change>Added Client scope handler, to set the scope from the client
and help preventing the browser back button cache problem
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-0"
date="2014-11-03">
<Change>Added possibility to define topics in a post using hashtags
</Change>
<Change>Added save attachments in VRE Group folder</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-5-1"
date="2014-07-03">
<Change>Fixed commons-validator dependency</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-5-0"
date="2014-06-06">
<Change>Adapted pom to the new portal bundle gcore free</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-4-0"
date="2014-05-22">
<Change>Fixed bug when posting in single vre</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-3-0"
date="2014-05-09">
<Change>Added possibility to alert the users of a VRE when sharing an
update
</Change>
<Change>Refined the way to guess content and images when parsing HTML
</Change>
<Change>Improved images recognition when parsing html pages having no
image indication from openGraph
</Change>
<Change>Added user agent property to http requests to avoid web
servers 'complaining' HTTP 403 errors
</Change>
<Change>Replaced all the line breaks and all the double spaces with
the html version to preserve new lines in posts
</Change>
<Change>Fixed bug when changing user avatar and minor restyle</Change>
<Change>Several improvements in url checkings</Change>
<Change>resolved problem with AdBlock plugin </Change>
<Change>Fixed mention user dialog y-position when textbox is higher
than usual due to new lines
</Change>
<Change>Mention users list now returns only the list of the available
users in the current organization
</Change>
<Change>Fixed posts when multiple tabs are open, now the status is
kept on the client
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-1-3"
date="2014-02-10">
<Change>added thumbnail generation and upload on FTP server</Change>
<Change>added upload a copy on my workspace file when sharing a file
</Change>
<Change>implemented the file preview with icons or preview depending
on the extension of the file
</Change>
<Change>integrated file uplod progress bar widget for sharing files
</Change>
<Change>fixed bug allowing users to post while generating file/url
previews
</Change>
<Change>fixed bug allowing users to mention theirselves</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-0-0"
date="2013-10-21">
<Change>Ported to GWT 251</Change>
<Change>Ported to Feather Weight Stack</Change>
<Change>Removed GCF Dependency</Change>
<Change>Logging with sl4j Enabled</Change>
<Change>Fixed image previes retrieval when image is in the same folder
of the linked page
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.0-5-0"
date="2013-07-18">
<Change>Mention people in tags correctly referred to user profiles
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.0-3-0"
date="2013-04-19">
<Change>Added possibility to mention people in tags</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.0-1-0"
date="2013-01-13">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,31 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>PortletUser</Class>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>target/${build.finalName}.war</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

25
pom.xml
View File

@ -14,15 +14,15 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>share-updates</artifactId>
<packaging>war</packaging>
<version>2.7.2-SNAPSHOT</version>
<version>2.8.1</version>
<name>gCube Share Updates Portlet</name>
<description>
gCube Share Updates for exchanging updates with other users of VREs.
</description>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</url>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm>
<properties>
<!-- Convenience property to set the GWT version -->
@ -41,7 +41,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.6.0</version>
<version>3.6.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -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>
@ -151,6 +155,7 @@
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.27</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
@ -167,16 +172,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>

View File

@ -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.StorageHubException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -58,45 +55,34 @@ public class UploadToWorkspaceThread implements Runnable {
@Override
public void run() {
try {
String currScope = ScopeProvider.instance.get();
ScopeProvider.instance.set("/"+PortalContext.getConfiguration().getInfrastructureName());
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(username).getWorkspace();
_log.info("File to upload="+fileabsolutePathOnServer);
String currContext = ScopeProvider.instance.get();
StorageHubClient shc = new StorageHubClient();
_log.debug("Trying to get VRE folder for scope="+currContext);
FolderContainer vreFolder = shc.openVREFolder();
_log.debug("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 (StorageHubException e) {
_log.info(ATTACHMENT_FOLDER + " in VRE Folder does not exists, creating it for "+currContext);
attachmentFolder = 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.info("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;
}
}