From 9e340f286e642ad052c0c479df1a00e32e9bb2d2 Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Mon, 7 Dec 2009 07:09:57 +0000 Subject: [PATCH] Issue 128: added initial vfs module and fixed dependent bugs git-svn-id: http://jclouds.googlecode.com/svn/trunk@2374 3d8758e0-26b5-11de-8745-db77d3ebf521 --- README.txt | 23 + .../saas/blobstore/AtmosAsyncBlobStore.java | 21 +- .../saas/blobstore/AtmosBlobStore.java | 15 +- .../blobstore/strategy/RecursiveRemove.java | 4 +- .../internal/StubAtmosStorageAsyncClient.java | 4 +- atmos/src/test/resources/hashstring.txt | 23 + .../BindGroupNameToIndexedFormParams.java | 23 + .../BindInetAddressesToIndexedFormParams.java | 23 + .../BindInstanceIdsToIndexedFormParams.java | 23 + .../BindKeyNameToIndexedFormParams.java | 23 + ...upPairToSourceSecurityGroupFormParams.java | 23 + .../org/jclouds/aws/ec2/domain/Image.java | 23 + .../aws/ec2/domain/ImageAttribute.java | 23 + .../jclouds/aws/ec2/domain/InstanceState.java | 23 + .../jclouds/aws/ec2/domain/InstanceType.java | 23 + .../jclouds/aws/ec2/domain/IpPermission.java | 23 + .../jclouds/aws/ec2/domain/IpProtocol.java | 23 + .../org/jclouds/aws/ec2/domain/KeyPair.java | 23 + .../ec2/domain/PublicIpInstanceIdPair.java | 23 + .../jclouds/aws/ec2/domain/Reservation.java | 23 + .../aws/ec2/domain/RunningInstance.java | 23 + .../jclouds/aws/ec2/domain/SecurityGroup.java | 23 + .../aws/ec2/domain/TerminatedInstance.java | 23 + .../aws/ec2/domain/UserIdGroupPair.java | 23 + .../functions/ReturnVoidOnGroupNotFound.java | 23 + .../ec2/options/DescribeImagesOptions.java | 23 + .../aws/ec2/options/RunInstancesOptions.java | 23 + .../internal/BaseEC2RequestOptions.java | 2 +- .../org/jclouds/aws/ec2/util/EC2Utils.java | 23 + .../xml/AllocateAddressResponseHandler.java | 2 +- .../aws/ec2/xml/BaseReservationHandler.java | 2 +- .../xml/DescribeAddressesResponseHandler.java | 2 +- .../xml/DescribeInstancesResponseHandler.java | 2 +- .../ec2/xml/RunInstancesResponseHandler.java | 2 +- .../TerminateInstancesResponseHandler.java | 2 +- .../jclouds/aws/s3/S3PropertiesBuilder.java | 3 + .../aws/s3/blobstore/S3AsyncBlobStore.java | 43 +- .../jclouds/aws/s3/blobstore/S3BlobStore.java | 32 +- .../functions/BlobToObjectGetOptions.java | 7 +- .../BucketToContainerListOptions.java | 2 +- .../ContainerToBucketListOptions.java | 10 +- .../functions/ObjectToBlobMetadata.java | 12 +- .../blobstore/internal/BaseS3BlobStore.java | 8 + .../java/org/jclouds/aws/util/AWSUtils.java | 23 + .../org/jclouds/aws/util/RequestSigner.java | 23 + .../ec2/config/EC2RestClientModuleTest.java | 23 + .../aws/ec2/filters/FormSignerTest.java | 23 + .../options/DescribeImagesOptionsTest.java | 23 + .../ec2/options/RunInstancesOptionsTest.java | 23 + .../BlobStoreContextToContainerResult.java | 2 +- .../aws/s3/BasePerformanceLiveTest.java | 2 +- .../blob/blobstore/AzureAsyncBlobStore.java | 38 +- .../blob/blobstore/AzureBlobStore.java | 35 +- .../BlobPropertiesToBlobMetadata.java | 7 + .../ListBlobsOptionsToListOptions.java | 2 +- .../ListOptionsToListBlobsOptions.java | 4 +- .../ListableBlobPropertiesToBlobMetadata.java | 12 +- .../internal/BaseAzureBlobStore.java | 8 + ...ontainerNameEnumerationResultsHandler.java | 3 +- .../ParseAzureStorageErrorFromXmlContent.java | 9 +- .../config/AzureBlobContextModuleTest.java | 76 ---- .../org/jclouds/blobstore/AsyncBlobStore.java | 6 +- .../java/org/jclouds/blobstore/BlobStore.java | 6 +- .../blobstore/BlobStoreContextFactory.java | 74 +++ .../functions/BlobToHttpGetOptions.java | 7 +- ...ParseSystemAndUserMetadataFromHeaders.java | 16 +- ...etadataToRelativePathResourceMetadata.java | 50 +++ .../blobstore/internal/BaseBlobMap.java | 8 +- .../internal/BlobStoreContextImpl.java | 4 +- .../internal/LocationAndCredentials.java | 143 ++++++ .../jclouds/blobstore/options/GetOptions.java | 9 + .../options/ListContainerOptions.java | 27 +- .../reference/BlobStoreConstants.java | 23 + .../strategy/GetDirectoryStrategy.java | 41 ++ .../strategy/IsDirectoryStrategy.java | 40 ++ .../blobstore/strategy/MkdirStrategy.java | 40 ++ .../internal/MarkerFileMkdirStrategy.java | 80 ++++ .../internal/MarkersGetDirectoryStrategy.java | 93 ++++ .../internal/MarkersIsDirectoryStrategy.java | 59 +++ .../blobstore/util/BlobStoreUtils.java | 23 + .../org/jclouds/http/options/GetOptions.java | 2 +- .../org/jclouds/rest/RestContextBuilder.java | 2 +- .../jclouds/rest/domain/NamedResource.java | 23 + .../rest/internal/NamedResourceImpl.java | 23 + .../rest/internal/RestContextImpl.java | 2 +- .../src/main/java/org/jclouds/util/Utils.java | 6 + .../BlobStoreContextFactoryTest.java | 66 +++ ...ataToRelativePathResourceMetadataTest.java | 80 ++++ .../ParseBlobMetadataFromHeadersTest.java | 8 +- .../StubBlobStoreContextBuilder.java | 9 + .../integration/StubPropertiesBuilder.java | 45 ++ .../BaseBlobStoreIntegrationTest.java | 4 +- .../BaseContainerIntegrationTest.java | 10 +- .../internal/StubAsyncBlobStore.java | 60 ++- .../internal/LocationAndCredentialsTest.java | 86 ++++ .../blobstore/options/ListOptionsTest.java | 18 +- .../org/jclouds/compute/ComputeService.java | 23 + .../java/org/jclouds/compute/Instance.java | 23 + .../java/org/jclouds/compute/Platform.java | 23 + .../test/java/org/jclouds/compute/Server.java | 25 +- .../jclouds/http/options/GetOptionsTest.java | 4 +- .../predicates/RetryablePredicateTest.java | 23 + .../test/java/org/jclouds/util/UtilsTest.java | 11 + .../integration/TweetStoreLiveTest.java | 2 +- .../blobstore/CloudFilesAsyncBlobStore.java | 35 +- .../blobstore/CloudFilesBlobStore.java | 31 +- ...ontainerOptionsToListContainerOptions.java | 12 +- .../functions/BlobToObjectGetOptions.java | 7 +- ...ptionsToBlobStoreListContainerOptions.java | 4 +- .../functions/ObjectToBlobMetadata.java | 15 +- .../internal/BaseCloudFilesBlobStore.java | 8 + .../RimuHostingCreateInstanceBinder.java | 23 + .../servers/RimuHostingComputeService.java | 23 + .../RimuHostingComputeServiceLiveTest.java | 23 + .../miro/servers/RimuHostingServer.java | 23 + .../jclouds/scriptbuilder/EnvBuilderTest.java | 23 + .../scriptbuilder/ScriptBuilderTest.java | 23 + thirdparty/README.txt | 23 + tools/getpath/.svnignore | 7 + tools/getpath/README.txt | 29 ++ tools/getpath/pom.xml | 148 ++++++ .../java/org/jclouds/blobstore/GetPath.java | 118 +++++ .../src/main/resources/jclouds.properties | 29 ++ .../jclouds/blobstore/GetPathLiveTest.java | 186 ++++++++ .../org/jclouds/blobstore/PropertiesTest.java | 76 ++++ tools/getpath/src/test/resources/log4j.xml | 118 +++++ tools/jclouds-ant-plugin/build.xml | 25 ++ .../org/jclouds/tools/ant/ComputeTask.java | 23 + .../org/jclouds/tools/ant/ServerElement.java | 23 + tools/vfs/README.txt | 29 ++ tools/vfs/pom.xml | 163 +++++++ .../provider/blobstore/BlobStoreFileName.java | 87 ++++ .../blobstore/BlobStoreFileNameParser.java | 80 ++++ .../blobstore/BlobStoreFileObject.java | 374 +++++++++++++++ .../blobstore/BlobStoreFileProvider.java | 108 +++++ .../blobstore/BlobStoreFileSystem.java | 60 +++ .../BlobStoreRandomAccessContent.java | 119 +++++ .../vfs/tools/blobstore/BlobStoreShell.java | 425 ++++++++++++++++++ .../vfs/src/main/resources/jclouds.properties | 29 ++ .../test/BlobStoreProviderTestCase.java | 114 +++++ .../test/BlobStoreProviderTestSuite.java | 73 +++ .../blobstore/test/FileNameTestCase.java | 151 +++++++ .../vfs/src/test/resources/jclouds.properties | 31 ++ tools/vfs/src/test/resources/log4j.xml | 118 +++++ ...tantiateVAppTemplateParamsToXmlEntity.java | 23 + .../jclouds/vcloud/domain/ResourceType.java | 23 + .../java/org/jclouds/vcloud/domain/VApp.java | 2 +- .../jclouds/vcloud/domain/VirtualSystem.java | 2 +- .../vcloud/functions/CatalogIdToUri.java | 23 + .../jclouds/vcloud/functions/VAppIdToUri.java | 23 + .../vcloud/functions/VAppTemplateIdToUri.java | 23 + .../InstantiateVAppTemplateOptions.java | 23 + .../vcloud/xml/ResourceAllocationHandler.java | 23 + .../org/jclouds/vcloud/xml/VAppHandler.java | 23 + .../vcloud/xml/VirtualSystemHandler.java | 23 + ...iateVAppTemplateParamsToXmlEntityTest.java | 23 + .../config/VCloudRestClientModuleTest.java | 23 + .../InstantiateVAppTemplateOptionsTest.java | 23 + .../vcloud/predicates/TaskSuccess.java | 23 + .../HostingDotComVCloudRestClientModule.java | 23 + .../domain/HostingDotComVApp.java | 23 + .../internal/HostingDotComVAppImpl.java | 23 + .../xml/HostingDotComVAppHandler.java | 23 + ...tingDotComVCloudComputeClientLiveTest.java | 23 + .../BindAddInternetServiceToXmlEntity.java | 23 + .../BindAddNodeServiceToXmlEntity.java | 23 + ...tantiateVAppTemplateParamsToXmlEntity.java | 23 + .../vcloud/terremark/domain/ResourceType.java | 23 + .../options/AddInternetServiceOptions.java | 23 + .../terremark/options/AddNodeOptions.java | 23 + ...rremarkInstantiateVAppTemplateOptions.java | 23 + .../reference/TerremarkVCloudConstants.java | 23 + .../terremark/xml/InternetServiceHandler.java | 2 +- .../vcloud/terremark/xml/NodeHandler.java | 2 +- ...BindAddInternetServiceToXmlEntityTest.java | 8 +- .../BindAddNodeServiceToXmlEntityTest.java | 8 +- ...iateVAppTemplateParamsToXmlEntityTest.java | 8 +- .../AddInternetServiceOptionsTest.java | 23 + .../terremark/options/AddNodeOptionsTest.java | 23 + ...arkInstantiateVAppTemplateOptionsTest.java | 23 + 180 files changed, 5872 insertions(+), 233 deletions(-) delete mode 100644 azure/src/test/java/org/jclouds/azure/storage/blob/config/AzureBlobContextModuleTest.java create mode 100644 core/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java create mode 100644 core/src/main/java/org/jclouds/blobstore/functions/ResourceMetadataToRelativePathResourceMetadata.java create mode 100644 core/src/main/java/org/jclouds/blobstore/internal/LocationAndCredentials.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/GetDirectoryStrategy.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/IsDirectoryStrategy.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/MkdirStrategy.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersGetDirectoryStrategy.java create mode 100644 core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersIsDirectoryStrategy.java create mode 100644 core/src/test/java/org/jclouds/blobstore/BlobStoreContextFactoryTest.java create mode 100644 core/src/test/java/org/jclouds/blobstore/functions/BlobMetadataToRelativePathResourceMetadataTest.java create mode 100644 core/src/test/java/org/jclouds/blobstore/integration/StubPropertiesBuilder.java create mode 100644 core/src/test/java/org/jclouds/blobstore/internal/LocationAndCredentialsTest.java create mode 100644 tools/getpath/.svnignore create mode 100755 tools/getpath/README.txt create mode 100644 tools/getpath/pom.xml create mode 100755 tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java create mode 100644 tools/getpath/src/main/resources/jclouds.properties create mode 100755 tools/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java create mode 100755 tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java create mode 100755 tools/getpath/src/test/resources/log4j.xml create mode 100755 tools/vfs/README.txt create mode 100644 tools/vfs/pom.xml create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileName.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileNameParser.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileSystem.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreRandomAccessContent.java create mode 100644 tools/vfs/src/main/java/org/jclouds/vfs/tools/blobstore/BlobStoreShell.java create mode 100644 tools/vfs/src/main/resources/jclouds.properties create mode 100644 tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestCase.java create mode 100644 tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestSuite.java create mode 100644 tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/FileNameTestCase.java create mode 100644 tools/vfs/src/test/resources/jclouds.properties create mode 100755 tools/vfs/src/test/resources/log4j.xml diff --git a/README.txt b/README.txt index db447e921e..9645b94e05 100644 --- a/README.txt +++ b/README.txt @@ -1,2 +1,25 @@ +==== + + Copyright (C) 2009 Cloud Conscious, LLC. + + ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + ==================================================================== +==== thirdparty module is code we are temporarily storing as there is no maven module for it (or the code we use from it). Please publish to maven repos manually as needed. diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java index 97e6d73df5..72d4d4ff34 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java @@ -111,6 +111,17 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob }); } + public Future createDirectory(String container, String directory) { + return wrapFuture(async.createDirectory(container + "/" + directory), + new Function() { + + public Void apply(URI from) { + return null;// no etag + } + + }); + } + public Future deleteContainer(final String container) { return service.submit(new Callable() { @@ -130,10 +141,14 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob }); } - public Future exists(String container) { + public Future containerExists(String container) { return async.pathExists(container); } + public Future directoryExists(String container, String directory) { + return async.pathExists(container + "/" + directory); + } + public Future getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions... optionsList) { GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList); @@ -151,8 +166,8 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob if (optionsList[0].isRecursive()) { throw new UnsupportedOperationException("recursive not currently supported in emcsaas"); } - if (optionsList[0].getPath() != null) { - container = container + "/" + optionsList[0].getPath(); + if (optionsList[0].getDir() != null) { + container = container + "/" + optionsList[0].getDir(); } } ListOptions nativeOptions = container2ContainerListOptions.apply(optionsList); diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStore.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStore.java index db4ebeeb38..71151c1d7f 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStore.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosBlobStore.java @@ -77,7 +77,6 @@ public class AtmosBlobStore extends BaseAtmosBlobStore implements BlobStore { } public void clearContainer(final String container) { - clearContainerStrategy.execute(container, recursive()); } @@ -86,6 +85,10 @@ public class AtmosBlobStore extends BaseAtmosBlobStore implements BlobStore { return true;// no etag } + public void createDirectory(String container, String directory) { + sync.createDirectory(container + "/" + directory); + } + public void deleteContainer(final String container) { clearContainerStrategy.execute(container, recursive()); deleteAndEnsurePathGone(container); @@ -106,10 +109,14 @@ public class AtmosBlobStore extends BaseAtmosBlobStore implements BlobStore { } } - public boolean exists(String container) { + public boolean containerExists(String container) { return sync.pathExists(container); } + public boolean directoryExists(String container, String directory) { + return sync.pathExists(container + "/" + directory); + } + public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions... optionsList) { GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList); @@ -126,8 +133,8 @@ public class AtmosBlobStore extends BaseAtmosBlobStore implements BlobStore { if (optionsList[0].isRecursive()) { throw new UnsupportedOperationException("recursive not currently supported in emcsaas"); } - if (optionsList[0].getPath() != null) { - container = container + "/" + optionsList[0].getPath(); + if (optionsList[0].getDir() != null) { + container = container + "/" + optionsList[0].getDir(); } } ListOptions nativeOptions = container2ContainerListOptions.apply(optionsList); diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/strategy/RecursiveRemove.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/strategy/RecursiveRemove.java index 3dfde346e8..32ccd4da32 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/strategy/RecursiveRemove.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/strategy/RecursiveRemove.java @@ -118,8 +118,8 @@ public class RecursiveRemove implements ClearListStrategy, ClearContainerStrateg public void execute(final String containerName, ListContainerOptions options) { String path = containerName; - if (options.getPath() != null) - path += "/" + options.getPath(); + if (options.getDir() != null) + path += "/" + options.getDir(); Set> deletes = Sets.newHashSet(); try { for (DirectoryEntry md : async.listDirectory(path).get(requestTimeoutMilliseconds, diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/internal/StubAtmosStorageAsyncClient.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/internal/StubAtmosStorageAsyncClient.java index cd8e51647c..43c2a1d0cf 100644 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/internal/StubAtmosStorageAsyncClient.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/internal/StubAtmosStorageAsyncClient.java @@ -197,7 +197,7 @@ public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient { container = directoryName.substring(0, directoryName.indexOf('/')); String path = directoryName.substring(directoryName.indexOf('/') + 1); if (!path.equals("")) - options.underPath(path); + options.inDirectory(path); } return wrapFuture(blobStore.list(container, options), resource2ObjectList); } @@ -208,7 +208,7 @@ public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient { public Future pathExists(final String path) { if (path.indexOf('/') == -1 || (path.endsWith("/"))) - return blobStore.exists(path); + return blobStore.containerExists(path); else { return new FutureBase() { public Boolean get() throws InterruptedException, ExecutionException { diff --git a/atmos/src/test/resources/hashstring.txt b/atmos/src/test/resources/hashstring.txt index ec250aa604..c073a93c0a 100644 --- a/atmos/src/test/resources/hashstring.txt +++ b/atmos/src/test/resources/hashstring.txt @@ -1,3 +1,26 @@ +==== + + Copyright (C) 2009 Cloud Conscious, LLC. + + ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + ==================================================================== +==== POST application/octet-stream diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindGroupNameToIndexedFormParams.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindGroupNameToIndexedFormParams.java index a3df128c4f..0cbf489b2c 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindGroupNameToIndexedFormParams.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindGroupNameToIndexedFormParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInetAddressesToIndexedFormParams.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInetAddressesToIndexedFormParams.java index b3d6df696a..632062f963 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInetAddressesToIndexedFormParams.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInetAddressesToIndexedFormParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInstanceIdsToIndexedFormParams.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInstanceIdsToIndexedFormParams.java index df2c10e43c..a27782119f 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInstanceIdsToIndexedFormParams.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindInstanceIdsToIndexedFormParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindKeyNameToIndexedFormParams.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindKeyNameToIndexedFormParams.java index 3734921ca4..9285c8f814 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindKeyNameToIndexedFormParams.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindKeyNameToIndexedFormParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java index 92a73cf2e0..9110c4589c 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Image.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Image.java index a048baa0fc..a7bc7ec179 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Image.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Image.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/ImageAttribute.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/ImageAttribute.java index a79d3465ae..cef64f02ca 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/ImageAttribute.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/ImageAttribute.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import org.jclouds.aws.ec2.EC2AsyncClient; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceState.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceState.java index 5741607c85..15b67bd513 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceState.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceState.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceType.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceType.java index e74df69ec8..a361c18360 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceType.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/InstanceType.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpPermission.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpPermission.java index 86021a23be..32db7dc5f0 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpPermission.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpPermission.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import java.util.SortedSet; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpProtocol.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpProtocol.java index 673104e0ca..f848f58097 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpProtocol.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/IpProtocol.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/KeyPair.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/KeyPair.java index b129614ec2..d1b81830cb 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/KeyPair.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/KeyPair.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/PublicIpInstanceIdPair.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/PublicIpInstanceIdPair.java index f1866b10e2..78870a8b62 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/PublicIpInstanceIdPair.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/PublicIpInstanceIdPair.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Reservation.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Reservation.java index e5714e87d5..8c50d745ba 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Reservation.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Reservation.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java index 0f42ce314e..8267449581 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/SecurityGroup.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/SecurityGroup.java index 6569a00bb5..f396814baf 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/SecurityGroup.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/SecurityGroup.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import java.util.SortedSet; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/TerminatedInstance.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/TerminatedInstance.java index 8ef4fa75e2..871bac9023 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/TerminatedInstance.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/TerminatedInstance.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/UserIdGroupPair.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/UserIdGroupPair.java index 8997462430..c486fa8058 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/UserIdGroupPair.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/UserIdGroupPair.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/functions/ReturnVoidOnGroupNotFound.java b/aws/core/src/main/java/org/jclouds/aws/ec2/functions/ReturnVoidOnGroupNotFound.java index 33a7416a9f..6a1eb27556 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/functions/ReturnVoidOnGroupNotFound.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/functions/ReturnVoidOnGroupNotFound.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.functions; import java.lang.reflect.Constructor; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeImagesOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeImagesOptions.java index 87bde1da41..a673d478c5 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeImagesOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/options/DescribeImagesOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.options; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java index 7a20c05fc6..19872c55ba 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.options; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/options/internal/BaseEC2RequestOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/options/internal/BaseEC2RequestOptions.java index a8f6745138..9f3278a1a7 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/options/internal/BaseEC2RequestOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/options/internal/BaseEC2RequestOptions.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java b/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java index 5d9e335ab6..13c5b7dcda 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/util/EC2Utils.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.util; import static com.google.common.base.Preconditions.checkArgument; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/AllocateAddressResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/AllocateAddressResponseHandler.java index eacf7122eb..07cb7901d6 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/AllocateAddressResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/AllocateAddressResponseHandler.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java index 1e651226bf..f3f1ae3410 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeAddressesResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeAddressesResponseHandler.java index fa54f4ed1f..c846ac739a 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeAddressesResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeAddressesResponseHandler.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandler.java index 0c712a1bc5..3b57f6f125 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandler.java @@ -11,7 +11,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http: + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandler.java index 5d2177a0b9..78e0b51028 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandler.java @@ -11,7 +11,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http: + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/TerminateInstancesResponseHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/TerminateInstancesResponseHandler.java index 0b664cfce4..7c69c3f880 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/TerminateInstancesResponseHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/TerminateInstancesResponseHandler.java @@ -11,7 +11,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http: + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java index 1ddba6e5ea..5c7237e8ec 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java @@ -31,6 +31,8 @@ import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_METADATA_PREF import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_RETRY; import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERVAL; import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_TIMEOUT; +import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX; import java.net.URI; import java.util.Properties; @@ -50,6 +52,7 @@ public class S3PropertiesBuilder extends HttpPropertiesBuilder { properties.setProperty(PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com"); properties.setProperty(PROPERTY_S3_METADATA_PREFIX, "x-amz-meta-"); properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, "60"); + properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER); return properties; } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java index 3248e7ad0a..96800ba93a 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java @@ -48,6 +48,7 @@ import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.aws.s3.domain.S3Object; import org.jclouds.aws.s3.options.ListBucketOptions; import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -57,6 +58,8 @@ import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; @@ -71,11 +74,13 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore ObjectToBlobMetadata object2BlobMd, ObjectToBlob object2Blob, BlobToObject blob2Object, ContainerToBucketListOptions container2BucketListOptions, BlobToObjectGetOptions blob2ObjectGetOptions, + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, BucketToResourceMetadata bucket2ResourceMd, BucketToResourceList bucket2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2BucketListOptions, blob2ObjectGetOptions, - bucket2ResourceMd, bucket2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, bucket2ResourceMd, bucket2ResourceList, + service); } /** @@ -104,10 +109,6 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore }); } - public Future createContainer(String container) { - return async.putBucketIfNotExists(container); - } - public Future deleteContainer(final String container) { return service.submit(new Callable() { @@ -120,10 +121,40 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore }); } - public Future exists(String container) { + public Future createContainer(String container) { + return async.putBucketIfNotExists(container); + } + + public Future containerExists(String container) { return async.bucketExists(container); } + public Future createDirectory(final String container, final String directory) { + return service.submit(new Callable() { + + public Void call() throws Exception { + mkdirStrategy.execute(S3AsyncBlobStore.this, container, directory); + return null; + } + + }); + } + + public Future directoryExists(final String container, final String directory) { + return service.submit(new Callable() { + + public Boolean call() throws Exception { + try { + getDirectoryStrategy.execute(S3AsyncBlobStore.this, container, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + }); + } + public Future getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions... optionsList) { GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList); diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3BlobStore.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3BlobStore.java index d9393fce01..d13f99b0b2 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3BlobStore.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3BlobStore.java @@ -43,6 +43,7 @@ import org.jclouds.aws.s3.blobstore.internal.BaseS3BlobStore; import org.jclouds.aws.s3.domain.BucketMetadata; import org.jclouds.aws.s3.options.ListBucketOptions; import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -52,6 +53,8 @@ import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; @@ -59,18 +62,22 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; public class S3BlobStore extends BaseS3BlobStore implements BlobStore { + private final S3AsyncBlobStore aBlobStore; @Inject - public S3BlobStore(S3AsyncClient async, S3Client sync, Factory blobFactory, - LoggerFactory logFactory, ClearListStrategy clearContainerStrategy, - ObjectToBlobMetadata object2BlobMd, ObjectToBlob object2Blob, BlobToObject blob2Object, + public S3BlobStore(S3AsyncBlobStore aBlobStore, S3AsyncClient async, S3Client sync, + Factory blobFactory, LoggerFactory logFactory, + ClearListStrategy clearContainerStrategy, ObjectToBlobMetadata object2BlobMd, + ObjectToBlob object2Blob, BlobToObject blob2Object, ContainerToBucketListOptions container2BucketListOptions, BlobToObjectGetOptions blob2ObjectGetOptions, + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, BucketToResourceMetadata bucket2ResourceMd, BucketToResourceList bucket2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2BucketListOptions, blob2ObjectGetOptions, - bucket2ResourceMd, bucket2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, bucket2ResourceMd, bucket2ResourceList, service); + this.aBlobStore = aBlobStore; } /** @@ -84,6 +91,10 @@ public class S3BlobStore extends BaseS3BlobStore implements BlobStore { clearContainerStrategy.execute(container, recursive()); } + public boolean containerExists(String container) { + return sync.bucketExists(container); + } + public boolean createContainer(String container) { return sync.putBucketIfNotExists(container); } @@ -93,8 +104,17 @@ public class S3BlobStore extends BaseS3BlobStore implements BlobStore { sync.deleteBucketIfEmpty(container); } - public boolean exists(String container) { - return sync.bucketExists(container); + public boolean directoryExists(String containerName, String directory) { + try { + getDirectoryStrategy.execute(aBlobStore, containerName, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + public void createDirectory(String containerName, String directory) { + mkdirStrategy.execute(aBlobStore, containerName, directory); } public Blob getBlob(String container, String key, diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BlobToObjectGetOptions.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BlobToObjectGetOptions.java index d302d877a1..60d778a262 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BlobToObjectGetOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BlobToObjectGetOptions.java @@ -52,7 +52,12 @@ public class BlobToObjectGetOptions implements } for (String range : from[0].getRanges()) { String[] firstLast = range.split("\\-"); - httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + if (firstLast.length == 2) + httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + else if (range.startsWith("-")) + httpOptions.tail(Long.parseLong(firstLast[0])); + else + httpOptions.startAt(Long.parseLong(firstLast[0])); } } return httpOptions; diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToContainerListOptions.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToContainerListOptions.java index f17031b981..92e55eb124 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToContainerListOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToContainerListOptions.java @@ -50,7 +50,7 @@ public class BucketToContainerListOptions implements Function { +public class ContainerToBucketListOptions implements + Function { public ListBucketOptions apply(ListContainerOptions[] optionsList) { ListBucketOptions httpOptions = new ListBucketOptions(); if (optionsList.length != 0) { if (!optionsList[0].isRecursive()) { httpOptions.delimiter("/"); } - if (optionsList[0].getPath() != null) { - httpOptions.withPrefix(optionsList[0].getPath()); + if (optionsList[0].getDir() != null) {// TODO unit test + String path = optionsList[0].getDir(); + if (!path.endsWith("/")) + path = path + "/"; + httpOptions.withPrefix(path); } if (optionsList[0].getMarker() != null) { httpOptions.afterMarker(optionsList[0].getMarker()); diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/ObjectToBlobMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/ObjectToBlobMetadata.java index 6dad4b1076..d389eedca7 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/ObjectToBlobMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/ObjectToBlobMetadata.java @@ -23,12 +23,14 @@ */ package org.jclouds.aws.s3.blobstore.functions; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.aws.s3.domain.ObjectMetadata; import org.jclouds.blobstore.domain.MutableBlobMetadata; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; import com.google.common.base.Function; @@ -37,6 +39,13 @@ import com.google.common.base.Function; */ @Singleton public class ObjectToBlobMetadata implements Function { + private final IsDirectoryStrategy isDirectoryStrategy; + + @Inject + public ObjectToBlobMetadata(IsDirectoryStrategy isDirectoryStrategy) { + this.isDirectoryStrategy = isDirectoryStrategy; + } + public MutableBlobMetadata apply(ObjectMetadata from) { MutableBlobMetadata to = new MutableBlobMetadataImpl(); to.setContentMD5(from.getContentMD5()); @@ -46,8 +55,9 @@ public class ObjectToBlobMetadata implements Function + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.util; import java.io.ByteArrayInputStream; diff --git a/aws/core/src/main/java/org/jclouds/aws/util/RequestSigner.java b/aws/core/src/main/java/org/jclouds/aws/util/RequestSigner.java index cb62222c67..3186134cad 100644 --- a/aws/core/src/main/java/org/jclouds/aws/util/RequestSigner.java +++ b/aws/core/src/main/java/org/jclouds/aws/util/RequestSigner.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.util; import org.jclouds.http.HttpRequest; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/config/EC2RestClientModuleTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/config/EC2RestClientModuleTest.java index 3bc84cda9d..e027107701 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/config/EC2RestClientModuleTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/config/EC2RestClientModuleTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.config; import static org.testng.Assert.assertEquals; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/filters/FormSignerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/filters/FormSignerTest.java index 5933578c58..c3e9361145 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/filters/FormSignerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/filters/FormSignerTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.filters; import static org.testng.Assert.assertEquals; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/options/DescribeImagesOptionsTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/options/DescribeImagesOptionsTest.java index da2256f201..a840559f26 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/options/DescribeImagesOptionsTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/options/DescribeImagesOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.options; import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.executableBy; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java index 58aab05577..2be4d544e5 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.aws.ec2.options; import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.asType; diff --git a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java index ac3d19ce57..4b994fa2e9 100755 --- a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java +++ b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java @@ -59,7 +59,7 @@ public class BlobStoreContextToContainerResult implements Function completer; diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java index 7dfc4a0031..dc8834d06e 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java @@ -47,6 +47,7 @@ import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; import org.jclouds.azure.storage.blob.options.ListBlobsOptions; import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -56,6 +57,8 @@ import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; @@ -70,12 +73,13 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob ClearListStrategy clearContainerStrategy, BlobPropertiesToBlobMetadata object2BlobMd, AzureBlobToBlob object2Blob, BlobToAzureBlob blob2Object, ListOptionsToListBlobsOptions container2ContainerListOptions, - BlobToHttpGetOptions blob2ObjectGetOptions, - ContainerToResourceMetadata container2ResourceMd, + BlobToHttpGetOptions blob2ObjectGetOptions, GetDirectoryStrategy getDirectoryStrategy, + MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd, ListBlobsResponseToResourceList container2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2ContainerListOptions, blob2ObjectGetOptions, - container2ResourceMd, container2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, container2ResourceMd, container2ResourceList, + service); } /** @@ -113,7 +117,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob } - public Future exists(String container) { + public Future containerExists(String container) { return async.containerExists(container); } @@ -151,4 +155,30 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob return async.deleteBlob(container, key); } + public Future createDirectory(final String container, final String directory) { + return service.submit(new Callable() { + + public Void call() throws Exception { + mkdirStrategy.execute(AzureAsyncBlobStore.this, container, directory); + return null; + } + + }); + } + + public Future directoryExists(final String container, final String directory) { + return service.submit(new Callable() { + + public Boolean call() throws Exception { + try { + getDirectoryStrategy.execute(AzureAsyncBlobStore.this, container, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + }); + } + } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureBlobStore.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureBlobStore.java index 8b55dbd379..aebb57c0ab 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureBlobStore.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureBlobStore.java @@ -42,6 +42,7 @@ import org.jclouds.azure.storage.blob.blobstore.internal.BaseAzureBlobStore; import org.jclouds.azure.storage.blob.domain.ListableContainerProperties; import org.jclouds.azure.storage.blob.options.ListBlobsOptions; import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -52,6 +53,8 @@ import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; @@ -59,19 +62,22 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; public class AzureBlobStore extends BaseAzureBlobStore implements BlobStore { + private final AzureAsyncBlobStore aBlobStore; @Inject - public AzureBlobStore(AzureBlobAsyncClient async, AzureBlobClient sync, Factory blobFactory, - LoggerFactory logFactory, ClearListStrategy clearContainerStrategy, - BlobPropertiesToBlobMetadata object2BlobMd, AzureBlobToBlob object2Blob, - BlobToAzureBlob blob2Object, + public AzureBlobStore(AzureAsyncBlobStore aBlobStore, AzureBlobAsyncClient async, + AzureBlobClient sync, Factory blobFactory, LoggerFactory logFactory, + ClearListStrategy clearContainerStrategy, BlobPropertiesToBlobMetadata object2BlobMd, + AzureBlobToBlob object2Blob, BlobToAzureBlob blob2Object, ListOptionsToListBlobsOptions container2ContainerListOptions, - BlobToHttpGetOptions blob2ObjectGetOptions, - ContainerToResourceMetadata container2ResourceMd, + BlobToHttpGetOptions blob2ObjectGetOptions, GetDirectoryStrategy getDirectoryStrategy, + MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd, ListBlobsResponseToResourceList container2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2ContainerListOptions, blob2ObjectGetOptions, - container2ResourceMd, container2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, container2ResourceMd, container2ResourceList, + service); + this.aBlobStore = aBlobStore; } /** @@ -93,7 +99,20 @@ public class AzureBlobStore extends BaseAzureBlobStore implements BlobStore { sync.deleteContainer(container); } - public boolean exists(String container) { + public boolean directoryExists(String containerName, String directory) { + try { + getDirectoryStrategy.execute(aBlobStore, containerName, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + public void createDirectory(String containerName, String directory) { + mkdirStrategy.execute(aBlobStore, containerName, directory); + } + + public boolean containerExists(String container) { return sync.containerExists(container); } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/BlobPropertiesToBlobMetadata.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/BlobPropertiesToBlobMetadata.java index 84d6b81333..385749a9a1 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/BlobPropertiesToBlobMetadata.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/BlobPropertiesToBlobMetadata.java @@ -23,10 +23,12 @@ */ package org.jclouds.azure.storage.blob.blobstore.functions; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.azure.storage.blob.domain.BlobProperties; import org.jclouds.blobstore.domain.MutableBlobMetadata; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; /** * @author Adrian Cole @@ -34,6 +36,11 @@ import org.jclouds.blobstore.domain.MutableBlobMetadata; @Singleton public class BlobPropertiesToBlobMetadata extends ListableBlobPropertiesToBlobMetadata { + @Inject + public BlobPropertiesToBlobMetadata(IsDirectoryStrategy isDirectoryStrategy) { + super(isDirectoryStrategy); + } + @Override public MutableBlobMetadata apply(BlobProperties from) { MutableBlobMetadata to = super.apply(from); diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/ListBlobsOptionsToListOptions.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/ListBlobsOptionsToListOptions.java index b465d1f69b..66dc2b7e5a 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/ListBlobsOptionsToListOptions.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/functions/ListBlobsOptionsToListOptions.java @@ -50,7 +50,7 @@ public class ListBlobsOptionsToListOptions implements Function implements Function { + private final IsDirectoryStrategy isDirectoryStrategy; + + @Inject + public ListableBlobPropertiesToBlobMetadata(IsDirectoryStrategy isDirectoryStrategy) { + this.isDirectoryStrategy = isDirectoryStrategy; + } + public MutableBlobMetadata apply(T from) { MutableBlobMetadata to = new MutableBlobMetadataImpl(); if (from.getContentType() != null) to.setContentType(from.getContentType()); to.setETag(from.getETag()); + to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setSize(from.getSize()); to.setType(ResourceType.BLOB); - if (from.getContentType() != null && from.getContentType().equals("application/directory")) { + if (isDirectoryStrategy.execute(to)) { to.setType(ResourceType.RELATIVE_PATH); } return to; diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/internal/BaseAzureBlobStore.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/internal/BaseAzureBlobStore.java index f484e5e2df..b20ba6a186 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/internal/BaseAzureBlobStore.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/internal/BaseAzureBlobStore.java @@ -41,6 +41,8 @@ import org.jclouds.azure.storage.blob.blobstore.functions.ListOptionsToListBlobs import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.concurrent.FutureFunctionWrapper; import org.jclouds.logging.Logger.LoggerFactory; @@ -60,6 +62,8 @@ public class BaseAzureBlobStore { protected final ContainerToResourceMetadata container2ResourceMd; protected final ListBlobsResponseToResourceList container2ResourceList; protected final ExecutorService service; + protected final GetDirectoryStrategy getDirectoryStrategy; + protected final MkdirStrategy mkdirStrategy; @Inject protected BaseAzureBlobStore(AzureBlobAsyncClient async, AzureBlobClient sync, @@ -68,6 +72,7 @@ public class BaseAzureBlobStore { AzureBlobToBlob object2Blob, BlobToAzureBlob blob2Object, ListOptionsToListBlobsOptions container2ContainerListOptions, BlobToHttpGetOptions blob2ObjectGetOptions, + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd, ListBlobsResponseToResourceList container2ResourceList, ExecutorService service) { this.async = checkNotNull(async, "async"); @@ -81,6 +86,9 @@ public class BaseAzureBlobStore { this.container2ContainerListOptions = checkNotNull(container2ContainerListOptions, "container2ContainerListOptions"); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); + this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, + "getDirectoryStrategy"); + this.mkdirStrategy = checkNotNull(mkdirStrategy, "mkdirStrategy"); this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd"); this.container2ResourceList = checkNotNull(container2ResourceList, "container2ResourceList"); this.service = checkNotNull(service, "service"); diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java index 62a7e148c2..2a1999464b 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/xml/ContainerNameEnumerationResultsHandler.java @@ -32,6 +32,7 @@ import org.jclouds.azure.storage.blob.domain.ListBlobsResponse; import org.jclouds.azure.storage.blob.domain.ListableBlobProperties; import org.jclouds.azure.storage.blob.domain.internal.ListableBlobPropertiesImpl; import org.jclouds.azure.storage.blob.domain.internal.TreeSetListBlobsResponse; +import org.jclouds.blobstore.internal.LocationAndCredentials; import org.jclouds.http.functions.ParseSax; import org.jclouds.util.DateService; import org.joda.time.DateTime; @@ -127,7 +128,7 @@ public class ContainerNameEnumerationResultsHandler extends currentContentEncoding = null; currentContentLanguage = null; } else if (qName.equals("Url")) { - currentUrl = URI.create(currentText.toString().trim()); + currentUrl = LocationAndCredentials.parse(currentText.toString().trim()).uri; } else if (qName.equals("LastModified")) { currentLastModified = dateParser.rfc822DateParse(currentText.toString().trim()); } else if (qName.equals("Etag")) { diff --git a/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java b/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java index 34dcaf223c..1102d27a51 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java +++ b/azure/src/main/java/org/jclouds/azure/storage/handlers/ParseAzureStorageErrorFromXmlContent.java @@ -29,6 +29,7 @@ import javax.inject.Inject; import org.jclouds.azure.storage.AzureStorageResponseException; import org.jclouds.azure.storage.domain.AzureStorageError; import org.jclouds.azure.storage.util.AzureStorageUtils; +import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpResponse; @@ -64,7 +65,13 @@ public class ParseAzureStorageErrorFromXmlContent implements HttpErrorHandler { if (content.indexOf('<') >= 0) { AzureStorageError error = utils.parseAzureStorageErrorFromContent(command, response, content); - command.setException(new AzureStorageResponseException(command, response, error)); + AzureStorageResponseException ex = new AzureStorageResponseException(command, + response, error); + if (error.getCode().equals("ContainerNotFound")) { + command.setException(new ContainerNotFoundException(ex)); + } else { + command.setException(ex); + } } else { command.setException(new HttpResponseException(command, response, content)); } diff --git a/azure/src/test/java/org/jclouds/azure/storage/blob/config/AzureBlobContextModuleTest.java b/azure/src/test/java/org/jclouds/azure/storage/blob/config/AzureBlobContextModuleTest.java deleted file mode 100644 index dac021333c..0000000000 --- a/azure/src/test/java/org/jclouds/azure/storage/blob/config/AzureBlobContextModuleTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - * Copyright (C) 2009 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * ==================================================================== - */ -package org.jclouds.azure.storage.blob.config; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.storage.blob.AzureBlobAsyncClient; -import org.jclouds.azure.storage.blob.AzureBlobClient; -import org.jclouds.azure.storage.blob.reference.AzureBlobConstants; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.RestContextImpl; -import org.jclouds.util.Jsr330; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "azureblob.AzureBlobContextModuleTest") -public class AzureBlobContextModuleTest { - - Injector createInjector() { - return Guice.createInjector(new AzureBlobStubClientModule(), new JDKLoggingModule(), - new AzureBlobContextModule() { - @Override - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to( - "user"); - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_KEY)).to("key"); - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZUREBLOB_ENDPOINT)).to( - "http://localhost"); - super.configure(); - } - }); - } - - @Test - void testContextImpl() { - Injector injector = createInjector(); - RestContext handler = injector.getInstance(Key - .get(new TypeLiteral>() { - })); - assertEquals(handler.getClass(), RestContextImpl.class); - - } - -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/core/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 2bf4c6603f..6052bc9e0b 100644 --- a/core/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/core/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -57,10 +57,14 @@ public interface AsyncBlobStore { Future> list(String container, ListContainerOptions... options); - Future exists(String container); + Future containerExists(String container); + + Future directoryExists(String container, String directory); Future createContainer(String container); + Future createDirectory(String container, String directory); + /** * This will delete a container recursively. * diff --git a/core/src/main/java/org/jclouds/blobstore/BlobStore.java b/core/src/main/java/org/jclouds/blobstore/BlobStore.java index f3fef9b91a..7303d4ae04 100644 --- a/core/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/core/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -55,10 +55,14 @@ public interface BlobStore { ListContainerResponse list(String container, ListContainerOptions... options); - boolean exists(String container); + boolean containerExists(String container); + + boolean directoryExists(String container, String directory); boolean createContainer(String container); + void createDirectory(String container, String directory); + /** * This will delete a container recursively. * diff --git a/core/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/core/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java new file mode 100644 index 0000000000..60a4676d04 --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -0,0 +1,74 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Properties; + +import javax.inject.Inject; + +import org.jclouds.http.HttpPropertiesBuilder; + +import com.google.inject.Module; + +public class BlobStoreContextFactory { + private final Properties properties; + + @Inject + public BlobStoreContextFactory(Properties properties) { + this.properties = properties; + } + + @SuppressWarnings("unchecked") + public BlobStoreContext createContext(URI blobStore, String account, String key, + Module... modules) { + String hint = checkNotNull(blobStore.getHost(), "host"); + checkNotNull(account, "account"); + checkNotNull(key, "key"); + + String propertiesBuilderKey = String.format("%s.propertiesbuilder", hint); + String propertiesBuilderClassName = checkNotNull( + properties.getProperty(propertiesBuilderKey), propertiesBuilderKey); + + String contextBuilderKey = String.format("%s.contextbuilder", hint); + String contextBuilderClassName = checkNotNull(properties.getProperty(contextBuilderKey), + contextBuilderKey); + + try { + Class propertiesBuilderClass = (Class) Class + .forName(propertiesBuilderClassName); + Class> contextBuilderClass = (Class>) Class + .forName(contextBuilderClassName); + + HttpPropertiesBuilder builder = propertiesBuilderClass.getConstructor(String.class, + String.class).newInstance(account, key); + return contextBuilderClass.getConstructor(Properties.class).newInstance(builder.build()) + .withModules(modules).buildContext(); + } catch (Exception e) { + throw new RuntimeException("error instantiating " + contextBuilderClassName, e); + } + } +} diff --git a/core/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java b/core/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java index 1feac2500b..0b06d6c025 100644 --- a/core/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java +++ b/core/src/main/java/org/jclouds/blobstore/functions/BlobToHttpGetOptions.java @@ -52,7 +52,12 @@ public class BlobToHttpGetOptions implements } for (String range : from[0].getRanges()) { String[] firstLast = range.split("\\-"); - httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + if (firstLast.length == 2) + httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + else if (range.startsWith("-")) + httpOptions.tail(Long.parseLong(firstLast[0])); + else + httpOptions.startAt(Long.parseLong(firstLast[0])); } } return httpOptions; diff --git a/core/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java b/core/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java index 5777664d50..434e942e51 100755 --- a/core/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java +++ b/core/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java @@ -46,8 +46,8 @@ import com.google.common.base.Function; /** * @author Adrian Cole */ -public class ParseSystemAndUserMetadataFromHeaders implements Function, - InvocationContext { +public class ParseSystemAndUserMetadataFromHeaders implements + Function, InvocationContext { private final String metadataPrefix; private final DateService dateParser; private final Provider metadataFactory; @@ -69,7 +69,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.functions; + +import javax.inject.Singleton; + +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.domain.ResourceType; +import org.jclouds.blobstore.domain.internal.ResourceMetadataImpl; +import org.jclouds.blobstore.reference.BlobStoreConstants; + +import com.google.common.base.Function; + +@Singleton +public class ResourceMetadataToRelativePathResourceMetadata implements + Function { + + public ResourceMetadata apply(ResourceMetadata md) { + String name = md.getName(); + for (String suffix : BlobStoreConstants.DIRECTORY_SUFFIXES) { + if (name.endsWith(suffix)) + name = name.substring(0, name.length() - suffix.length()); + } + return new ResourceMetadataImpl(ResourceType.RELATIVE_PATH, md.getId(), name, md + .getLocation(), md.getETag(), md.getSize(), md.getLastModified(), md + .getUserMetadata()); + } + +} diff --git a/core/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java b/core/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java index 0988c23c9c..88f5d21df6 100755 --- a/core/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java +++ b/core/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java @@ -135,12 +135,12 @@ public abstract class BaseBlobMap { this.connection = checkNotNull(connection, "connection"); this.containerName = checkNotNull(containerName, "container"); this.options = options; - if (options.getPath() == null) { + if (options.getDir() == null) { prefixer = new PassThrough(); pathStripper = prefixer; } else { - prefixer = new PrefixKey(options.getPath(), "/"); - pathStripper = new StripPath(options.getPath(), "/"); + prefixer = new PrefixKey(options.getDir(), "/"); + pathStripper = new StripPath(options.getDir(), "/"); } this.getAllBlobs = checkNotNull(getAllBlobs, "getAllBlobs"); @@ -225,7 +225,7 @@ public abstract class BaseBlobMap { public SortedSet list() { SortedSet returnVal = getAllBlobMetadata.execute(containerName, options); - if (options.getPath() != null) { + if (options.getDir() != null) { returnVal = Sets.newTreeSet(Iterables.transform(returnVal, new Function() { diff --git a/core/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java b/core/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java index f516b7bd5c..6a821e9c11 100644 --- a/core/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java +++ b/core/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java @@ -77,7 +77,7 @@ public class BlobStoreContextImpl extends RestContextImpl implements String prefix = BlobStoreUtils.parsePrefixFromPath(path); ListContainerOptions options = new ListContainerOptions(); if (prefix != null) - options.underPath(prefix); + options.inDirectory(prefix); return blobMapFactory.create(container, options); } @@ -87,7 +87,7 @@ public class BlobStoreContextImpl extends RestContextImpl implements String prefix = BlobStoreUtils.parsePrefixFromPath(path); ListContainerOptions options = new ListContainerOptions(); if (prefix != null) - options.underPath(prefix); + options.inDirectory(prefix); return inputStreamMapFactory.create(container, options); } diff --git a/core/src/main/java/org/jclouds/blobstore/internal/LocationAndCredentials.java b/core/src/main/java/org/jclouds/blobstore/internal/LocationAndCredentials.java new file mode 100644 index 0000000000..f41398ef9b --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/internal/LocationAndCredentials.java @@ -0,0 +1,143 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.internal; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jclouds.util.Utils; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; + +/** + * Used to extract the URI and authentication data from a String. Note that the java URI class + * breaks, if there are special characters like '/' present. Otherwise, we wouldn't need this class, + * and we could simply use URI.create("uri").getUserData(); + * + * @author Adrian Cole + */ +public class LocationAndCredentials { + public static final Pattern URI_PATTERN = Pattern.compile("([a-z0-9]+)://([^:]*):(.*)@(.*)"); + public static final Pattern PATTERN_THAT_BREAKS_URI = Pattern.compile("[a-z0-9]+://.*/.*@.*"); // slash + // in + // userdata + // breaks + // URI.create() + public final URI uri; + public final String acccount; + public final String key; + + public LocationAndCredentials(URI uri, String acccount, String key) { + this.uri = checkNotNull(uri, "uri"); + checkArgument(uri.getHost() != null, "type missing from %s", uri.toASCIIString()); + checkArgument(uri.getPath() != null, "path missing from %s", uri.toASCIIString()); + this.acccount = acccount; + this.key = key; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((acccount == null) ? 0 : acccount.hashCode()); + result = prime * result + ((key == null) ? 0 : key.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LocationAndCredentials other = (LocationAndCredentials) obj; + if (acccount == null) { + if (other.acccount != null) + return false; + } else if (!acccount.equals(other.acccount)) + return false; + if (key == null) { + if (other.key != null) + return false; + } else if (!key.equals(other.key)) + return false; + if (uri == null) { + if (other.uri != null) + return false; + } else if (!uri.equals(other.uri)) + return false; + return true; + } + + public static LocationAndCredentials parse(String uriPath) { + if (uriPath.indexOf('@') != 1) { + List parts = Lists.newArrayList(Splitter.on('@').split(uriPath)); + String path = parts.remove(parts.size() - 1); + parts.add(Utils.urlEncode(path, '/', ':')); + uriPath = Joiner.on('@').join(parts); + } else { + List parts = Lists.newArrayList(Splitter.on('/').split(uriPath)); + String path = parts.remove(parts.size() - 1); + parts.add(Utils.urlEncode(path, ':')); + uriPath = Joiner.on('/').join(parts); + } + LocationAndCredentials locationAndCredentials; + + if (PATTERN_THAT_BREAKS_URI.matcher(uriPath).matches()) { + // Compile and use regular expression + Matcher matcher = URI_PATTERN.matcher(uriPath); + if (matcher.find()) { + String scheme = matcher.group(1); + String rest = matcher.group(4); + String account = matcher.group(2); + String key = matcher.group(3); + locationAndCredentials = new LocationAndCredentials(URI.create(String.format("%s://%s", + scheme, rest)), account, key); + } else { + throw new IllegalArgumentException("bad syntax"); + } + } else { + URI uri = URI.create(uriPath); + String account = null; + String key = null; + if (uri.getUserInfo() != null) { + List userInfo = Lists.newArrayList(Splitter.on(':').split(uri.getUserInfo())); + account = userInfo.get(0); + key = userInfo.size() > 1 ? userInfo.get(1) : null; + } + locationAndCredentials = new LocationAndCredentials(uri, account, key); + } + return locationAndCredentials; + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/options/GetOptions.java b/core/src/main/java/org/jclouds/blobstore/options/GetOptions.java index 418b43683d..8080c2a57c 100644 --- a/core/src/main/java/org/jclouds/blobstore/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/blobstore/options/GetOptions.java @@ -65,6 +65,15 @@ public class GetOptions { return this; } + /** + * download the specified range of the object. + */ + public GetOptions startAt(long start) { + checkArgument(start >= 0, "start must be >= 0"); + getRanges().add(String.format("%d-", start)); + return this; + } + /** * Only return the object if it has changed since this time. *

diff --git a/core/src/main/java/org/jclouds/blobstore/options/ListContainerOptions.java b/core/src/main/java/org/jclouds/blobstore/options/ListContainerOptions.java index 16becf0373..3879b91b58 100644 --- a/core/src/main/java/org/jclouds/blobstore/options/ListContainerOptions.java +++ b/core/src/main/java/org/jclouds/blobstore/options/ListContainerOptions.java @@ -29,26 +29,26 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Contains options supported in the list container operation.

* Usage

The recommended way to instantiate a ListOptions object is to statically import - * ListContainerOptions.* and invoke a static creation method followed by an instance mutator (if needed): + * ListContainerOptions.* and invoke a static creation method followed by an instance mutator (if + * needed): *

* * import static org.jclouds.blobstore.options.ListContainerOptions.Builder.* *

* BlobStore connection = // get connection - * Future> list = connection.list("container",underPath("home/users").maxResults(1000)); + * Future> list = connection.list("container",inDirectory("home/users").maxResults(1000)); * * * @author Adrian Cole */ public class ListContainerOptions extends ListOptions { - private String path; + private String dir; private boolean recursive; - - public String getPath() { - return path; + public String getDir() { + return dir; } public boolean isRecursive() { @@ -59,9 +59,10 @@ public class ListContainerOptions extends ListOptions { * Returns a pseudo-directory listing. * */ - public ListContainerOptions underPath(String path) { - checkArgument(!recursive, "path and recursive combination currently not supported"); - this.path = checkNotNull(path, "path"); + public ListContainerOptions inDirectory(String dir) { + checkArgument(!recursive, "dir and recursive combination currently not supported"); + this.dir = checkNotNull(dir, "dir"); + checkArgument(!dir.equals("/"), "dir must not be a slash"); return this; } @@ -83,7 +84,7 @@ public class ListContainerOptions extends ListOptions { * return a listing of all objects inside the store, recursively. */ public ListContainerOptions recursive() { -// checkArgument(path == null, "path and recursive combination currently not supported"); + // checkArgument(path == null, "path and recursive combination currently not supported"); this.recursive = true; return this; } @@ -91,11 +92,11 @@ public class ListContainerOptions extends ListOptions { public static class Builder { /** - * @see ListContainerOptions#underPath(String) + * @see ListContainerOptions#inDirectory(String) */ - public static ListContainerOptions underPath(String path) { + public static ListContainerOptions inDirectory(String directory) { ListContainerOptions options = new ListContainerOptions(); - return options.underPath(path); + return options.inDirectory(directory); } /** diff --git a/core/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java b/core/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java index 05f0d84324..ecee9c17e4 100755 --- a/core/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java +++ b/core/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java @@ -29,6 +29,29 @@ package org.jclouds.blobstore.reference; * @author Adrian Cole */ public interface BlobStoreConstants { + /** + *

+ * To interoperate with other S3 tools, we also accept the following: + *

    + *
  • an object named '#{dirpath}_$folder$' or '#{dirpath}/' denoting a directory marker
  • + *
  • an object with content type set to 'application/directory' denoting a directory marker
  • + *
  • if there exists any objects with the prefix "#{dirpath}/", then the directory is said to + * exist
  • + *
  • if both a file with the name of a directory and a marker for that directory exists, then + * the *file masks the directory*, and the directory is never returned.
  • + *
+ */ + public static final String DIRECTORY_SUFFIX_ROOT = "/"; + public static final String DIRECTORY_SUFFIX_FOLDER = "_$folder$"; + public static final String[] DIRECTORY_SUFFIXES = { DIRECTORY_SUFFIX_FOLDER, + DIRECTORY_SUFFIX_ROOT }; + + /** + * Key-value implementations of BlobStore, such as S3, do not have directories. We use an empty + * object '#{dirpath}_$folder$' with content type set to 'application/directory'. + */ + public static final String PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX = "jclouds.blobstore.directorysuffix"; + /** * comma-separated, fully qualified class names of implementations of BlobStoreContextBuilder * diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/GetDirectoryStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/GetDirectoryStrategy.java new file mode 100644 index 0000000000..a33587d669 --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/GetDirectoryStrategy.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy; + +import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.strategy.internal.MarkersGetDirectoryStrategy; + +import com.google.inject.ImplementedBy; + +/** + * Gets a directory or throws KeyNotFoundException + * + * @author Adrian Cole + */ +@ImplementedBy(MarkersGetDirectoryStrategy.class) +public interface GetDirectoryStrategy { + + ResourceMetadata execute(AsyncBlobStore connection, String containerName, String directory); +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/IsDirectoryStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/IsDirectoryStrategy.java new file mode 100644 index 0000000000..8a278ac328 --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/IsDirectoryStrategy.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy; + +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.strategy.internal.MarkersIsDirectoryStrategy; + +import com.google.inject.ImplementedBy; + +/** + * Determines if a directory exists or not. + * + * @author Adrian Cole + */ +@ImplementedBy(MarkersIsDirectoryStrategy.class) +public interface IsDirectoryStrategy { + + boolean execute(ResourceMetadata metadata); +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/MkdirStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/MkdirStrategy.java new file mode 100644 index 0000000000..c36271d020 --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/MkdirStrategy.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy; + +import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.strategy.internal.MarkerFileMkdirStrategy; + +import com.google.inject.ImplementedBy; + +/** + * Creates a directory + * + * @author Adrian Cole + */ +@ImplementedBy(MarkerFileMkdirStrategy.class) +public interface MkdirStrategy { + + void execute(AsyncBlobStore connection, String containerName, String directory); +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java new file mode 100644 index 0000000000..34dd18c57c --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkerFileMkdirStrategy.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy.internal; + +import java.util.concurrent.TimeUnit; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.KeyNotFoundException; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.internal.BlobRuntimeException; +import org.jclouds.blobstore.reference.BlobStoreConstants; +import org.jclouds.blobstore.strategy.MkdirStrategy; +import org.jclouds.util.Utils; + +import com.google.inject.Inject; + +/** + * Key-value implementations of BlobStore, such as S3, do not have directories. In following the + * rackspace cloud files project, we use an empty object '#{dirpath}' with content type set to + * 'application/directory'. + * + * @author Adrian Cole + */ +@Singleton +public class MarkerFileMkdirStrategy implements MkdirStrategy { + + /** + * maximum duration of an blob Request + */ + @Inject(optional = true) + @Named(BlobStoreConstants.PROPERTY_BLOBSTORE_TIMEOUT) + protected long requestTimeoutMilliseconds = 30000; + + @Inject(optional = true) + @Named(BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX) + protected String directorySuffix = ""; + + public void execute(AsyncBlobStore connection, String containerName, String directory) { + try { + if (!connection.directoryExists(containerName, directory).get(requestTimeoutMilliseconds, + TimeUnit.MILLISECONDS)) { + Blob blob = connection.newBlob(); + blob.getMetadata().setName(directory + directorySuffix); + blob.setData(""); + blob.getMetadata().setContentType("application/directory"); + connection.putBlob(containerName, blob).get(requestTimeoutMilliseconds, + TimeUnit.MILLISECONDS); + } + } catch (Exception e) { + e = Utils. rethrowIfRuntimeOrSameType(e); + if (!(e instanceof KeyNotFoundException)) + throw new BlobRuntimeException("Error creating marker directory: " + containerName + + "/" + directory, e); + } + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersGetDirectoryStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersGetDirectoryStrategy.java new file mode 100644 index 0000000000..df142c17c1 --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersGetDirectoryStrategy.java @@ -0,0 +1,93 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy.internal; + +import java.util.concurrent.TimeUnit; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.KeyNotFoundException; +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.functions.ResourceMetadataToRelativePathResourceMetadata; +import org.jclouds.blobstore.internal.BlobRuntimeException; +import org.jclouds.blobstore.reference.BlobStoreConstants; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.util.Utils; + +import com.google.inject.Inject; + +/** + * Key-value implementations of BlobStore, such as S3, do not have directories. In following the + * rackspace cloud files project, we use an empty object '#{dirpath}' with content type set to + * 'application/directory'. + * + *

+ * To interoperate with other S3 tools, we accept the following ways to tell if the directory + * exists: + *

    + *
  • an object named '#{dirpath}_$folder$' or '#{dirpath}/' denoting a directory marker
  • + *
  • an object with content type set to 'application/directory' denoting a directory marker
  • + *
  • if there exists any objects with the prefix "#{dirpath}/", then the directory is said to + * exist
  • + *
  • if both a file with the name of a directory and a marker for that directory exists, then the + * *file masks the directory*, and the directory is never returned.
  • + *
+ * + * @see MarkerFileMkdirStrategy + * @author Adrian Cole + */ +@Singleton +public class MarkersGetDirectoryStrategy implements GetDirectoryStrategy { + /** + * maximum duration of an blob Request + */ + @Inject(optional = true) + @Named(BlobStoreConstants.PROPERTY_BLOBSTORE_TIMEOUT) + protected long requestTimeoutMilliseconds = 30000; + protected final ResourceMetadataToRelativePathResourceMetadata resource2Directory; + + @Inject + public MarkersGetDirectoryStrategy(ResourceMetadataToRelativePathResourceMetadata resource2Directory) { + this.resource2Directory = resource2Directory; + } + + public ResourceMetadata execute(AsyncBlobStore connection, String containerName, String directory) { + for (String suffix : BlobStoreConstants.DIRECTORY_SUFFIXES) { + try { + return resource2Directory.apply(connection.blobMetadata(containerName, + directory + suffix).get(requestTimeoutMilliseconds, TimeUnit.MILLISECONDS)); + } catch (KeyNotFoundException e) { + } catch (Exception e) { + e = Utils. rethrowIfRuntimeOrSameType(e); + if (!(e instanceof KeyNotFoundException)) + throw new BlobRuntimeException("Error determining if a directory exists at: " + + containerName + "/" + directory, e); + } + } + throw new KeyNotFoundException(containerName, directory); + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersIsDirectoryStrategy.java b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersIsDirectoryStrategy.java new file mode 100644 index 0000000000..b965375eed --- /dev/null +++ b/core/src/main/java/org/jclouds/blobstore/strategy/internal/MarkersIsDirectoryStrategy.java @@ -0,0 +1,59 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.strategy.internal; + +import javax.inject.Singleton; + +import org.jclouds.blobstore.domain.BlobMetadata; +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.reference.BlobStoreConstants; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class MarkersIsDirectoryStrategy implements IsDirectoryStrategy { + + public boolean execute(ResourceMetadata metadata) { + switch (metadata.getType()) { + case CONTAINER: + case FOLDER: + case RELATIVE_PATH: + return true; + case BLOB: + BlobMetadata blobMd = (BlobMetadata) metadata; + if (blobMd.getContentType() != null + && blobMd.getContentType().equals("application/directory")) + return true; + for (String suffix : BlobStoreConstants.DIRECTORY_SUFFIXES) { + if (metadata.getName().endsWith(suffix)) { + return true; + } + } + } + return false; + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java b/core/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java index a47d6d97b2..affce5c5c3 100644 --- a/core/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java +++ b/core/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java @@ -28,7 +28,10 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.io.InputStream; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.domain.BlobMetadata; +import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.util.Utils; /** @@ -37,6 +40,26 @@ import org.jclouds.util.Utils; * @author Adrian Cole */ public class BlobStoreUtils { + public static Blob newBlob(BlobStore blobStore, ResourceMetadata blobMeta) { + Blob blob = blobStore.newBlob(); + if (blobMeta instanceof BlobMetadata) { + blob.getMetadata().setContentMD5(((BlobMetadata) blobMeta).getContentMD5()); + blob.getMetadata().setContentType(((BlobMetadata) blobMeta).getContentType()); + } + blob.getMetadata().setETag(blobMeta.getETag()); + blob.getMetadata().setId(blobMeta.getId()); + blob.getMetadata().setLastModified(blobMeta.getLastModified()); + blob.getMetadata().setLocation(blobMeta.getLocation()); + blob.getMetadata().setName(blobMeta.getName()); + blob.getMetadata().setUserMetadata(blobMeta.getUserMetadata()); + return blob; + } + + public static Blob newBlob(BlobStore blobStore, String name) { + Blob blob = blobStore.newBlob(); + blob.getMetadata().setName(name); + return blob; + } public static String parseContainerFromPath(String path) { String container = path; diff --git a/core/src/main/java/org/jclouds/http/options/GetOptions.java b/core/src/main/java/org/jclouds/http/options/GetOptions.java index 562b97e1c3..7091212dbf 100644 --- a/core/src/main/java/org/jclouds/http/options/GetOptions.java +++ b/core/src/main/java/org/jclouds/http/options/GetOptions.java @@ -84,7 +84,7 @@ public class GetOptions extends BaseHttpRequestOptions { */ public GetOptions startAt(long start) { checkArgument(start >= 0, "start must be >= 0"); - ranges.add(String.format("%d-", start)); + ranges.add(String.format("%d-%d", start, Long.MAX_VALUE)); return this; } diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java index 9586454947..298bd3d904 100755 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java @@ -1,6 +1,6 @@ /** * - * Copyright (A) 2009 Cloud Conscious, LLC. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/core/src/main/java/org/jclouds/rest/domain/NamedResource.java b/core/src/main/java/org/jclouds/rest/domain/NamedResource.java index 16cc978bb7..0f273a0aeb 100644 --- a/core/src/main/java/org/jclouds/rest/domain/NamedResource.java +++ b/core/src/main/java/org/jclouds/rest/domain/NamedResource.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rest.domain; import org.jclouds.rest.internal.NamedResourceImpl; diff --git a/core/src/main/java/org/jclouds/rest/internal/NamedResourceImpl.java b/core/src/main/java/org/jclouds/rest/internal/NamedResourceImpl.java index f5bd11f769..50c70baabe 100644 --- a/core/src/main/java/org/jclouds/rest/internal/NamedResourceImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/NamedResourceImpl.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rest.internal; import java.net.URI; diff --git a/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java b/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java index ac8410ea30..7b47d373a3 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java @@ -1,6 +1,6 @@ /** * - * Copyright (A) 2009 Cloud Conscious, LLC. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/core/src/main/java/org/jclouds/util/Utils.java b/core/src/main/java/org/jclouds/util/Utils.java index cec4747a49..920e735564 100644 --- a/core/src/main/java/org/jclouds/util/Utils.java +++ b/core/src/main/java/org/jclouds/util/Utils.java @@ -77,6 +77,8 @@ public class Utils { * Web browsers do not always handle '+' characters well, use the well-supported '%20' instead. */ public static String urlEncode(String in, char... skipEncode) { + if (isUrlEncoded(in)) + return in; try { String returnVal = URLEncoder.encode(in, "UTF-8").replaceAll("\\+", "%20").replaceAll( "\\*", "%2A").replaceAll("%7E", "~"); @@ -89,6 +91,10 @@ public class Utils { } } + public static boolean isUrlEncoded(String in) { + return in.matches(".*%[a-fA-F0-9][a-fA-F0-9].*"); + } + static Map plainToEncodedChars = new MapMaker() .makeComputingMap(new Function() { public String apply(String plain) { diff --git a/core/src/test/java/org/jclouds/blobstore/BlobStoreContextFactoryTest.java b/core/src/test/java/org/jclouds/blobstore/BlobStoreContextFactoryTest.java new file mode 100644 index 0000000000..1a21eee956 --- /dev/null +++ b/core/src/test/java/org/jclouds/blobstore/BlobStoreContextFactoryTest.java @@ -0,0 +1,66 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.net.URI; +import java.util.Iterator; + +import org.testng.annotations.Test; + +import com.google.common.base.Splitter; + +/** + * Tests parsing of a request + * + * @author Adrian Cole + */ +@Test(testName = "blobstore.BlobStoreContextFactoryTest") +public class BlobStoreContextFactoryTest { + + public void test() throws IOException { + URI blobStore = URI.create("service://account:key@container/path"); + assertEquals(blobStore.getScheme(), "service"); + Iterator accountKey = Splitter.on(":").split( + checkNotNull(blobStore.getUserInfo(), "userInfo")).iterator(); + assertEquals(accountKey.next(), "account"); + assertEquals(accountKey.next(), "key"); + assertEquals(blobStore.getHost(), "container"); + assertEquals(blobStore.getPath(), "/path"); + } + + public void testNoPassword() throws IOException { + URI blobStore = URI.create("service://account@container/path"); + assertEquals(blobStore.getScheme(), "service"); + Iterator accountKey = Splitter.on(":").split( + checkNotNull(blobStore.getUserInfo(), "userInfo")).iterator(); + assertEquals(accountKey.next(), "account"); + assertEquals(blobStore.getHost(), "container"); + assertEquals(blobStore.getPath(), "/path"); + } + +} diff --git a/core/src/test/java/org/jclouds/blobstore/functions/BlobMetadataToRelativePathResourceMetadataTest.java b/core/src/test/java/org/jclouds/blobstore/functions/BlobMetadataToRelativePathResourceMetadataTest.java new file mode 100644 index 0000000000..42505f7148 --- /dev/null +++ b/core/src/test/java/org/jclouds/blobstore/functions/BlobMetadataToRelativePathResourceMetadataTest.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.functions; + +import static org.testng.Assert.assertEquals; + +import javax.inject.Provider; + +import org.jclouds.blobstore.domain.MutableBlobMetadata; +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.domain.ResourceType; +import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; +import org.testng.annotations.Test; + +public class BlobMetadataToRelativePathResourceMetadataTest { + + private ResourceMetadataToRelativePathResourceMetadata parser = new ResourceMetadataToRelativePathResourceMetadata(); + + private Provider blobMetadataProvider = new Provider() { + + public MutableBlobMetadata get() { + return new MutableBlobMetadataImpl(); + } + + }; + + @Test + public void test1() { + MutableBlobMetadata md = blobMetadataProvider.get(); + md.setName("dir/"); + md.setId("dir/"); + ResourceMetadata rd = parser.apply(md); + assertEquals(rd.getName(), "dir"); + assertEquals(rd.getId(), "dir/"); + assertEquals(rd.getType(), ResourceType.RELATIVE_PATH); + } + + @Test + public void test2() { + MutableBlobMetadata md = blobMetadataProvider.get(); + md.setName("dir_$folder$"); + md.setId("dir_$folder$"); + ResourceMetadata rd = parser.apply(md); + assertEquals(rd.getName(), "dir"); + assertEquals(rd.getId(), "dir_$folder$"); + assertEquals(rd.getType(), ResourceType.RELATIVE_PATH); + } + + @Test + public void testNoNameChange() { + MutableBlobMetadata md = blobMetadataProvider.get(); + md.setName("dir"); + md.setId("dir"); + ResourceMetadata rd = parser.apply(md); + assertEquals(rd.getName(), "dir"); + assertEquals(rd.getId(), "dir"); + assertEquals(rd.getType(), ResourceType.RELATIVE_PATH); + } +} diff --git a/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java b/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java index 26a36d605d..aa9db55540 100644 --- a/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java +++ b/core/src/test/java/org/jclouds/blobstore/functions/ParseBlobMetadataFromHeadersTest.java @@ -85,15 +85,15 @@ public class ParseBlobMetadataFromHeadersTest { HttpResponse from = new HttpResponse(); from.getHeaders().put(HttpHeaders.CONTENT_LENGTH, "100"); MutableBlobMetadata metadata = blobMetadataProvider.get(); - parser.setContentLengthOrThrowException(from, metadata); + parser.setContentLength(from, metadata); assertEquals(metadata.getSize(), new Long(100)); } - @Test(expectedExceptions = HttpException.class) - public void testSetContentLengthException() { + public void testSetContentLengthNoHeader() { HttpResponse from = new HttpResponse(); MutableBlobMetadata metadata = blobMetadataProvider.get(); - parser.setContentLengthOrThrowException(from, metadata); + parser.setContentLength(from, metadata); + assertEquals(metadata.getSize(), new Long(0)); } @Test diff --git a/core/src/test/java/org/jclouds/blobstore/integration/StubBlobStoreContextBuilder.java b/core/src/test/java/org/jclouds/blobstore/integration/StubBlobStoreContextBuilder.java index 3202a88098..878be02394 100644 --- a/core/src/test/java/org/jclouds/blobstore/integration/StubBlobStoreContextBuilder.java +++ b/core/src/test/java/org/jclouds/blobstore/integration/StubBlobStoreContextBuilder.java @@ -25,6 +25,7 @@ package org.jclouds.blobstore.integration; import java.net.URI; import java.util.List; +import java.util.Properties; import java.util.concurrent.TimeUnit; import javax.inject.Singleton; @@ -54,6 +55,14 @@ import com.google.inject.TypeLiteral; */ public class StubBlobStoreContextBuilder extends BlobStoreContextBuilder { + /** + * This is only to have the same syntax. + * + */ + public StubBlobStoreContextBuilder(Properties props) { + this(); + } + public StubBlobStoreContextBuilder() { super(new TypeLiteral() { }, new TypeLiteral() { diff --git a/core/src/test/java/org/jclouds/blobstore/integration/StubPropertiesBuilder.java b/core/src/test/java/org/jclouds/blobstore/integration/StubPropertiesBuilder.java new file mode 100644 index 0000000000..fcea954948 --- /dev/null +++ b/core/src/test/java/org/jclouds/blobstore/integration/StubPropertiesBuilder.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.integration; + +import java.util.Properties; + +import org.jclouds.http.HttpPropertiesBuilder; + +/** + * Builds properties used in Stub Connections + * + * @author Adrian Cole + */ +public class StubPropertiesBuilder extends HttpPropertiesBuilder { + + public StubPropertiesBuilder(Properties properties) { + super(properties); + } + + public StubPropertiesBuilder(String id, String secret) { + super(); + } + +} diff --git a/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index 8f65e186f3..04cbb8e66a 100644 --- a/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -397,13 +397,13 @@ public class BaseBlobStoreIntegrationTest { protected static void deleteContainer(final BlobStoreContext context, final String name) throws InterruptedException { - if (context.getBlobStore().exists(name)) { + if (context.getBlobStore().containerExists(name)) { System.err.printf("*** deleting container %s...%n", name); context.getBlobStore().deleteContainer(name); assertConsistencyAware(context, new Runnable() { public void run() { try { - assert !context.getBlobStore().exists(name) : "container " + name + assert !context.getBlobStore().containerExists(name) : "container " + name + " still exists"; } catch (Exception e) { Utils. rethrowIfRuntimeOrSameType(e); diff --git a/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index 6ca9cf30e3..907df164ac 100755 --- a/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/core/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -25,7 +25,7 @@ package org.jclouds.blobstore.integration.internal; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.afterMarker; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults; -import static org.jclouds.blobstore.options.ListContainerOptions.Builder.underPath; +import static org.jclouds.blobstore.options.ListContainerOptions.Builder.inDirectory; import static org.testng.Assert.assertEquals; import java.io.UnsupportedEncodingException; @@ -47,7 +47,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration @Test(groups = { "integration", "live" }) public void containerDoesntExist() { - assert !context.getBlobStore().exists("forgetaboutit"); + assert !context.getBlobStore().containerExists("forgetaboutit"); } @Test(groups = { "integration", "live" }) @@ -112,7 +112,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration add15UnderRoot(containerName); ListContainerResponse container = context.getBlobStore().list( - containerName, underPath("apps/")); + containerName, inDirectory("apps/")); assert !container.isTruncated(); assertEquals(container.size(), 10); assertEquals(container.getPath(), "apps/"); @@ -141,7 +141,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration public void containerExists() throws InterruptedException { String containerName = getContainerName(); try { - assert context.getBlobStore().exists(containerName); + assert context.getBlobStore().containerExists(containerName); } finally { returnContainer(containerName); } @@ -175,7 +175,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegration assertConsistencyAware(new Runnable() { public void run() { try { - assert !context.getBlobStore().exists(containerName) : "container " + containerName + assert !context.getBlobStore().containerExists(containerName) : "container " + containerName + " still exists"; } catch (Exception e) { Utils. rethrowIfRuntimeOrSameType(e); diff --git a/core/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java b/core/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java index 738a6fd8a0..6f8bf2b3ab 100755 --- a/core/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java +++ b/core/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java @@ -41,9 +41,11 @@ import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; import java.util.Map.Entry; +import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -72,6 +74,9 @@ import org.jclouds.blobstore.domain.internal.MutableResourceMetadataImpl; import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions; import org.jclouds.blobstore.options.GetOptions; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -103,17 +108,29 @@ public class StubAsyncBlobStore implements AsyncBlobStore { private final ConcurrentMap> containerToBlobs; protected final Blob.Factory blobProvider; protected final HttpGetOptionsListToGetOptions httpGetOptionsConverter; + protected final GetDirectoryStrategy getDirectoryStrategy; + protected final MkdirStrategy mkdirStrategy; + private final IsDirectoryStrategy isDirectoryStrategy; + + protected final ExecutorService service; @Inject protected StubAsyncBlobStore( ConcurrentMap> containerToBlobs, DateService dateService, Blob.Factory blobProvider, - HttpGetOptionsListToGetOptions httpGetOptionsConverter) { + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, + IsDirectoryStrategy isDirectoryStrategy, + HttpGetOptionsListToGetOptions httpGetOptionsConverter, ExecutorService service) { this.dateService = checkNotNull(dateService, "dateService"); this.containerToBlobs = checkNotNull(containerToBlobs, "containerToBlobs"); this.blobProvider = checkNotNull(blobProvider, "blobProvider"); + this.getDirectoryStrategy = checkNotNull(getDirectoryStrategy, "getDirectoryStrategy"); + this.mkdirStrategy = checkNotNull(mkdirStrategy, "mkdirStrategy"); + this.isDirectoryStrategy = checkNotNull(isDirectoryStrategy, "isDirectoryStrategy"); this.httpGetOptionsConverter = checkNotNull(httpGetOptionsConverter, "httpGetOptionsConverter"); + this.service = checkNotNull(service, "service"); + getContainerToBlobs().put("stub", new ConcurrentHashMap()); } /** @@ -170,7 +187,10 @@ public class StubAsyncBlobStore implements AsyncBlobStore { SortedSet contents = Sets.newTreeSet(Iterables.transform(realContents .keySet(), new Function() { public ResourceMetadata apply(String key) { - return copy(realContents.get(key).getMetadata()); + MutableBlobMetadata md = copy(realContents.get(key).getMetadata()); + if (isDirectoryStrategy.execute(md)) + md.setType(ResourceType.RELATIVE_PATH); + return md; } })); @@ -186,7 +206,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { contents.remove(lastMarkerMetadata); } - final String prefix = options.getPath(); + final String prefix = options.getDir(); if (prefix != null) { contents = Sets.newTreeSet(Iterables.filter(contents, new Predicate() { @@ -315,7 +335,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { }; } - public Future exists(final String container) { + public Future containerExists(final String container) { return new FutureBase() { public Boolean get() throws InterruptedException, ExecutionException { return getContainerToBlobs().containsKey(container); @@ -490,9 +510,10 @@ public class StubAsyncBlobStore implements AsyncBlobStore { new RuntimeException("bucketName not found: " + bucketName); } try { + byte[] data = toByteArray(object.getData()); + object.getMetadata().setSize(data.length); MutableBlobMetadata newMd = copy(object.getMetadata()); newMd.setLastModified(new DateTime()); - byte[] data = toByteArray(object.getData()); final byte[] md5 = HttpUtils.md5(data); final String eTag = HttpUtils.toHexString(md5); newMd.setETag(eTag); @@ -573,10 +594,10 @@ public class StubAsyncBlobStore implements AsyncBlobStore { ByteArrayOutputStream out = new ByteArrayOutputStream(); for (String s : options.getRanges()) { if (s.startsWith("-")) { - int length = Integer.parseInt(s); + int length = Integer.parseInt(s.substring(1)); out.write(data, data.length - length, length); } else if (s.endsWith("-")) { - int offset = Integer.parseInt(s); + int offset = Integer.parseInt(s.substring(0, s.length()-1)); out.write(data, offset, data.length - offset); } else if (s.contains("-")) { String[] firstLast = s.split("\\-"); @@ -632,6 +653,31 @@ public class StubAsyncBlobStore implements AsyncBlobStore { }; } + public Future createDirectory(final String container, final String directory) { + return service.submit(new Callable() { + + public Void call() throws Exception { + mkdirStrategy.execute(StubAsyncBlobStore.this, container, directory); + return null; + } + + }); + } + + public Future directoryExists(final String container, final String directory) { + return service.submit(new Callable() { + + public Boolean call() throws Exception { + try { + return getDirectoryStrategy.execute(StubAsyncBlobStore.this, container, directory) != null; + } catch (KeyNotFoundException e) { + return false; + } + } + + }); + } + public Blob newBlob() { return blobProvider.create(null); } diff --git a/core/src/test/java/org/jclouds/blobstore/internal/LocationAndCredentialsTest.java b/core/src/test/java/org/jclouds/blobstore/internal/LocationAndCredentialsTest.java new file mode 100644 index 0000000000..8b0060c0f2 --- /dev/null +++ b/core/src/test/java/org/jclouds/blobstore/internal/LocationAndCredentialsTest.java @@ -0,0 +1,86 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore.internal; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; + +import org.jclouds.blobstore.internal.LocationAndCredentials; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "blobstore.LocationAndCredentialsTest") +public class LocationAndCredentialsTest { + + public void testAzure() { + LocationAndCredentials creds = LocationAndCredentials + .parse("blobstore://account:Base64==@azureblob/container-hyphen/prefix"); + assertEquals(creds.acccount, "account"); + assertEquals(creds.key, "Base64=="); + assertEquals(creds.uri, URI + .create("blobstore://account:Base64==@azureblob/container-hyphen/prefix")); + } + + public void testCloudFiles() { + LocationAndCredentials creds = LocationAndCredentials + .parse("blobstore://account:h3c@cloudfiles/container-hyphen/prefix"); + assertEquals(creds.acccount, "account"); + assertEquals(creds.key, "h3c"); + assertEquals(creds.uri, URI + .create("blobstore://account:h3c@cloudfiles/container-hyphen/prefix")); + } + + public void testS3() { + + LocationAndCredentials creds = LocationAndCredentials + .parse("blobstore://0AB:aA+/0@s3/buck-et/prefix"); + assertEquals(creds.acccount, "0AB"); + assertEquals(creds.key, "aA+/0"); + assertEquals(creds.uri, URI.create("blobstore://s3/buck-et/prefix")); + } + + public void testS3Space() { + + LocationAndCredentials creds = LocationAndCredentials + .parse("blobstore://0AB:aA+/0@s3/buck-et/pre fix"); + assertEquals(creds.acccount, "0AB"); + assertEquals(creds.key, "aA+/0"); + assertEquals(creds.uri, URI.create("blobstore://s3/buck-et/pre%20fix")); + } + + public void testPercent() { + LocationAndCredentials creds = LocationAndCredentials + .parse("https://jclouds.blob.core.windows.net/jclouds-getpath/write-tests/file1%.txt"); + assertEquals(creds.acccount, null); + assertEquals(creds.key, null); + assertEquals( + creds.uri, + URI + .create("https://jclouds.blob.core.windows.net/jclouds-getpath/write-tests/file1%25.txt")); + + } +} diff --git a/core/src/test/java/org/jclouds/blobstore/options/ListOptionsTest.java b/core/src/test/java/org/jclouds/blobstore/options/ListOptionsTest.java index 15741eae11..299dda82c8 100644 --- a/core/src/test/java/org/jclouds/blobstore/options/ListOptionsTest.java +++ b/core/src/test/java/org/jclouds/blobstore/options/ListOptionsTest.java @@ -26,7 +26,7 @@ package org.jclouds.blobstore.options; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.afterMarker; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive; -import static org.jclouds.blobstore.options.ListContainerOptions.Builder.underPath; +import static org.jclouds.blobstore.options.ListContainerOptions.Builder.inDirectory; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -54,21 +54,21 @@ public class ListOptionsTest { @Test public void testPath() { ListContainerOptions options = new ListContainerOptions(); - options.underPath("test"); - assertEquals(options.getPath(), "test"); + options.inDirectory("test"); + assertEquals(options.getDir(), "test"); } @Test public void testPathStatic() { - ListContainerOptions options = underPath("test"); - assertEquals(options.getPath(), "test"); + ListContainerOptions options = inDirectory("test"); + assertEquals(options.getDir(), "test"); } @Test public void testTwoOptions() { ListContainerOptions options = new ListContainerOptions(); - options.underPath("test").maxResults(1); - assertEquals(options.getPath(), "test"); + options.inDirectory("test").maxResults(1); + assertEquals(options.getDir(), "test"); assertEquals(options.getMaxResults(), new Integer(1)); } @@ -76,12 +76,12 @@ public class ListOptionsTest { @Test public void testNullPath() { ListContainerOptions options = new ListContainerOptions(); - assertEquals(options.getPath(), null); + assertEquals(options.getDir(), null); } @Test(expectedExceptions = NullPointerException.class) public void testPathNPE() { - underPath(null); + inDirectory(null); } @Test diff --git a/core/src/test/java/org/jclouds/compute/ComputeService.java b/core/src/test/java/org/jclouds/compute/ComputeService.java index b413578602..96082aba71 100644 --- a/core/src/test/java/org/jclouds/compute/ComputeService.java +++ b/core/src/test/java/org/jclouds/compute/ComputeService.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.compute; import java.util.SortedSet; diff --git a/core/src/test/java/org/jclouds/compute/Instance.java b/core/src/test/java/org/jclouds/compute/Instance.java index 59ec237d8b..9acbc4a32e 100644 --- a/core/src/test/java/org/jclouds/compute/Instance.java +++ b/core/src/test/java/org/jclouds/compute/Instance.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.compute; import com.google.common.base.Service; diff --git a/core/src/test/java/org/jclouds/compute/Platform.java b/core/src/test/java/org/jclouds/compute/Platform.java index 07d3cdee0e..dd5926b1db 100644 --- a/core/src/test/java/org/jclouds/compute/Platform.java +++ b/core/src/test/java/org/jclouds/compute/Platform.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.compute; import java.util.SortedSet; diff --git a/core/src/test/java/org/jclouds/compute/Server.java b/core/src/test/java/org/jclouds/compute/Server.java index 24bd05594e..9b37d2ceb7 100644 --- a/core/src/test/java/org/jclouds/compute/Server.java +++ b/core/src/test/java/org/jclouds/compute/Server.java @@ -1,7 +1,28 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.compute; -import com.google.common.base.Service; - import java.util.SortedSet; /** diff --git a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java index 649e60fd5f..0a9e2d00d0 100644 --- a/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java +++ b/core/src/test/java/org/jclouds/http/options/GetOptionsTest.java @@ -160,13 +160,13 @@ public class GetOptionsTest { public void testStartAt() { GetOptions options = new GetOptions(); options.startAt(100); - assertEquals(options.getRange(), "bytes=100-"); + assertEquals(options.getRange(), "bytes=100-9223372036854775807"); } @Test public void testStartAtStatic() { GetOptions options = startAt(100); - assertEquals(options.getRange(), "bytes=100-"); + assertEquals(options.getRange(), "bytes=100-9223372036854775807"); } @Test(expectedExceptions = IllegalArgumentException.class) diff --git a/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java b/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java index 73b0ef553f..057f0904f2 100644 --- a/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java +++ b/core/src/test/java/org/jclouds/predicates/RetryablePredicateTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.predicates; import java.util.concurrent.TimeUnit; diff --git a/core/src/test/java/org/jclouds/util/UtilsTest.java b/core/src/test/java/org/jclouds/util/UtilsTest.java index 5f0ed29dd4..da49796e95 100644 --- a/core/src/test/java/org/jclouds/util/UtilsTest.java +++ b/core/src/test/java/org/jclouds/util/UtilsTest.java @@ -41,4 +41,15 @@ public class UtilsTest { assertEquals(Utils.replaceTokens("hello {where}", ImmutableMap.of("where", "world")), "hello world"); } + + public void testIsEncoded() { + assert Utils.isUrlEncoded("/read-tests/%73%6f%6d%65%20%66%69%6c%65"); + assert !Utils.isUrlEncoded("/read-tests/ tep"); + } + + public void testNoDoubleEncode() { + assertEquals(Utils.urlEncode("/read-tests/%73%6f%6d%65%20%66%69%6c%65", '/'), + "/read-tests/%73%6f%6d%65%20%66%69%6c%65"); + assertEquals(Utils.urlEncode("/read-tests/ tep", '/'), "/read-tests/%20tep"); + } } diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 6fe00c8854..65423c9e94 100755 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -138,7 +138,7 @@ public class TweetStoreLiveTest { this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); boolean deleted = false; for (BlobStoreContext context : contexts) { - if (context.getBlobStore().exists(container)) { + if (context.getBlobStore().containerExists(container)) { System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); context.getBlobStore().deleteContainer(container); deleted = true; diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java index 1bea4d311d..8a047041ea 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java @@ -33,6 +33,7 @@ import java.util.concurrent.Future; import javax.inject.Inject; import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -42,6 +43,8 @@ import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient; @@ -71,11 +74,13 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements ObjectToBlob object2Blob, BlobToObject blob2Object, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, BlobToObjectGetOptions blob2ObjectGetOptions, + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd, ContainerToResourceList container2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2ContainerListOptions, blob2ObjectGetOptions, - container2ResourceMd, container2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, container2ResourceMd, container2ResourceList, + service); } /** @@ -121,7 +126,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements }); } - public Future exists(String container) { + public Future containerExists(String container) { return async.containerExists(container); } @@ -161,4 +166,30 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements return async.removeObject(container, key); } + public Future createDirectory(final String container, final String directory) { + return service.submit(new Callable() { + + public Void call() throws Exception { + mkdirStrategy.execute(CloudFilesAsyncBlobStore.this, container, directory); + return null; + } + + }); + } + + public Future directoryExists(final String container, final String directory) { + return service.submit(new Callable() { + + public Boolean call() throws Exception { + try { + getDirectoryStrategy.execute(CloudFilesAsyncBlobStore.this, container, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + }); + } + } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStore.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStore.java index e121bc10e4..464753d3a3 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStore.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesBlobStore.java @@ -31,6 +31,7 @@ import java.util.concurrent.ExecutorService; import javax.inject.Inject; import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.ListContainerResponse; @@ -40,6 +41,9 @@ import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.blobstore.domain.internal.ListResponseImpl; import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.strategy.ClearListStrategy; +import org.jclouds.blobstore.strategy.GetDirectoryStrategy; +import org.jclouds.blobstore.strategy.MkdirStrategy; +import org.jclouds.blobstore.util.BlobStoreUtils; import org.jclouds.http.options.GetOptions; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient; @@ -58,19 +62,23 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; public class CloudFilesBlobStore extends BaseCloudFilesBlobStore implements BlobStore { + private final CloudFilesAsyncBlobStore aBlobStore; @Inject - public CloudFilesBlobStore(CloudFilesAsyncClient async, CloudFilesClient sync, - Factory blobFactory, LoggerFactory logFactory, + public CloudFilesBlobStore(CloudFilesAsyncBlobStore aBlobStore, CloudFilesAsyncClient async, + CloudFilesClient sync, Factory blobFactory, LoggerFactory logFactory, ClearListStrategy clearContainerStrategy, ObjectToBlobMetadata object2BlobMd, ObjectToBlob object2Blob, BlobToObject blob2Object, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, BlobToObjectGetOptions blob2ObjectGetOptions, + GetDirectoryStrategy getDirectoryStrategy, MkdirStrategy mkdirStrategy, ContainerToResourceMetadata container2ResourceMd, ContainerToResourceList container2ResourceList, ExecutorService service) { super(async, sync, blobFactory, logFactory, clearContainerStrategy, object2BlobMd, object2Blob, blob2Object, container2ContainerListOptions, blob2ObjectGetOptions, - container2ResourceMd, container2ResourceList, service); + getDirectoryStrategy, mkdirStrategy, container2ResourceMd, container2ResourceList, + service); + this.aBlobStore = aBlobStore; } /** @@ -93,8 +101,8 @@ public class CloudFilesBlobStore extends BaseCloudFilesBlobStore implements Blob sync.deleteContainerIfEmpty(container); } - public boolean exists(String container) { - return sync.containerExists(container); + public boolean containerExists(String path) { + return sync.containerExists(BlobStoreUtils.parseContainerFromPath(path)); } public Blob getBlob(String container, String key, @@ -128,4 +136,17 @@ public class CloudFilesBlobStore extends BaseCloudFilesBlobStore implements Blob sync.removeObject(container, key); } + public boolean directoryExists(String containerName, String directory) { + try { + getDirectoryStrategy.execute(aBlobStore, containerName, directory); + return true; + } catch (KeyNotFoundException e) { + return false; + } + } + + public void createDirectory(String containerName, String directory) { + mkdirStrategy.execute(aBlobStore, containerName, directory); + } + } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java index c533348fa4..622a6b24aa 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobStoreListContainerOptionsToListContainerOptions.java @@ -41,17 +41,17 @@ public class BlobStoreListContainerOptionsToListContainerOptions org.jclouds.rackspace.cloudfiles.options.ListContainerOptions options = new org.jclouds.rackspace.cloudfiles.options.ListContainerOptions(); if (optionsList.length != 0) { - if ((optionsList[0].getPath() == null) && (optionsList[0].isRecursive())) { + if ((optionsList[0].getDir() == null) && (optionsList[0].isRecursive())) { options.withPrefix(""); } - if ((optionsList[0].getPath() == null) && (!optionsList[0].isRecursive())) { + if ((optionsList[0].getDir() == null) && (!optionsList[0].isRecursive())) { options.underPath(""); } - if ((optionsList[0].getPath() != null) && (optionsList[0].isRecursive())) { - options.withPrefix(optionsList[0].getPath()); + if ((optionsList[0].getDir() != null) && (optionsList[0].isRecursive())) { + options.withPrefix(optionsList[0].getDir()); } - if ((optionsList[0].getPath() != null) && (!optionsList[0].isRecursive())) { - options.underPath(optionsList[0].getPath()); + if ((optionsList[0].getDir() != null) && (!optionsList[0].isRecursive())) { + options.underPath(optionsList[0].getDir()); } if (optionsList[0].getMarker() != null) { options.afterMarker(optionsList[0].getMarker()); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java index dd53a3e691..aad66f4c6f 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/BlobToObjectGetOptions.java @@ -52,7 +52,12 @@ public class BlobToObjectGetOptions implements } for (String range : from[0].getRanges()) { String[] firstLast = range.split("\\-"); - httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + if (firstLast.length == 2) + httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); + else if (range.startsWith("-")) + httpOptions.tail(Long.parseLong(firstLast[0])); + else + httpOptions.startAt(Long.parseLong(firstLast[0])); } } return httpOptions; diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java index 6f445e52a1..a9e21e726d 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ListContainerOptionsToBlobStoreListContainerOptions.java @@ -41,10 +41,10 @@ public class ListContainerOptionsToBlobStoreListContainerOptions ListContainerOptions options = new ListContainerOptions(); if (optionsList.length != 0) { if (optionsList[0].getPath() != null) { - options.underPath(optionsList[0].getPath()); + options.inDirectory(optionsList[0].getPath()); } if (optionsList[0].getPrefix() != null) { - options.underPath(optionsList[0].getPrefix()); + options.inDirectory(optionsList[0].getPrefix()); options.recursive(); } if (optionsList[0].getMarker() != null) { diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java index c9d9d76514..b0df505f9a 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/functions/ObjectToBlobMetadata.java @@ -23,11 +23,13 @@ */ package org.jclouds.rackspace.cloudfiles.blobstore.functions; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.blobstore.domain.MutableBlobMetadata; import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; import org.jclouds.http.HttpUtils; import org.jclouds.rackspace.cloudfiles.domain.MutableObjectInfoWithMetadata; import org.jclouds.rackspace.cloudfiles.domain.ObjectInfo; @@ -39,6 +41,13 @@ import com.google.common.base.Function; */ @Singleton public class ObjectToBlobMetadata implements Function { + private final IsDirectoryStrategy isDirectoryStrategy; + + @Inject + public ObjectToBlobMetadata(IsDirectoryStrategy isDirectoryStrategy) { + this.isDirectoryStrategy = isDirectoryStrategy; + } + public MutableBlobMetadata apply(ObjectInfo from) { MutableBlobMetadata to = new MutableBlobMetadataImpl(); to.setContentMD5(from.getHash()); @@ -49,10 +58,12 @@ public class ObjectToBlobMetadata implements Function + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rimuhosting.miro.binder; import org.jclouds.http.HttpRequest; diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java index 12ff860938..eb6ca95354 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rimuhosting.miro.servers; import org.jclouds.compute.ComputeService; diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeServiceLiveTest.java index 3ddd9dc6ba..f92d36eff5 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeServiceLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeServiceLiveTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rimuhosting.miro.servers; import org.testng.annotations.Test; diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java index fdeacc4bd2..f4994ef53b 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.rimuhosting.miro.servers; import org.jclouds.compute.Server; diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/EnvBuilderTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/EnvBuilderTest.java index f0c718ccfb..abc98e16a5 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/EnvBuilderTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/EnvBuilderTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.scriptbuilder; import static org.testng.Assert.assertEquals; diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/ScriptBuilderTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/ScriptBuilderTest.java index 2d3499278e..73269b56dc 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/ScriptBuilderTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/ScriptBuilderTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.scriptbuilder; import static org.jclouds.scriptbuilder.domain.Statements.call; diff --git a/thirdparty/README.txt b/thirdparty/README.txt index db447e921e..9645b94e05 100644 --- a/thirdparty/README.txt +++ b/thirdparty/README.txt @@ -1,2 +1,25 @@ +==== + + Copyright (C) 2009 Cloud Conscious, LLC. + + ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + ==================================================================== +==== thirdparty module is code we are temporarily storing as there is no maven module for it (or the code we use from it). Please publish to maven repos manually as needed. diff --git a/tools/getpath/.svnignore b/tools/getpath/.svnignore new file mode 100644 index 0000000000..87e4fd304e --- /dev/null +++ b/tools/getpath/.svnignore @@ -0,0 +1,7 @@ +target +.settings +.classpath +.project +jclouds-aws-sample-createandlistbuckets.iml +jclouds-aws-sample-createandlistbuckets.ipr +jclouds-aws-sample-createandlistbuckets.iws \ No newline at end of file diff --git a/tools/getpath/README.txt b/tools/getpath/README.txt new file mode 100755 index 0000000000..04a57d1e68 --- /dev/null +++ b/tools/getpath/README.txt @@ -0,0 +1,29 @@ +==== + + Copyright (C) 2009 Cloud Conscious, LLC. + + ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + ==================================================================== +==== +# +# this is a simple command line client that obtains the contents of a container +# 1. execute 'mvn install' to build the sample +# 2. invoke the jar, passing your credentials and the container you wish to get +# ex. +# java -jar target/jclouds-getpath-jar-with-dependencies.jar accesskey secretkey container/path diff --git a/tools/getpath/pom.xml b/tools/getpath/pom.xml new file mode 100644 index 0000000000..80888aaaf9 --- /dev/null +++ b/tools/getpath/pom.xml @@ -0,0 +1,148 @@ + + + + jclouds-tools-project + org.jclouds + 1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + jclouds-getpath + jclouds getpath + jclouds blobstore tool that downloads a container path to a local directory + + jclouds-getpath + 1 + + + + + + ${project.groupId} + jclouds-aws + ${project.version} + + + ${project.groupId} + jclouds-azure + ${project.version} + + + ${project.groupId} + jclouds-rackspace + ${project.version} + + + ${project.groupId} + jclouds-log4j + ${project.version} + test + + + log4j + log4j + 1.2.14 + test + + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.jclouds.blobstore.GetPath + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + org.jclouds.blobstore.GetPath + + + + + + make-assembly + package + + single + + + + + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + jclouds.azure.storage.account + ${jclouds.azure.storage.account} + + + jclouds.azure.storage.key + ${jclouds.azure.storage.key} + + + jclouds.rackspace.user + ${jclouds.rackspace.user} + + + jclouds.rackspace.key + ${jclouds.rackspace.key} + + + jclouds.aws.accesskeyid + ${jclouds.aws.accesskeyid} + + + jclouds.aws.secretaccesskey + ${jclouds.aws.secretaccesskey} + + + jclouds.getpath.container + ${jclouds.getpath.container} + + + jclouds.getpath.path + ${jclouds.getpath.path} + + + + + + + + + + + + diff --git a/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java b/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java new file mode 100755 index 0000000000..9163726c6b --- /dev/null +++ b/tools/getpath/src/main/java/org/jclouds/blobstore/GetPath.java @@ -0,0 +1,118 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore; + +import static com.google.common.base.Preconditions.*; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Properties; +import java.util.Map.Entry; + +import org.apache.commons.io.IOUtils; +import org.jclouds.blobstore.internal.LocationAndCredentials; +import org.jclouds.blobstore.util.BlobStoreUtils; + +import com.google.common.io.Resources; + +/** + * + * Usage is: java GetPath blobstore://account:key@service/container/path destinationPath + * + * @author Adrian Cole + */ +public class GetPath { + + public static String INVALID_SYNTAX = "Invalid parameters. Syntax is: blobstore://account:key@service/container/path destinationPath"; + + public static void main(String... args) throws IOException { + if (args.length < 2) + throw new IllegalArgumentException(INVALID_SYNTAX); + LocationAndCredentials locationAndCredentials; + try { + locationAndCredentials = LocationAndCredentials.parse(args[0]); + checkArgument(locationAndCredentials.uri.getScheme().equals("blobstore"), "wrong scheme"); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException(String.format("%s%n%s", e.getMessage(), INVALID_SYNTAX)); + } + checkArgument(args[1] != null, String.format("destination must be specified%n%s", + INVALID_SYNTAX)); + + File destinationDir = new File(args[1]); + destinationDir.mkdirs(); + + BlobStoreContext context = init(locationAndCredentials); + String path = locationAndCredentials.uri.getPath(); + if (path.startsWith("/")) + path = path.substring(1); + String container = BlobStoreUtils.parseContainerFromPath(path); + String directory = BlobStoreUtils.parsePrefixFromPath(path); + copyDirectoryToDestination(context, container, directory, destinationDir); + context.close(); + + } + + private static void copyDirectoryToDestination(BlobStoreContext context, String container, + String directory, File destinationDir) throws FileNotFoundException, IOException { + InputStream input = null; + + try { + checkState(context.getBlobStore().containerExists(container), String.format( + "source container %s does not exist", directory, container)); + checkState(context.getBlobStore().directoryExists(container, directory), String.format( + "source directory %s does not exist in container %s", directory, container)); + + String path = container + "/" + directory; + InputStreamMap map = context.createInputStreamMap(path); + System.out.printf("fetching %d entries from %s %s%n", map.size(), context.getAccount(), + path); + for (Entry entry : map.entrySet()) { + System.out.printf("getting file: %s/%s%n", path, entry.getKey()); + input = entry.getValue(); + File file = new File(destinationDir, entry.getKey()); + OutputStream out = new FileOutputStream(file); + IOUtils.copyLarge(input, out); + out.flush(); + out.close(); + } + + } finally { + // Close connecton + IOUtils.closeQuietly(input); + } + } + + private static BlobStoreContext init(LocationAndCredentials locationAndCredentials) + throws IOException { + Properties properties = new Properties(); + properties.load(Resources.newInputStreamSupplier(Resources.getResource("jclouds.properties")) + .getInput()); + return new BlobStoreContextFactory(properties).createContext(locationAndCredentials.uri, + locationAndCredentials.acccount, locationAndCredentials.key); + } +} diff --git a/tools/getpath/src/main/resources/jclouds.properties b/tools/getpath/src/main/resources/jclouds.properties new file mode 100644 index 0000000000..9dbb7e82e7 --- /dev/null +++ b/tools/getpath/src/main/resources/jclouds.properties @@ -0,0 +1,29 @@ +# +# +# Copyright (C) 2009 Cloud Conscious, LLC. +# +# ==================================================================== +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ==================================================================== +# +azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder +azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder +cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder +cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder +s3.contextbuilder=org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder +s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder \ No newline at end of file diff --git a/tools/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java b/tools/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java new file mode 100755 index 0000000000..895d4afade --- /dev/null +++ b/tools/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java @@ -0,0 +1,186 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID; +import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT; +import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY; +import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_KEY; +import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_USER; +import static org.testng.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; +import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextFactory; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextFactory; +import org.jclouds.util.Utils; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", sequential = true, testName = "functionalTests") +public class GetPathLiveTest { + + public static final String PROPERTY_GETPATH_CONTAINER = "jclouds.getpath.container"; + public static final String PROPERTY_GETPATH_PATH = "jclouds.getpath.path"; + + private ImmutableSet> contexts; + private String container; + private String path; + + private String tmpDirectory; + + protected static final String XML_STRING_FORMAT = " "; + + protected Map fiveStrings = ImmutableMap.of("one.txt", String.format( + XML_STRING_FORMAT, "apple"), "two.txt", String.format(XML_STRING_FORMAT, "bear"), + "three.txt", String.format(XML_STRING_FORMAT, "candy"), "four.txt", String.format( + XML_STRING_FORMAT, "dogma"), "five.txt", String.format(XML_STRING_FORMAT, + "emma")); + + List urisToTest = Lists.newArrayList(); + + @BeforeClass(groups = { "integration", "live" }) + void clearAndCreateContainers() throws InterruptedException, ExecutionException, + TimeoutException { + container = checkNotNull(System.getProperty(PROPERTY_GETPATH_CONTAINER)); + path = checkNotNull(System.getProperty(PROPERTY_GETPATH_PATH)); + BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext(checkNotNull( + System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System + .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY), + new Log4JLoggingModule()); + urisToTest.add(String.format("blobstore://%s:%s@%s/%s/%s", System + .getProperty(PROPERTY_AWS_ACCESSKEYID), System + .getProperty(PROPERTY_AWS_SECRETACCESSKEY), "s3", container, path)); + + BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY), + new Log4JLoggingModule()); + urisToTest.add(String.format("blobstore://%s:%s@%s/%s/%s", System + .getProperty(PROPERTY_RACKSPACE_USER), System.getProperty(PROPERTY_RACKSPACE_KEY), + "cloudfiles", container, path)); + + BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext(checkNotNull( + System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), + System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY), + new Log4JLoggingModule()); + urisToTest.add(String.format("blobstore://%s:%s@%s/%s/%s", System + .getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), System + .getProperty(PROPERTY_AZURESTORAGE_KEY), "azureblob", container, path)); + + this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); + boolean deleted = false; + for (BlobStoreContext context : contexts) { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } + if (deleted) { + System.err.println("sleeping 30 seconds to allow containers to clear"); + Thread.sleep(30000); + } + for (BlobStoreContext context : contexts) { + System.err.printf("creating container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().createContainer(container); + } + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(30000); + } + for (BlobStoreContext context : contexts) { + System.err.printf("creating directory %s in container %s at %s%n", container, path, + context.getEndPoint()); + context.getBlobStore().createDirectory(container, path); + } + } + + @BeforeClass(dependsOnMethods = "clearAndCreateContainers", groups = { "integration", "live" }) + protected void addFiles() { + for (BlobStoreContext context : contexts) { + System.err + .printf("adding files to container %s at %s%n", container, context.getEndPoint()); + context.createInputStreamMap(container + "/" + path).putAllStrings(fiveStrings); + } + } + + @BeforeClass(groups = { "integration", "live" }) + @Parameters( { "basedir" }) + protected void setUpTempDir(@Optional String basedir) throws InterruptedException, + ExecutionException, FileNotFoundException, IOException, TimeoutException { + if (basedir == null) { + basedir = System.getProperty("java.io.tmpdir"); + } + tmpDirectory = basedir + File.separator + "target" + File.separator + "testFiles" + + File.separator + getClass().getSimpleName(); + new File(tmpDirectory).mkdirs(); + } + + @Test + public void testAllContainers() throws IOException, InterruptedException { + + for (String uriKey : urisToTest) { + System.out.println("storing at context: " + uriKey); + new File(tmpDirectory).delete(); + new File(tmpDirectory).mkdirs(); + GetPath.main(uriKey, tmpDirectory); + for (Entry entry : fiveStrings.entrySet()) { + assertEquals(Utils.toStringAndClose(new FileInputStream(new File(tmpDirectory, entry + .getKey()))), entry.getValue()); + } + } + + } + + @AfterTest + public void closeContexts() { + for (BlobStoreContext context : contexts) { + context.close(); + } + } +} diff --git a/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java b/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java new file mode 100755 index 0000000000..3505055754 --- /dev/null +++ b/tools/getpath/src/test/java/org/jclouds/blobstore/PropertiesTest.java @@ -0,0 +1,76 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.blobstore; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; + +import org.jclouds.aws.s3.S3PropertiesBuilder; +import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; +import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; +import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder; +import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; +import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.google.common.io.Resources; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "getpath.PropertiesTest") +public class PropertiesTest { + private Properties properties; + + @BeforeTest + public void setUp() throws IOException { + properties = new Properties(); + properties.load(Resources.newInputStreamSupplier(Resources.getResource("jclouds.properties")) + .getInput()); + } + + public void testAzure() { + assertEquals(properties.getProperty("azureblob.contextBuilder"), + AzureBlobStoreContextBuilder.class.getName()); + assertEquals(properties.getProperty("azureblob.propertiesBuilder"), + AzureBlobPropertiesBuilder.class.getName()); + } + + public void testCloudFiles() { + assertEquals(properties.getProperty("cloudfiles.contextBuilder"), + CloudFilesBlobStoreContextBuilder.class.getName()); + assertEquals(properties.getProperty("cloudfiles.propertiesBuilder"), + CloudFilesPropertiesBuilder.class.getName()); + } + + public void testBlobStore() { + assertEquals(properties.getProperty("s3.contextBuilder"), S3BlobStoreContextBuilder.class + .getName()); + assertEquals(properties.getProperty("s3.propertiesBuilder"), S3PropertiesBuilder.class + .getName()); + } +} diff --git a/tools/getpath/src/test/resources/log4j.xml b/tools/getpath/src/test/resources/log4j.xml new file mode 100755 index 0000000000..8a56dec6f6 --- /dev/null +++ b/tools/getpath/src/test/resources/log4j.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/jclouds-ant-plugin/build.xml b/tools/jclouds-ant-plugin/build.xml index c521caf4cb..731c6ad618 100644 --- a/tools/jclouds-ant-plugin/build.xml +++ b/tools/jclouds-ant-plugin/build.xml @@ -1,3 +1,28 @@ + diff --git a/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ComputeTask.java b/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ComputeTask.java index 32212807c2..4806b38a58 100644 --- a/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ComputeTask.java +++ b/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ComputeTask.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.tools.ant; import org.apache.tools.ant.Task; diff --git a/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ServerElement.java b/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ServerElement.java index dc36746dca..e9cd951b21 100644 --- a/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ServerElement.java +++ b/tools/jclouds-ant-plugin/src/main/java/org/jclouds/tools/ant/ServerElement.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.tools.ant; /** diff --git a/tools/vfs/README.txt b/tools/vfs/README.txt new file mode 100755 index 0000000000..7feb31735c --- /dev/null +++ b/tools/vfs/README.txt @@ -0,0 +1,29 @@ +==== + + Copyright (C) 2009 Cloud Conscious, LLC. + + ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + ==================================================================== +==== +# +# this is a simple command line client that obtains the contents of a container +# 1. execute 'mvn install' to build the sample +# 2. invoke the jar, passing your credentials and the container you wish to get +# ex. +# java -jar target/jclouds-vfs-jar-with-dependencies.jar blobstore://account:key@service/container diff --git a/tools/vfs/pom.xml b/tools/vfs/pom.xml new file mode 100644 index 0000000000..9606b3bb51 --- /dev/null +++ b/tools/vfs/pom.xml @@ -0,0 +1,163 @@ + + + + jclouds-tools-project + org.jclouds + 1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + jclouds-vfs + jclouds blobstore-vfs integration + jclouds blobstore integration with apache commons vfs + + blobstore://${jclouds.aws.accesskeyid}:${jclouds.aws.secretaccesskey}@s3/jclouds-getpath + + + + + + org.apache.commons + commons-vfs + 2.0-SNAPSHOT + + + commons-httpclient + commons-httpclient + + + + + org.apache.commons + commons-vfs + 2.0-SNAPSHOT + test-jar + test + + + junit + junit + 3.8.2 + test + + + + ${project.groupId} + jclouds-aws + ${project.version} + + + ${project.groupId} + jclouds-azure + ${project.version} + + + ${project.groupId} + jclouds-rackspace + ${project.version} + + + ${project.groupId} + jclouds-log4j + ${project.version} + test + + + log4j + log4j + 1.2.14 + + + + ${project.artifactId} + + + + maven-surefire-plugin + 2.4.3 + + + + test.basedir + src/test/resources/test-data + + + test.basedir.res + test-data + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.jclouds.vfs.tools.blobstore.BlobStoreShell + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + org.jclouds.vfs.tools.blobstore.BlobStoreShell + + + + + + make-assembly + package + + single + + + + + + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + test.basedir + src/test/resources/test-data + + + test.blobstore.uri + ${test.blobstore.uri} + + + + **/*TestCase.java + + + none + + + + + + + + + + diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileName.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileName.java new file mode 100644 index 0000000000..c8dda8bc0d --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileName.java @@ -0,0 +1,87 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import org.apache.commons.vfs.FileName; +import org.apache.commons.vfs.FileType; +import org.apache.commons.vfs.provider.GenericFileName; + +/** + * + * @author Adrian Cole + */ +public class BlobStoreFileName extends GenericFileName { + + private static final int DEFAULT_PORT = 443; + + private final String container; + private String uriWithoutAuth; + + protected BlobStoreFileName(final String service, final String account, final String key, + final String path, final FileType type, final String container) { + super("blobstore", service, DEFAULT_PORT, DEFAULT_PORT, account, key, path, type); + this.container = container; + } + + /** + * Returns the container name. + */ + public String getContainer() { + return container; + } + + @Override + protected void appendRootUri(final StringBuffer buffer, boolean addPassword) { + super.appendRootUri(buffer, addPassword); + buffer.append('/'); + buffer.append(getContainer()); + } + + @Override + public FileName createName(final String path, FileType type) { + return new BlobStoreFileName(getService(), getUserName(), getPassword(), path, type, + getContainer()); + } + + @Override + public String getFriendlyURI() { + if (uriWithoutAuth != null) { + return uriWithoutAuth; + } + + StringBuffer sb = new StringBuffer(120); + sb.append(getScheme()); + sb.append("://"); + sb.append(getService()); + sb.append("/"); + sb.append(getContainer()); + sb.append(getPath()); + uriWithoutAuth = sb.toString(); + return uriWithoutAuth; + } + + public String getService() { + return getHostName(); + } +} diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileNameParser.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileNameParser.java new file mode 100644 index 0000000000..cf9aa58f8b --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileNameParser.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import org.apache.commons.vfs.FileName; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileType; +import org.apache.commons.vfs.provider.URLFileNameParser; +import org.apache.commons.vfs.provider.UriParser; +import org.apache.commons.vfs.provider.VfsComponentContext; +import org.jclouds.blobstore.internal.LocationAndCredentials; + +/** + * @author Adrian Cole + */ +public class BlobStoreFileNameParser extends URLFileNameParser { + public static final BlobStoreFileNameParser INSTANCE = new BlobStoreFileNameParser(); + + public static BlobStoreFileNameParser getInstance() { + return INSTANCE; + } + + public BlobStoreFileNameParser() { + super(443); + } + + public FileName parseUri(final VfsComponentContext context, FileName base, String filename) + throws FileSystemException { + + // if there are unencoded characters in the password, things break. + LocationAndCredentials creds = LocationAndCredentials.parse(filename); + + filename = creds.uri.toASCIIString(); + + StringBuffer name = new StringBuffer(); + + // Extract the scheme and authority parts + Authority auth = extractToPath(filename, name); + + // Decode and adjust separators + UriParser.canonicalizePath(name, 0, name.length(), this); + UriParser.fixSeparators(name); + + // Extract the container + String container = UriParser.extractFirstElement(name); + if (container == null || container.length() == 0) { + throw new FileSystemException("vfs.provider.blobstore/missing-container-name.error", + filename); + } + + // Normalise the path. Do this after extracting the container name + FileType fileType = UriParser.normalisePath(name); + String path = name.toString(); + + return new BlobStoreFileName(auth.getHostName(), creds.acccount, creds.key, path, fileType, + container); + } + +} diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java new file mode 100644 index 0000000000..3a0705cf9d --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileObject.java @@ -0,0 +1,374 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.channels.Channels; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.apache.commons.vfs.FileName; +import org.apache.commons.vfs.FileNotFolderException; +import org.apache.commons.vfs.FileObject; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileType; +import org.apache.commons.vfs.FileTypeHasNoContentException; +import org.apache.commons.vfs.NameScope; +import org.apache.commons.vfs.RandomAccessContent; +import org.apache.commons.vfs.provider.AbstractFileObject; +import org.apache.commons.vfs.util.FileObjectUtils; +import org.apache.commons.vfs.util.MonitorOutputStream; +import org.apache.commons.vfs.util.RandomAccessMode; +import org.apache.log4j.Logger; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.KeyNotFoundException; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.domain.BlobMetadata; +import org.jclouds.blobstore.domain.ListContainerResponse; +import org.jclouds.blobstore.domain.ResourceMetadata; +import org.jclouds.blobstore.domain.ResourceType; +import org.jclouds.blobstore.functions.ResourceMetadataToRelativePathResourceMetadata; +import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.blobstore.strategy.IsDirectoryStrategy; +import org.jclouds.blobstore.strategy.internal.MarkersIsDirectoryStrategy; +import org.jclouds.blobstore.util.BlobStoreUtils; +import org.jclouds.util.Utils; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; + +/** + * @author Adrian Cole + */ +public class BlobStoreFileObject extends AbstractFileObject { + private final BlobStore blobStore; + private final String container; + private ResourceMetadata metadata; + + private static final IsDirectoryStrategy isDirectoryStrategy = new MarkersIsDirectoryStrategy(); + private static final ResourceMetadataToRelativePathResourceMetadata resource2Directory = new ResourceMetadataToRelativePathResourceMetadata(); + private static final Logger logger = Logger.getLogger(BlobStoreFileObject.class); + + public BlobStoreFileObject(FileName fileName, BlobStoreFileSystem fileSystem, + BlobStore blobStore, String container) throws FileSystemException { + super(fileName, fileSystem); + this.blobStore = checkNotNull(blobStore, "blobStore"); + this.container = checkNotNull(container, "container"); + } + + private class BlobStoreOutputStream extends MonitorOutputStream { + + private final BlobStore blobStore; + private final Blob blob; + private final File file; + + public BlobStoreOutputStream(File file, BlobStore blobStore, Blob blob) + throws FileNotFoundException { + super(Channels.newOutputStream(new RandomAccessFile(file, "rw").getChannel())); + this.blobStore = blobStore; + this.file = file; + this.blob = blob; + } + + protected void onClose() throws IOException { + try { + blob.setData(file); + blob.generateMD5(); + logger.info(String.format(">> put: %s/%s %d bytes", getContainer(), + getNameTrimLeadingSlashes(), blob.getContentLength())); + String tag = blobStore.putBlob(getContainer(), blob); + logger.info(String.format("<< tag %s: %s/%s", tag, getContainer(), + getNameTrimLeadingSlashes())); + } finally { + file.delete(); + } + } + } + + public static File allocateFile() throws IOException { + return File.createTempFile("jclouds.", ".blobstore"); + } + + @Override + protected long doGetContentSize() throws Exception { + if (metadata == null || metadata.getSize() == null || metadata.getSize() == 0) { + getMetadataAtPath(getNameTrimLeadingSlashes()); + } + return metadata.getSize() != null ? metadata.getSize() : 0; + } + + @Override + protected InputStream doGetInputStream() throws Exception { + if (!getType().hasContent()) { + throw new FileSystemException("vfs.provider/read-not-file.error", getName()); + } + if (metadata != null && metadata.getType() != ResourceType.BLOB) { + throw new FileTypeHasNoContentException(getName()); + } + logger.info(String.format(">> get: %s/%s", getContainer(), getNameTrimLeadingSlashes())); + Blob blob = getBlobStore().getBlob(getContainer(), getNameTrimLeadingSlashes()); + return (InputStream) blob.getData(); + } + + String getNameTrimLeadingSlashes() { + return getName().getPath().replaceAll("^[/]+", ""); + } + + @Override + protected FileType doGetType() throws Exception { + if (metadata == null) + return FileType.IMAGINARY; + if (getNameTrimLeadingSlashes().equals("") || getName().getParent() == null) + return FileType.FOLDER; + return (metadata.getType() == ResourceType.BLOB) ? FileType.FILE : FileType.FOLDER; + } + + @Override + protected FileObject[] doListChildrenResolved() throws Exception { + // if metadata is null, then the path does not exist, as doAttach would have certainly set + // this. + doAttach(); + if (metadata == null) + throw new FileNotFolderException(getName()); + ListContainerOptions options = new ListContainerOptions(); + String name = getNameTrimLeadingSlashes(); + if (!name.equals("") && !name.equals("/")) { + options.inDirectory(name + "/"); + logger.info(String.format(">> list: %s[%s]", getContainer(), name)); + } else { + logger.info(String.format(">> list: %s", getContainer())); + } + ListContainerResponse list = getBlobStore().list(getContainer(), + options); + Set children = Sets.newHashSet(); + loop: for (ResourceMetadata md : list) { + if (!md.getName().equals("")) { + if (name.equals(md.getName()) && md.getType() != ResourceType.BLOB) { + continue loop; + } + if (isDirectoryStrategy.execute(md)) { + md = resource2Directory.apply(md); + } + String childName = md.getName().replaceAll("[^/]*//*", ""); + BlobStoreFileObject fo = (BlobStoreFileObject) FileObjectUtils + .getAbstractFileObject(getFileSystem().resolveFile( + getFileSystem().getFileSystemManager().resolveName(getName(), + childName, NameScope.CHILD))); + children.add(fo); + } + } + logger.info(String.format("<< list: %s", children)); + return children.toArray(new BlobStoreFileObject[] {}); + } + + @Override + public FileObject[] getChildren() throws FileSystemException { + if (metadata != null && metadata.getType() == ResourceType.BLOB) + throw new FileNotFolderException(getName()); + if (metadata == null) { + try { + FileType type = doGetType(); + if (type == FileType.FILE) { + throw new FileNotFolderException(getName()); + } + } catch (Exception ex) { + Utils. rethrowIfRuntimeOrSameType(ex); + throw new FileNotFolderException(getName(), ex); + } + } + return super.getChildren(); + } + + /** + * Lists the children of the file. + */ + protected String[] doListChildren() throws Exception { + // use doListChildrenResolved for performance + return null; + } + + @Override + protected void doDelete() throws Exception { + logger.info(String.format(">> delete: %s/%s", getContainer(), getNameTrimLeadingSlashes())); + if (metadata != null) + deleteBasedOnType(); + else + deleteBlob(getNameTrimLeadingSlashes()); + } + + private void deleteBasedOnType() { + if (metadata.getType() != ResourceType.CONTAINER) { + deleteBlob(metadata.getId()); + } else { + getBlobStore().deleteContainer(getContainer()); + logger.info(String.format("<< deleted container: %s", getContainer())); + } + } + + private void deleteBlob(String id) { + getBlobStore().removeBlob(getContainer(), getNameTrimLeadingSlashes()); + logger.info(String.format("<< deleted blob: %s/%s", getContainer(), + getNameTrimLeadingSlashes())); + } + + @Override + protected OutputStream doGetOutputStream(boolean bAppend) throws Exception { + File file = allocateFile(); + checkState(file != null, "file was null"); + if (metadata != null) { + return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob( + getBlobStore(), metadata)); + } else { + return new BlobStoreOutputStream(file, getBlobStore(), BlobStoreUtils.newBlob( + getBlobStore(), getNameTrimLeadingSlashes())); + } + } + + @Override + protected void doCreateFolder() throws Exception { + logger.info(String + .format(">> put folder: %s/%s", getContainer(), getNameTrimLeadingSlashes())); + getBlobStore().createDirectory(getContainer(), getNameTrimLeadingSlashes()); + } + + @Override + protected void doAttach() throws Exception { + String name = getNameTrimLeadingSlashes(); + if (name.equals("")) { + logger.info(String.format(">> head: %s", getContainer())); + getContainer(name); + } else { + logger.info(String.format(">> head: %s/%s", getContainer(), name)); + try { + getMetadataAtPath(name); + } catch (KeyNotFoundException e) { + tryDirectoryAtPath(name); + } + } + } + + private void getContainer(String name) { + metadata = Iterables.find(Iterables.transform(getBlobStore().list(), resource2Directory), + new Predicate() { + @Override + public boolean apply(ResourceMetadata input) { + return input.getName().equals(container); + } + }); + logger.info(String.format("<< container: %s/%s", container, name)); + } + + private void getMetadataAtPath(String name) { + BlobMetadata md = getBlobStore().blobMetadata(getContainer(), name); + if (isDirectoryStrategy.execute(md)) { + metadata = resource2Directory.apply(md); + logger.info(String.format("<< dir: %s/%s", getContainer(), name)); + } else { + metadata = md; + logger.info(String.format("<< blob: %s/%s", getContainer(), name)); + } + } + + private void tryDirectoryAtPath(final String name) { + ListContainerOptions options = new ListContainerOptions(); + if (getName().getParent() != null) { + String dir = trimLeadingAndTrailingSlashes(getName().getParent().getPath()); + if (!dir.equals("")) + options.inDirectory(dir); + } + try { + metadata = Iterables.find(Iterables.transform( + getBlobStore().list(getContainer(), options), resource2Directory), + new Predicate() { + @Override + public boolean apply(ResourceMetadata input) { + return input.getName().equals(name); + } + }); + logger.info(String.format("<< dir: %s/%s", getContainer(), name)); + } catch (NoSuchElementException nse) { + metadata = null; + logger.info(String.format("<< not found: %s/%s", getContainer(), name)); + } + } + + public String trimLeadingAndTrailingSlashes(String in) { + return in.replaceAll("^[/]*", "").replaceAll("[/]*$", ""); + } + + @Override + protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) + throws Exception { + return new BlobStoreRandomAccessContent(this, mode); + } + + protected void doDetach() throws Exception { + metadata = null; + } + + @Override + protected long doGetLastModifiedTime() throws Exception { + if (metadata == null || metadata.getLastModified() == null) { + getMetadataAtPath(getNameTrimLeadingSlashes()); + } + return metadata.getLastModified() != null ? metadata.getLastModified().getMillis() : super + .doGetLastModifiedTime(); + } + + @SuppressWarnings("unchecked") + @Override + protected Map doGetAttributes() throws Exception { + if (metadata == null || metadata.getUserMetadata() == null) { + getMetadataAtPath(getNameTrimLeadingSlashes()); + } + return metadata.getUserMetadata() != null ? metadata.getUserMetadata() : super + .doGetAttributes(); + } + + @Override + protected void doSetAttribute(String atttrName, Object value) throws Exception { + if (metadata == null || metadata.getUserMetadata() == null) { + metadata.getUserMetadata().put(atttrName, value.toString()); + } + super.doSetAttribute(atttrName, value); + } + + public BlobStore getBlobStore() { + return blobStore; + } + + public String getContainer() { + return container; + } +} diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java new file mode 100644 index 0000000000..376f30813f --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Properties; + +import org.apache.commons.vfs.Capability; +import org.apache.commons.vfs.FileName; +import org.apache.commons.vfs.FileSystem; +import org.apache.commons.vfs.FileSystemConfigBuilder; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileSystemOptions; +import org.apache.commons.vfs.UserAuthenticationData; +import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider; +import org.apache.commons.vfs.provider.http.HttpFileSystemConfigBuilder; +import org.apache.commons.vfs.util.UserAuthenticatorUtils; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.internal.LocationAndCredentials; + +import com.google.common.io.Resources; +import com.google.inject.Module; + +/** + * @author Adrian Cole + */ +public class BlobStoreFileProvider extends AbstractOriginatingFileProvider { + + public final static Collection capabilities = Collections + .unmodifiableCollection(Arrays.asList(Capability.CREATE, Capability.DELETE, + Capability.GET_TYPE, Capability.GET_LAST_MODIFIED, Capability.LIST_CHILDREN, + Capability.READ_CONTENT, Capability.URI, Capability.WRITE_CONTENT, + Capability.RANDOM_ACCESS_READ, Capability.ATTRIBUTES)); + + public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[] { + UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD }; + + private final Module[] modules; + + public BlobStoreFileProvider(Module... modules) { + this.modules = modules; + setFileNameParser(new BlobStoreFileNameParser()); + } + + protected FileSystem doCreateFileSystem(final FileName name, + final FileSystemOptions fileSystemOptions) throws FileSystemException { + BlobStoreFileName rootName = (BlobStoreFileName) name; + + UserAuthenticationData authData = null; + BlobStore blobStore; + try { + String uriToParse = rootName.getFriendlyURI(); + authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES); + Properties properties = new Properties(); + properties.load(Resources.newInputStreamSupplier( + Resources.getResource("jclouds.properties")).getInput()); + LocationAndCredentials locationAndCredentials = LocationAndCredentials.parse(uriToParse); + + blobStore = new BlobStoreContextFactory(properties).createContext( + locationAndCredentials.uri, + UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, + UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName + .getUserName()))), + UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, + UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName + .getPassword()))),modules).getBlobStore(); + } catch (IOException e) { + throw new FileSystemException("vfs.provider.blobstore/properties.error", name, e); + } finally { + UserAuthenticatorUtils.cleanup(authData); + } + + return new BlobStoreFileSystem(rootName, blobStore, fileSystemOptions); + } + + public FileSystemConfigBuilder getConfigBuilder() { + return HttpFileSystemConfigBuilder.getInstance(); + } + + public Collection getCapabilities() { + return capabilities; + } +} diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileSystem.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileSystem.java new file mode 100644 index 0000000000..48916b68c2 --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileSystem.java @@ -0,0 +1,60 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.Collection; + +import org.apache.commons.vfs.FileName; +import org.apache.commons.vfs.FileObject; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileSystemOptions; +import org.apache.commons.vfs.provider.AbstractFileSystem; +import org.jclouds.blobstore.BlobStore; + +/** + * @author Adrian Cole + */ +public class BlobStoreFileSystem extends AbstractFileSystem { + final BlobStore blobStore; + final String container; + + public BlobStoreFileSystem(BlobStoreFileName fileName, BlobStore blobStore, + FileSystemOptions fileSystemOptions) throws FileSystemException { + super(fileName, null, fileSystemOptions); + this.container = fileName.getContainer(); + checkArgument(!container.equals(""), "container must not be an empty String"); + this.blobStore = blobStore; + } + + @SuppressWarnings("unchecked") + protected void addCapabilities(Collection caps) { + caps.addAll(BlobStoreFileProvider.capabilities); + } + + protected FileObject createFile(FileName fileName) throws Exception { + return new BlobStoreFileObject(fileName, this, blobStore, container); + } +} diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreRandomAccessContent.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreRandomAccessContent.java new file mode 100644 index 0000000000..2f4761c004 --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreRandomAccessContent.java @@ -0,0 +1,119 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore; + +import java.io.DataInputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.provider.AbstractRandomAccessStreamContent; +import org.apache.commons.vfs.util.RandomAccessMode; +import org.jclouds.blobstore.options.GetOptions; +/** + * @author Adrian Cole + */ +public class BlobStoreRandomAccessContent extends AbstractRandomAccessStreamContent { + private final BlobStoreFileObject fileObject; + private final BlobStoreFileSystem fileSystem; + + protected long filePointer = 0; + private DataInputStream dis = null; + + BlobStoreRandomAccessContent(final BlobStoreFileObject fileObject, RandomAccessMode mode) { + super(mode); + + this.fileObject = fileObject; + fileSystem = (BlobStoreFileSystem) this.fileObject.getFileSystem(); + } + + public long getFilePointer() throws IOException { + return filePointer; + } + + public void seek(long pos) throws IOException { + if (pos == filePointer) { + // no change + return; + } + + if (pos < 0) { + throw new FileSystemException("vfs.provider/random-access-invalid-position.error", + new Object[] { new Long(pos) }); + } + if (dis != null) { + close(); + } + + filePointer = pos; + } + + protected DataInputStream getDataInputStream() throws IOException { + if (dis != null) { + return dis; + } + + dis = new DataInputStream(new FilterInputStream((InputStream) fileSystem.blobStore.getBlob( + fileSystem.container, fileObject.getNameTrimLeadingSlashes(), + new GetOptions().startAt(filePointer)).getData()) { + public int read() throws IOException { + int ret = super.read(); + if (ret > -1) { + filePointer++; + } + return ret; + } + + public int read(byte b[]) throws IOException { + int ret = super.read(b); + if (ret > -1) { + filePointer += ret; + } + return ret; + } + + public int read(byte b[], int off, int len) throws IOException { + int ret = super.read(b, off, len); + if (ret > -1) { + filePointer += ret; + } + return ret; + } + }); + + return dis; + } + + public void close() throws IOException { + if (dis != null) { + dis.close(); + dis = null; + } + } + + public long length() throws IOException { + return fileObject.getContent().getSize(); + } +} \ No newline at end of file diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/tools/blobstore/BlobStoreShell.java b/tools/vfs/src/main/java/org/jclouds/vfs/tools/blobstore/BlobStoreShell.java new file mode 100644 index 0000000000..692f90fca2 --- /dev/null +++ b/tools/vfs/src/main/java/org/jclouds/vfs/tools/blobstore/BlobStoreShell.java @@ -0,0 +1,425 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.tools.blobstore; + +import static com.google.common.base.Preconditions.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.DateFormat; +import java.util.Date; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.commons.vfs.FileContent; +import org.apache.commons.vfs.FileObject; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileSystemManager; +import org.apache.commons.vfs.FileType; +import org.apache.commons.vfs.FileUtil; +import org.apache.commons.vfs.Selectors; +import org.apache.commons.vfs.VFS; +import org.apache.commons.vfs.cache.SoftRefFilesCache; +import org.apache.commons.vfs.impl.DefaultFileSystemManager; +import org.jclouds.blobstore.internal.LocationAndCredentials; +import org.jclouds.vfs.provider.blobstore.BlobStoreFileProvider; + +import com.google.common.collect.Lists; + +/** + * A simple command-line shell for performing file operations. Adapted from original file: + * org.apache.commons.vfs.example.Shell written by Adam + * Murdoch and Gary D. Gregory. + * + * @author Adrian Cole + * @author Adam Murdoch + * @author Gary D. Gregory + */ +public class BlobStoreShell { + public static String INVALID_SYNTAX = "Invalid parameters. Syntax is: blobstore://account:key@service/container"; + + private final DefaultFileSystemManager remoteMgr; + private FileObject remoteCwd; + + private final FileSystemManager mgr; + private FileObject cwd; + + private final BufferedReader reader; + + public static void main(String... args) { + + if (args.length != 1) + throw new IllegalArgumentException(INVALID_SYNTAX); + LocationAndCredentials locationAndCredentials; + try { + locationAndCredentials = LocationAndCredentials.parse(args[0]); + checkArgument(locationAndCredentials.uri.getScheme().equals("blobstore"), "wrong scheme"); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException(String.format("%s%n%s", e.getMessage(), INVALID_SYNTAX)); + } + try { + (new BlobStoreShell(args[0])).go(); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + System.exit(0); + } + + private BlobStoreShell(String uri) throws FileSystemException { + remoteMgr = new DefaultFileSystemManager(); + remoteMgr.setFilesCache(new SoftRefFilesCache()); + remoteMgr.addProvider("blobstore", new BlobStoreFileProvider()); + remoteMgr.init(); + remoteCwd = remoteMgr.resolveFile(checkNotNull(uri, "uri")); + mgr = VFS.getManager(); + cwd = mgr.resolveFile(System.getProperty("user.dir")); + reader = new BufferedReader(new InputStreamReader(System.in)); + } + + private void go() throws Exception { + System.out.println("BlobStore Shell [ 1.0 ]"); + while (true) { + final String[] cmd = nextCommand(); + if (cmd == null) { + return; + } + if (cmd.length == 0) { + continue; + } + final String cmdName = cmd[0]; + if (cmdName.equalsIgnoreCase("exit") || cmdName.equalsIgnoreCase("quit")) { + return; + } + try { + handleCommand(cmd); + } catch (final Exception e) { + System.err.println("Command failed:"); + e.printStackTrace(System.err); + } + } + } + + /** + * Handles a command. + */ + private void handleCommand(final String[] cmd) throws Exception { + final String cmdName = cmd[0]; + if (cmdName.equalsIgnoreCase("cat")) { + cat(cmd); + } else if (cmdName.equalsIgnoreCase("cd")) { + cd(cmd); + } else if (cmdName.equalsIgnoreCase("lcd")) { + lcd(cmd); + } else if (cmdName.equalsIgnoreCase("cp")) { + cp(cmd); + } else if (cmdName.equalsIgnoreCase("put")) { + put(cmd); + } else if (cmdName.equalsIgnoreCase("get")) { + get(cmd); + } else if (cmdName.equalsIgnoreCase("help")) { + help(); + } else if (cmdName.equalsIgnoreCase("ls")) { + ls(cmd); + } else if (cmdName.equalsIgnoreCase("lls")) { + lls(cmd); + } else if (cmdName.equalsIgnoreCase("pwd")) { + pwd(); + } else if (cmdName.equalsIgnoreCase("lpwd")) { + lpwd(); + } else if (cmdName.equalsIgnoreCase("rm")) { + rm(cmd); + } else if (cmdName.equalsIgnoreCase("touch")) { + touch(cmd); + } else { + System.err.println("Unknown command \"" + cmdName + "\"."); + } + } + + /** + * Does a 'help' command. + */ + private void help() { + System.out.println("Commands:"); + System.out + .println("cat Displays the contents of a file on the remote machine."); + System.out.println("cd [folder] Changes current folder on the remote machine."); + System.out.println("lcd [folder] Changes current folder on the local machine."); + System.out.println("cp Copies a file or folder on the remote machine."); + System.out + .println("put Copies a file or folder on the local machine to remote one."); + System.out + .println("get Copies a file or folder on the remote machine to local one."); + System.out.println("help Shows this message on the remote machine."); + System.out + .println("ls [-R] [path] Lists contents of a file or folder on the remote machine."); + System.out + .println("lls [-R] [path] Lists contents of a file or folder on the local machine."); + System.out.println("pwd Displays current folder on the remote machine."); + System.out.println("lpwd Displays current folder on the local machine."); + System.out.println("rm Deletes a file or folder on the remote machine."); + System.out + .println("touch Sets the last-modified time of a file on the remote machine."); + System.out.println("exit Exits this program."); + System.out.println("quit Exits this program."); + } + + /** + * Does an 'rm' command. + */ + private void rm(final String[] cmd) throws Exception { + if (cmd.length < 2) { + throw new Exception("USAGE: rm "); + } + + final FileObject file = remoteMgr.resolveFile(remoteCwd, cmd[1]); + file.delete(Selectors.SELECT_SELF); + } + + /** + * Does a 'cp' command. + */ + private void cp(final String[] cmd) throws Exception { + if (cmd.length < 3) { + throw new Exception("USAGE: cp "); + } + + FileObject src = remoteMgr.resolveFile(remoteCwd, cmd[1]); + FileObject dest = remoteMgr.resolveFile(remoteCwd, cmd[2]); + if (dest.exists() && dest.getType() == FileType.FOLDER) { + dest = dest.resolveFile(src.getName().getBaseName()); + } + + dest.copyFrom(src, Selectors.SELECT_ALL); + } + + /** + * Does a 'get' command. + */ + private void get(final String[] cmd) throws Exception { + if (cmd.length < 3) { + throw new Exception("USAGE: get "); + } + + FileObject src = remoteMgr.resolveFile(remoteCwd, cmd[1]); + FileObject dest = mgr.resolveFile(cwd, cmd[2]); + if (dest.exists() && dest.getType() == FileType.FOLDER) { + dest = dest.resolveFile(src.getName().getBaseName()); + } + + dest.copyFrom(src, Selectors.SELECT_ALL); + } + + /** + * Does a 'put' command. + */ + private void put(final String[] cmd) throws Exception { + if (cmd.length < 3) { + throw new Exception("USAGE: put "); + } + + FileObject src = mgr.resolveFile(cwd, cmd[2]); + FileObject dest = remoteMgr.resolveFile(remoteCwd, cmd[1]); + if (dest.exists() && dest.getType() == FileType.FOLDER) { + dest = dest.resolveFile(src.getName().getBaseName()); + } + + dest.copyFrom(src, Selectors.SELECT_ALL); + } + + /** + * Does a 'cat' command. + */ + private void cat(final String[] cmd) throws Exception { + if (cmd.length < 2) { + throw new Exception("USAGE: cat "); + } + + // Locate the file + final FileObject file = remoteMgr.resolveFile(remoteCwd, cmd[1]); + + // Dump the contents to System.out + FileUtil.writeContent(file, System.out); + System.out.println(); + } + + /** + * Does a 'pwd' command. + */ + private void pwd() { + System.out.println("Current remote folder is " + remoteCwd.getName().getFriendlyURI()); + } + + /** + * Does a 'lpwd' command. + */ + private void lpwd() { + System.out.println("Current local folder is " + cwd.getName().getFriendlyURI()); + } + + /** + * Does a 'cd' command. If the target directory does not exist, a message is printed to + * System.err. + */ + private void cd(final String[] cmd) throws Exception { + final String path; + if (cmd.length > 1) { + path = cmd[1]; + } else { + path = System.getProperty("user.home"); + } + + // Locate and validate the folder + FileObject tmp = remoteMgr.resolveFile(remoteCwd, path); + if (tmp.exists()) { + remoteCwd = tmp; + } else { + System.out.println("Folder does not exist: " + tmp.getName().getFriendlyURI()); + } + System.out.println("Current remote folder is " + remoteCwd.getName().getFriendlyURI()); + } + + /** + * Does a 'lcd' command. If the target directory does not exist, a message is printed to + * System.err. + */ + private void lcd(final String[] cmd) throws Exception { + final String path; + if (cmd.length > 1) { + path = cmd[1]; + } else { + path = System.getProperty("user.home"); + } + + // Locate and validate the folder + FileObject tmp = mgr.resolveFile(cwd, path); + if (tmp.exists()) { + cwd = tmp; + } else { + System.out.println("Folder does not exist: " + tmp.getName().getFriendlyURI()); + } + System.out.println("Current local folder is " + cwd.getName().getFriendlyURI()); + } + + /** + * Does an 'ls' command. + */ + private void ls(final String[] cmd) throws FileSystemException { + ls(remoteMgr, remoteCwd, cmd); + } + + /** + * Does an 'lls' command. + */ + private void lls(final String[] cmd) throws FileSystemException { + ls(mgr, cwd, cmd); + } + + private void ls(FileSystemManager mg, FileObject wd, final String[] cmd) + throws FileSystemException { + int pos = 1; + final boolean recursive; + if (cmd.length > pos && cmd[pos].equals("-R")) { + recursive = true; + pos++; + } else { + recursive = false; + } + + final FileObject file; + if (cmd.length > pos) { + file = mg.resolveFile(wd, cmd[pos]); + } else { + file = wd; + } + + if (file.getType() == FileType.FOLDER) { + // List the contents + System.out.println("Contents of " + file.getName().getFriendlyURI()); + listChildren(file, recursive, ""); + } else { + // Stat the file + System.out.println(file.getName()); + final FileContent content = file.getContent(); + System.out.println("Size: " + content.getSize() + " bytes."); + final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, + DateFormat.MEDIUM); + final String lastMod = dateFormat.format(new Date(content.getLastModifiedTime())); + System.out.println("Last modified: " + lastMod); + } + } + + /** + * Does a 'touch' command. + */ + private void touch(final String[] cmd) throws Exception { + if (cmd.length < 2) { + throw new Exception("USAGE: touch "); + } + final FileObject file = remoteMgr.resolveFile(remoteCwd, cmd[1]); + if (!file.exists()) { + file.createFile(); + } + file.getContent().setLastModifiedTime(System.currentTimeMillis()); + } + + /** + * Lists the children of a folder. + */ + private void listChildren(final FileObject dir, final boolean recursive, final String prefix) + throws FileSystemException { + final FileObject[] children = dir.getChildren(); + for (int i = 0; i < children.length; i++) { + final FileObject child = children[i]; + System.out.print(prefix); + System.out.print(child.getName().getBaseName()); + if (child.getType() == FileType.FOLDER) { + System.out.println("/"); + if (recursive) { + listChildren(child, recursive, prefix + " "); + } + } else { + System.out.println(); + } + } + } + + /** + * Returns the next command, split into tokens. + */ + private String[] nextCommand() throws IOException { + System.out.print("> "); + final String line = reader.readLine(); + if (line == null) { + return null; + } + final List cmd = Lists.newArrayList(); + final StringTokenizer tokens = new StringTokenizer(line); + while (tokens.hasMoreTokens()) { + cmd.add(tokens.nextToken()); + } + return (String[]) cmd.toArray(new String[cmd.size()]); + } +} diff --git a/tools/vfs/src/main/resources/jclouds.properties b/tools/vfs/src/main/resources/jclouds.properties new file mode 100644 index 0000000000..9dbb7e82e7 --- /dev/null +++ b/tools/vfs/src/main/resources/jclouds.properties @@ -0,0 +1,29 @@ +# +# +# Copyright (C) 2009 Cloud Conscious, LLC. +# +# ==================================================================== +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ==================================================================== +# +azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder +azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder +cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder +cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder +s3.contextbuilder=org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder +s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder \ No newline at end of file diff --git a/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestCase.java b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestCase.java new file mode 100644 index 0000000000..b40697e5c2 --- /dev/null +++ b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestCase.java @@ -0,0 +1,114 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore.test; + +import java.io.IOException; + +import junit.framework.Test; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.vfs.AllFileSelector; +import org.apache.commons.vfs.FileContent; +import org.apache.commons.vfs.FileObject; +import org.apache.commons.vfs.FileSystemException; +import org.apache.commons.vfs.FileSystemManager; +import org.apache.commons.vfs.impl.DefaultFileSystemManager; +import org.apache.commons.vfs.test.AbstractProviderTestConfig; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.vfs.provider.blobstore.BlobStoreFileObject; +import org.jclouds.vfs.provider.blobstore.BlobStoreFileProvider; + +/** + * @author Adrian Cole + */ +public class BlobStoreProviderTestCase extends AbstractProviderTestConfig { + private static final String TEST_URI = "test.blobstore.uri"; + + public static Test suite() throws Exception { + return new BlobStoreProviderTestSuite(new BlobStoreProviderTestCase()); + } + + /** + * Prepares the file system manager. + */ + public void prepare(final DefaultFileSystemManager manager) throws Exception { + manager.addProvider("blobstore", new BlobStoreFileProvider(new Log4JLoggingModule())); + } + + /** + * Returns the base folder for tests. + */ + public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { + String uri = System.getProperty(TEST_URI, "blobstore://account:key@stub/stub"); + return setUpTests(manager, uri); + } + + private FileObject setUpTests(final FileSystemManager manager, String uri) + throws FileSystemException, IOException { + FileObject base = manager.resolveFile(uri); + FileObject writeTests = base.resolveFile("write-tests"); + FileObject readTests = base.resolveFile("read-tests"); + + if (base instanceof BlobStoreFileObject) { + BlobStore blobStore = ((BlobStoreFileObject) base).getBlobStore(); + String container = ((BlobStoreFileObject) base).getContainer(); + blobStore.clearContainer(container); + } else { + writeTests.delete(new AllFileSelector()); + readTests.delete(new AllFileSelector()); + } + + writeTests.createFolder(); + readTests.createFolder(); + for (String name : new String[] { "file1.txt", "file%25.txt", "file space.txt" }) { + writeFile(readTests, name, FILE1_CONTENT); + } + writeFile(readTests, "empty.txt", ""); + FileObject dir = readTests.resolveFile("dir1"); + dir.createFolder(); + write3Files(dir); + for (String subdirName : new String[] { "subdir1", "subdir2", "subdir3" }) { + FileObject subdir = dir.resolveFile(subdirName); + subdir.createFolder(); + write3Files(subdir); + } + return base; + } + + private void write3Files(FileObject base) throws IOException { + for (String name : new String[] { "file1.txt", "file2.txt", "file3.txt" }) { + writeFile(base, name, TEST_FILE_CONTENT); + } + } + + private void writeFile(FileObject base, String name, String value) throws FileSystemException, + IOException { + FileObject file = base.resolveFile(name); + FileContent content = file.getContent(); + IOUtils.write(value, content.getOutputStream()); + content.close(); + } + +} diff --git a/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestSuite.java b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestSuite.java new file mode 100644 index 0000000000..5922ca974b --- /dev/null +++ b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/BlobStoreProviderTestSuite.java @@ -0,0 +1,73 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore.test; + +import org.apache.commons.vfs.test.ContentTests; +import org.apache.commons.vfs.test.LastModifiedTests; +import org.apache.commons.vfs.test.NamingTests; +import org.apache.commons.vfs.test.ProviderCacheStrategyTests; +import org.apache.commons.vfs.test.ProviderDeleteTests; +import org.apache.commons.vfs.test.ProviderRandomReadTests; +import org.apache.commons.vfs.test.ProviderRandomReadWriteTests; +import org.apache.commons.vfs.test.ProviderReadTests; +import org.apache.commons.vfs.test.ProviderRenameTests; +import org.apache.commons.vfs.test.ProviderTestConfig; +import org.apache.commons.vfs.test.ProviderTestSuite; +import org.apache.commons.vfs.test.ProviderWriteAppendTests; +import org.apache.commons.vfs.test.ProviderWriteTests; +import org.apache.commons.vfs.test.UriTests; +import org.apache.commons.vfs.test.UrlStructureTests; +import org.apache.commons.vfs.test.UrlTests; + +/** + * @author Adrian Cole + */ +public class BlobStoreProviderTestSuite extends ProviderTestSuite { + + public BlobStoreProviderTestSuite(ProviderTestConfig providerConfig) throws Exception { + super(providerConfig, "", false, false); + } + + /** + * Adds base tests - excludes the nested test cases. + */ + protected void addBaseTests() throws Exception { + addTests(ProviderCacheStrategyTests.class); + addTests(UriTests.class); + addTests(NamingTests.class); + addTests(ContentTests.class); + addTests(ProviderReadTests.class); + addTests(ProviderRandomReadTests.class); + addTests(ProviderWriteTests.class); + addTests(ProviderWriteAppendTests.class); + addTests(ProviderRandomReadWriteTests.class); + addTests(ProviderRenameTests.class); + addTests(ProviderDeleteTests.class); + addTests(LastModifiedTests.class); + addTests(UrlTests.class); + addTests(UrlStructureTests.class); + // The class loader test requires the classes be uploaded to the webdav repo. + // addTests(VfsClassLoaderTests.class); + } +} \ No newline at end of file diff --git a/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/FileNameTestCase.java b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/FileNameTestCase.java new file mode 100644 index 0000000000..589e3286c1 --- /dev/null +++ b/tools/vfs/src/test/java/org/jclouds/vfs/provider/blobstore/test/FileNameTestCase.java @@ -0,0 +1,151 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.vfs.provider.blobstore.test; + +import org.apache.commons.AbstractVfsTestCase; +import org.apache.commons.vfs.FileSystemException; +import org.jclouds.vfs.provider.blobstore.BlobStoreFileName; +import org.jclouds.vfs.provider.blobstore.BlobStoreFileNameParser; + +/** + * @author Adrian Cole + */ +public class FileNameTestCase extends AbstractVfsTestCase { + /** + * Tests parsing a URI into its parts. + */ + public void testParseUri() throws Exception { + // Simple name + BlobStoreFileName name = (BlobStoreFileName) BlobStoreFileNameParser.getInstance().parseUri( + null, null, "blobstore://service/container/file"); + assertEquals("blobstore", name.getScheme()); + assertNull(name.getUserName()); + assertNull(name.getPassword()); + assertEquals("service", name.getHostName()); + assertEquals(443, name.getPort()); + assertEquals(name.getDefaultPort(), name.getPort()); + assertEquals("container", name.getContainer()); + assertEquals("/file", name.getPath()); + assertEquals("blobstore://service/container/", name.getRootURI()); + assertEquals("blobstore://service/container/file", name.getURI()); + + // Name with no path + name = (BlobStoreFileName) BlobStoreFileNameParser.getInstance().parseUri(null, null, + "blobstore://service/container"); + assertEquals("blobstore", name.getScheme()); + assertNull(name.getUserName()); + assertNull(name.getPassword()); + assertEquals("service", name.getHostName()); + assertEquals(443, name.getPort()); + assertEquals("container", name.getContainer()); + assertEquals("/", name.getPath()); + assertEquals("blobstore://service/container/", name.getRootURI()); + assertEquals("blobstore://service/container/", name.getURI()); + + // Name with username + name = (BlobStoreFileName) BlobStoreFileNameParser.getInstance().parseUri(null, null, + "blobstore://user@service/container/file"); + assertEquals("blobstore", name.getScheme()); + assertEquals("user", name.getUserName()); + assertNull(name.getPassword()); + assertEquals("service", name.getHostName()); + assertEquals(443, name.getPort()); + assertEquals("container", name.getContainer()); + assertEquals("/file", name.getPath()); + assertEquals("blobstore://user@service/container/", name.getRootURI()); + assertEquals("blobstore://user@service/container/file", name.getURI()); + + // Name with extension + name = (BlobStoreFileName) BlobStoreFileNameParser.getInstance().parseUri(null, null, + "blobstore://user@service/container/file.txt"); + assertEquals("blobstore", name.getScheme()); + assertEquals("user", name.getUserName()); + assertNull(name.getPassword()); + assertEquals("service", name.getHostName()); + assertEquals(443, name.getPort()); + assertEquals("container", name.getContainer()); + assertEquals("/file.txt", name.getPath()); + assertEquals("file.txt", name.getBaseName()); + assertEquals("txt", name.getExtension()); + assertEquals("blobstore://user@service/container/", name.getRootURI()); + assertEquals("blobstore://user@service/container/file.txt", name.getURI()); + + // Name look likes extension, but isnt + name = (BlobStoreFileName) BlobStoreFileNameParser.getInstance().parseUri(null, null, + "blobstore://user@service/container/.bashrc"); + assertEquals("blobstore", name.getScheme()); + assertEquals("user", name.getUserName()); + assertNull(name.getPassword()); + assertEquals("service", name.getHostName()); + assertEquals(443, name.getPort()); + assertEquals("container", name.getContainer()); + assertEquals("/.bashrc", name.getPath()); + assertEquals(".bashrc", name.getBaseName()); + assertEquals("", name.getExtension()); + assertEquals("blobstore://user@service/container/", name.getRootURI()); + assertEquals("blobstore://user@service/container/.bashrc", name.getURI()); + } + + /** + * Tests error handling in URI parser. + */ + public void disabledTestBadlyFormedUri() throws Exception { + // Does not start with blobstore:// + testBadlyFormedUri("blobstore:", "vfs.provider/missing-double-slashes.error"); + testBadlyFormedUri("blobstore:/", "vfs.provider/missing-double-slashes.error"); + testBadlyFormedUri("blobstore:a", "vfs.provider/missing-double-slashes.error"); + + // Missing service + testBadlyFormedUri("blobstore://", "vfs.provider/missing-hostname.error"); + testBadlyFormedUri("blobstore://:21/container", "vfs.provider/missing-hostname.error"); + testBadlyFormedUri("blobstore:///container", "vfs.provider/missing-hostname.error"); + + // Empty port + testBadlyFormedUri("blobstore://host:", "vfs.provider/missing-port.error"); + testBadlyFormedUri("blobstore://host:/container", "vfs.provider/missing-port.error"); + testBadlyFormedUri("blobstore://host:port/container/file", "vfs.provider/missing-port.error"); + + // Missing absolute path + testBadlyFormedUri("blobstore://host:90a", "vfs.provider/missing-hostname-path-sep.error"); + testBadlyFormedUri("blobstore://host?a", "vfs.provider/missing-hostname-path-sep.error"); + + // Missing container name + testBadlyFormedUri("blobstore://host", "vfs.provider.blobstore/missing-container-name.error"); + testBadlyFormedUri("blobstore://host/", "vfs.provider.blobstore/missing-container-name.error"); + testBadlyFormedUri("blobstore://host:9090/", + "vfs.provider.blobstore/missing-container-name.error"); + } + + /** + * Tests that parsing a URI fails with the expected error. + */ + private void testBadlyFormedUri(final String uri, final String errorMsg) { + try { + BlobStoreFileNameParser.getInstance().parseUri(null, null, uri); + fail(); + } catch (final FileSystemException e) { + assertSameMessage(errorMsg, uri, e); + } + } +} diff --git a/tools/vfs/src/test/resources/jclouds.properties b/tools/vfs/src/test/resources/jclouds.properties new file mode 100644 index 0000000000..7c2e244c6f --- /dev/null +++ b/tools/vfs/src/test/resources/jclouds.properties @@ -0,0 +1,31 @@ +# +# +# Copyright (C) 2009 Cloud Conscious, LLC. +# +# ==================================================================== +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ==================================================================== +# +azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder +azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder +cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder +cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder +s3.contextbuilder=org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder +s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder +stub.contextbuilder=org.jclouds.blobstore.integration.StubBlobStoreContextBuilder +stub.propertiesbuilder=org.jclouds.blobstore.integration.StubPropertiesBuilder \ No newline at end of file diff --git a/tools/vfs/src/test/resources/log4j.xml b/tools/vfs/src/test/resources/log4j.xml new file mode 100755 index 0000000000..8a56dec6f6 --- /dev/null +++ b/tools/vfs/src/test/resources/log4j.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java index f7f21c7a8a..5824f4c329 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.binders; import static com.google.common.base.Preconditions.checkArgument; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java index 300c774143..8ec0b82639 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java index a4a76274f3..56d8796b1d 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java index 06ac7d2130..02880d6e45 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/CatalogIdToUri.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/CatalogIdToUri.java index 77c556c7d8..078d433e90 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/CatalogIdToUri.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/CatalogIdToUri.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.functions; import static com.google.common.base.Preconditions.checkArgument; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppIdToUri.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppIdToUri.java index 0a43243be0..bce060d8f1 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppIdToUri.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppIdToUri.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.functions; import static com.google.common.base.Preconditions.checkArgument; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java index 262d227f86..653c9bc278 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.functions; import static com.google.common.base.Preconditions.checkArgument; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/vcloud/core/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java index 10472d386b..9c6230a78e 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.options; import static com.google.common.base.Preconditions.checkArgument; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java index 6717f1561a..5a05b6a282 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.xml; import org.jclouds.http.functions.ParseSax; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index 5f3a112736..4838a4a923 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.xml; import java.net.InetAddress; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualSystemHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualSystemHandler.java index 5374cd17a3..c2d2b7746a 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualSystemHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualSystemHandler.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.xml; import org.jclouds.http.functions.ParseSax; diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntityTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntityTest.java index ef0fe6a426..1901c518b5 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntityTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntityTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.binders; import static org.easymock.EasyMock.expect; diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/config/VCloudRestClientModuleTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/config/VCloudRestClientModuleTest.java index c4523e29b3..2e03beda67 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/config/VCloudRestClientModuleTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/config/VCloudRestClientModuleTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.config; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT; diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java index e086a32c53..68e30b508c 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.options; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.cpuCount; diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/vcloud/core/src/test/java/org/jclouds/vcloud/predicates/TaskSuccess.java index d2f0187584..bcce2e2c12 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/predicates/TaskSuccess.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/predicates/TaskSuccess.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.predicates; import java.net.URI; diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/config/HostingDotComVCloudRestClientModule.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/config/HostingDotComVCloudRestClientModule.java index 59c534a759..697eeef7dc 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/config/HostingDotComVCloudRestClientModule.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/config/HostingDotComVCloudRestClientModule.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.hostingdotcom.config; import java.net.URI; diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/HostingDotComVApp.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/HostingDotComVApp.java index f44cfdbb30..37d812b00d 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/HostingDotComVApp.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/HostingDotComVApp.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.hostingdotcom.domain; import org.jclouds.vcloud.domain.VApp; diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java index 6700024168..ba1ed05572 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/domain/internal/HostingDotComVAppImpl.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.hostingdotcom.domain.internal; import java.net.InetAddress; diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java index 8620cd6edd..64beeaffab 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/xml/HostingDotComVAppHandler.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.hostingdotcom.xml; import javax.inject.Inject; diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudComputeClientLiveTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudComputeClientLiveTest.java index 4418ca1e58..3f1cbd3b6a 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudComputeClientLiveTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudComputeClientLiveTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.hostingdotcom; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntity.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntity.java index 87087059e8..08f5a2fcd7 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntity.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntity.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.binders; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntity.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntity.java index 0d19586163..c28bc9af71 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntity.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntity.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.binders; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.java index 11776b8b07..706cdcf3bc 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.binders; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTCPUCOUNT; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/ResourceType.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/ResourceType.java index 27844568cd..2b039baf55 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/ResourceType.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/ResourceType.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.domain; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptions.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptions.java index 9e4e7ce61b..2b5c50d1c0 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptions.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import java.util.Map; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddNodeOptions.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddNodeOptions.java index ef288f14ad..1f67819aa0 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddNodeOptions.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/AddNodeOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import java.util.Map; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptions.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptions.java index 0bb618e310..e0874ad6c8 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptions.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptions.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import java.net.URI; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/reference/TerremarkVCloudConstants.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/reference/TerremarkVCloudConstants.java index f6619a5645..9bcdfe932f 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/reference/TerremarkVCloudConstants.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/reference/TerremarkVCloudConstants.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.reference; import org.jclouds.vcloud.reference.VCloudConstants; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java index 0426893223..4e9b1219b1 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/NodeHandler.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/NodeHandler.java index 6f148b67fd..29eb2d86bb 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/NodeHandler.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/xml/NodeHandler.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntityTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntityTest.java index a18dbcfc84..f93fd9c0e0 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntityTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddInternetServiceToXmlEntityTest.java @@ -1,13 +1,13 @@ /** * - * Copyright (C) 2009 Cloud Conscious,"LLC. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License,"Version 2.0 (the + * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * @@ -15,8 +15,8 @@ * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS,"WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND,"either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntityTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntityTest.java index 19655967a1..459fba865f 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntityTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindAddNodeServiceToXmlEntityTest.java @@ -1,13 +1,13 @@ /** * - * Copyright (C) 2009 Cloud Conscious,"LLC. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License,"Version 2.0 (the + * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * @@ -15,8 +15,8 @@ * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS,"WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND,"either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest.java index d7c16d62b8..9040355a92 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest.java @@ -1,13 +1,13 @@ /** * - * Copyright (C) 2009 Cloud Conscious,"LLC. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License,"Version 2.0 (the + * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * @@ -15,8 +15,8 @@ * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS,"WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND,"either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptionsTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptionsTest.java index ee48726c9b..6be94bf4c3 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptionsTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddInternetServiceOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddNodeOptionsTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddNodeOptionsTest.java index 0d0ffb0d4b..175296d931 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddNodeOptionsTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/AddNodeOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import static org.jclouds.vcloud.terremark.options.AddNodeOptions.Builder.disabled; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptionsTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptionsTest.java index afaffbe24b..f64be49a6c 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptionsTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/options/TerremarkInstantiateVAppTemplateOptionsTest.java @@ -1,3 +1,26 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ package org.jclouds.vcloud.terremark.options; import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.cpuCount;