use of diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage in project dcache by dCache.
the class PnfsManagerV3 method writeExtendedAttributes.
private void writeExtendedAttributes(PnfsWriteExtendedAttributesMessage message) {
try {
if (message.getFsPath() == null) {
throw new CacheException("PNFS-ID based xattr writing is not supported");
}
checkRestriction(message, UPDATE_METADATA);
populatePnfsId(message);
checkMask(message);
FsPath path = message.getFsPath();
NameSpaceProvider.SetExtendedAttributeMode m;
switch(message.getMode()) {
case CREATE:
m = NameSpaceProvider.SetExtendedAttributeMode.CREATE;
break;
case MODIFY:
m = NameSpaceProvider.SetExtendedAttributeMode.REPLACE;
break;
case EITHER:
m = NameSpaceProvider.SetExtendedAttributeMode.EITHER;
break;
default:
throw new RuntimeException("Unknown mode " + message.getMode());
}
for (Map.Entry<String, byte[]> modification : message.getAllValues().entrySet()) {
_nameSpaceProvider.writeExtendedAttribute(message.getSubject(), path, modification.getKey(), modification.getValue(), m);
}
message.clearValues();
message.setSucceeded();
} catch (CacheException e) {
message.clearValues();
message.setFailed(e.getRc(), e);
}
}
use of diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage in project dcache by dCache.
the class PnfsHandler method writeExtendedAttribute.
/**
* Create or modify the value of extended attributes.
*
* @param path The file for which the extended attribute is created or modified.
* @param xattrs The attributes to modify.
* @param mode How the attribute value is to be updated.
* @throws FileNotFoundCacheException if the path does not exist.
* @throws PermissionDeniedCacheException if the user is not allowed to modify this attribute.
* @throws AttributeExistsCacheException if mode is Mode.CREATE and the attribute exists.
* @throws NoAttributeCacheException if mode is Mode.MODIFY and the attribute does not
* exist.
* @throws CacheException a generic failure in modify the attribute.
*/
public void writeExtendedAttribute(FsPath path, Map<String, byte[]> xattrs, Mode mode) throws CacheException {
PnfsWriteExtendedAttributesMessage message = new PnfsWriteExtendedAttributesMessage(path.toString(), mode);
xattrs.forEach(message::putValue);
request(message);
}
use of diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage in project dcache by dCache.
the class PnfsHandler method writeExtendedAttribute.
/**
* Create or modify the value of an extended attribute.
*
* @param path The file for which the extended attribute is created or modified.
* @param name The ID of the extended attribute.
* @param value The value of the attribute if the operation is successful.
* @param mode How the attribute value is to be updated.
* @throws FileNotFoundCacheException if the path does not exist.
* @throws PermissionDeniedCacheException if the user is not allowed to modify this attribute.
* @throws AttributeExistsCacheException if mode is Mode.CREATE and the attribute exists.
* @throws NoAttributeCacheException if mode is Mode.MODIFY and the attribute does not
* exist.
* @throws CacheException a generic failure in modify the attribute.
*/
public void writeExtendedAttribute(FsPath path, String name, byte[] value, Mode mode) throws CacheException {
PnfsWriteExtendedAttributesMessage message = new PnfsWriteExtendedAttributesMessage(path.toString(), mode);
message.putValue(name, value);
request(message);
}
use of diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage in project dcache by dCache.
the class RemoteNameSpaceProvider method writeExtendedAttribute.
public void writeExtendedAttribute(Subject subject, FsPath path, String name, byte[] value, SetExtendedAttributeMode mode) throws CacheException {
PnfsWriteExtendedAttributesMessage.Mode m;
switch(mode) {
case CREATE:
m = PnfsWriteExtendedAttributesMessage.Mode.CREATE;
break;
case REPLACE:
m = PnfsWriteExtendedAttributesMessage.Mode.MODIFY;
break;
case EITHER:
m = PnfsWriteExtendedAttributesMessage.Mode.EITHER;
break;
default:
throw new RuntimeException("Unknown mode " + mode);
}
PnfsWriteExtendedAttributesMessage message = new PnfsWriteExtendedAttributesMessage(path.toString(), m);
message.setSubject(subject);
message.setRestriction(Restrictions.none());
message.putValue(name, value);
_pnfs.request(message);
}
Aggregations