solved bug on messages attachments

This commit is contained in:
lucio.lelii 2021-09-10 10:59:07 +02:00
parent f68588e05c
commit 24576cd30f
7 changed files with 23 additions and 11 deletions

View File

@ -3,6 +3,10 @@
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).
## [v1.3.1] - [2021-09-08]
- solved bug on attachment rights
## [v1.3.0] - [2021-03-31] ## [v1.3.0] - [2021-03-31]
- possibility to impersonate people added - possibility to impersonate people added

View File

@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data.access</groupId> <groupId>org.gcube.data.access</groupId>
<artifactId>storagehub</artifactId> <artifactId>storagehub</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<name>storagehub</name> <name>storagehub</name>
<scm> <scm>

View File

@ -64,6 +64,12 @@ public class AuthorizationChecker {
if (hasParentPublicFolder(session, item)) return; if (hasParentPublicFolder(session, item)) return;
//TODO: remove when messages will be passed to a new system
String parentPath = item.getParentPath();
if (parentPath.endsWith("hl:attachments") && (parentPath.contains("/OutBox/") || parentPath.contains("/InBox/"))) {
return ;
}
if (item.isShared()) { if (item.isShared()) {
//SharedFolder parentShared = node2Item.getItem(retrieveSharedFolderParent(node, session), Excludes.EXCLUDE_ACCOUNTING); //SharedFolder parentShared = node2Item.getItem(retrieveSharedFolderParent(node, session), Excludes.EXCLUDE_ACCOUNTING);
//if (parentShared.getUsers().getMap().keySet().contains(userToCheck)) return; //if (parentShared.getUsers().getMap().keySet().contains(userToCheck)) return;
@ -95,6 +101,7 @@ public class AuthorizationChecker {
private boolean hasParentPublicFolder(Session session, Item item) { private boolean hasParentPublicFolder(Session session, Item item) {
if(item==null || item.getParentPath()==null) return false;
if (item.getParentPath().replaceAll("/Home/[^/]*/"+Constants.WORKSPACE_ROOT_FOLDER_NAME,"").isEmpty() || item.getParentPath().replaceAll(Constants.SHARED_FOLDER_PATH, "").isEmpty()) { if (item.getParentPath().replaceAll("/Home/[^/]*/"+Constants.WORKSPACE_ROOT_FOLDER_NAME,"").isEmpty() || item.getParentPath().replaceAll(Constants.SHARED_FOLDER_PATH, "").isEmpty()) {
if (item instanceof FolderItem) if (item instanceof FolderItem)
return ((FolderItem) item).isPublicItem(); return ((FolderItem) item).isPublicItem();

View File

@ -10,7 +10,6 @@ import javax.inject.Inject;
import javax.jcr.ItemNotFoundException; import javax.jcr.ItemNotFoundException;
import javax.jcr.Node; import javax.jcr.Node;
import javax.jcr.NodeIterator; import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException; import javax.jcr.RepositoryException;
import javax.jcr.Session; import javax.jcr.Session;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -394,10 +393,11 @@ public class MessageManager extends Impersonable{
Node newNode = session.getNode(newPath); Node newNode = session.getNode(newPath);
if (itemToCopy instanceof AbstractFileItem) { if (itemToCopy instanceof AbstractFileItem) {
((AbstractFileItem) itemToCopy).getContent().setRemotePath(newPath); AbstractFileItem newNodeItem = node2Item.getItem(newNode, Excludes.EXCLUDE_ACCOUNTING);
String newStorageID = folderPluginHandler.getDefault().getStorageBackend().onCopy((AbstractFileItem) itemToCopy); newNodeItem.getContent().setRemotePath(newPath);
((AbstractFileItem) itemToCopy).getContent().setStorageId(newStorageID); String newStorageID = folderPluginHandler.getDefault().getStorageBackend().onCopy(newNodeItem);
item2Node.replaceContent(newNode, (AbstractFileItem) itemToCopy, ItemAction.CLONED); newNodeItem.getContent().setStorageId(newStorageID);
item2Node.replaceContent(newNode, newNodeItem, ItemAction.CLONED);
} }
Utils.setPropertyOnChangeNode(newNode, currentUser, ItemAction.CLONED); Utils.setPropertyOnChangeNode(newNode, currentUser, ItemAction.CLONED);

View File

@ -38,8 +38,9 @@ public class GCubeStorageBackend implements StorageBackend {
@Override @Override
public String onCopy(AbstractFileItem item) { public String onCopy(AbstractFileItem item) {
log.info("copying storage Id {} to newPath {}", item.getContent().getStorageId(), item.getPath());
String newStorageID = getStorageClient(AuthorizationProvider.instance.get().getClient().getId()).getClient().copyFile(true).from(item.getContent().getStorageId()).to(item.getPath()); String newStorageID = getStorageClient(AuthorizationProvider.instance.get().getClient().getId()).getClient().copyFile(true).from(item.getContent().getStorageId()).to(item.getPath());
log.info("copying storage Id {} to newPath {} and the id returned by storage is {}", item.getContent().getStorageId(), item.getPath(), newStorageID); log.info("The id returned by storage is {}", newStorageID);
return newStorageID; return newStorageID;
} }

View File

@ -25,7 +25,7 @@ The projects leading to this software have received funding from a series of
Version Version
-------------------------------------------------- --------------------------------------------------
1.3.0-SNAPSHOT (20210504-102919) 1.3.1 (20210910-085653)
Please see the file named "changelog.xml" in this directory for the release notes. Please see the file named "changelog.xml" in this directory for the release notes.

View File

@ -1,7 +1,7 @@
<application mode='online'> <application mode='online'>
<name>StorageHub</name> <name>StorageHub</name>
<group>DataAccess</group> <group>DataAccess</group>
<version>1.3.0-SNAPSHOT</version> <version>1.3.1</version>
<description>Storage Hub webapp</description> <description>Storage Hub webapp</description>
<local-persistence location='target' /> <local-persistence location='target' />
</application> </application>