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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion g11n-ws/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion g11n-ws/modules/md-data-api-mt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 VMware, Inc.
* Copyright 2019-2025 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
package com.vmware.vip.core.except;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<JSONObject> 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<resultList.size(); i++){
wbc.write(buf);
wbc.write(ByteBuffer.wrap(resultList.get(0).toJSONString().getBytes()));
wbc.write(ByteBuffer.wrap(resultList.get(0).toString().getBytes()));
((Buffer) buf).rewind();
}
wbc.write(sr.getEndBytes());
Expand All @@ -214,18 +214,18 @@ private List<JSONObject> formatResultBundles(List<String> components, List<Strin
}
}
}else {
Iterator<JSONObject> objectIterator = result.iterator();
Iterator<Object> 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<JSONObject> objectIterator = result.iterator();
Iterator<Object> 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)) {
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

}
Expand All @@ -163,10 +163,10 @@ private JSONObject getBundle(String component, String locale, TranslationDTO all

JSONArray array = allTranslationDTO.getBundles();
@SuppressWarnings("unchecked")
Iterator<JSONObject> objectIterator = array.iterator();
Iterator<Object> 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)) {
Expand Down Expand Up @@ -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));
}
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion g11n-ws/modules/md-restful-synch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -49,7 +49,7 @@ public List<String> updateTranslationBatch(List<ComponentMessagesDTO> 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;
Expand Down Expand Up @@ -77,7 +77,7 @@ public List<String> updateTranslationBatch(List<ComponentMessagesDTO> 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);
Expand Down
2 changes: 1 addition & 1 deletion g11n-ws/modules/md-service-i18n-l2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion g11n-ws/modules/md-service-i18n-l3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -126,7 +126,7 @@ public ComponentMessagesDTO getComponentMTTranslation(
e.printStackTrace();
}
}
} catch (ParseException | DataException | MTException
} catch (JSONException | DataException | MTException
| VIPCacheException e) {

LOGGER.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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<String> locales = translationDTO.getLocales();
List<String> components = translationDTO.getComponents();
List<String> bundles = multipleComponentsDao.get2JsonStrs(translationDTO.getProductName(),
Expand All @@ -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;
Expand Down
Loading
Loading