Skip to content

Commit

Permalink
Merge pull request #23 from gcheng/global
Browse files Browse the repository at this point in the history
Unicode issue for this sprint.
  • Loading branch information
Albert Cheng committed Mar 7, 2013
2 parents 84403a6 + 0ecdd94 commit 171f6ad
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.microsoft.windowsazure.services.blob.implementation;

import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -808,7 +809,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser

@Override
@Deprecated
public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException {
public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options)
throws ServiceException {
breakLease(container, blob, options);
}

Expand All @@ -819,8 +821,8 @@ public BreakLeaseResult breakLease(String container, String blob) throws Service

@Override
public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options)
throws ServiceException {
ClientResponse response = doLeaseOperation("break", container, blob, null, options, null);
throws ServiceException {
ClientResponse response = doLeaseOperation("break", container, blob, null, options, null);

BreakLeaseResult result = new BreakLeaseResult();
result.setRemainingLeaseTimeInSeconds(Integer.parseInt(response.getHeaders().getFirst("x-ms-lease-time")));
Expand All @@ -836,7 +838,8 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St
return result;
}

private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) {
private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId,
BlobServiceOptions options, AccessCondition accessCondition) {
String path = createPathFromContainer(container);
WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease");

Expand Down Expand Up @@ -941,7 +944,12 @@ public void createBlobBlock(String container, String blob, String blockId, Input
CreateBlobBlockOptions options) throws ServiceException {
String path = createPathFromContainer(container);
WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block");
webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId)));
try {
webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId), "UTF-8"));
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}

Builder builder = webResource.header("x-ms-version", API_VERSION);
builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright Microsoft Corporation
*
* Licensed 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
* 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.
* 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 com.microsoft.windowsazure.services.blob.implementation;

Expand All @@ -33,8 +33,8 @@ public String sign(String stringToSign) {

Mac hmac = Mac.getInstance("hmacSHA256");
hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256"));
byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8"));
return new String(Base64.encode(digest));
byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF-8"));
return new String(Base64.encode(digest), "UTF-8");
}
catch (Exception e) {
throw new IllegalArgumentException("accessKey", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright Microsoft Corporation
*
* Licensed 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
* 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.
* 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 com.microsoft.windowsazure.services.core.utils.pipeline;

Expand All @@ -25,7 +25,7 @@ public class Base64StringAdapter extends XmlAdapter<String, String> {

@Override
public String marshal(String arg0) throws Exception {
return new String(Base64.encode(arg0));
return new String(Base64.encode(arg0), "UTF-8");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BrokerPropertiesMapper {
public BrokerProperties fromString(String value) throws IllegalArgumentException {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.readValue(value.getBytes(), BrokerProperties.class);
return mapper.readValue(value.getBytes("UTF-8"), BrokerProperties.class);
}
catch (JsonParseException e) {
throw new IllegalArgumentException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -70,7 +71,12 @@ public BrokeredMessage(byte[] body) {
*/
public BrokeredMessage(String body) {
this(new BrokerProperties());
this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes());
try {
this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes("UTF-8"));
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.microsoft.windowsazure.services.core.Builder;
import com.microsoft.windowsazure.services.core.UserAgentFilter;
import com.microsoft.windowsazure.services.table.implementation.AtomReaderWriter;
import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConterter;
import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConverter;
import com.microsoft.windowsazure.services.table.implementation.DefaultXMLStreamFactory;
import com.microsoft.windowsazure.services.table.implementation.HttpReaderWriter;
import com.microsoft.windowsazure.services.table.implementation.MimeReaderWriter;
Expand All @@ -39,7 +39,7 @@ public void register(Builder.Registry registry) {
registry.add(AtomReaderWriter.class);
registry.add(MimeReaderWriter.class);
registry.add(HttpReaderWriter.class);
registry.add(EdmValueConverter.class, DefaultEdmValueConterter.class);
registry.add(EdmValueConverter.class, DefaultEdmValueConverter.class);
registry.add(UserAgentFilter.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import com.microsoft.windowsazure.services.table.models.EdmType;
import com.sun.jersey.core.util.Base64;

public class DefaultEdmValueConterter implements EdmValueConverter {
public class DefaultEdmValueConverter implements EdmValueConverter {

private final ISO8601DateConverter iso8601DateConverter;

@Inject
public DefaultEdmValueConterter(ISO8601DateConverter iso8601DateConverter) {
public DefaultEdmValueConverter(ISO8601DateConverter iso8601DateConverter) {
this.iso8601DateConverter = iso8601DateConverter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AtomReaderWriterTests extends IntegrationTestBase {
public void parseTableEntriesWorks() throws Exception {
// Arrange
AtomReaderWriter atom = new AtomReaderWriter(new DefaultXMLStreamFactory(), new DefaultDateFactory(),
new ISO8601DateConverter(), new DefaultEdmValueConterter(new ISO8601DateConverter()));
new ISO8601DateConverter(), new DefaultEdmValueConverter(new ISO8601DateConverter()));
String feed = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n"
+ "<feed xml:base=\"http://rpaquaytest.table.core.windows.net/\" xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" xmlns=\"http://www.w3.org/2005/Atom\">\r\n"
+ " <title type=\"text\">Tables</title>\r\n"
Expand Down

0 comments on commit 171f6ad

Please sign in to comment.