Search in sources :

Example 1 with PnfsWriteExtendedAttributesMessage

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);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) Map(java.util.Map) FsPath(diskCacheV111.util.FsPath)

Example 2 with PnfsWriteExtendedAttributesMessage

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);
}
Also used : PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage)

Example 3 with PnfsWriteExtendedAttributesMessage

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);
}
Also used : PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage)

Example 4 with PnfsWriteExtendedAttributesMessage

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);
}
Also used : PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage)

Aggregations

PnfsWriteExtendedAttributesMessage (diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage)3 CacheException (diskCacheV111.util.CacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 FsPath (diskCacheV111.util.FsPath)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 Map (java.util.Map)1