Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pdowler committed Oct 30, 2024
2 parents e13f443 + 1e70e55 commit 138eadc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion vault/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
compile 'org.opencadc:cadc-log:[1.1.6,2.0)'
compile 'org.opencadc:cadc-gms:[1.0.5,)'
compile 'org.opencadc:cadc-rest:[1.3.16,)'
compile 'org.opencadc:cadc-vos:[2.0.6,)'
compile 'org.opencadc:cadc-vos:[2.0.7,)'
compile 'org.opencadc:cadc-vos-server:[2.0.18,)'
compile 'org.opencadc:cadc-vosi:[1.3.2,)'
compile 'org.opencadc:cadc-uws:[1.0,)'
Expand Down
31 changes: 20 additions & 11 deletions vault/src/main/java/org/opencadc/vault/NodePersistenceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ private class ChildNodeWrapper implements ResourceIterator<Node> {

private final ContainerNode parent;
private ResourceIterator<Node> childIter;
private boolean closedForException = false;

private final IdentityManager identityManager = AuthenticationUtil.getIdentityManager();
private final Map<Object, Subject> identCache = new TreeMap<>();
Expand All @@ -520,10 +521,7 @@ private class ChildNodeWrapper implements ResourceIterator<Node> {

@Override
public boolean hasNext() {
if (childIter != null) {
return childIter.hasNext();
}
return false;
return !closedForException && childIter != null && childIter.hasNext();
}

@Override
Expand All @@ -534,14 +532,25 @@ public Node next() {
Node ret = childIter.next();
ret.parent = parent;

// owner
Subject s = identCache.get(ret.ownerID);
if (s == null) {
s = identityManager.toSubject(ret.ownerID);
identCache.put(ret.ownerID, s);
try {
// owner
Subject s = identCache.get(ret.ownerID);
if (s == null) {
s = identityManager.toSubject(ret.ownerID);
identCache.put(ret.ownerID, s);
}
ret.owner = s;
ret.ownerDisplay = identityManager.toDisplayString(ret.owner);
} catch (RuntimeException ex) {
try {
// abort
close();
} catch (Exception cex) {
log.error("failed to close iterator", ex);
}
closedForException = true;
throw ex;
}
ret.owner = s;
ret.ownerDisplay = identityManager.toDisplayString(ret.owner);

if (ret instanceof DataNode) {
DataNode dn = (DataNode) ret;
Expand Down
10 changes: 9 additions & 1 deletion vault/src/main/java/org/opencadc/vault/files/GetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void doAction() throws Exception {
boolean noArtifact = node.bytesUsed == null || node.bytesUsed == 0L;
noArtifact = noArtifact && nodePersistence.preventNotFound && rn.artifact == null;
if (noArtifact) {
// no file
// no artifact found by preventNotFound
syncOutput.setCode(HttpURLConnection.HTTP_NO_CONTENT);
return;
}
Expand All @@ -126,6 +126,14 @@ public void doAction() throws Exception {
rn.protos = tg.getEndpoints(targetURI, pullTransfer, null);
rn.artifact = tg.resolvedArtifact; // currently unused at this point
}
// check artifact again (!preventNotFound)
noArtifact = node.bytesUsed == null || node.bytesUsed == 0L;
noArtifact = noArtifact && rn.artifact == null;
if (noArtifact) {
// no file
syncOutput.setCode(HttpURLConnection.HTTP_NO_CONTENT);
return;
}

if (rn.protos.isEmpty()) {
throw new TransientException("No location found for file " + Utils.getPath(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ public void setOperation(String op) {
}

public void setLastModified(Date ts) {
DateFormat df = DateUtil.getDateFormat(DateUtil.IVOA_DATE_FORMAT, DateUtil.UTC);
this.lastmodified = df.format(ts);
if (ts != null) {
DateFormat df = DateUtil.getDateFormat(DateUtil.IVOA_DATE_FORMAT, DateUtil.UTC);
this.lastmodified = df.format(ts);
} else {
this.lastmodified = null;
}
}


}

0 comments on commit 138eadc

Please sign in to comment.