if (UtilValidate.isNotEmpty(requiredLabels)) {
// Transform JSON String to Object
uiLabelObject = (JSONObject) JSONSerializer.toJSON(requiredLabels);
}
JSONArray jsonUiLabel = new JSONArray();
Locale locale = request.getLocale();
if(!uiLabelObject.isEmpty()) {
Set<String> resourceSet = UtilGenerics.checkSet(uiLabelObject.keySet());
// Iterate over the resource set
// here we need a keySet because we don't now which label resource to load
// the key set should have the size one, if greater or empty error should returned
if (UtilValidate.isEmpty(resourceSet)) {
Debug.logError("No resource and labels found", module);
return "error";
} else if (resourceSet.size() > 1) {
Debug.logError("More than one resource found, please use the method: getJSONuiLabelArray", module);
return "error";
}
for (String resource : resourceSet) {
String label = uiLabelObject.getString(resource);
if (UtilValidate.isEmail(label)) {
continue;
}
String receivedLabel = UtilProperties.getMessage(resource, label, locale);
jsonUiLabel.add(receivedLabel);
}
}
writeJSONtoResponse(jsonUiLabel, response);
return "success";