update for test issue
This commit is contained in:
parent
f2742ce0e0
commit
70ae49e28d
|
@ -15,7 +15,6 @@ import org.apache.jackrabbit.api.security.user.Group;
|
||||||
import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
|
import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||||
import org.gcube.common.storagehub.model.Excludes;
|
import org.gcube.common.storagehub.model.Excludes;
|
||||||
import org.gcube.common.storagehub.model.Paths;
|
|
||||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||||
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
||||||
|
@ -128,8 +127,9 @@ public class AuthorizationChecker {
|
||||||
if (Constants.WRITE_PROTECTED_FOLDER.contains(item.getName()) || Constants.WRITE_PROTECTED_FOLDER.contains(item.getTitle()))
|
if (Constants.WRITE_PROTECTED_FOLDER.contains(item.getName()) || Constants.WRITE_PROTECTED_FOLDER.contains(item.getTitle()))
|
||||||
throw new UserNotAuthorizedException("Insufficent Privileges for user "+login+" to write into node with id "+item.getId()+": it's a protected folder");
|
throw new UserNotAuthorizedException("Insufficent Privileges for user "+login+" to write into node with id "+item.getId()+": it's a protected folder");
|
||||||
|
|
||||||
|
/*
|
||||||
if (item.isTrashed())
|
if (item.isTrashed())
|
||||||
throw new UserNotAuthorizedException("Trashed item cannot be written");
|
throw new UserNotAuthorizedException("Trashed item cannot be written");*/
|
||||||
|
|
||||||
if (item.isShared()) {
|
if (item.isShared()) {
|
||||||
Node parentSharedNode = retrieveSharedFolderParent(node, session);
|
Node parentSharedNode = retrieveSharedFolderParent(node, session);
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class ItemsManager {
|
||||||
@Inject Item2NodeConverter item2Node;
|
@Inject Item2NodeConverter item2Node;
|
||||||
|
|
||||||
@Inject StorageBackendHandler storageBackend;
|
@Inject StorageBackendHandler storageBackend;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -150,7 +150,7 @@ public class ItemsManager {
|
||||||
|
|
||||||
return new ItemWrapper<Item>(toReturn);
|
return new ItemWrapper<Item>(toReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/path")
|
@Path("{id}/path")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -161,13 +161,13 @@ public class ItemsManager {
|
||||||
try{
|
try{
|
||||||
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
authChecker.checkReadAuthorizationControl(ses, id);
|
authChecker.checkReadAuthorizationControl(ses, id);
|
||||||
|
|
||||||
String relativePath = path.startsWith("/")? path.substring(1) : path;
|
String relativePath = path.startsWith("/")? path.substring(1) : path;
|
||||||
if (path.endsWith("/"))
|
if (path.endsWith("/"))
|
||||||
relativePath.substring(0,relativePath.lastIndexOf("/"));
|
relativePath.substring(0,relativePath.lastIndexOf("/"));
|
||||||
|
|
||||||
if (relativePath.isEmpty()) throw new InvalidCallParameters("empty path");
|
if (relativePath.isEmpty()) throw new InvalidCallParameters("empty path");
|
||||||
|
|
||||||
Item item =null;
|
Item item =null;
|
||||||
String nextId = id;
|
String nextId = id;
|
||||||
String[] paths = relativePath.split("/");
|
String[] paths = relativePath.split("/");
|
||||||
|
@ -177,7 +177,7 @@ public class ItemsManager {
|
||||||
authChecker.checkReadAuthorizationControl(ses, item.getId());
|
authChecker.checkReadAuthorizationControl(ses, item.getId());
|
||||||
nextId = item.getId();
|
nextId = item.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludes.containsAll(Excludes.ALL))
|
if (excludes.containsAll(Excludes.ALL))
|
||||||
return new ItemWrapper<Item>(item);
|
return new ItemWrapper<Item>(item);
|
||||||
else
|
else
|
||||||
|
@ -195,9 +195,9 @@ public class ItemsManager {
|
||||||
|
|
||||||
return new ItemWrapper<Item>(toReturn);
|
return new ItemWrapper<Item>(toReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item getChildrenMatchingName(Session ses, String id, String name, List<String> excludes) throws ItemNotFoundException , RepositoryException, StorageHubException {
|
private Item getChildrenMatchingName(Session ses, String id, String name, List<String> excludes) throws ItemNotFoundException , RepositoryException, StorageHubException {
|
||||||
|
|
||||||
NodeIterator it = ses.getNodeByIdentifier(id).getNodes();
|
NodeIterator it = ses.getNodeByIdentifier(id).getNodes();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Node child= it.nextNode();
|
Node child= it.nextNode();
|
||||||
|
@ -211,7 +211,7 @@ public class ItemsManager {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/items/{name}")
|
@Path("{id}/items/{name}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -342,7 +342,7 @@ public class ItemsManager {
|
||||||
|
|
||||||
return new ItemList(toReturn);
|
return new ItemList(toReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/children/paged")
|
@Path("{id}/children/paged")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -521,7 +521,7 @@ public class ItemsManager {
|
||||||
String filePublicUrl = String.format("%s/%s%s",basepath, enchriptedPrefix, enchriptedString);
|
String filePublicUrl = String.format("%s/%s%s",basepath, enchriptedPrefix, enchriptedString);
|
||||||
return filePublicUrl;
|
return filePublicUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}/publish")
|
@Path("{id}/publish")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -539,11 +539,11 @@ public class ItemsManager {
|
||||||
|
|
||||||
if (!(folder instanceof FolderItem))
|
if (!(folder instanceof FolderItem))
|
||||||
throw new InvalidCallParameters("item is not a folder");
|
throw new InvalidCallParameters("item is not a folder");
|
||||||
|
|
||||||
currentNode.setProperty(NodeProperty.IS_PUBLIC.toString(), publish);
|
currentNode.setProperty(NodeProperty.IS_PUBLIC.toString(), publish);
|
||||||
|
|
||||||
ses.save();
|
ses.save();
|
||||||
|
|
||||||
}catch(RepositoryException re ){
|
}catch(RepositoryException re ){
|
||||||
log.error("jcr error getting rootSharedFolder", re);
|
log.error("jcr error getting rootSharedFolder", re);
|
||||||
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||||
|
@ -874,10 +874,10 @@ public class ItemsManager {
|
||||||
if (!(destinationItem instanceof FolderItem))
|
if (!(destinationItem instanceof FolderItem))
|
||||||
throw new InvalidItemException("destination item is not a folder");
|
throw new InvalidItemException("destination item is not a folder");
|
||||||
|
|
||||||
|
|
||||||
boolean movingSharedItemOutside = item.isShared() && (!destinationItem.isShared() || !getSharedParentNode(nodeToMove).getIdentifier().equals(getSharedParentNode(destination).getIdentifier()));
|
boolean movingSharedItemOutside = item.isShared() && (!destinationItem.isShared() || !getSharedParentNode(nodeToMove).getIdentifier().equals(getSharedParentNode(destination).getIdentifier()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ses.getWorkspace().getLockManager().lock(destination.getPath(), false, true, 0,login);
|
ses.getWorkspace().getLockManager().lock(destination.getPath(), false, true, 0,login);
|
||||||
|
@ -891,12 +891,12 @@ public class ItemsManager {
|
||||||
|
|
||||||
ses.getWorkspace().move(nodeToMove.getPath(), newPath);
|
ses.getWorkspace().move(nodeToMove.getPath(), newPath);
|
||||||
Utils.setPropertyOnChangeNode(ses.getNode(newPath), login, ItemAction.MOVED);
|
Utils.setPropertyOnChangeNode(ses.getNode(newPath), login, ItemAction.MOVED);
|
||||||
|
|
||||||
String mimeTypeForAccounting = (item instanceof AbstractFileItem)? ((AbstractFileItem) item).getContent().getMimeType(): null;
|
String mimeTypeForAccounting = (item instanceof AbstractFileItem)? ((AbstractFileItem) item).getContent().getMimeType(): null;
|
||||||
|
|
||||||
if (movingSharedItemOutside)
|
if (movingSharedItemOutside)
|
||||||
item2Node.updateOwnerOnSubTree(nodeToMove, login);
|
item2Node.updateOwnerOnSubTree(nodeToMove, login);
|
||||||
|
|
||||||
accountingHandler.createFolderAddObj(uniqueName, item.getClass().getSimpleName(), mimeTypeForAccounting , ses, destination, false);
|
accountingHandler.createFolderAddObj(uniqueName, item.getClass().getSimpleName(), mimeTypeForAccounting , ses, destination, false);
|
||||||
accountingHandler.createFolderRemoveObj(item.getTitle(), item.getClass().getSimpleName(), mimeTypeForAccounting, ses, originalParent, false);
|
accountingHandler.createFolderRemoveObj(item.getTitle(), item.getClass().getSimpleName(), mimeTypeForAccounting, ses, originalParent, false);
|
||||||
ses.save();
|
ses.save();
|
||||||
|
@ -1100,7 +1100,7 @@ public class ItemsManager {
|
||||||
}
|
}
|
||||||
return Response.ok(id).build();
|
return Response.ok(id).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Path("/{id}/metadata")
|
@Path("/{id}/metadata")
|
||||||
|
@ -1152,7 +1152,7 @@ public class ItemsManager {
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
public Response deleteItem(@QueryParam("force") boolean force){
|
public Response deleteItem(@QueryParam("force") boolean force){
|
||||||
InnerMethodName.instance.set("deleteItem("+force+")");
|
InnerMethodName.instance.set("deleteItem("+force+")");
|
||||||
|
|
||||||
Session ses = null;
|
Session ses = null;
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
@ -1160,25 +1160,25 @@ public class ItemsManager {
|
||||||
|
|
||||||
//TODO check if it is possible to change all the ACL on a workspace
|
//TODO check if it is possible to change all the ACL on a workspace
|
||||||
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
authChecker.checkMoveOpsForProtectedFolders(ses, id);
|
|
||||||
authChecker.checkWriteAuthorizationControl(ses, id, false);
|
authChecker.checkWriteAuthorizationControl(ses, id, false);
|
||||||
|
authChecker.checkMoveOpsForProtectedFolders(ses, id);
|
||||||
|
|
||||||
final Node nodeToDelete = ses.getNodeByIdentifier(id);
|
final Node nodeToDelete = ses.getNodeByIdentifier(id);
|
||||||
|
|
||||||
Item itemToDelete = node2Item.getItem(nodeToDelete, Excludes.GET_ONLY_CONTENT);
|
Item itemToDelete = node2Item.getItem(nodeToDelete, Excludes.GET_ONLY_CONTENT);
|
||||||
|
|
||||||
if (itemToDelete instanceof SharedFolder || itemToDelete instanceof VreFolder || (itemToDelete instanceof FolderItem && Utils.hasSharedChildren(nodeToDelete)))
|
if (itemToDelete instanceof SharedFolder || itemToDelete instanceof VreFolder || (itemToDelete instanceof FolderItem && Utils.hasSharedChildren(nodeToDelete)))
|
||||||
throw new InvalidItemException("SharedFolder, VreFolder or folders with shared children cannot be deleted");
|
throw new InvalidItemException("SharedFolder, VreFolder or folders with shared children cannot be deleted");
|
||||||
|
|
||||||
log.debug("item is trashed? {}", itemToDelete.isTrashed());
|
log.debug("item is trashed? {}", itemToDelete.isTrashed());
|
||||||
|
|
||||||
if (!itemToDelete.isTrashed() && !force)
|
if (!itemToDelete.isTrashed() && !force) {
|
||||||
trashHandler.moveToTrash(ses, nodeToDelete, itemToDelete);
|
trashHandler.moveToTrash(ses, nodeToDelete, itemToDelete);
|
||||||
else
|
}else
|
||||||
trashHandler.removeNodes(ses, Collections.singletonList(itemToDelete));
|
trashHandler.removeNodes(ses, Collections.singletonList(itemToDelete));
|
||||||
|
|
||||||
}catch (LockException e) {
|
}catch (LockException e) {
|
||||||
|
|
||||||
}catch(RepositoryException re ){
|
}catch(RepositoryException re ){
|
||||||
log.error("jcr error moving item", re);
|
log.error("jcr error moving item", re);
|
||||||
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||||
|
|
|
@ -25,7 +25,7 @@ The projects leading to this software have received funding from a series of
|
||||||
Version
|
Version
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
1.2.0-SNAPSHOT (2020-04-17)
|
1.2.0-SNAPSHOT (2020-04-23)
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue