get info added on all folder
This commit is contained in:
parent
afbaceffa9
commit
0f59bc8d8c
|
@ -86,7 +86,7 @@ public class Utils {
|
|||
@Deprecated
|
||||
public static long countSubItems(Node parent) throws RepositoryException, BackendGenericError{
|
||||
long count = 0;
|
||||
List<Item> items = getItemList(parent, Excludes.ALL, null, true, null);
|
||||
List<Item> items = getItemList(parent, Excludes.ALL, null, false, null);
|
||||
for (Item item: items) {
|
||||
if (item instanceof FolderItem)
|
||||
count += Utils.countSubItems((Node)item.getRelatedNode());
|
||||
|
@ -98,7 +98,7 @@ public class Utils {
|
|||
@Deprecated
|
||||
public static long getSubItemsSize(Node parent) throws RepositoryException, BackendGenericError{
|
||||
long size = 0;
|
||||
List<Item> items = getItemList(parent, Excludes.GET_ONLY_CONTENT, null, true, new IncludeTypePredicate(Arrays.asList(GenericFileItem.class, FolderItem.class)));
|
||||
List<Item> items = getItemList(parent, Excludes.GET_ONLY_CONTENT, null, false, new IncludeTypePredicate(Arrays.asList(GenericFileItem.class, FolderItem.class)));
|
||||
for (Item item: items)
|
||||
if (item instanceof FolderItem)
|
||||
size += Utils.getSubItemsSize((Node)item.getRelatedNode());
|
||||
|
@ -109,7 +109,7 @@ public class Utils {
|
|||
|
||||
public static FolderInfoType getFolderInfo(Node parent) throws RepositoryException, BackendGenericError{
|
||||
FolderInfoType info = new FolderInfoType(0, 0);
|
||||
List<Item> items = getItemList(parent, Excludes.GET_ONLY_CONTENT, null, true, null);
|
||||
List<Item> items = getItemList(parent, Excludes.GET_ONLY_CONTENT, null, false, null);
|
||||
for (Item item: items)
|
||||
if (item instanceof FolderItem) {
|
||||
FolderInfoType fit = getFolderInfo((Node) item.getRelatedNode());
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.gcube.common.storagehub.model.service.ItemList;
|
|||
import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||
import org.gcube.common.storagehub.model.service.VersionList;
|
||||
import org.gcube.common.storagehub.model.storages.MetaInfo;
|
||||
import org.gcube.common.storagehub.model.types.FolderInfoType;
|
||||
import org.gcube.common.storagehub.model.types.ItemAction;
|
||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
||||
import org.gcube.data.access.storagehub.AuthorizationChecker;
|
||||
|
@ -1161,5 +1162,30 @@ public class ItemsManager extends Impersonable{
|
|||
return Response.ok().build();
|
||||
}
|
||||
|
||||
@Path("{id}/info")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public FolderInfoType getFolderInfo() {
|
||||
InnerMethodName.set("getFolderInfo");
|
||||
Session ses = null;
|
||||
try {
|
||||
ses = repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
Node node = ses.getNodeByIdentifier(id);
|
||||
Item item = node2Item.getItem(node, Excludes.ALL);
|
||||
if (!(item instanceof FolderItem))
|
||||
throw new InvalidCallParameters("the item is not a folder");
|
||||
return Utils.getFolderInfo(node);
|
||||
} catch (RepositoryException re) {
|
||||
log.error("error getting workspace total size", re);
|
||||
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||
} catch (StorageHubException she) {
|
||||
log.error(she.getErrorMessage(), she);
|
||||
GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
|
||||
} finally {
|
||||
if (ses != null)
|
||||
ses.logout();
|
||||
}
|
||||
return new FolderInfoType(0, 0);
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,6 @@ import org.gcube.common.storagehub.model.service.ItemWrapper;
|
|||
import org.gcube.common.storagehub.model.storages.MetaInfo;
|
||||
import org.gcube.common.storagehub.model.storages.StorageBackend;
|
||||
import org.gcube.common.storagehub.model.storages.StorageBackendFactory;
|
||||
import org.gcube.common.storagehub.model.types.FolderInfoType;
|
||||
import org.gcube.data.access.storagehub.AuthorizationChecker;
|
||||
import org.gcube.data.access.storagehub.Constants;
|
||||
import org.gcube.data.access.storagehub.PathUtil;
|
||||
|
@ -537,28 +536,5 @@ public class WorkspaceManager extends Impersonable {
|
|||
return "0";
|
||||
}
|
||||
|
||||
@Path("info")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public FolderInfoType getWorkspaceInfo() {
|
||||
InnerMethodName.set("getWorkspaceInfo");
|
||||
Session ses = null;
|
||||
try {
|
||||
ses = repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
Node wsNode = ses.getNode(pathUtil.getWorkspacePath(currentUser).toPath());
|
||||
return Utils.getFolderInfo(wsNode);
|
||||
} catch (RepositoryException re) {
|
||||
log.error("error getting workspace total size", re);
|
||||
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||
} catch (StorageHubException she) {
|
||||
log.error(she.getErrorMessage(), she);
|
||||
GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
|
||||
} finally {
|
||||
if (ses != null)
|
||||
ses.logout();
|
||||
}
|
||||
return new FolderInfoType(0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue