diff --git a/modules/dcache-webdav/src/main/java/org/dcache/webdav/DcacheResourceFactory.java b/modules/dcache-webdav/src/main/java/org/dcache/webdav/DcacheResourceFactory.java index 4d39366656c..e7be0392ca9 100644 --- a/modules/dcache-webdav/src/main/java/org/dcache/webdav/DcacheResourceFactory.java +++ b/modules/dcache-webdav/src/main/java/org/dcache/webdav/DcacheResourceFactory.java @@ -53,6 +53,7 @@ import diskCacheV111.util.PnfsHandler; import diskCacheV111.util.PnfsId; import diskCacheV111.util.QuotaExceededCacheException; +import diskCacheV111.util.RetentionPolicy; import diskCacheV111.util.TimeoutCacheException; import diskCacheV111.vehicles.DoorRequestInfoMessage; import diskCacheV111.vehicles.DoorTransferFinishedMessage; @@ -1858,6 +1859,8 @@ public synchronized void finished(CacheException error) { private class WriteTransfer extends HttpTransfer { private final Optional _contentMd5; + /** optional hits to tape system how to store the file */ + private final Optional _archiveMetadata; public WriteTransfer(PnfsHandler pnfs, Subject subject, Restriction restriction, FsPath path) throws URISyntaxException { @@ -1876,6 +1879,8 @@ public WriteTransfer(PnfsHandler pnfs, Subject subject, throw new UncheckedBadRequestException("Bad Content-MD5 header: " + e.toString(), null); } + + _archiveMetadata = Optional.ofNullable(ServletRequest.getRequest().getHeader("ArchiveMetadata")); } @Override @@ -1930,6 +1935,11 @@ public void createNameSpaceEntry() throws CacheException { } getMaxUploadSize().ifPresent(this::setMaximumLength); + + // for CUSTODIAL files on upload client might provide extra information that should be passed to the tape system + if (_archiveMetadata.isPresent() && getFileAttributes().getRetentionPolicy() == RetentionPolicy.CUSTODIAL) { + getFileAttributes().getStorageInfo().setKey("archive_metadata", _archiveMetadata.get()); + } } public void relayData(InputStream inputStream) diff --git a/modules/dcache-webdav/src/main/java/org/dcache/webdav/transfer/RemoteTransferHandler.java b/modules/dcache-webdav/src/main/java/org/dcache/webdav/transfer/RemoteTransferHandler.java index ff306464fcc..7a05b62a022 100644 --- a/modules/dcache-webdav/src/main/java/org/dcache/webdav/transfer/RemoteTransferHandler.java +++ b/modules/dcache-webdav/src/main/java/org/dcache/webdav/transfer/RemoteTransferHandler.java @@ -56,6 +56,7 @@ import diskCacheV111.util.PnfsHandler; import diskCacheV111.util.PnfsId; import diskCacheV111.util.QuotaExceededCacheException; +import diskCacheV111.util.RetentionPolicy; import diskCacheV111.util.TimeoutCacheException; import diskCacheV111.vehicles.IoDoorEntry; import diskCacheV111.vehicles.IoJobInfo; @@ -905,7 +906,17 @@ private FileAttributes resolvePath() throws ErrorResponseException { msg = _pnfs.createPnfsEntry(_path.toString(), attributes, TransferManagerHandler.ATTRIBUTES_FOR_PULL); } - return msg.getFileAttributes(); + + var attrs = msg.getFileAttributes(); + // for CUSTODIAL files on upload client might provide extra information that should be passed to the tape system + if (attrs.getRetentionPolicy() == RetentionPolicy.CUSTODIAL) { + var archiveMetadata = ServletRequest.getRequest().getHeader("ArchiveMetadata"); + if (archiveMetadata != null) { + attrs.getStorageInfo().setKey("archive_metadata", archiveMetadata); + } + } + + return attrs; default: throw new ErrorResponseException(Response.Status.SC_INTERNAL_SERVER_ERROR,