diff --git a/cavern/src/main/java/org/opencadc/cavern/files/PutAction.java b/cavern/src/main/java/org/opencadc/cavern/files/PutAction.java index 095c2456..cf0bd171 100644 --- a/cavern/src/main/java/org/opencadc/cavern/files/PutAction.java +++ b/cavern/src/main/java/org/opencadc/cavern/files/PutAction.java @@ -98,7 +98,7 @@ import org.opencadc.vospace.VOSURI; /** - * + * @author pdowler * @author majorb * @author jeevesh */ @@ -174,6 +174,13 @@ public void doAction() throws Exception { throw new IllegalArgumentException("not a data node"); } node = (DataNode) n; + if (node == null) { + log.warn("target node: " + node + ": creating"); + node = new DataNode(nodeURI.getName()); + node.owner = caller; + node.parent = cn; + nodePersistence.put(node); + } // check write permission if (!preauthGranted) { @@ -197,8 +204,9 @@ public void doAction() throws Exception { //Files.copy(vis, target, StandardCopyOption.REPLACE_EXISTING); // truncate: do not recreate file with wrong owner + StandardOpenOption openOption = StandardOpenOption.TRUNCATE_EXISTING; DigestOutputStream out = new DigestOutputStream( - Files.newOutputStream(target, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING), md); + Files.newOutputStream(target, StandardOpenOption.WRITE, openOption), md); ByteCountOutputStream bcos = new ByteCountOutputStream(out); MultiBufferIO io = new MultiBufferIO(); io.copy(in, bcos); @@ -223,7 +231,7 @@ public void doAction() throws Exception { // update Node node.owner = caller; - node.ownerID = identityManager.toPosixPrincipal(caller); + node.ownerID = null; // just in case log.debug(nodeURI + " MD5: " + propValue); NodeProperty csp = node.getProperty(VOS.PROPERTY_URI_CONTENTMD5);