Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

unit-test:
name: Unit Test
runs-on: windows-latest
runs-on: ubuntu-latest
needs: pre-process
if: needs.pre-process.outputs.were-only-docs-updated != 'yes'
steps:
Expand Down Expand Up @@ -103,7 +103,8 @@ jobs:
run: |
git clone --branch=master https://github.com/vmware/singleton.git server
cd $GITHUB_WORKSPACE/server/g11n-ws && ./gradlew build -x test
find $GITHUB_WORKSPACE/server/publish/ -name 'singleton-[0~9]*.jar' -exec mv '{}' $GITHUB_WORKSPACE/server/publish/singleton.jar \;
#find $GITHUB_WORKSPACE/server/publish/ -name 'singleton-[0~9]*.jar' -exec mv '{}' $GITHUB_WORKSPACE/server/publish/singleton.jar \;
mv $GITHUB_WORKSPACE/server/publish/singleton-0.1.0.jar $GITHUB_WORKSPACE/server/publish/singleton.jar
- uses: actions/upload-artifact@v4
with:
name: singleton-service
Expand Down Expand Up @@ -139,9 +140,11 @@ jobs:
cd $GITHUB_WORKSPACE
./gradlew clean build -x test
cp ./build/libs/*.jar $GITHUB_WORKSPACE/devops/autotest/client/java/lib/
ls -l $GITHUB_WORKSPACE/devops/autotest/client/java/lib/
cd $GITHUB_WORKSPACE/devops/autotest/client/java
./gradlew build -x test
docker cp src/main/resources/l10n singleton:/
cd target
ls -l
java -cp '.:./*' org.testng.TestNG -d test-output testng.xml

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ dependencies {
compile group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.1'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile group: 'org.apache.taglibs', name: 'taglibs-standard-impl', version: '1.2.5'
compile group: 'org.json', name: 'json', version: '20250107'
compile group: 'com.vmware.singleton', name: 'singleton-i18n-patterns-core', version: '[0.5.1,)'
compile group: 'org.json', name: 'json', version: '20250107'
compile group: 'com.vmware.singleton', name: 'singleton-i18n-patterns-core', version: '0.5.17.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'
testCompile group: 'log4j', name: 'log4j', version: '1.2.17'
Expand Down
8 changes: 5 additions & 3 deletions sample-client-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
apply plugin: 'eclipse'
Expand All @@ -26,12 +26,14 @@ repositories {
}

dependencies {
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'org.json', name: 'json', version:'20250107'
// compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'com.vmware.singleton', name: 'singleton-i18n-patterns-core', version: '0.4.0'
compile group: 'com.vmware.singleton', name: 'singleton-i18n-patterns-core', version: '0.5.17.1'
compile group: 'junit', name: 'junit', version: '4.10'
compile fileTree(dir: 'lib', include: ['*.jar'])
}

Expand Down
4 changes: 2 additions & 2 deletions sample-client-app/sample-app-with-shared-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ How to build and run this sample application as an executable jar
```
* Put the Singleton Java client library into the lib folder.
```
cp ../../build/libs/vip4java-0.1.0.jar ./lib/
cp ../../build/libs/singleton-client-java-0.1.0.jar ./lib/
```
* Put the sample shared library into the lib folder. See how to build the sample shared library in [here](https://github.com/vmware/singleton/blob/g11n-java-client/sample-client-app/sample-shared-library/README.md)
```
Expand All @@ -46,7 +46,7 @@ How to build and run this sample application as a Spring Boot executable jar
```
* Put the Singleton Java client library into the lib folder.
```
cp ../../build/libs/vip4java-0.1.0.jar ./lib/
cp ../../build/libs/singleton-client-java-0.1.0.jar ./lib/
```
* Put the sample shared library into the lib folder. See how to build the sample shared library in [here](https://github.com/vmware/singleton/blob/g11n-java-client/sample-client-app/sample-shared-library/README.md)
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
plugins {
Expand All @@ -19,8 +19,8 @@ repositories {

dependencies {
implementation files('lib/sample-shared-library-1.0.jar')
implementation files('lib/vip4java-0.1.0.jar')
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
implementation files('lib/singleton-client-java-0.1.0.jar')
compile group: 'org.json', name: 'json', version:'20250107'

// tag::actuator[]
implementation 'org.springframework.boot:spring-boot-starter-actuator'
Expand Down
4 changes: 2 additions & 2 deletions sample-client-app/sample-app-with-shared-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
apply plugin: 'eclipse'
Expand All @@ -26,7 +26,7 @@ repositories {
}

dependencies {
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'org.json', name: 'json', version:'20250107'

compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version = 1.0.0
# [cacheExpiredTime ] - Cache expiration time. unit: millisecond.
# [machineTranslation] - If machineTranslation is true, will get translation by machine translation.
######################################################################################
vipServer = http://localhost:8099
vipServer = http://localhost:8091
offlineResourcesBaseUrl = offlineBundles/
initializeCache = false
pseudo = false
Expand Down
4 changes: 2 additions & 2 deletions sample-client-app/sample-shared-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ How to build and run this sample shared library
------------
* Go to the root directory of this sample application
```
g11n-java-client/sample/-client-app/sample-shared-library
g11n-java-client/sample-client-app/sample-shared-library
```
* Create a lib folder.
```
mkdir lib
```
* Put the Singleton Java client library into the lib folder.
```
cp ../../build/libs/vip4java-0.1.0.jar ./lib/
cp ../../build/libs/singleton-client-java-0.1.0.jar ./lib/
```
* Build the sample application.
```
Expand Down
4 changes: 2 additions & 2 deletions sample-client-app/sample-shared-library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
apply plugin: 'eclipse'
Expand All @@ -21,7 +21,7 @@ repositories {
}

dependencies {
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'org.json', name: 'json', version:'20250107'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.sample;
Expand All @@ -8,7 +8,7 @@
import java.util.Locale;
import java.util.Map;

import org.json.simple.JSONObject;
import org.json.JSONObject;

import com.vmware.vipclient.i18n.I18nFactory;
import com.vmware.vipclient.i18n.base.instances.TranslationMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.sample;

import static org.junit.Assert.assertEquals;

import java.util.Date;
import java.util.TimeZone;
import java.text.SimpleDateFormat;
import java.util.Locale;

import com.vmware.vipclient.i18n.I18nFactory;
Expand Down Expand Up @@ -134,11 +136,18 @@ private static void getMessageWithSimpleArg(){
new Date(timestamp),
"a disturbance in the Force"
};
// get expected date string based on default timezone
Date d = new Date(timestamp);
final SimpleDateFormat df = new SimpleDateFormat("MMMMM d, yyyy");
df.setTimeZone(TimeZone.getDefault());
final SimpleDateFormat tf = new SimpleDateFormat("h:mm a");
tf.setTimeZone(TimeZone.getDefault());
String dateString = tf.format(d) + " on " + df.format(d);

String includeFormatMessage = t.getMessage(Locale.ENGLISH, component, "sample.includeFormat.message",
arguments);
System.out.println("message with number&date arguments: " + includeFormatMessage);
Assert.assertEquals("At 1:39 PM on November 20, 2017, there was a disturbance in the Force on planet 7.", includeFormatMessage);
Assert.assertEquals("At " + dateString + ", there was a disturbance in the Force on planet 7.", includeFormatMessage);
System.out.println(">>>>>> TranslationDemo.getMessageWithSimpleArg success");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.base.cache.persist;
Expand All @@ -15,7 +15,8 @@
import java.util.Map;

import com.vmware.vipclient.i18n.base.cache.TranslationCacheManager;
import org.json.simple.parser.JSONParser;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,10 +40,8 @@ public Map<String, String> load(String key) {
}
}
reader = new InputStreamReader(fis, "UTF-8");
Object o = new JSONParser().parse(reader);
if (o != null) {
map = (Map) o;
}
JSONObject jsonObject = new JSONObject(new JSONTokener(reader));
map = jsonObject.toMap();
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.base.instances;

import com.vmware.vipclient.i18n.I18nFactory;
import com.vmware.vipclient.i18n.l2.common.PatternCategory;
import org.json.simple.JSONObject;
import org.json.JSONObject;

import java.util.Locale;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.base.instances;

import com.vmware.vipclient.i18n.messages.service.PatternService;
import org.json.simple.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.base.instances;
Expand All @@ -12,7 +12,7 @@
import com.vmware.vipclient.i18n.messages.service.ComponentsService;
import com.vmware.vipclient.i18n.messages.service.StringService;
import com.vmware.vipclient.i18n.util.*;
import org.json.simple.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -529,7 +529,7 @@ public Map<String, String> getMessages(String resourceBundle, final Locale local

Map<String, String> messages = new LinkedHashMap<>();

Map<String,String> sources = resourceBundle != null ? getSourcesFromBundle(resourceBundle):
Map<String, String> sources = resourceBundle != null ? getSourcesFromBundle(resourceBundle):
getMessages(Locale.forLanguageTag(ConstantsKeys.SOURCE), component, false).getMessages();

if(!sources.isEmpty()) {
Expand Down Expand Up @@ -597,8 +597,7 @@ private ComponentService.TranslationsDTO getMultiVersionMessagesOfKey(final Loca
*/
public Map<Locale, Map<String, Map<String, String>>> getStrings(final Set<Locale> locales,
final Set<String> components) {
this.logger.trace("Start to execute TranslationMessage.getStrings of multiple components of multiple locales.");

this.logger.info("Start to execute TranslationMessage.getStrings of multiple components of multiple locales.");
Map<Locale, Map<String, Map<String, String>>> retMap = new HashMap<>();
if (null == locales || locales.isEmpty() || null == components || components.isEmpty()) {
this.logger.error(ConstantsMsg.WRONG_PARAMETER + "locales: {}, components: {}.", locales, components);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.filters;
Expand All @@ -17,7 +17,7 @@

import com.vmware.vipclient.i18n.exceptions.VIPJavaClientException;
import com.vmware.vipclient.i18n.util.StringUtil;
import org.json.simple.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -45,7 +45,8 @@ public void doFilter(ServletRequest request, ServletResponse response,
Map<String, String> ctmap = translation.getStrings(LocaleUtility.fmtToMappedLocale(locale),
component);
if (ctmap != null) {
messages = JSONObject.toJSONString(ctmap);
JSONObject jsonObject = new JSONObject(ctmap);
messages = jsonObject.toString();
}
}
OutputStream os = response.getOutputStream();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.filters;
Expand All @@ -21,7 +21,7 @@
import com.vmware.vipclient.i18n.base.instances.PatternMessage;
import com.vmware.vipclient.i18n.exceptions.VIPJavaClientException;
import com.vmware.vipclient.i18n.util.StringUtil;
import org.json.simple.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -46,9 +46,11 @@ public void doFilter(final ServletRequest request, ServletResponse response,

String patterns = "{}";
if (!StringUtil.isEmpty(locale) && !LocaleUtility.isDefaultLocale(locale)) {
Map<String, String> ctmap = patternMessage.getPatternMessage(Locale.forLanguageTag(locale));
if (ctmap != null) {
patterns = JSONObject.toJSONString(ctmap);
JSONObject jsonObject = patternMessage.getPatternMessage(Locale.forLanguageTag(locale));
if (jsonObject != null) {
// JSONObject jsonObject = new JSONObject(ctmap);
patterns = jsonObject.toString();
// patterns = JSONObject.toJSONString(ctmap);
}
}
OutputStream os = response.getOutputStream();
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/vmware/vipclient/i18n/formats/DateFormat.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
* Copyright 2019-2022 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vipclient.i18n.formats;

import java.util.Map;

import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;
import org.json.JSONObject;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -53,7 +52,7 @@ private String getFormatFromRemote(String longDate, String pattern) {
}
JSONObject retJson;
try {
retJson = (JSONObject) JSONValue.parseWithException(retJsonStr);
retJson = new JSONObject(retJsonStr);
if (retJson != null) {
JSONObject dataJson = (JSONObject) retJson
.get(ConstantsKeys.DATA);
Expand All @@ -63,7 +62,7 @@ private String getFormatFromRemote(String longDate, String pattern) {
.toString();
}
}
} catch (ParseException e) {
} catch (JSONException e) {
logger.error(e.getMessage());
}
return format;
Expand Down
Loading
Loading