mirror of https://github.com/apache/jclouds.git
removed multimap for user metadata
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1984 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
bf0943ac6c
commit
eefd7d47f8
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.jclouds.azure.storage.blob;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
@ -51,7 +52,7 @@ import org.jclouds.azure.storage.filters.SharedKeyAuthentication;
|
|||
import org.jclouds.azure.storage.options.ListOptions;
|
||||
import org.jclouds.azure.storage.reference.AzureStorageHeaders;
|
||||
import org.jclouds.blobstore.binders.BindBlobToEntity;
|
||||
import org.jclouds.blobstore.binders.BindMultimapToHeadersWithPrefix;
|
||||
import org.jclouds.blobstore.binders.BindMapToHeadersWithPrefix;
|
||||
import org.jclouds.blobstore.functions.BlobKey;
|
||||
import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||
|
@ -69,8 +70,6 @@ import org.jclouds.rest.annotations.ResponseParser;
|
|||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Provides access to Azure Blob via their REST API.
|
||||
* <p/>
|
||||
|
@ -144,7 +143,7 @@ public interface AzureBlobConnection {
|
|||
@Path("{container}")
|
||||
@QueryParams(keys = { "restype", "comp" }, values = { "container", "metadata" })
|
||||
void setContainerMetadata(@PathParam("container") String container,
|
||||
@BinderParam(BindMultimapToHeadersWithPrefix.class) Multimap<String, String> metadata);
|
||||
@BinderParam(BindMapToHeadersWithPrefix.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
* The Delete Container operation marks the specified container for deletion. The container and
|
||||
|
@ -302,7 +301,7 @@ public interface AzureBlobConnection {
|
|||
@Path("{container}/{key}")
|
||||
@QueryParams(keys = { "comp" }, values = { "metadata" })
|
||||
void setBlobMetadata(@PathParam("container") String container, @PathParam("key") String key,
|
||||
@BinderParam(BindMultimapToHeadersWithPrefix.class) Multimap<String, String> metadata);
|
||||
@BinderParam(BindMapToHeadersWithPrefix.class) Map<String, String> metadata);
|
||||
|
||||
/**
|
||||
* The Delete Blob operation marks the specified blob for deletion. The blob is later deleted
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
@ -62,8 +63,8 @@ import org.jclouds.util.Jsr330;
|
|||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -301,10 +302,10 @@ public class AzureBlobConnectionTest {
|
|||
|
||||
public void testSetContainerMetadata() throws SecurityException, NoSuchMethodException {
|
||||
Method method = AzureBlobConnection.class.getMethod("setContainerMetadata", String.class,
|
||||
Multimap.class);
|
||||
Map.class);
|
||||
|
||||
GeneratedHttpRequest<AzureBlobConnection> httpMethod = processor.createRequest(method,
|
||||
new Object[] { "container", ImmutableMultimap.of("key", "value") });
|
||||
new Object[] { "container", ImmutableMap.of("key", "value") });
|
||||
assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net");
|
||||
assertEquals(httpMethod.getEndpoint().getPath(), "/container");
|
||||
assertEquals(httpMethod.getEndpoint().getQuery(), "restype=container&comp=metadata");
|
||||
|
@ -323,9 +324,9 @@ public class AzureBlobConnectionTest {
|
|||
|
||||
public void testSetBlobMetadata() throws SecurityException, NoSuchMethodException {
|
||||
Method method = AzureBlobConnection.class.getMethod("setBlobMetadata", String.class,
|
||||
String.class, Multimap.class);
|
||||
String.class, Map.class);
|
||||
GeneratedHttpRequest<AzureBlobConnection> httpMethod = processor.createRequest(method,
|
||||
new Object[] { "container", "blob", ImmutableMultimap.of("key", "value") });
|
||||
new Object[] { "container", "blob", ImmutableMap.of("key", "value") });
|
||||
assertEquals(httpMethod.getEndpoint().getHost(), "myaccount.blob.core.windows.net");
|
||||
assertEquals(httpMethod.getEndpoint().getPath(), "/container/blob");
|
||||
assertEquals(httpMethod.getEndpoint().getQuery(), "comp=metadata");
|
||||
|
|
|
@ -50,7 +50,6 @@ import org.jclouds.util.DateService;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
|
@ -128,11 +127,11 @@ public class StubAzureBlobConnection extends StubBlobStore<ContainerMetadata, Bl
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setContainerMetadata(String container, Multimap<String, String> metadata) {
|
||||
public void setContainerMetadata(String container, Map<String, String> metadata) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setBlobMetadata(String container, String key, Multimap<String, String> metadata) {
|
||||
public void setBlobMetadata(String container, String key, Map<String, String> metadata) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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.config;
|
||||
|
||||
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.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||
import org.jclouds.http.handlers.RedirectionRetryHandler;
|
||||
import org.jclouds.util.DateService;
|
||||
import org.jclouds.util.Jsr330;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "azure.RestAzureStorageConnectionModuleTest")
|
||||
public class RestAzureStorageConnectionModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new RestAzureStorageConnectionModule(), new ParserModule(),
|
||||
new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to(
|
||||
"user");
|
||||
bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_KEY)).to(
|
||||
"secret");
|
||||
bindConstant().annotatedWith(
|
||||
Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to("2");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
|
||||
RestAzureStorageConnectionModule module = new RestAzureStorageConnectionModule();
|
||||
|
||||
ConcurrentMap<String, String> map = module.provideTimeStampCache(1, new DateService());
|
||||
String timeStamp = map.get("foo");
|
||||
for (int i = 0; i < 10; i++)
|
||||
map.get("foo");
|
||||
assertEquals(timeStamp, map.get("foo"));
|
||||
Thread.sleep(1001);
|
||||
assertFalse(timeStamp.equals(map.get("foo")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testServerErrorHandler() {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getServerErrorHandler().getClass(),
|
||||
ParseAzureStorageErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientErrorHandler() {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getClientErrorHandler().getClass(),
|
||||
ParseAzureStorageErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientRetryHandler() {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getClientErrorRetryHandler(), HttpRetryHandler.NEVER_RETRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRedirectionRetryHandler() {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getRedirectionRetryHandler().getClass(),
|
||||
RedirectionRetryHandler.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@ package org.jclouds.blobstore.binders;
|
|||
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -33,20 +34,18 @@ import javax.inject.Named;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class BindMultimapToHeadersWithPrefix implements Binder {
|
||||
public class BindMapToHeadersWithPrefix implements Binder {
|
||||
private final String metadataPrefix;
|
||||
|
||||
@Inject
|
||||
public BindMultimapToHeadersWithPrefix(@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
|
||||
public BindMapToHeadersWithPrefix(@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
|
||||
this.metadataPrefix = metadataPrefix;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindToRequest(HttpRequest request, Object entity) {
|
||||
Multimap<String, String> userMetadata = (Multimap<String, String>) entity;
|
||||
for (Entry<String, String> entry : userMetadata.entries()) {
|
||||
Map<String, String> userMetadata = (Map<String, String>) entity;
|
||||
for (Entry<String, String> entry : userMetadata.entrySet()) {
|
||||
if (entry.getKey().startsWith(metadataPrefix)) {
|
||||
request.getHeaders().put(entry.getKey().toLowerCase(), entry.getValue());
|
||||
} else {
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.jclouds.rackspace.cloudfiles;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -37,7 +38,7 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.PathParam;
|
||||
|
||||
import org.jclouds.blobstore.binders.BindBlobToEntity;
|
||||
import org.jclouds.blobstore.binders.BindMultimapToHeadersWithPrefix;
|
||||
import org.jclouds.blobstore.binders.BindMapToHeadersWithPrefix;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||
import org.jclouds.blobstore.functions.BlobKey;
|
||||
|
@ -74,8 +75,6 @@ import org.jclouds.rest.annotations.RequestFilters;
|
|||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Provides access to Cloud Files via their REST API.
|
||||
* <p/>
|
||||
|
@ -142,7 +141,7 @@ public interface CloudFilesConnection {
|
|||
boolean setObjectMetadata(
|
||||
@PathParam("container") String container,
|
||||
@PathParam("key") String key,
|
||||
@BinderParam(BindMultimapToHeadersWithPrefix.class) Multimap<String, String> userMetadata);
|
||||
@BinderParam(BindMapToHeadersWithPrefix.class) Map<String, String> userMetadata);
|
||||
|
||||
@GET
|
||||
@ResponseParser(ParseContainerCDNMetadataListFromGsonResponse.class)
|
||||
|
|
|
@ -30,6 +30,7 @@ import static org.testng.Assert.fail;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -52,9 +53,8 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code JaxrsAnnotationProcessor}
|
||||
|
@ -307,7 +307,7 @@ public class CloudFilesConnectionLiveTest {
|
|||
assertEquals(metadata.getUserMetadata().get("metadata"), "metadata-value");
|
||||
|
||||
// // Test POST to update object's metadata
|
||||
Multimap<String, String> userMetadata = HashMultimap.create();
|
||||
Map<String, String> userMetadata = Maps.newHashMap();
|
||||
userMetadata.put("New-Metadata-1", "value-1");
|
||||
userMetadata.put("New-Metadata-2", "value-2");
|
||||
assertTrue(connection.setObjectMetadata(containerName, object.getKey(), userMetadata));
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.jclouds.rackspace.cloudfiles.options.ListCdnContainerOptions;
|
|||
import org.jclouds.rackspace.cloudfiles.options.ListContainerOptions;
|
||||
import org.jclouds.util.DateService;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Implementation of {@link CloudFilesBlobStore} which keeps all data in a local Map object.
|
||||
*
|
||||
|
@ -71,8 +69,7 @@ public class StubCloudFilesConnection extends
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean setObjectMetadata(String container, String key,
|
||||
Multimap<String, String> userMetadata) {
|
||||
public boolean setObjectMetadata(String container, String key, Map<String, String> userMetadata) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue