Author: fmui
Date: Thu Aug 20 10:26:25 2015
New Revision: 1696752
URL: http://svn.apache.org/r1696752
Log:
transmit language and country in local binding
Added:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/LocalCallContextTest.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/LocalCallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java?rev=1696752&r1=1696751&r2=1696752&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
Thu Aug 20 10:26:25 2015
@@ -38,6 +38,8 @@ public abstract class AbstractLocalServi
private String user;
private String password;
+ private String language;
+ private String country;
/**
* Sets the current session.
@@ -50,6 +52,12 @@ public abstract class AbstractLocalServi
Object passwordObj = session.get(SessionParameter.PASSWORD);
password = passwordObj instanceof String ? passwordObj.toString() :
null;
+
+ Object localeLanguageObj =
session.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
+ language = localeLanguageObj instanceof String ?
localeLanguageObj.toString() : null;
+
+ Object localeCountryObj =
session.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
+ country = localeCountryObj instanceof String ?
localeCountryObj.toString() : null;
}
/**
@@ -107,7 +115,7 @@ public abstract class AbstractLocalServi
* creates a local call context.
*/
protected CallContext createCallContext(String repositoryId) {
- return new LocalCallContext(repositoryId, user, password);
+ return new LocalCallContext(repositoryId, user, password, language,
country);
}
protected CmisService getService(String repositoryId) {
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/LocalCallContext.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/LocalCallContext.java?rev=1696752&r1=1696751&r2=1696752&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/LocalCallContext.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/LocalCallContext.java
Thu Aug 20 10:26:25 2015
@@ -42,6 +42,20 @@ public class LocalCallContext implements
contextMap.put(PASSWORD, password);
}
+ public LocalCallContext(String repositoryId, String user, String password,
String language, String country) {
+ this(repositoryId, user, password);
+
+ if (language != null) {
+ put(LOCALE_ISO639_LANGUAGE, language);
+ put(LOCALE, language);
+ }
+
+ if (country != null) {
+ put(LOCALE_ISO3166_COUNTRY, country);
+ put(LOCALE, language + "-" + country);
+ }
+ }
+
@Override
public String getBinding() {
return BINDING_LOCAL;
@@ -74,7 +88,7 @@ public class LocalCallContext implements
@Override
public String getLocale() {
- return null;
+ return (String) get(LOCALE);
}
@Override
Added:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/LocalCallContextTest.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/LocalCallContextTest.java?rev=1696752&view=auto
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/LocalCallContextTest.java
(added)
+++
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/misc/LocalCallContextTest.java
Thu Aug 20 10:26:25 2015
@@ -0,0 +1,63 @@
+/*
+ * 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.apache.chemistry.opencmis.client.bindings.misc;
+
+import junit.framework.TestCase;
+
+import
org.apache.chemistry.opencmis.client.bindings.spi.local.LocalCallContext;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+
+public class LocalCallContextTest extends TestCase {
+
+ public void testLocalCallContextSimple() {
+ LocalCallContext lcc = new LocalCallContext("repId", "user",
"password");
+
+ assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
+ assertEquals("repId", lcc.getRepositoryId());
+ assertEquals("user", lcc.getUsername());
+ assertEquals("password", lcc.getPassword());
+ assertNull(lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
+ assertNull(lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
+ assertNull(lcc.getLocale());
+ }
+
+ public void testLocalCallContextLang() {
+ LocalCallContext lcc = new LocalCallContext("repId", "user",
"password", "de", null);
+
+ assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
+ assertEquals("repId", lcc.getRepositoryId());
+ assertEquals("user", lcc.getUsername());
+ assertEquals("password", lcc.getPassword());
+ assertEquals("de", lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
+ assertNull(lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
+ assertEquals("de", lcc.getLocale());
+ }
+
+ public void testLocalCallContextLangCountry() {
+ LocalCallContext lcc = new LocalCallContext("repId", "user",
"password", "de", "ch");
+
+ assertEquals(CallContext.BINDING_LOCAL, lcc.getBinding());
+ assertEquals("repId", lcc.getRepositoryId());
+ assertEquals("user", lcc.getUsername());
+ assertEquals("password", lcc.getPassword());
+ assertEquals("de", lcc.get(CallContext.LOCALE_ISO639_LANGUAGE));
+ assertEquals("ch", lcc.get(CallContext.LOCALE_ISO3166_COUNTRY));
+ assertEquals("de-ch", lcc.getLocale());
+ }
+}
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
URL:
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java?rev=1696752&r1=1696751&r2=1696752&view=diff
==============================================================================
---
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
(original)
+++
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
Thu Aug 20 10:26:25 2015
@@ -1142,7 +1142,7 @@ public final class Base64 {
else {
// There's a bad input character in the Base64 stream.
throw new java.io.IOException(String.format(
- "Bad Base64 input character decimal %d in array
position %d", (source[i]) & 0xFF, i));
+ "Bad Base64 input character decimal %d in array
position %d", ((int) source[i]) & 0xFF, i));
} // end else:
} // each input character
@@ -1204,7 +1204,7 @@ public final class Base64 {
boolean dontGunzip = (options & DONT_GUNZIP) != 0;
if ((bytes != null) && (bytes.length >= 4) && (!dontGunzip)) {
- int head = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
+ int head = ((int) bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) {
java.io.ByteArrayInputStream bais = null;
java.util.zip.GZIPInputStream gzis = null;