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.
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]
- possibility to impersonate people added

View File

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

View File

@ -64,6 +64,12 @@ public class AuthorizationChecker {
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()) {
//SharedFolder parentShared = node2Item.getItem(retrieveSharedFolderParent(node, session), Excludes.EXCLUDE_ACCOUNTING);
//if (parentShared.getUsers().getMap().keySet().contains(userToCheck)) return;
@ -88,13 +94,14 @@ public class AuthorizationChecker {
}
}
}
throw new UserNotAuthorizedException("Insufficent Privileges for user "+userToCheck+" to read node with id "+id);
}
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 instanceof FolderItem)
return ((FolderItem) item).isPublicItem();

View File

@ -10,7 +10,6 @@ import javax.inject.Inject;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.servlet.ServletContext;
@ -392,12 +391,13 @@ public class MessageManager extends Impersonable{
String newPath= String.format("%s/%s", destination.getPath(), uniqueName);
session.getWorkspace().copy(nodeToCopy.getPath(), newPath);
Node newNode = session.getNode(newPath);
if (itemToCopy instanceof AbstractFileItem) {
((AbstractFileItem) itemToCopy).getContent().setRemotePath(newPath);
String newStorageID = folderPluginHandler.getDefault().getStorageBackend().onCopy((AbstractFileItem) itemToCopy);
((AbstractFileItem) itemToCopy).getContent().setStorageId(newStorageID);
item2Node.replaceContent(newNode, (AbstractFileItem) itemToCopy, ItemAction.CLONED);
AbstractFileItem newNodeItem = node2Item.getItem(newNode, Excludes.EXCLUDE_ACCOUNTING);
newNodeItem.getContent().setRemotePath(newPath);
String newStorageID = folderPluginHandler.getDefault().getStorageBackend().onCopy(newNodeItem);
newNodeItem.getContent().setStorageId(newStorageID);
item2Node.replaceContent(newNode, newNodeItem, ItemAction.CLONED);
}
Utils.setPropertyOnChangeNode(newNode, currentUser, ItemAction.CLONED);

View File

@ -38,8 +38,9 @@ public class GCubeStorageBackend implements StorageBackend {
@Override
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());
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;
}

View File

@ -25,7 +25,7 @@ The projects leading to this software have received funding from a series of
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.

View File

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