diff --git a/g11n-ws/build.gradle b/g11n-ws/build.gradle index cc8faa7c4..52622732a 100644 --- a/g11n-ws/build.gradle +++ b/g11n-ws/build.gradle @@ -57,7 +57,7 @@ subprojects{ cacheApiVersion='1.1.1' hsqlVersion = '2.3.3' junitVersion = '4.13.2' - jsonSimpleVersion = '1.1.1' + jsonVersion = '20250107' commonsCollectionsVersion = '3.2.2' commonsLangVersion = '3.12.0' commonsIoVersion = '2.17.0' diff --git a/g11n-ws/modules/md-data-api-mt/build.gradle b/g11n-ws/modules/md-data-api-mt/build.gradle index 5b3cb970f..87aa789de 100644 --- a/g11n-ws/modules/md-data-api-mt/build.gradle +++ b/g11n-ws/modules/md-data-api-mt/build.gradle @@ -25,7 +25,7 @@ dependencies { compileOnly("commons-collections:commons-collections:$commonsCollectionsVersion") compileOnly("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") compileOnly("org.apache.commons:commons-lang3:$commonsLangVersion") - compileOnly("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + compileOnly("org.json:json:$jsonVersion"){ exclude group: 'junit' } diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/core/except/ExceptionHandle.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/core/except/ExceptionHandle.java index db776daa6..86658f55a 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/core/except/ExceptionHandle.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/core/except/ExceptionHandle.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2024 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.except; @@ -72,7 +72,7 @@ public APIResponseDTO handler(Exception e) { String errorStr = MessageFormat.format("unknown error: {0}" ,e.getMessage()); logger.error(errorStr, e); } - String rstr = "[response] " + response.getResponse().toJSONString(); + String rstr = "[response] " + response.getResponse().toString(); logger.info(rstr); String endHandle = "[thread-" + Thread.currentThread().getId() + "] End to handle request."; logger.info(endHandle); diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/StreamProductAction.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/StreamProductAction.java index 4b1f49bd1..ed5492f09 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/StreamProductAction.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/StreamProductAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.base; @@ -14,8 +14,8 @@ import com.vmware.vip.core.messages.service.product.IProductService; import com.vmware.vip.messages.data.dao.model.ResultMessageChannel; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import jakarta.servlet.http.HttpServletResponse; @@ -193,13 +193,13 @@ private void writePseudoTranslationsToChannel(String productName, String version resp.setContentType(ConstantsKeys.CONTENT_TYPE_JSON); WritableByteChannel wbc = Channels.newChannel(resp.getOutputStream()); - boolean isPartContent = writeResponseHeader(reqVersion.equals(versionStr), components.size() * locales.size(), result.size(), wbc, sr); + boolean isPartContent = writeResponseHeader(reqVersion.equals(versionStr), components.size() * locales.size(), result.toList().size(), wbc, sr); List resultList = formatResultBundles(components, locales, result, isPartContent); - wbc.write(ByteBuffer.wrap(resultList.get(0).toJSONString().getBytes())); + wbc.write(ByteBuffer.wrap(resultList.get(0).toString().getBytes())); ByteBuffer buf = ByteBuffer.wrap(byteComm); for (int i =1; i formatResultBundles(List components, List objectIterator = result.iterator(); + Iterator objectIterator = result.iterator(); while(objectIterator.hasNext()) { - resultList.add(objectIterator.next()); + resultList.add((JSONObject) objectIterator.next()); } } return resultList; } private JSONObject addNullBundle(String component, String locale, JSONArray result){ - Iterator objectIterator = result.iterator(); + Iterator objectIterator = result.iterator(); while(objectIterator.hasNext()) { - JSONObject object = objectIterator.next(); + JSONObject object = (JSONObject) objectIterator.next(); String fileLocale = (String) object.get(ConstantsKeys.lOCALE); String fileComponent = (String) object.get(ConstantsKeys.COMPONENT); if(locale.equals(fileLocale)&& component.equals(fileComponent)) { @@ -235,7 +235,7 @@ private JSONObject addNullBundle(String component, String locale, JSONArray resu JSONObject nullObj = new JSONObject(); nullObj.put("locale", locale); nullObj.put("component", component); - nullObj.put("messages", null); + // nullObj.put("messages", null); return nullObj; } diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductAction.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductAction.java index ca2e4cf55..fe581b0ce 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductAction.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.base; @@ -16,8 +16,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -153,7 +153,7 @@ private JSONObject getNUllBundle(String component, String locale) { JSONObject object = new JSONObject(); object.put("locale", locale); object.put("component", component); - object.put("messages", null); + // object.put("messages", null); return object; } @@ -163,10 +163,10 @@ private JSONObject getBundle(String component, String locale, TranslationDTO all JSONArray array = allTranslationDTO.getBundles(); @SuppressWarnings("unchecked") - Iterator objectIterator = array.iterator(); + Iterator objectIterator = array.iterator(); while (objectIterator.hasNext()) { - JSONObject object = objectIterator.next(); + JSONObject object = (JSONObject) objectIterator.next(); String fileLocale = (String) object.get(ConstantsKeys.lOCALE); String fileComponent = (String) object.get(ConstantsKeys.COMPONENT); if (locale.equals(fileLocale) && component.equals(fileComponent)) { @@ -203,7 +203,7 @@ public APIResponseDTO getPartialComTrans(String productName, for (String locale : reqLocales) { JSONObject jsonObj = getBundle(component, locale, allTranslationDTO); if (jsonObj != null) { - ja.add(jsonObj); + ja.put(jsonObj); } else { jsonNullList.add(getNUllBundle(component, locale)); } @@ -215,12 +215,12 @@ public APIResponseDTO getPartialComTrans(String productName, if (ja.isEmpty()) { throw new L3APIException(ConstantsMsg.TRANS_IS_NOT_FOUND); - } else if (ja.size() == (reqLocaleSize * reqComponentSite)) { + } else if (ja.toList().size() == (reqLocaleSize * reqComponentSite)) { resulttranslationDTO.setBundles(ja); return super.handleVersionFallbackResponse(oldVersion, version, resulttranslationDTO); } else { for (JSONObject jsonNullObj : jsonNullList) { - ja.add(jsonNullObj); + ja.put(jsonNullObj); } resulttranslationDTO.setBundles(ja); if (oldVersion.equals(version)) { diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductComponentAction.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductComponentAction.java index bac819c8f..cb9226b3a 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductComponentAction.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/base/TranslationProductComponentAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.base; @@ -14,7 +14,7 @@ import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import com.vmware.vip.common.constants.ConstantsKeys; @@ -138,7 +138,7 @@ public APIResponseDTO checkTranslationResult(String productName, String componen } } - ((ComponentMessagesDTO)o).setStatus(JSONObject.toJSONString(r)); + ((ComponentMessagesDTO)o).setStatus(new JSONObject(r).toString()); } if(!r.isEmpty() && !r.containsValue("0")) { return super.handleResponse(APIResponseStatus.TRANSLATION_READY, resp.getData()); diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationComponentAPI.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationComponentAPI.java index dc2635936..71848cd1f 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationComponentAPI.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationComponentAPI.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.translation; @@ -121,7 +121,7 @@ public APIResponseDTO getMultipleComponentsTranslation( translationDTO.setLocales(localeList); translationDTO.setPseudo(Boolean.parseBoolean(pseudo)); translationDTO =multipleComponentsService.getMultiComponentsTranslation(translationDTO); - if(translationDTO.getBundles() == null || translationDTO.getBundles().size() == 0) { + if(translationDTO.getBundles() == null || translationDTO.getBundles().toList().size() == 0) { throw new L3APIException(String.format(ConstantsMsg.TRANS_GET_FAILD, productName + ConstantsChar.BACKSLASH + version)); } return super.handleResponse(APIResponseStatus.OK, translationDTO); diff --git a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductComponentAPI.java b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductComponentAPI.java index 012c983e3..fef33e7a0 100644 --- a/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductComponentAPI.java +++ b/g11n-ws/modules/md-restful-api-i18n/src/main/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductComponentAPI.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.translation; @@ -68,7 +68,7 @@ public APIResponseDTO getMultipleComponentsTrans( HttpServletRequest req) throws Exception { APIResponseDTO resp = super.getMultipleComponentsTrans(productName, components, version, locales, pseudo, req); TranslationDTO translationDTO = (TranslationDTO) resp.getData(); - if (translationDTO.getBundles() == null || translationDTO.getBundles().size() == 0) { + if (translationDTO.getBundles() == null || translationDTO.getBundles().toList().size() == 0) { throw new L3APIException( String.format(ConstantsMsg.TRANS_GET_FAILD, productName + ConstantsChar.BACKSLASH + version)); } diff --git a/g11n-ws/modules/md-restful-synch/build.gradle b/g11n-ws/modules/md-restful-synch/build.gradle index d45a7c844..13adbdb69 100644 --- a/g11n-ws/modules/md-restful-synch/build.gradle +++ b/g11n-ws/modules/md-restful-synch/build.gradle @@ -18,7 +18,7 @@ dependencies { api project(":md-service-i18n-l3") compileOnly("org.apache.httpcomponents:httpclient:$httpclient") api("com.alibaba:fastjson:1.2.51") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } compileOnly("org.springdoc:springdoc-openapi-starter-webmvc-api:$springdocVersion") diff --git a/g11n-ws/modules/md-restful-synch/src/main/java/com/vmware/vip/messages/synch/service/SynchServiceImpl.java b/g11n-ws/modules/md-restful-synch/src/main/java/com/vmware/vip/messages/synch/service/SynchServiceImpl.java index c98d75c37..54df25f46 100644 --- a/g11n-ws/modules/md-restful-synch/src/main/java/com/vmware/vip/messages/synch/service/SynchServiceImpl.java +++ b/g11n-ws/modules/md-restful-synch/src/main/java/com/vmware/vip/messages/synch/service/SynchServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.messages.synch.service; @@ -11,7 +11,7 @@ import java.util.Map; import com.vmware.vip.common.cache.SingletonCache; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,7 +49,7 @@ public List updateTranslationBatch(List comps) { // TODO Auto-generated catch block logger.error(e.getMessage(), e); fileResult = null; - } catch (ParseException e) { + } catch (JSONException e) { // TODO Auto-generated catch block logger.error(e.getMessage(), e); fileResult = null; @@ -77,7 +77,7 @@ public List updateTranslationBatch(List comps) { public File updateTranslation(ComponentMessagesDTO componentMessagesDTO) - throws DataException, ParseException, VIPCacheException { + throws DataException, JSONException, VIPCacheException { String key = CachedKeyGetter.getOneCompnentCachedKey(componentMessagesDTO); File updateFile; ComponentMessagesDTO result = singletonCache.getCachedObject(CacheName.ONECOMPONENT, key, ComponentMessagesDTO.class); diff --git a/g11n-ws/modules/md-service-i18n-l2/build.gradle b/g11n-ws/modules/md-service-i18n-l2/build.gradle index cae1820d9..5cc00fa75 100644 --- a/g11n-ws/modules/md-service-i18n-l2/build.gradle +++ b/g11n-ws/modules/md-service-i18n-l2/build.gradle @@ -13,7 +13,7 @@ configurations { dependencies { api project(":vip-common") api project(":md-service-i18n-l3") - api("com.vmware.singleton:singleton-i18n-patterns-core:+") + api("com.vmware.singleton:singleton-i18n-patterns-core:0.5.17.+") api("com.ibm.icu:icu4j:$icu4jVersion") compileOnly("org.springframework:spring-context") compileOnly("org.springframework.boot:spring-boot-starter-data-jpa") diff --git a/g11n-ws/modules/md-service-i18n-l3/build.gradle b/g11n-ws/modules/md-service-i18n-l3/build.gradle index 7d5a549b5..d96db3e1a 100644 --- a/g11n-ws/modules/md-service-i18n-l3/build.gradle +++ b/g11n-ws/modules/md-service-i18n-l3/build.gradle @@ -30,7 +30,7 @@ dependencies { implementation('org.springframework.boot:spring-boot-autoconfigure') compileOnly("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") compileOnly("org.apache.commons:commons-lang3:$commonsLangVersion") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/MTService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/MTService.java index 77da14205..f4caec415 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/MTService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/MTService.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.mt; @@ -20,7 +20,7 @@ import com.vmware.vip.messages.data.dao.exception.MTException; import com.vmware.vip.messages.mt.MTConfig; import com.vmware.vip.messages.mt.MTFactory; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -126,7 +126,7 @@ public ComponentMessagesDTO getComponentMTTranslation( e.printStackTrace(); } } - } catch (ParseException | DataException | MTException + } catch (JSONException | DataException | MTException | VIPCacheException e) { LOGGER.error(e.getMessage(), e); diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/SourceToLatestCron.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/SourceToLatestCron.java index e54851b5f..63b8550f2 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/SourceToLatestCron.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/mt/SourceToLatestCron.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.mt; @@ -13,7 +13,7 @@ import com.vmware.vip.core.messages.service.singlecomponent.ComponentMessagesDTO; import com.vmware.vip.core.messages.service.singlecomponent.IOneComponentService; import com.vmware.vip.messages.data.dao.exception.DataException; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -62,7 +62,7 @@ public void syncBkSourceToRemote() { } } } - } catch (VIPCacheException | DataException | ParseException e1) { + } catch (VIPCacheException | DataException | JSONException e1) { // TODO Auto-generated catch block LOGGER.error(e1.getMessage(), e1); diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/multcomponent/MultComponentService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/multcomponent/MultComponentService.java index a84ee534d..8e1a6fae3 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/multcomponent/MultComponentService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/multcomponent/MultComponentService.java @@ -1,15 +1,14 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.multcomponent; import java.util.List; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +47,7 @@ public TranslationDTO getMultiComponentsTranslation(TranslationDTO translationDT TranslationDTO result = null; try { result = this.getTranslation(translationDTO); - } catch (ParseException e) { + } catch (JSONException e) { LOGGER.error(e.getMessage(), e); throw new L3APIException(ConstantsKeys.FATA_ERROR + "Parse error when get translation for " + translationDTO.getProductName() + ConstantsChar.BACKSLASH + translationDTO.getVersion(), e); @@ -70,7 +69,7 @@ public TranslationDTO getMultiComponentsTranslation(TranslationDTO translationDT } @SuppressWarnings({ "unchecked" }) - private TranslationDTO getTranslation(TranslationDTO translationDTO) throws ParseException, DataException { + private TranslationDTO getTranslation(TranslationDTO translationDTO) throws JSONException, DataException { List locales = translationDTO.getLocales(); List components = translationDTO.getComponents(); List bundles = multipleComponentsDao.get2JsonStrs(translationDTO.getProductName(), @@ -81,8 +80,8 @@ private TranslationDTO getTranslation(TranslationDTO translationDTO) throws Pars if (s.equalsIgnoreCase("")) { continue; } - JSONObject jo = (JSONObject) new JSONParser().parse(s); - ja.add(jo); + JSONObject jo = new JSONObject(s); + ja.put(jo); } translationDTO.setBundles(ja); return translationDTO; diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/IProductService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/IProductService.java index f336b62a9..9c2ca6e7b 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/IProductService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/IProductService.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.product; @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import com.vmware.vip.common.exceptions.VIPCacheException; import com.vmware.vip.common.i18n.dto.DropVersionDTO; @@ -41,7 +41,7 @@ public interface IProductService { public List updateBatchTranslation(List componentMessagesDTOList) throws L3APIException; public boolean updateTranslation(ComponentMessagesDTO componentMessagesDTO) - throws DataException, ParseException, VIPCacheException; + throws DataException, JSONException, VIPCacheException; /** * Get supported language list diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/ProductService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/ProductService.java index a9868f170..7a1ff00e9 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/ProductService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/product/ProductService.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.product; @@ -24,8 +24,8 @@ import com.vmware.vip.messages.data.dao.api.IOneComponentDao; import com.vmware.vip.messages.data.dao.api.IProductDao; import com.vmware.vip.messages.data.dao.exception.DataException; -import org.json.simple.JSONObject; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -158,7 +158,7 @@ public List updateBatchTranslation( + componentMessagesDTO.getProductName() + ConstantsChar.BACKSLASH + componentMessagesDTO.getVersion(), e); - } catch (ParseException e) { + } catch (JSONException e) { logger.error(e.getMessage(), e); throw new L3APIException(ConstantsKeys.FATA_ERROR + "Failed to parse content for " @@ -185,7 +185,7 @@ public List updateBatchTranslation( */ @SuppressWarnings("unchecked") public boolean updateTranslation(ComponentMessagesDTO componentMessagesDTO) - throws DataException, ParseException, VIPCacheException { + throws DataException, JSONException, VIPCacheException { String key = CachedKeyGetter .getOneCompnentCachedKey(componentMessagesDTO); boolean updateFlag = false; @@ -228,7 +228,7 @@ public boolean updateTranslation(ComponentMessagesDTO componentMessagesDTO) @SuppressWarnings({ "unchecked", "rawtypes" }) private ComponentMessagesDTO mergeComponentMessagesDTOWithFile( ComponentMessagesDTO componentMessagesDTO) throws DataException, - ParseException { + JSONException { ComponentMessagesDTO paramComponentMessagesDTO = new ComponentMessagesDTO(); BeanUtils.copyProperties(componentMessagesDTO, paramComponentMessagesDTO); @@ -237,7 +237,7 @@ private ComponentMessagesDTO mergeComponentMessagesDTOWithFile( result = this.getLinkedTranslation(paramComponentMessagesDTO); } catch (DataException e1) { logger.warn(e1.getMessage(), e1); - } catch (ParseException e2) { + } catch (JSONException e2) { logger.error(e2.getMessage(), e2); } if(!StringUtils.isEmpty(result)) { @@ -268,7 +268,7 @@ private ComponentMessagesDTO mergeComponentMessagesDTOWithFile( */ private ComponentMessagesDTO getLinkedTranslation( ComponentMessagesDTO componentMessagesDTO) throws DataException, - ParseException { + JSONException { SingleComponentDTO caseComponentMessagesDTO = new SingleComponentDTO(); String result = oneComponentDao.get2JsonStr( componentMessagesDTO.getProductName(), diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/IOneComponentService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/IOneComponentService.java index 6956d3d48..fca47e2b8 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/IOneComponentService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/IOneComponentService.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.singlecomponent; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import com.vmware.vip.core.messages.exception.L3APIException; import com.vmware.vip.messages.data.dao.exception.DataException; @@ -38,6 +38,6 @@ public ComponentMessagesDTO getComponentTranslation( * @throws DataException */ public ComponentMessagesDTO getTranslationFromDisk( - ComponentMessagesDTO componentMessagesDTO) throws ParseException, + ComponentMessagesDTO componentMessagesDTO) throws JSONException, DataException; } diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/OneComponentService.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/OneComponentService.java index 016463978..3a06504ae 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/OneComponentService.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/service/singlecomponent/OneComponentService.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.service.singlecomponent; @@ -19,7 +19,7 @@ import com.vmware.vip.core.messages.utils.PseudoMessagesUtils; import com.vmware.vip.messages.data.dao.api.IOneComponentDao; import com.vmware.vip.messages.data.dao.exception.DataException; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -103,7 +103,7 @@ public ComponentMessagesDTO getComponentTranslation( LOGGER.debug(msg); } } - } catch (ParseException e) { + } catch (JSONException e) { LOGGER.error(e.getMessage(), e); throw new L3APIException(ConstantsKeys.FATA_ERROR + "Parse json failed."); } catch (DataException e) { @@ -157,7 +157,7 @@ private String getFallbackLocale(String productName, String version, * @see com.vmware.vip.core.translation.dao.BaseComponentDao#getTranslation(Object) */ public ComponentMessagesDTO getTranslationFromDisk( - ComponentMessagesDTO componentMessagesDTO) throws ParseException, + ComponentMessagesDTO componentMessagesDTO) throws JSONException, DataException { String result = oneComponentDao.get2JsonStr( componentMessagesDTO.getProductName(), diff --git a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/utils/PseudoMessagesUtils.java b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/utils/PseudoMessagesUtils.java index 8db54e2ca..34a24af0d 100644 --- a/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/utils/PseudoMessagesUtils.java +++ b/g11n-ws/modules/md-service-i18n-l3/src/main/java/com/vmware/vip/core/messages/utils/PseudoMessagesUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.core.messages.utils; @@ -7,8 +7,8 @@ import java.util.Map; import org.apache.commons.lang3.SerializationUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.springframework.beans.BeanUtils; import org.springframework.util.StringUtils; @@ -60,7 +60,7 @@ public static TranslationDTO getPseudoMessages2( jo.put(ConstantsKeys.MESSAGES, JSONUtils.getOrderedMapForPseudo(messages, pseudoConfig.getExistSourceTag())); - pseudoList.add(jo); + pseudoList.put(jo); } } t.setBundles(pseudoList); diff --git a/g11n-ws/tools/tool-cldr-extractor/build.gradle b/g11n-ws/tools/tool-cldr-extractor/build.gradle index 2b72fc126..9172c1c45 100644 --- a/g11n-ws/tools/tool-cldr-extractor/build.gradle +++ b/g11n-ws/tools/tool-cldr-extractor/build.gradle @@ -1,4 +1,4 @@ -//Copyright 2019-2022 VMware, Inc. +//Copyright 2019-2025 VMware, Inc. //SPDX-License-Identifier: EPL-2.0 apply plugin: 'java' @@ -32,7 +32,7 @@ repositories { dependencies { implementation group: 'commons-collections', name: 'commons-collections', version: '3.2.2' - implementation('com.googlecode.json-simple:json-simple:1.1.1'){ + implementation('org.json:json:20250107'){ exclude group: 'junit' } implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.6.1' diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/CLDRUtils.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/CLDRUtils.java index 74e62387e..1e80c98f7 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/CLDRUtils.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/CLDRUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils; @@ -30,8 +30,8 @@ import com.vmware.i18n.common.OfficialStatusEnum; import com.vmware.i18n.utils.timezone.CldrTimeZoneUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/JSONUtil.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/JSONUtil.java index cbf16cf68..87448deef 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/JSONUtil.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/JSONUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils; @@ -11,11 +11,8 @@ import java.util.Map; import java.util.TreeMap; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.ContainerFactory; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONException; public class JSONUtil { diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/LocaleDataUtils.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/LocaleDataUtils.java index 9e2f7d75f..445b5faba 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/LocaleDataUtils.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/LocaleDataUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils; @@ -7,8 +7,8 @@ import java.io.File; import java.util.*; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/MiscUtils.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/MiscUtils.java index d5a8259c0..c567d4436 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/MiscUtils.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/MiscUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils; @@ -7,7 +7,7 @@ import com.vmware.i18n.cldr.CLDR; import com.vmware.i18n.common.CLDRConstants; import com.vmware.i18n.common.Constants; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/SupplementUtils.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/SupplementUtils.java index 4ee3af08e..ed79c1ec1 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/SupplementUtils.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/SupplementUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils; @@ -11,7 +11,7 @@ import java.util.Map; import com.vmware.i18n.common.Constants; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/timezone/CldrTimeZoneUtils.java b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/timezone/CldrTimeZoneUtils.java index e54e7708e..060c32904 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/timezone/CldrTimeZoneUtils.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/main/java/com/vmware/i18n/utils/timezone/CldrTimeZoneUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.i18n.utils.timezone; @@ -17,8 +17,8 @@ import java.util.TimeZone; import java.util.TreeMap; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/g11n-ws/tools/tool-cldr-extractor/src/test/java/com/vmware/test/i18n/I18nUtilTest.java b/g11n-ws/tools/tool-cldr-extractor/src/test/java/com/vmware/test/i18n/I18nUtilTest.java index be91eff2b..19e656440 100644 --- a/g11n-ws/tools/tool-cldr-extractor/src/test/java/com/vmware/test/i18n/I18nUtilTest.java +++ b/g11n-ws/tools/tool-cldr-extractor/src/test/java/com/vmware/test/i18n/I18nUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.test.i18n; @@ -10,8 +10,8 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.json.simple.JSONValue; -import org.json.simple.parser.ParseException; +import org.json.JSONException; +import org.json.JSONObject; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -62,7 +62,7 @@ public void testLocalesExtract() { for(int i=0;i genreJsonObject = null; - genreJsonObject = (Map) JSONValue.parseWithException(regions); + genreJsonObject = new JSONObject(regions).toMap(); Map territoriesObject = (Map) JSONValue.parseWithException(genreJsonObject.get("territories").toString()); if (languageArray[i].equals("zh")) { Assert.assertEquals("zh", genreJsonObject.get("language")); @@ -103,7 +103,7 @@ public void testLocalesExtract() { } } - } catch (ParseException e) { + } catch (JSONException e) { e.printStackTrace(); } } diff --git a/g11n-ws/tools/tool-trans-fetcher/build.gradle b/g11n-ws/tools/tool-trans-fetcher/build.gradle index c1c7595d8..813c9eb98 100644 --- a/g11n-ws/tools/tool-trans-fetcher/build.gradle +++ b/g11n-ws/tools/tool-trans-fetcher/build.gradle @@ -13,7 +13,7 @@ dependencies { implementation("commons-io:commons-io:$commonsIoVersion") implementation("org.apache.commons:commons-lang3:$commonsLangVersion") implementation project(":vip-common") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } diff --git a/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/ProToJSONConverter.java b/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/ProToJSONConverter.java index 2d3e69ad6..da0b8b9f1 100644 --- a/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/ProToJSONConverter.java +++ b/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/ProToJSONConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.fetcher.translation; @@ -7,7 +7,7 @@ import java.util.Enumeration; import java.util.Properties; -import org.json.simple.JSONObject; +import org.json.JSONObject; /** * Convert key/value pairs in properties file to JSON format @@ -26,7 +26,7 @@ public JSONObject getJSONFromProp(Properties pro){ Enumeration en = pro.keys(); while(en.hasMoreElements()) { Object key = en.nextElement(); - pairs.put(key, pro.get(key)); + pairs.put((String) key, pro.get(key)); } return pairs; } diff --git a/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/TranslationConverterMain.java b/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/TranslationConverterMain.java index 604c8309b..3578ed3b6 100644 --- a/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/TranslationConverterMain.java +++ b/g11n-ws/tools/tool-trans-fetcher/src/main/java/com/vmware/vip/fetcher/translation/TranslationConverterMain.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.fetcher.translation; @@ -10,8 +10,8 @@ import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsChar; import com.vmware.vip.common.exceptions.VIPResourceOperationException; @@ -114,7 +114,7 @@ public static void combinePropertiesToJSON() { JSONObject pairs = new ProToJSONConverter().getJSONFromProp(pro); bundle.put(locale, pairs); } - bundles.add(bundle); + bundles.put(bundle); } baseTranslationDTO.setBundles(bundles); singleComponentDTO.setComponent(""); diff --git a/g11n-ws/vip-common/build.gradle b/g11n-ws/vip-common/build.gradle index 48ab8af39..8a72af24c 100644 --- a/g11n-ws/vip-common/build.gradle +++ b/g11n-ws/vip-common/build.gradle @@ -12,7 +12,7 @@ dependencies { implementation("commons-io:commons-io:$commonsIoVersion") implementation("commons-codec:commons-codec:$commonsCodecVersion") implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } compileOnly("org.slf4j:slf4j-api:$slf4jVersion") diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/KeySourceCommentDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/KeySourceCommentDTO.java index 7ef3d9343..c5bfd8725 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/KeySourceCommentDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/KeySourceCommentDTO.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.dto; -import org.json.simple.JSONObject; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsKeys; @@ -57,7 +57,7 @@ public String toJSONString() { jo.put(ConstantsKeys.KEY, this.getKey()); jo.put(ConstantsKeys.COMMENT_FOR_SOURCE, this.getCommentForSource()); jo.put(ConstantsKeys.SOURCE_FORMAT, this.getSourceFormat()); - return jo.toJSONString(); + return jo.toString(); } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/MultiComponentsDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/MultiComponentsDTO.java index 89bdc763f..7cc68646e 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/MultiComponentsDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/MultiComponentsDTO.java @@ -1,15 +1,14 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.dto; import java.util.List; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.ParseException; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONException; import com.vmware.vip.common.constants.ConstantsKeys; import com.vmware.vip.common.exceptions.VIPAPIException; @@ -74,7 +73,7 @@ public String toJSONString() { jo.put(ConstantsKeys.lOCALES, this.getLocales()); jo.put(ConstantsKeys.COMPONENTS, this.getComponents()); jo.put(ConstantsKeys.BUNDLES, this.getBundles()); - return jo.toJSONString(); + return jo.toString(); } /* @@ -91,8 +90,8 @@ public String toJSONString() { public static MultiComponentsDTO getMultiComponentsDTO(String jsonStr) throws VIPAPIException { JSONObject genreJsonObject = null; try { - genreJsonObject = (JSONObject) JSONValue.parseWithException(jsonStr); - } catch (ParseException e) { + genreJsonObject = new JSONObject(jsonStr); + } catch (JSONException e) { throw new VIPAPIException("Parse string '" + jsonStr + "' failed."); } if (genreJsonObject == null) { @@ -104,7 +103,7 @@ public static MultiComponentsDTO getMultiComponentsDTO(String jsonStr) throws VI baseTranslationDTO.setVersion((String) genreJsonObject.get(ConstantsKeys.VERSION)); baseTranslationDTO.setLocales((List) genreJsonObject.get(ConstantsKeys.lOCALES)); baseTranslationDTO.setComponents((List) genreJsonObject.get(ConstantsKeys.COMPONENTS)); - baseTranslationDTO.setBundles((JSONArray) JSONValue.parse(bundleStr)); + baseTranslationDTO.setBundles(new JSONArray(bundleStr)); return baseTranslationDTO; } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/SingleComponentDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/SingleComponentDTO.java index 11fb110b1..d2b14c535 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/SingleComponentDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/SingleComponentDTO.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.dto; @@ -11,11 +11,8 @@ import java.util.List; import java.util.Map; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.ContainerFactory; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -97,7 +94,7 @@ public String toJSONString() { jo.put(ConstantsKeys.COMPONENT, this.getComponent()); jo.put(ConstantsKeys.lOCALE, this.getLocale()); jo.put(ConstantsKeys.BUNDLES, this.getMessages()); - return jo.toJSONString(); + return jo.toString(); } public String toString() { @@ -119,9 +116,9 @@ public String toPrettyString() throws JsonProcessingException { * @param jsonStr One JSON string can convert to a SingleComponentDTO object * @return SingleComponentDTO */ - public static SingleComponentDTO getSingleComponentDTO(String jsonStr) throws ParseException { + public static SingleComponentDTO getSingleComponentDTO(String jsonStr) throws JSONException { JSONObject genreJsonObject = null; - genreJsonObject = (JSONObject) JSONValue.parseWithException(jsonStr); + genreJsonObject = new JSONObject(jsonStr); if (genreJsonObject == null) { return null; } @@ -142,12 +139,10 @@ public static SingleComponentDTO getSingleComponentDTO(String jsonStr) throws Pa */ @SuppressWarnings("unchecked") public static SingleComponentDTO getSingleComponentDTOWithLinkedMessages(String jsonStr) - throws ParseException { - JSONParser parser = new JSONParser(); - ContainerFactory containerFactory = getContainerFactory(); + throws JSONException { Map messages = new LinkedHashMap(); Map bundle = null; - bundle = (Map) parser.parse(jsonStr, containerFactory); + bundle = (Map) (new JSONObject(jsonStr)).toMap(); if (bundle == null) { return null; } @@ -159,17 +154,4 @@ public static SingleComponentDTO getSingleComponentDTOWithLinkedMessages(String baseComponentMessagesDTO.setMessages(messages); return baseComponentMessagesDTO; } - - private static ContainerFactory getContainerFactory() { - ContainerFactory containerFactory = new ContainerFactory() { - public List creatArrayContainer() { - return new LinkedList(); - } - - public Map createObjectContainer() { - return new LinkedHashMap(); - } - }; - return containerFactory; - } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/StringBasedDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/StringBasedDTO.java index b1b52d85e..55846e6cd 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/StringBasedDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/dto/StringBasedDTO.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.dto; -import org.json.simple.JSONObject; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsKeys; import com.vmware.vip.common.utils.LocaleUtils; @@ -95,6 +95,6 @@ public String toJSONString() { jo.put(ConstantsKeys.TRANSLATION, this.getTranslation()); jo.put(ConstantsKeys.KEY, this.getKey()); jo.put(ConstantsKeys.COMPONENT, this.getComponent()); - return jo.toJSONString(); + return jo.toString(); } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/resourcefile/ResourceFileWritter.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/resourcefile/ResourceFileWritter.java index 02f04a5b7..c7ed07458 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/resourcefile/ResourceFileWritter.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/resourcefile/ResourceFileWritter.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.resourcefile; @@ -16,9 +16,8 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; -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; @@ -66,15 +65,14 @@ public static void writeStrToMultiJSONFiles(String remoteRusult) } catch (VIPAPIException e1) { e1.printStackTrace(); } - List bundles = baseTranslationDTO.getBundles(); + List bundles = baseTranslationDTO.getBundles().toList(); Iterator it = bundles.iterator(); SingleComponentDTO singleComponentDTO = new SingleComponentDTO(); singleComponentDTO.setProductName(baseTranslationDTO.getProductName()); singleComponentDTO.setVersion(baseTranslationDTO.getVersion()); while (it.hasNext()) { try { - JSONObject bundleObj = (JSONObject) JSONValue - .parseWithException(it.next().toString()); + JSONObject bundleObj = new JSONObject(it.next().toString()); String component = (String) bundleObj .get(ConstantsKeys.COMPONENT); singleComponentDTO.setComponent(component); @@ -93,7 +91,7 @@ public static void writeStrToMultiJSONFiles(String remoteRusult) .getLocalizedJSONFileName(tLocale), singleComponentDTO); } - } catch (ParseException e) { + } catch (JSONException e) { throw new VIPResourceOperationException("Parse '" + it.next().toString() + "' failed."); } @@ -133,7 +131,7 @@ public static void writeJSONObjectToJSONFile(String jsonFileName, outputStream = new FileOutputStream(f); write = new OutputStreamWriter(outputStream, ConstantsUnicode.UTF8); writer = new BufferedWriter(write); - writer.write(json.toJSONString()); + writer.write(json.toString()); } catch (IOException e) { throw new VIPResourceOperationException("Write file '" + jsonFileName + "' failed."); diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/status/Response.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/status/Response.java index 55d5eff6f..cf071d1f8 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/status/Response.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/status/Response.java @@ -1,12 +1,12 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.status; import java.io.Serializable; -import org.json.simple.JSONObject; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsKeys; @@ -68,7 +68,7 @@ public String toJSONString() { JSONObject jo = new JSONObject(); jo.put(ConstantsKeys.CODE, this.getCode()); jo.put(ConstantsKeys.MESSAGE, this.getMessage()); - return jo.toJSONString(); + return jo.toString(); } @Override diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/BundlesGenerator.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/BundlesGenerator.java index 4101c4a1a..7b3ebd257 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/BundlesGenerator.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/BundlesGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.translation; @@ -14,9 +14,8 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; -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 com.vmware.vip.common.constants.ConstantsChar; import com.vmware.vip.common.constants.ConstantsFile; @@ -44,13 +43,12 @@ public class BundlesGenerator { */ public void handleRemoteRusult(String remoteRusult) { MultiComponentsDTO baseTranslationDTO = TranslationUtil.getBaseTranslationDTO(remoteRusult); - List bundles = baseTranslationDTO.getBundles(); + List bundles = baseTranslationDTO.getBundles().toList(); Iterator it = bundles.iterator(); String jsonFilePathDir = this.getJsonPath(baseTranslationDTO); while (it.hasNext()) { try { - JSONObject bundleObj = (JSONObject) JSONValue.parseWithException(it.next() - .toString()); + JSONObject bundleObj = new JSONObject(it.next().toString()); String component = (String) bundleObj.get(ConstantsKeys.COMPONENT); List locales = baseTranslationDTO.getLocales(); String componentPath = jsonFilePathDir + ConstantsChar.BACKSLASH + component; @@ -62,7 +60,7 @@ public void handleRemoteRusult(String remoteRusult) { + TranslationUtil.genernateJsonLocalizedFileName(tLocale), component, tLocale, (JSONObject) bundleObj.get(tLocale)); } - } catch (ParseException e) { + } catch (JSONException e) { e.printStackTrace(); } } @@ -108,7 +106,7 @@ public void writeToBundle(String jsonFileName, String component, String locale, out = new FileOutputStream(f); write = new OutputStreamWriter(out, ConstantsUnicode.UTF8); writer = new BufferedWriter(write); - writer.write(json.toJSONString()); + writer.write(json.toString()); } catch (IOException e) { e.printStackTrace(); } finally { diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/TranslationUtil.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/TranslationUtil.java index 99c6fc561..797c9ac3d 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/TranslationUtil.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/i18n/translation/TranslationUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.i18n.translation; @@ -7,10 +7,9 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.ParseException; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONException; import com.vmware.vip.common.constants.ConstantsChar; import com.vmware.vip.common.constants.ConstantsFile; @@ -127,8 +126,8 @@ public static String genernatePropertiesLocalizedFileName(String locale) { public static MultiComponentsDTO getBaseTranslationDTO(String jsonStr) { JSONObject genreJsonObject = null; try { - genreJsonObject = (JSONObject) JSONValue.parseWithException(jsonStr); - } catch (ParseException e) { + genreJsonObject = new JSONObject(jsonStr); + } catch (JSONException e) { e.printStackTrace(); } if (genreJsonObject == null) { @@ -140,7 +139,7 @@ public static MultiComponentsDTO getBaseTranslationDTO(String jsonStr) { baseTranslationDTO.setVersion((String) genreJsonObject.get(ConstantsKeys.VERSION)); baseTranslationDTO.setLocales((List) genreJsonObject.get(ConstantsKeys.lOCALES)); baseTranslationDTO.setComponents((List) genreJsonObject.get(ConstantsKeys.COMPONENTS)); - baseTranslationDTO.setBundles((JSONArray)JSONValue.parse(bundleStr)); + baseTranslationDTO.setBundles(new JSONArray(bundleStr)); return baseTranslationDTO; } @@ -153,8 +152,8 @@ public static MultiComponentsDTO getBaseTranslationDTO(String jsonStr) { public static SingleComponentDTO getBaseComponentMessagesDTO(String jsonStr) { JSONObject genreJsonObject = null; try { - genreJsonObject = (JSONObject) JSONValue.parseWithException(jsonStr); - } catch (ParseException e) { + genreJsonObject = new JSONObject(jsonStr); + } catch (JSONException e) { e.printStackTrace(); } if (genreJsonObject == null) { @@ -166,8 +165,7 @@ public static SingleComponentDTO getBaseComponentMessagesDTO(String jsonStr) { baseComponentMessagesDTO .setComponent((String) genreJsonObject.get(ConstantsKeys.COMPONENT)); baseComponentMessagesDTO.setLocale((String) genreJsonObject.get(ConstantsKeys.lOCALE)); - baseComponentMessagesDTO.setMessages(JSONValue.toJSONString(genreJsonObject - .get(ConstantsKeys.MESSAGES))); + baseComponentMessagesDTO.setMessages(((JSONObject) genreJsonObject.get(ConstantsKeys.MESSAGES)).toString()); return baseComponentMessagesDTO; } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentBaseDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentBaseDTO.java index 99fda594e..eeaa1bb8b 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentBaseDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentBaseDTO.java @@ -1,12 +1,12 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.l10n.source.dto; import java.io.Serializable; -import org.json.simple.JSONObject; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsKeys; import com.vmware.vip.common.utils.LocaleUtils; @@ -46,6 +46,6 @@ public String toJSONString() { jo.put(ConstantsKeys.PRODUCTNAME, this.getProductName()); jo.put(ConstantsKeys.VERSION, this.getVersion()); jo.put(ConstantsKeys.COMPONENT, this.getComponent()); - return jo.toJSONString(); + return jo.toString(); } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentSourceDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentSourceDTO.java index e5acbe3db..f884d78a4 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentSourceDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/ComponentSourceDTO.java @@ -1,13 +1,15 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.l10n.source.dto; import java.io.Serializable; -import org.json.simple.JSONObject; +import org.json.JSONObject; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.vmware.vip.common.constants.ConstantsKeys; /** @@ -29,6 +31,8 @@ public class ComponentSourceDTO extends ComponentBaseDTO implements /* put source format key-value pairs to this messages */ private JSONObject sourceFormats = new JSONObject(); + @JsonSerialize(using = JSONObjectSerializer.class) + @JsonDeserialize(using = JSONObjectDeserializer.class) public JSONObject getMessages() { return messages; } @@ -38,6 +42,8 @@ public void setMessages(String key, String message) { this.messages.put(key, message); } + @JsonSerialize(using = JSONObjectSerializer.class) + @JsonDeserialize(using = JSONObjectDeserializer.class) public JSONObject getComments() { return comments; } @@ -47,6 +53,8 @@ public void setComments(String key, String comment) { this.comments.put(key, comment); } + @JsonSerialize(using = JSONObjectSerializer.class) + @JsonDeserialize(using = JSONObjectDeserializer.class) public JSONObject getSourceFormats() { return sourceFormats; } @@ -61,9 +69,9 @@ public String toJSONString() { JSONObject jo = new JSONObject(); jo.put(ConstantsKeys.PRODUCTNAME, this.getProductName()); jo.put(ConstantsKeys.VERSION, this.getVersion()); - jo.put(ConstantsKeys.MESSAGES, this.getMessages().toJSONString()); + jo.put(ConstantsKeys.MESSAGES, this.getMessages().toString()); jo.put(ConstantsKeys.COMPONENT, this.getComponent()); - return jo.toJSONString(); + return jo.toString(); } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectDeserializer.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectDeserializer.java new file mode 100644 index 000000000..841e9bf9b --- /dev/null +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectDeserializer.java @@ -0,0 +1,60 @@ +/* + * Copyright 2019-2025 VMware, Inc. + * SPDX-License-Identifier: EPL-2.0 + */ +package com.vmware.vip.common.l10n.source.dto; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import org.json.JSONObject; +import java.io.IOException; +import java.util.Iterator; + +public class JSONObjectDeserializer extends JsonDeserializer { + + @Override + public JSONObject deserialize(JsonParser parser, DeserializationContext context) throws IOException { + JsonNode node = parser.getCodec().readTree(parser); + JSONObject jsonObject = new JSONObject(); + + if (node.isObject()) { + Iterator fieldNames = node.fieldNames(); + while (fieldNames.hasNext()) { + String fieldName = fieldNames.next(); + JsonNode valueNode = node.get(fieldName); + jsonObject.put(fieldName, convertJsonNode(valueNode)); + } + } + return jsonObject; + } + + private Object convertJsonNode(JsonNode node) { + if (node.isTextual()) { + return node.asText(); + } else if (node.isNumber()) { + return node.numberValue(); + } else if (node.isBoolean()) { + return node.asBoolean(); + } else if (node.isObject()) { + JSONObject jsonObject = new JSONObject(); + Iterator fieldNames = node.fieldNames(); + while (fieldNames.hasNext()) { + String fieldName = fieldNames.next(); + JsonNode valueNode = node.get(fieldName); + jsonObject.put(fieldName, convertJsonNode(valueNode)); + } + return jsonObject; + } else if (node.isArray()) { + org.json.JSONArray jsonArray = new org.json.JSONArray(); + for (JsonNode arrayElement : node) { + jsonArray.put(convertJsonNode(arrayElement)); + } + return jsonArray; + } else if (node.isNull()) { + return null; + } + return null; + } +} diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectSerializer.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectSerializer.java new file mode 100644 index 000000000..f73e6acdf --- /dev/null +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/JSONObjectSerializer.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2025 VMware, Inc. + * SPDX-License-Identifier: EPL-2.0 + */ +package com.vmware.vip.common.l10n.source.dto; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.util.Iterator; +import java.io.IOException; + +import org.json.JSONObject; + +public class JSONObjectSerializer extends JsonSerializer { + + @Override + public void serialize(JSONObject jsonObject, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + System.out.println("jsonObject=" + jsonObject.toString()); + //jsonGenerator.writeString(jsonObject.toString()); + jsonGenerator.writeStartObject(); + Iterator keys = jsonObject.keys(); + while (keys.hasNext()) { + String key = keys.next(); + Object value = jsonObject.get(key); + jsonGenerator.writeFieldName(key); + serializerProvider.defaultSerializeValue(value, jsonGenerator); + } + jsonGenerator.writeEndObject(); + } +} \ No newline at end of file diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/StringSourceDTO.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/StringSourceDTO.java index 759989c50..24a5d7da6 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/StringSourceDTO.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/l10n/source/dto/StringSourceDTO.java @@ -1,12 +1,12 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.l10n.source.dto; import java.io.Serializable; -import org.json.simple.JSONObject; +import org.json.JSONObject; import com.vmware.vip.common.constants.ConstantsKeys; @@ -70,6 +70,6 @@ public String toJSONString() { jo.put(ConstantsKeys.SOURCE, this.getSource()); jo.put(ConstantsKeys.lOCALE, this.getLocale()); jo.put(ConstantsKeys.COMPONENT, this.getComponent()); - return jo.toJSONString(); + return jo.toString(); } } diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/JSONUtils.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/JSONUtils.java index 7d4ce64b6..62b19f3c6 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/JSONUtils.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/JSONUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.utils; @@ -19,11 +19,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.json.simple.parser.ContainerFactory; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,8 +47,8 @@ public class JSONUtils { public static JSONObject string2JSON(String jsonStr) { JSONObject genreJsonObject = null; try { - genreJsonObject = (JSONObject) JSONValue.parseWithException(jsonStr); - } catch (ParseException e) { + genreJsonObject = new JSONObject(jsonStr); + } catch (JSONException e) { logger.error(e.getMessage(), e); } return genreJsonObject; @@ -68,8 +65,8 @@ public static JSONObject string2JSON(String jsonStr) { public static Map string2Map(String jsonStr) { Map genreJsonObject = null; try { - genreJsonObject = (Map) JSONValue.parseWithException(jsonStr); - } catch (ParseException e) { + genreJsonObject = new JSONObject(jsonStr).toMap(); + } catch (JSONException e) { logger.error(e.getMessage(), e); } return genreJsonObject; @@ -120,7 +117,7 @@ public static JSONObject getJSONObjectForPseudo(Map map, String pseudoTag) { Set set = map.keySet(); Iterator it = set.iterator(); while (it.hasNext()) { - Object key = it.next(); + String key = (String) it.next(); jsonObj.put(key, pseudoTag + map.get(key) + pseudoTag); } } @@ -135,13 +132,11 @@ public static JSONObject getJSONObjectForPseudo(Map map, String pseudoTag) { */ @SuppressWarnings("unchecked") public static Map getMapFromJson(String json) { - JSONParser parser = new JSONParser(); - ContainerFactory containerFactory = getContainerFactory(); Map result = null; if (!StringUtils.isEmpty(json)) { try { - result = (Map) parser.parse(json, containerFactory); - } catch (ParseException e) { + result = new JSONObject(json).toMap(); + } catch (JSONException e) { logger.error(e.getMessage(), e); } } @@ -188,19 +183,6 @@ public static void writeMapToJsonFile(String filePath, Map map) } } - private static ContainerFactory getContainerFactory() { - ContainerFactory containerFactory = new ContainerFactory() { - public List creatArrayContainer() { - return new LinkedList(); - } - - public Map createObjectContainer() { - return new LinkedHashMap(); - } - }; - return containerFactory; - } - /** * Read a JSON file in a jar * diff --git a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/SortJSONUtils.java b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/SortJSONUtils.java index c5585d781..f9d91e34f 100644 --- a/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/SortJSONUtils.java +++ b/g11n-ws/vip-common/src/main/java/com/vmware/vip/common/utils/SortJSONUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.common.utils; @@ -22,6 +22,7 @@ import com.vmware.vip.common.i18n.dto.SingleComponentDTO; import com.vmware.vip.common.l10n.source.util.IOUtil; import com.vmware.vip.common.l10n.source.util.PathUtil; +import org.json.JSONObject; public class SortJSONUtils { @@ -50,7 +51,10 @@ public static void writeJSONObjectToJSONFile(String jsonFileName, Map json = new HashMap(); json.put(ConstantsKeys.COMPONENT, singleComponentDTO.getComponent()); json.put(ConstantsKeys.lOCALE, singleComponentDTO.getLocale()); - json.put(ConstantsKeys.MESSAGES, singleComponentDTO.getMessages()); + json.put(ConstantsKeys.MESSAGES, singleComponentDTO.getMessages()); + if (singleComponentDTO.getMessages() instanceof JSONObject) { + json.put(ConstantsKeys.MESSAGES, ((JSONObject) singleComponentDTO.getMessages()).toMap()); + } OutputStreamWriter write = null; BufferedWriter writer = null; FileOutputStream outputStream = null; diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java index b14b5d971..c59750dcc 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java @@ -1,10 +1,11 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.common; -import org.json.simple.JSONObject; +import org.json.JSONObject; +import org.json.JSONException; import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.WebApplicationContext; @@ -14,16 +15,28 @@ public class CacheUtil { public static void cacheKey(WebApplicationContext webApplicationContext,String result) { JSONObject jsonObj=JSONUtils.string2JSON(result); - JSONObject data=(JSONObject) jsonObj.get("data"); - String key=(String) data.get("key"); + JSONObject data= null; + String key = null; + try { + data=(JSONObject) jsonObj.get("data"); + key=(String) data.get("key"); + } catch (JSONException e) { + + } MockServletContext application = (MockServletContext) webApplicationContext.getServletContext(); application.setAttribute("key", key); } public static void cacheSessionAndToken(WebApplicationContext webApplicationContext,String authenticationResult) { JSONObject jsonObj=JSONUtils.string2JSON(authenticationResult); - String sessionID=(String) jsonObj.get("sessionID"); - String token=(String) jsonObj.get("token"); + String sessionID = null; + String token = null; + try { + sessionID=(String) jsonObj.get("sessionID"); + token=(String) jsonObj.get("token"); + } catch (JSONException e) { + + } MockServletContext application = (MockServletContext) webApplicationContext.getServletContext(); application.setAttribute("sessionID", sessionID); application.setAttribute("token", token); diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java index ef873512b..2764e6c87 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.common; @@ -7,9 +7,8 @@ import java.io.IOException; 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 com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -24,8 +23,7 @@ public static Object getMessagesFromResponse(String responseStr, String node) { if (responseStr == null || responseStr.equalsIgnoreCase("")) return msgObject; try { - JSONObject responseObj = (JSONObject) JSONValue - .parseWithException(responseStr); + JSONObject responseObj = new JSONObject(responseStr); if (responseObj != null) { JSONObject dataObj = (JSONObject) responseObj .get(ConstantsForTest.DATA); @@ -33,7 +31,7 @@ public static Object getMessagesFromResponse(String responseStr, String node) { msgObject = dataObj.get(node); } } - } catch (ParseException e) { + } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductAPITest.java index 2415d909d..9df176bcf 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationProductAPITest.java @@ -1,12 +1,12 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.translation; import java.util.List; -import org.json.simple.JSONArray; +import org.json.JSONArray; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java index 29dc4b54a..549604630 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.translation; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -37,7 +37,7 @@ public void testCreateSource() throws Exception{ JSONObject requestBody=new JSONObject(); requestBody.put("source", "For more information about EVC modes and EVC modes supported in an ESX release, please refer to VMware KB 1003212"); String responseStr=RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.POST, - ConstantsForTest.CreateSourceAPIURI,requestBody.toJSONString()); + ConstantsForTest.CreateSourceAPIURI,requestBody.toString()); int businessCode=ResponseUtil.getResponseCode(responseStr); Assert.assertTrue(businessCode==200); } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java index c654c57b6..c4f701b02 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.List; import org.junit.Assert; @@ -45,7 +45,7 @@ public void authentication() throws Exception { @Test public void testRegionListAPI() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, REGION_LIST_API_URI); - List> list = (List>) JSONUtils.getMapFromJson(json).get("data"); + List> list = (List>) JSONUtils.getMapFromJson(json).get("data"); for (int i = 0; i < list.size(); i++) { Assert.assertNotNull(list.get(i).get("language")); Assert.assertNotNull(list.get(i).get("territories")); diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/combine/TranslationWithPatternTest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/combine/TranslationWithPatternTest.java index 27120cdf7..4ba50e939 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/combine/TranslationWithPatternTest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/combine/TranslationWithPatternTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.combine; @@ -91,8 +91,8 @@ public void testTranslationWithPatternWithoutRegion() throws Exception { logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -104,8 +104,8 @@ public void testTranslationWithPatternRegion() throws Exception { logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -120,8 +120,8 @@ public void testTranslationWithPatternWithoutRegionGet() throws Exception { logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -133,8 +133,8 @@ public void testTranslationWithPatternRegionGet() throws Exception { logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -145,8 +145,8 @@ public void testTranslationWithPatternRegionVersionFallback() throws Exception { logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @Test @@ -157,8 +157,8 @@ public void testTranslationWithPatternRegionGetVersionFallback() throws Exceptio logger.info(responseStr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(responseStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/formatting/pattern/FormattingPatternAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/formatting/pattern/FormattingPatternAPITest.java index becec80b0..8f201ba1e 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/formatting/pattern/FormattingPatternAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/formatting/pattern/FormattingPatternAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.formatting.pattern; @@ -61,7 +61,7 @@ public void testGetI18nPattern() throws Exception { .toString(); json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, url); Map respMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - Assert.assertEquals(400L, respMap.get("code")); + Assert.assertEquals(400, respMap.get("code")); //Test with valid 'scope' and 'scopeFilter' parameter url = new StringBuilder( @@ -71,7 +71,7 @@ public void testGetI18nPattern() throws Exception { .toString(); json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, url); respMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - Assert.assertEquals(200L, respMap.get("code")); + Assert.assertEquals(200, respMap.get("code")); //Test with valid 'scope' and invalid 'scopeFilter' parameter url = new StringBuilder( @@ -81,7 +81,7 @@ public void testGetI18nPattern() throws Exception { .toString(); json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, url); respMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - Assert.assertEquals(200L, respMap.get("code")); + Assert.assertEquals(200, respMap.get("code")); } @SuppressWarnings("unchecked") @@ -114,7 +114,7 @@ public void testGetI18nPatternWithLanguageAndRegion() throws Exception { .toString(); json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, url); Map respMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - Assert.assertEquals(200L, respMap.get("code")); + Assert.assertEquals(200, respMap.get("code")); } } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java index 2064ecfe9..3f8151f81 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ @@ -53,8 +53,8 @@ public void testCountryFlag1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagDefaultSucc); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -64,8 +64,8 @@ public void testCountryFlag2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagScaleSucc); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -75,8 +75,8 @@ public void testCountryFlag3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagRegionErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } @@ -86,8 +86,8 @@ public void testCountryFlag4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET,countryFlagScaleErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } @@ -108,8 +108,8 @@ public void testCountryFlag6() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET,countryFlagIMageTypeErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java index a9b4738bb..748a27da8 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.translation; @@ -141,8 +141,8 @@ public void testMultiComponents1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -159,8 +159,8 @@ public void testMultiComponents2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } /** @@ -172,8 +172,8 @@ public void testMultiComponents3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI3); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } /** @@ -185,8 +185,8 @@ public void testMultiComponents4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI4); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==404L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==404); } @Test @@ -194,8 +194,8 @@ public void testMultiComponents5() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI5); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -203,16 +203,16 @@ public void testMultiComponents6() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI6); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test public void testMultiComponents7() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multComponentTranslationAPIURI7); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } @Test @@ -220,8 +220,8 @@ public void testSingleComponent() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, singleComponentTranslationAPIURI); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -234,8 +234,8 @@ public void testVersionFallbackMultiComponents1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionFallbackMultComponentTranslationAPIURI1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @Test @@ -243,8 +243,8 @@ public void testVersionFallbackSingleComponent() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionFallbackSingleComponentTranslationAPIURI); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @@ -253,8 +253,8 @@ public void testVersionSupportLanguageList() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionFallbackSupportLanguageList); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @@ -263,8 +263,8 @@ public void testVersionComponentList() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionFallbackComponentlist); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @@ -273,8 +273,8 @@ public void testVersionLocaleList() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionFallbackLocalelist); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==604L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==604); } @@ -283,8 +283,8 @@ public void testVersionList() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionList); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -292,9 +292,9 @@ public void testVersionListNoProduct() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionListNoProduct); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); + int code = (int) dataMap.get("code"); - Assert.assertTrue(code==404L); + Assert.assertTrue(code==404); } @Test @@ -302,9 +302,9 @@ public void testVersionListIsNull() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, versionListNull); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); + int code = (int) dataMap.get("code"); - Assert.assertTrue(code==200L); + Assert.assertTrue(code==200); } diff --git a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java index 393356c9c..d8075e8bd 100644 --- a/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java +++ b/g11n-ws/vip-manager-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.translation; @@ -68,8 +68,8 @@ public void testGetKeysTranslation1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -78,8 +78,8 @@ public void testGetKeysTranslation2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } @Test @@ -87,8 +87,8 @@ public void testGetKeysTranslation3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl3); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==404L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==404); } @@ -97,8 +97,8 @@ public void testGetKeysTranslation4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl4); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -106,8 +106,8 @@ public void testGetTranslationByGetTest1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, keyGetUrl1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -115,7 +115,7 @@ public void testGetTranslationByGetTest2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, keyGetUrl2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } } diff --git a/g11n-ws/vip-manager-l10n/build.gradle b/g11n-ws/vip-manager-l10n/build.gradle index b586fad5b..6bd07f28c 100644 --- a/g11n-ws/vip-manager-l10n/build.gradle +++ b/g11n-ws/vip-manager-l10n/build.gradle @@ -26,7 +26,7 @@ dependencies { // implementation("org.apache.commons:commons-lang3:$commonsLangVersion") implementation("commons-io:commons-io:$commonsIoVersion") // implementation("commons-codec:commons-codec:$commonsCodecVersion") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/controller/SourceController.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/controller/SourceController.java index 105970b21..ec1c40795 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/controller/SourceController.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/controller/SourceController.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.source.controller; @@ -12,8 +12,7 @@ import com.vmware.vip.common.utils.SourceFormatUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONValue; +import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -122,7 +121,7 @@ public SourceAPIResponseDTO postSourceByKey( JSONArray listKSC = null; if (ConstantsKeys.JSON_KEYSET.equalsIgnoreCase(key) && sourceStr.startsWith("[") && sourceStr.endsWith("]")) { - listKSC = (JSONArray) JSONValue.parseWithException(sourceStr); + listKSC = new JSONArray(sourceStr); ObjectMapper objectMapper = new ObjectMapper(); for (Object kscObj : listKSC) { final KeySourceCommentDTO kscDTO = objectMapper.readValue( diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/RemoteSyncServicempl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/RemoteSyncServicempl.java index 997df7def..a60d4bfad 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/RemoteSyncServicempl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/RemoteSyncServicempl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.source.service.impl; @@ -9,7 +9,7 @@ import com.vmware.l10n.source.service.SourceService; import com.vmware.l10n.utils.MapUtil; import com.vmware.vip.common.l10n.source.dto.ComponentMessagesDTO; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -83,7 +83,7 @@ public void send(ComponentSourceDTO componentSourceDTO, String remoteURL) componentSourceDTO.getComments()); requestParam.put(ConstantsKeys.CONTENT_TYPES, componentSourceDTO.getSourceFormats()); - pushFlag = sendToRemote(url.toString(), requestParam); + pushFlag = sendToRemote(url.toString(), requestParam.toMap()); } if (!pushFlag) { throw new L10nAPIException("Error occur when send to remote [" diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SourceServiceImpl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SourceServiceImpl.java index 3fd146ec7..af15c835d 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SourceServiceImpl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SourceServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.source.service.impl; @@ -109,7 +109,7 @@ private boolean mergeSource2Map() { @SuppressWarnings("unchecked") private void updateStringSource(ComponentSourceDTO comp, String key, String source, String comment, String sourceFormat) { - MapUtil.updateKeyValue(comp.getMessages(), key, source); + MapUtil.updateKeyValue(comp.getMessages().toMap(), key, source); if (!StringUtils.isEmpty(comment)) { comp.setComments(key, comment); } @@ -129,6 +129,7 @@ private void addNewStringSource(StringSourceDTO strDTO, String catcheKey, Stri if (!StringUtils.isEmpty(sourceFormat)) { comp.setSourceFormats(key, sourceFormat); } + System.out.println("comp.message=" + comp.getMessages().toString()); PREPARE_MAP.put(catcheKey, comp); } diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncI18nSourceServiceImpl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncI18nSourceServiceImpl.java index 6af05459c..b7e8d9d1c 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncI18nSourceServiceImpl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncI18nSourceServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.source.service.impl; @@ -126,7 +126,7 @@ private void sendData2RemoteVIP(ComponentSourceDTO cachedComDTO) throws VIPHttpE String locale = ConstantsKeys.LATEST; String jsonStr = "{\"data\":{\"productName\": \"" + cachedComDTO.getProductName() + "\",\"pseudo\": false,\"translation\": [{\"component\": \"" + cachedComDTO.getComponent() - + "\",\"locale\": \"" + locale + "\",\"messages\": " + cachedComDTO.getMessages().toJSONString() + + "\",\"locale\": \"" + locale + "\",\"messages\": " + cachedComDTO.getMessages().toString() + "}],\"version\": \"" + cachedComDTO.getVersion() + "\"},\"requester\": \"" + ConstantsKeys.VL10N + "\"}"; Map header = new HashMap(); diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncLocalBundleServiceImpl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncLocalBundleServiceImpl.java index f4d543937..e32dae786 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncLocalBundleServiceImpl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/source/service/impl/SyncLocalBundleServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.source.service.impl; @@ -80,12 +80,12 @@ private void processSendFilePath(String basePath, File source) throws IOExceptio @Override public synchronized void mergeSourceToLocalBundle() { - LOGGER.debug("--Synchronize the updated source to local--"); + LOGGER.info("--Synchronize the updated source to local--"); List queueFiles = DiskQueueUtils.listSourceQueueFile(basePath); if (queueFiles == null) { return; } - LOGGER.debug("the source cache file size---{}", queueFiles.size()); + LOGGER.info("the source cache file size---{}", queueFiles.size()); for (File quefile : queueFiles) { try { Map mapObj = DiskQueueUtils.getQueueFile2Obj(quefile); diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/LocalSingleComponentDaoImpl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/LocalSingleComponentDaoImpl.java index 6ddc03156..04ca4629e 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/LocalSingleComponentDaoImpl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/LocalSingleComponentDaoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.translation.dao.impl; @@ -9,7 +9,7 @@ import java.util.Map; import org.apache.commons.io.FileUtils; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -95,7 +95,7 @@ public ComponentMessagesDTO getTranslationFromFile(ComponentMessagesDTO componen caseComponentMessagesDTO.setVersion(componentMessagesDTO.getVersion()); caseComponentMessagesDTO.setStatus(componentMessagesDTO.getStatus()); - } catch (ParseException e){ + } catch (JSONException e){ throw new L10nAPIException("Parse json failed.", e); } ComponentMessagesDTO msgDTO = new ComponentMessagesDTO(); diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/S3SingleComponentDaoImpl.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/S3SingleComponentDaoImpl.java index 4a1b985c0..1ff58e51a 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/S3SingleComponentDaoImpl.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/translation/dao/impl/S3SingleComponentDaoImpl.java @@ -1,4 +1,4 @@ -//Copyright 2019-2023 VMware, Inc. +//Copyright 2019-2025 VMware, Inc. //SPDX-License-Identifier: EPL-2.0 package com.vmware.l10n.translation.dao.impl; @@ -6,7 +6,7 @@ import jakarta.annotation.PostConstruct; -import org.json.simple.parser.ParseException; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -86,7 +86,7 @@ public ComponentMessagesDTO getTranslationFromFile(ComponentMessagesDTO componen caseComponentMessagesDTO.setProductName(componentMessagesDTO.getProductName()); caseComponentMessagesDTO.setVersion(componentMessagesDTO.getVersion()); caseComponentMessagesDTO.setStatus(componentMessagesDTO.getStatus()); - } catch (ParseException e) { + } catch (JSONException e) { throw new L10nAPIException("Parsing json failed.", e); } diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/DiskQueueUtils.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/DiskQueueUtils.java index 0ff3c90da..7ac37101a 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/DiskQueueUtils.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/DiskQueueUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.utils; @@ -80,6 +80,7 @@ private static File createJsonFile(String fileDir, Object obj, int sourceSize) t if(file.exists()) { String resultFileName = tempFileName.replace("tmp_", SourceStr); + System.out.println("resultFileName=" + resultFileName); File resultFile = new File(resultFileName); if(file.renameTo(resultFile)) { return resultFile; @@ -137,9 +138,10 @@ public boolean accept(File dir, String name) { */ public static Map getQueueFile2Obj(File file) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - + System.out.println("file=" + file); @SuppressWarnings("unchecked") Map resultMap = objectMapper.readValue(file, Map.class); + System.out.println("resultMap=" + resultMap.toString()); Map result = new HashMap(); for(Entry entry: resultMap.entrySet()) { ComponentSourceDTO dto = objectMapper.convertValue(entry.getValue(), ComponentSourceDTO.class); @@ -171,6 +173,7 @@ public static void moveQueueFile(File source, File target) throws IOException { * @param prefix */ public static void moveFile2ExceptPath(String basePath, File source, String prefix){ + System.out.println("moveFile2ExceptPath=" + source); String targetFileName = basePath+L10N_TMP_EXCEP_PATH+source.getName().replace(SourceStr, SourceStr+prefix+ConstantsChar.UNDERLINE); File file = new File(targetFileName); try { diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/MapUtil.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/MapUtil.java index 4e2dc2266..a154537a4 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/MapUtil.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/MapUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.utils; @@ -9,8 +9,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.json.JSONObject; -import org.json.simple.parser.ContainerFactory; import org.springframework.util.StringUtils; public class MapUtil { @@ -50,7 +50,35 @@ public static void updateKeyValue(Map messages, String key, } } - + public static void updateKeyValue(JSONObject messages, String key, + Object value) { + String updatedTrimKey = ""; + if (StringUtils.isEmpty(key)) { + return; + } else { + updatedTrimKey = getTrimKey(key); + } + Iterator it = messages.keySet().iterator(); + boolean isNew = true; + while (it.hasNext()) { + String originalKey = it.next(); + String originalTrimKey = getTrimKey(originalKey); + if (updatedTrimKey.equals(originalTrimKey)) { + if (originalKey.equals(key)) { // Source Format not changed. + messages.put(key, value); + } else { // Source Format changed. + messages.remove(originalKey); + messages.put(key, value); + } + isNew = false; + break; + } + } + if (isNew) { + // new key + messages.put(key, value); + } + } /* * get the trim key, e.g. get "a.b.c" from "a.b.c.#HTML". @@ -65,22 +93,5 @@ private static String getTrimKey(String key) { } return updatedTrimKey; } - - - /** - * Get the factory which is used to create own object. - * - * @return - */ - public static ContainerFactory getContainerFactory() { - return new ContainerFactory() { - public List creatArrayContainer() { - return new LinkedList(); - } - public Map createObjectContainer() { - return new LinkedHashMap(); - } - }; - } } diff --git a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/SourceUtils.java b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/SourceUtils.java index 091f6f6d5..38ae7d601 100644 --- a/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/SourceUtils.java +++ b/g11n-ws/vip-manager-l10n/src/main/java/com/vmware/l10n/utils/SourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.utils; @@ -9,9 +9,8 @@ import com.vmware.l10n.record.model.RecordModel; import com.vmware.vip.common.constants.ConstantsChar; -import org.json.simple.parser.ContainerFactory; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -65,21 +64,27 @@ public static SingleComponentDTO mergeCacheWithBundle( ComponentMessagesDTO componentMessagesDTO = new ComponentMessagesDTO(); BeanUtils.copyProperties(cachedComponentSourceDTO, componentMessagesDTO); if (!StringUtils.isEmpty(componentJSON)) { - JSONParser parser = new JSONParser(); - ContainerFactory containerFactory = MapUtil.getContainerFactory(); Map messages; Map bundle = null; try { - bundle = (Map) parser.parse(componentJSON, - containerFactory); - } catch (ParseException e) { + bundle = new JSONObject(componentJSON).toMap(); + } catch (JSONException e) { logger.error(e.getMessage(), e); } if (bundle != null && !bundle.isEmpty()) { messages = (Map) bundle.get(ConstantsKeys.MESSAGES); - Iterator> it = ((Map)cachedComponentSourceDTO - .getMessages()).entrySet().iterator(); + Iterator> it = null; + if (cachedComponentSourceDTO.getMessages() instanceof JSONObject) { + System.out.println("messages is JSONObject"); + it = (((JSONObject) cachedComponentSourceDTO + .getMessages()).toMap()).entrySet().iterator(); + } else { + System.out.println("messages is Map object"); + it = ((Map) cachedComponentSourceDTO + .getMessages()).entrySet().iterator(); + } + System.out.println("messages=" + messages.toString()); boolean isChanged = false ; while (it.hasNext()) { Map.Entry entry = it.next(); diff --git a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/RecordControllerTest.java b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/RecordControllerTest.java index 400d14a51..6db4b5c3b 100644 --- a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/RecordControllerTest.java +++ b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/RecordControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.controller; @@ -112,8 +112,8 @@ public void test004getRecoredModelfromV2() throws Exception { String resultStr = mvcRS.getResponse().getContentAsString(); logger.info(resultStr); Map dataMap = (Map) JSONUtils.getMapFromJson(resultStr).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); List queueFiles = DiskQueueUtils.listQueueFiles(new File("viprepo-bundle" + File.separator + DiskQueueUtils.L10N_TMP_GRM_PATH)); for (File delFile : queueFiles) { DiskQueueUtils.delQueueFile(delFile); diff --git a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/S3Test.java b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/S3Test.java index 68b6aace3..fba64d75d 100644 --- a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/S3Test.java +++ b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/controller/S3Test.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.controller; @@ -10,9 +10,9 @@ import com.vmware.l10n.translation.dao.SingleComponentDao; import com.vmware.vip.common.l10n.exception.L10nAPIException; import com.vmware.vip.common.l10n.source.dto.ComponentMessagesDTO; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.json.JSONException; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -146,9 +146,12 @@ public void test002() throws Exception { JSONObject obj; try { - obj = (JSONObject) new JSONParser().parse(new FileReader(filePath.toString())); + obj = new JSONObject(new JSONTokener(new FileReader(filePath.toString()))); + System.out.println("filePath=" + filePath.toString()); + System.out.println("obj=" + obj.toString()); + System.out.println("messages=" + obj.get("messages").toString()); dto.setMessages(obj.get("messages")); - } catch (IOException | ParseException e) { + } catch (IOException | JSONException e) { logger.error(e.getMessage(), e); } diff --git a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/l10n/utils/TestDiskQueueUtils.java b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/l10n/utils/TestDiskQueueUtils.java index 62f10558b..12c72cd3c 100644 --- a/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/l10n/utils/TestDiskQueueUtils.java +++ b/g11n-ws/vip-manager-l10n/src/test/java/com/vmware/l10n/utils/TestDiskQueueUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.l10n.utils; @@ -36,8 +36,12 @@ public void test001moveFile2ExceptPath() { try { File file = DiskQueueUtils.createQueueFile(prepareMap, basePath); + System.out.println("prepareMap=" + prepareMap); DiskQueueUtils.moveFile2ExceptPath(basePath, file, "locale"); List exepQueueFiles = DiskQueueUtils.listExceptQueueFile(basePath); + System.out.println("basePath=" + basePath); + System.out.println("exepQueueFiles=" + exepQueueFiles); + System.out.println("exepQueueFiles.size()=" + exepQueueFiles.size()); Assert.isTrue(exepQueueFiles.size() == 1); for(File delFile : exepQueueFiles) { diff --git a/g11n-ws/vip-manager-lite-i18n/build.gradle b/g11n-ws/vip-manager-lite-i18n/build.gradle index d9b1618b5..688bb7952 100644 --- a/g11n-ws/vip-manager-lite-i18n/build.gradle +++ b/g11n-ws/vip-manager-lite-i18n/build.gradle @@ -42,7 +42,7 @@ dependencies { implementation("org.apache.commons:commons-lang3:$commonsLangVersion") implementation("commons-io:commons-io:$commonsIoVersion") implementation("commons-codec:commons-codec:$commonsCodecVersion") - implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion"){ + implementation("org.json:json:$jsonVersion"){ exclude group: 'junit' } diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java index b14b5d971..3299e1a0b 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/CacheUtil.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.common; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.WebApplicationContext; diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java index ef873512b..2764e6c87 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/common/ResponseUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.common; @@ -7,9 +7,8 @@ import java.io.IOException; 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 com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -24,8 +23,7 @@ public static Object getMessagesFromResponse(String responseStr, String node) { if (responseStr == null || responseStr.equalsIgnoreCase("")) return msgObject; try { - JSONObject responseObj = (JSONObject) JSONValue - .parseWithException(responseStr); + JSONObject responseObj = new JSONObject(responseStr); if (responseObj != null) { JSONObject dataObj = (JSONObject) responseObj .get(ConstantsForTest.DATA); @@ -33,7 +31,7 @@ public static Object getMessagesFromResponse(String responseStr, String node) { msgObject = dataObj.get(node); } } - } catch (ParseException e) { + } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java index 282a74817..d2e448c09 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v1/translation/TranslationSourceAPITest.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v1.translation; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -37,7 +37,7 @@ public void testCreateSource() throws Exception{ JSONObject requestBody=new JSONObject(); requestBody.put("source", "For more information about EVC modes and EVC modes supported in an ESX release, please refer to VMware KB 1003212"); String responseStr=RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.POST, - ConstantsForTest.CreateSourceAPIURI,requestBody.toJSONString()); + ConstantsForTest.CreateSourceAPIURI,requestBody.toString()); int businessCode=ResponseUtil.getResponseCode(responseStr); Assert.assertTrue(businessCode==200); } diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java index 110371afe..5d49bd556 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/LocaleAPITest.java @@ -1,10 +1,10 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.List; import org.junit.Assert; @@ -44,7 +44,7 @@ public void authentication() throws Exception { @Test public void testRegionListAPI() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, REGION_LIST_API_URI); - List> list = (List>) JSONUtils.getMapFromJson(json).get("data"); + List> list = (List>) JSONUtils.getMapFromJson(json).get("data"); for (int i = 0; i < list.size(); i++) { Assert.assertNotNull(list.get(i).get("language")); Assert.assertNotNull(list.get(i).get("territories")); diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java index 52574242d..046adec98 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/image/ImageAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ @@ -54,8 +54,8 @@ public void testCountryFlag1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagDefaultSucc); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -65,8 +65,8 @@ public void testCountryFlag2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagScaleSucc); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -76,8 +76,8 @@ public void testCountryFlag3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET, countryFlagRegionErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } @@ -87,8 +87,8 @@ public void testCountryFlag4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET,countryFlagScaleErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } @@ -110,8 +110,8 @@ public void testCountryFlag6() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext, ConstantsForTest.GET,countryFlagIMageTypeErr); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==400L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==400); } diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java index d03539222..e8bb95576 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.translation; @@ -124,8 +124,8 @@ public void testMultiComponents1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -138,8 +138,8 @@ public void testMultiComponents2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } /** @@ -151,8 +151,8 @@ public void testMultiComponents3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI3); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } /** @@ -164,8 +164,8 @@ public void testMultiComponents4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI4); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==404L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==404); } @Test @@ -173,8 +173,8 @@ public void testMultiComponents5() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI5); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -182,16 +182,16 @@ public void testMultiComponents6() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI6); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test public void testMultiComponents7() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, MultComponentTranslationAPIURI7); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } @Test @@ -199,8 +199,8 @@ public void testSingleComponent() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, SingleComponentTranslationAPIURI); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } diff --git a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java index d4c9295a2..724dc2f98 100644 --- a/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java +++ b/g11n-ws/vip-manager-lite-i18n/src/test/java/com/vmware/vip/i18n/api/v2/translation/TranslationProductComponentKeyAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 VMware, Inc. + * Copyright 2019-2025 VMware, Inc. * SPDX-License-Identifier: EPL-2.0 */ package com.vmware.vip.i18n.api.v2.translation; @@ -69,8 +69,8 @@ public void testGetKeysTranslation1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @@ -79,8 +79,8 @@ public void testGetKeysTranslation2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==207L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==207); } @Test @@ -88,8 +88,8 @@ public void testGetKeysTranslation3() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl3); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==404L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==404); } @@ -98,8 +98,8 @@ public void testGetKeysTranslation4() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, multKeyGetUrl4); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -107,8 +107,8 @@ public void testGetTranslationByGetTest1() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, keyGetUrl1); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } @Test @@ -116,7 +116,7 @@ public void testGetTranslationByGetTest2() throws Exception { String json = RequestUtil.sendRequest(webApplicationContext,ConstantsForTest.GET, keyGetUrl2); @SuppressWarnings("unchecked") Map dataMap = (Map) JSONUtils.getMapFromJson(json).get("response"); - long code = (long) dataMap.get("code"); - Assert.assertTrue(code==200L); + int code = (int) dataMap.get("code"); + Assert.assertTrue(code==200); } }