Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed: wflow-plugin-base - Property Util - Proper handle Invalid JSON…

… String exception.

git-svn-id: http://dev.joget.org/svn/jw-community/trunk@422 1bff935d-2fe2-40b7-b00f-c2aca69a7612
  • Loading branch information...
commit 7ebab1bc0f4b0d6a6a1e753070d8fb5b0549bf9e 1 parent 5362265
owen authored
View
44 wflow-plugin-base/src/main/java/org/joget/plugin/property/service/PropertyUtil.java
@@ -17,6 +17,7 @@
import net.sf.json.JSONSerializer;
import net.sf.json.util.JSONUtils;
import net.sf.json.xml.XMLSerializer;
+import org.joget.commons.util.LogUtil;
import org.joget.plugin.property.model.PropertyOptions;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -116,30 +117,35 @@ public static String getPropertiesJSONObject(String[] fileNames) {
* Parse default properties string from json
*/
public static String getDefaultPropertyValues(String json) {
- JSONArray pages = (JSONArray) JSONSerializer.toJSON(json);
- String defaultProperties = "{";
-
- //loop page
- if (!JSONUtils.isNull(pages)) {
- for (int i = 0; i < pages.size(); i++) {
- JSONObject page = (JSONObject) pages.get(i);
- if (!JSONUtils.isNull(page)) {
- //loop properties
- JSONArray properties = (JSONArray) page.get("properties");
- for (int j = 0; j < properties.size(); j++) {
- JSONObject property = (JSONObject) properties.get(j);
- if (property.containsKey("value")) {
- defaultProperties += "'" + property.getString("name") + "':'" + property.getString("value") + "',";
+ try {
+ JSONArray pages = (JSONArray) JSONSerializer.toJSON(json);
+ String defaultProperties = "{";
+
+ //loop page
+ if (!JSONUtils.isNull(pages)) {
+ for (int i = 0; i < pages.size(); i++) {
+ JSONObject page = (JSONObject) pages.get(i);
+ if (!JSONUtils.isNull(page)) {
+ //loop properties
+ JSONArray properties = (JSONArray) page.get("properties");
+ for (int j = 0; j < properties.size(); j++) {
+ JSONObject property = (JSONObject) properties.get(j);
+ if (property.containsKey("value")) {
+ defaultProperties += "'" + property.getString("name") + "':'" + property.getString("value") + "',";
+ }
}
}
}
}
+ if (defaultProperties.endsWith(",")) {
+ defaultProperties = defaultProperties.substring(0, defaultProperties.length() - 1);
+ }
+ defaultProperties += "}";
+ return defaultProperties;
+ }catch(Exception ex){
+ LogUtil.error("PropertyUtil", ex, json);
}
- if (defaultProperties.endsWith(",")) {
- defaultProperties = defaultProperties.substring(0, defaultProperties.length() - 1);
- }
- defaultProperties += "}";
- return defaultProperties;
+ return "{}";
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.