Skip to content

Commit

Permalink
SAK-29519 - Upgrade jclouds to 1.9.0 to resolve guava version issues
Browse files Browse the repository at this point in the history
  • Loading branch information
botimer committed Jun 13, 2015
1 parent 1e46070 commit bea0b79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<name>Openstack Swift Sakai Resources</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<jclouds.version>1.7.2</jclouds.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jclouds.version>1.9.0</jclouds.version>
</properties>
<dependencies>
<!-- sakai dependencies -->
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
<version>10.1</version>
<version>11-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -31,20 +31,20 @@
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
<scope>provided</scope>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-swift</artifactId>
<version>${jclouds.version}</version>
<scope>provided</scope>
<!--<scope>provided</scope>-->
</dependency>
<!-- 3rd party dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>provided</scope>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -83,4 +83,4 @@
</plugin>-->
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jclouds.openstack.swift.v1.features.ContainerApi;
import org.jclouds.openstack.swift.v1.features.ObjectApi;
import org.jclouds.openstack.swift.v1.options.CreateContainerOptions;
import org.jclouds.openstack.swift.v1.options.PutOptions;
import org.sakaiproject.content.api.FileSystemHandler;
import org.springframework.util.FileCopyUtils;

Expand Down Expand Up @@ -253,7 +254,7 @@ public void destroy() throws IOException{
@Override
public InputStream getInputStream(String id, String root, String filePath) throws IOException {
ContainerAndName can = getContainerAndName(id, root, filePath);
ObjectApi objectApi = swiftApi.objectApiInRegionForContainer(region, can.container);
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
SwiftObject so = objectApi.get(can.name, GetOptions.NONE);
if(so == null){
throw new IOException("No object found for " + id);
Expand All @@ -275,10 +276,10 @@ public long saveInputStream(String id, String root, String filePath, InputStream
checkAccountSpace();
createContainerIfNotExist(can.container);
checkContainerSpace(can.container);
ObjectApi objectApi = swiftApi.objectApiInRegionForContainer(region, can.container);
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
CountingInputStream in = new CountingInputStream((stream));
Payload payload = Payloads.newInputStreamPayload(in);
objectApi.replace(can.name, payload, ImmutableMap.of("id", id, "path", filePath));
objectApi.put(can.name, payload, PutOptions.Builder.metadata(ImmutableMap.of("id", id, "path", filePath)));
return in.getCount();
}

Expand All @@ -288,8 +289,8 @@ public long saveInputStream(String id, String root, String filePath, InputStream
@Override
public boolean delete(String id, String root, String filePath) {
ContainerAndName can = getContainerAndName(id, root, filePath);
ObjectApi objectApi = swiftApi.objectApiInRegionForContainer(region, can.container);
if(objectApi.head(can.name) == null){
ObjectApi objectApi = swiftApi.getObjectApi(region, can.container);
if(objectApi.getWithoutBody(can.name) == null){
return false;
}else{
objectApi.delete(can.name);
Expand All @@ -306,7 +307,7 @@ private void checkAccountSpace() throws IOException{
if(warningLimitForAccountSizeInBytes <= 0L && errorLimitForAccountSizeInBytes <= 0L){
return;
}
long bytesUsed = swiftApi.accountApiInRegion(region).get().getBytesUsed();
long bytesUsed = swiftApi.getAccountApi(region).get().getBytesUsed();
if(errorLimitForAccountSizeInBytes > 0L && errorLimitForAccountSizeInBytes < bytesUsed){
logger.errorOnAccountSize(errorLimitForAccountSizeInBytes, bytesUsed);
throw new IOException("No more space available for account!\nMax:" + errorLimitForAccountSizeInBytes + "\nUsed:" + bytesUsed);
Expand All @@ -325,7 +326,7 @@ private void checkContainerSpace(String container) throws IOException{
if(warningLimitForContainerSizeInBytes <= 0L && errorLimitForContainerSizeInBytes <= 0L){
return;
}
long bytesUsed = swiftApi.containerApiInRegion(region).head(container).getBytesUsed();
long bytesUsed = swiftApi.getContainerApi(region).get(container).getBytesUsed();
if(errorLimitForContainerSizeInBytes > 0L && errorLimitForContainerSizeInBytes < bytesUsed){
logger.errorOnContainerSize(errorLimitForContainerSizeInBytes, bytesUsed);
throw new IOException("No more space available for container!\nMax:" + errorLimitForContainerSizeInBytes + "\nUsed:" + bytesUsed);
Expand All @@ -340,17 +341,17 @@ private void checkContainerSpace(String container) throws IOException{
* Make sure the container exist.
*/
private void createContainerIfNotExist(String container) {
ContainerApi containerApi = swiftApi.containerApiInRegion(region);
ContainerApi containerApi = swiftApi.getContainerApi(region);
CreateContainerOptions options = CreateContainerOptions.Builder.anybodyRead();
containerApi.createIfAbsent(container, options);
containerApi.create(container, options);
}

/**
* Delete the container if it is empty.
*/
private void deleteContainerIfEmpty(String container){
if(deleteEmptyContainers) {
ContainerApi containerApi = swiftApi.containerApiInRegion(region);
ContainerApi containerApi = swiftApi.getContainerApi(region);
containerApi.deleteIfEmpty(container);
}
}
Expand Down

0 comments on commit bea0b79

Please sign in to comment.