JCLOUDS-732: Filesystem portable object ACLs

This commit is contained in:
Andrew Gaul 2015-03-31 15:24:29 -07:00
parent 279a984fee
commit fadbbad8ac
2 changed files with 32 additions and 6 deletions

View File

@ -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;
@ -430,6 +431,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) {
@ -475,6 +477,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<PosixFilePermission> 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<PosixFilePermission> 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;

View File

@ -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");
}
}