solved bug with getAnchestors and public folders
This commit is contained in:
parent
7ed01ecc4e
commit
f2742ce0e0
|
@ -14,6 +14,7 @@ import org.gcube.data.access.storagehub.services.ItemsCreator;
|
||||||
import org.gcube.data.access.storagehub.services.ItemsManager;
|
import org.gcube.data.access.storagehub.services.ItemsManager;
|
||||||
import org.gcube.data.access.storagehub.services.UserManager;
|
import org.gcube.data.access.storagehub.services.UserManager;
|
||||||
import org.gcube.data.access.storagehub.services.WorkspaceManager;
|
import org.gcube.data.access.storagehub.services.WorkspaceManager;
|
||||||
|
import org.gcube.data.access.storagehub.services.admin.ItemManagerAdmin;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
|
|
||||||
@Path("workspace")
|
@Path("workspace")
|
||||||
|
@ -31,6 +32,7 @@ public class StorageHub extends Application {
|
||||||
classes.add(ItemSharing.class);
|
classes.add(ItemSharing.class);
|
||||||
classes.add(UserManager.class);
|
classes.add(UserManager.class);
|
||||||
classes.add(GroupManager.class);
|
classes.add(GroupManager.class);
|
||||||
|
classes.add(ItemManagerAdmin.class);
|
||||||
classes.add(SerializableErrorEntityTextWriter.class);
|
classes.add(SerializableErrorEntityTextWriter.class);
|
||||||
classes.add(MyApplicationListener.class);
|
classes.add(MyApplicationListener.class);
|
||||||
return classes;
|
return classes;
|
||||||
|
|
|
@ -716,16 +716,19 @@ public class ItemsManager {
|
||||||
Node currentNode = ses.getNodeByIdentifier(id);
|
Node currentNode = ses.getNodeByIdentifier(id);
|
||||||
Item currentItem = node2Item.getItem(currentNode, excludes);
|
Item currentItem = node2Item.getItem(currentNode, excludes);
|
||||||
log.trace("current node is {}",currentNode.getPath());
|
log.trace("current node is {}",currentNode.getPath());
|
||||||
while (!(currentNode.getPath()+"/").equals(absolutePath.toPath())) {
|
while (!(currentNode.getPath().matches("/Home/[^/]{1,}/Workspace"))) {
|
||||||
if (currentItem instanceof SharedFolder){
|
if (currentItem instanceof SharedFolder){
|
||||||
NodeIterator sharedSetIterator = currentNode.getSharedSet();
|
NodeIterator sharedSetIterator = currentNode.getSharedSet();
|
||||||
|
boolean found = false;
|
||||||
while (sharedSetIterator.hasNext()) {
|
while (sharedSetIterator.hasNext()) {
|
||||||
Node sharedNode = sharedSetIterator.nextNode();
|
Node sharedNode = sharedSetIterator.nextNode();
|
||||||
if (sharedNode.getPath().startsWith(Utils.getWorkspacePath(login).toPath())) {
|
if (sharedNode.getPath().startsWith(Utils.getWorkspacePath(login).toPath())) {
|
||||||
currentNode = sharedNode.getParent();
|
currentNode = sharedNode.getParent();
|
||||||
|
found=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found) break;
|
||||||
currentItem = node2Item.getItem(currentNode, excludes);
|
currentItem = node2Item.getItem(currentNode, excludes);
|
||||||
}else {
|
}else {
|
||||||
currentNode = currentNode.getParent();
|
currentNode = currentNode.getParent();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.ServletContext;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
@ -26,6 +27,7 @@ import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
||||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
import org.gcube.common.storagehub.model.service.ItemList;
|
||||||
import org.gcube.common.storagehub.model.service.ItemWrapper;
|
import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||||
import org.gcube.data.access.storagehub.StorageHubAppllicationManager;
|
import org.gcube.data.access.storagehub.StorageHubAppllicationManager;
|
||||||
import org.gcube.data.access.storagehub.Utils;
|
import org.gcube.data.access.storagehub.Utils;
|
||||||
|
@ -54,6 +56,7 @@ public class ItemManagerAdmin {
|
||||||
@Path("items/{id}")
|
@Path("items/{id}")
|
||||||
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
||||||
public String createItem(@PathParam("id") String id, Item item) {
|
public String createItem(@PathParam("id") String id, Item item) {
|
||||||
|
InnerMethodName.instance.set("creteItemAdmin)");
|
||||||
//TODO: implement this method
|
//TODO: implement this method
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +66,7 @@ public class ItemManagerAdmin {
|
||||||
@Path("{user}")
|
@Path("{user}")
|
||||||
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
||||||
public ItemWrapper<Item> getWorkspace(@PathParam("user") String user) {
|
public ItemWrapper<Item> getWorkspace(@PathParam("user") String user) {
|
||||||
InnerMethodName.instance.set("move");
|
InnerMethodName.instance.set("getWorkspaceAdmin");
|
||||||
|
|
||||||
Item item =null;
|
Item item =null;
|
||||||
Session session = null;
|
Session session = null;
|
||||||
|
@ -87,12 +90,41 @@ public class ItemManagerAdmin {
|
||||||
return new ItemWrapper<Item>(item);
|
return new ItemWrapper<Item>(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@Path("items/{id}")
|
||||||
|
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
||||||
|
public ItemWrapper<Item> getItem(@PathParam("id") String id) {
|
||||||
|
InnerMethodName.instance.set("getChildrenAdmin");
|
||||||
|
|
||||||
|
Item item =null;
|
||||||
|
Session session = null;
|
||||||
|
try{
|
||||||
|
session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
Node node = session.getNodeByIdentifier(id);
|
||||||
|
|
||||||
|
item = node2Item.getItem(node, Collections.emptyList());
|
||||||
|
|
||||||
|
}catch(RepositoryException re ){
|
||||||
|
log.error("jcr error moving item", re);
|
||||||
|
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||||
|
}catch(StorageHubException she ){
|
||||||
|
log.error(she.getErrorMessage(), she);
|
||||||
|
GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
|
||||||
|
} finally{
|
||||||
|
if (session!=null) {
|
||||||
|
session.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ItemWrapper<Item>(item);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("items/{id}/children")
|
@Path("items/{id}/children")
|
||||||
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
||||||
public List<Item> getChildren(@PathParam("id") String id) {
|
public ItemList getChildren(@PathParam("id") String id) {
|
||||||
InnerMethodName.instance.set("move");
|
InnerMethodName.instance.set("getChildrenAdmin");
|
||||||
|
|
||||||
List<Item> items =null;
|
List<Item> items =null;
|
||||||
Session session = null;
|
Session session = null;
|
||||||
|
@ -113,6 +145,32 @@ public class ItemManagerAdmin {
|
||||||
session.logout();
|
session.logout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new ItemList(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Consumes(MediaType.TEXT_PLAIN)
|
||||||
|
@Path("items/{id}/{propertyName}")
|
||||||
|
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE},exception=MyAuthException.class)
|
||||||
|
public List<Item> setProperty(@PathParam("id") String id, @PathParam("propertyName") String propertyName, String value) {
|
||||||
|
InnerMethodName.instance.set("setPropertyAdmin");
|
||||||
|
|
||||||
|
List<Item> items =null;
|
||||||
|
Session session = null;
|
||||||
|
try{
|
||||||
|
session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
Node node = session.getNodeByIdentifier(id);
|
||||||
|
node.setProperty(propertyName, value);
|
||||||
|
session.save();
|
||||||
|
|
||||||
|
}catch(RepositoryException re ){
|
||||||
|
log.error("jcr error moving item", re);
|
||||||
|
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||||
|
} finally{
|
||||||
|
if (session!=null) {
|
||||||
|
session.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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-15)
|
1.2.0-SNAPSHOT (2020-04-17)
|
||||||
|
|
||||||
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