From e25a44eab916a554f17be39d733242ca59d56583 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 31 Mar 2015 15:24:29 -0700 Subject: [PATCH] JCLOUDS-732: Filesystem portable object ACLs --- .../FilesystemStorageStrategyImpl.java | 32 +++++++++++++++++++ .../FilesystemBlobIntegrationTest.java | 6 ---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java index 53b26e753d..6c579185f0 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java @@ -45,6 +45,7 @@ import javax.inject.Provider; import org.jclouds.blobstore.LocalStorageStrategy; import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.domain.BlobAccess; import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.blobstore.domain.ContainerAccess; import org.jclouds.blobstore.domain.MutableStorageMetadata; @@ -431,6 +432,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { logger.debug("xattrs not supported on %s", outputPath); } } + setBlobAccess(containerName, blobKey, BlobAccess.PRIVATE); return base16().lowerCase().encode(actualHashCode.asBytes()); } catch (IOException ex) { if (outputFile != null) { @@ -476,6 +478,36 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy { removeDirectoriesTreeOfBlobKey(container, blobKey); } + @Override + public BlobAccess getBlobAccess(String containerName, String blobName) { + Path path = new File(buildPathStartingFromBaseDir(containerName, blobName)).toPath(); + Set permissions; + try { + permissions = getPosixFilePermissions(path); + } catch (IOException ioe) { + throw Throwables.propagate(ioe); + } + return permissions.contains(PosixFilePermission.OTHERS_READ) + ? BlobAccess.PUBLIC_READ : BlobAccess.PRIVATE; + } + + @Override + public void setBlobAccess(String container, String name, BlobAccess access) { + Path path = new File(buildPathStartingFromBaseDir(container, name)).toPath(); + Set permissions; + try { + permissions = getPosixFilePermissions(path); + if (access == BlobAccess.PRIVATE) { + permissions.remove(PosixFilePermission.OTHERS_READ); + } else if (access == BlobAccess.PUBLIC_READ) { + permissions.add(PosixFilePermission.OTHERS_READ); + } + setPosixFilePermissions(path, permissions); + } catch (IOException ioe) { + throw Throwables.propagate(ioe); + } + } + @Override public Location getLocation(final String containerName) { return null; diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java index 417a4d9ca8..0452389bc7 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemBlobIntegrationTest.java @@ -27,7 +27,6 @@ import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.filesystem.reference.FilesystemConstants; import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.Test; -import org.testng.SkipException; @Test(groups = { "integration" }, singleThreaded = true, testName = "blobstore.FilesystemBlobIntegrationTest") public class FilesystemBlobIntegrationTest extends BaseBlobIntegrationTest { @@ -86,9 +85,4 @@ public class FilesystemBlobIntegrationTest extends BaseBlobIntegrationTest { super.checkUserMetadata(userMetadata1, userMetadata2); } } - - @Override - public void testSetBlobAccess() throws Exception { - throw new SkipException("Intentionally not implemented for the transient provider"); - } }