Example usage for java.nio.file.attribute UserDefinedFileAttributeView delete

List of usage examples for java.nio.file.attribute UserDefinedFileAttributeView delete

Introduction

In this page you can find the example usage for java.nio.file.attribute UserDefinedFileAttributeView delete.

Prototype

void delete(String name) throws IOException;

Source Link

Document

Deletes a user-defined attribute.

Usage

From source file:org.jclouds.kinetic.strategy.internal.KineticStorageStrategyImpl.java

@Override
public void removeBlob(final String container, final String blobKey) {
    kineticContainerNameValidator.validate(container);
    kineticBlobKeyValidator.validate(blobKey);
    String fileName = buildPathStartingFromBaseDir(container, blobKey);
    logger.debug("Deleting blob %s", fileName);
    File fileToBeDeleted = new File(fileName);

    if (fileToBeDeleted.isDirectory()) {
        try {/*from   w w w.java 2  s .c  om*/
            UserDefinedFileAttributeView view = getUserDefinedFileAttributeView(fileToBeDeleted.toPath());
            if (view != null) {
                for (String s : view.list()) {
                    view.delete(s);
                }
            }
        } catch (IOException e) {
            logger.debug("Could not delete attributes from %s: %s", fileToBeDeleted, e);
        }
    }

    try {
        delete(fileToBeDeleted);
    } catch (IOException e) {
        logger.debug("Could not delete %s: %s", fileToBeDeleted, e);
    }

    // now examine if the key of the blob is a complex key (with a directory structure)
    // and eventually remove empty directory
    removeDirectoriesTreeOfBlobKey(container, blobKey);
}