Commit 6531931d authored by mhellka's avatar mhellka
Browse files

Added ?with=snapshots option to getArchiveInfo API.

parent 8710889a
......@@ -73,7 +73,7 @@ import de.gwdg.cdstar.web.common.model.SnapshotList;
public class ArchiveEndpoint implements RestBlueprint {
private static final String SNAPSHOT_SEP = "@";
private static final Set<String> withOptions = new HashSet<>(Arrays.asList("files", "meta", "acl"));
private static final Set<String> withOptions = new HashSet<>(Arrays.asList("files", "meta", "acl", "snapshots"));
private RequestThrottle zipBreaker;
@Override
......@@ -174,6 +174,7 @@ public class ArchiveEndpoint implements RestBlueprint {
|| qh.has("reverse") || qh.has("offset") || qh.has("limit");
final boolean showMeta = with.contains("meta");
final boolean showACL = with.contains("acl");
final boolean showSnaps = with.contains("snapshots");
final ArchiveInfo info = new ArchiveInfo();
info.id = source.getSourceArchive().getId();
......@@ -214,6 +215,15 @@ public class ArchiveEndpoint implements RestBlueprint {
}
}
if (showSnaps) {
try {
info.snapshots = source.getSourceArchive().getSnapshots().stream()
.map(this::snapshotInfo).collect(Collectors.toList());
} catch (final AccessError e) {
// Just keep it blank
}
}
return info;
}
......
......@@ -25,4 +25,5 @@ public class ArchiveInfo {
public MetaMap meta;
public String owner;
public AclMap acl;
public List<SnapshotInfo> snapshots;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment