Skip to content

Commit

Permalink
Return xml inside JSON status (#8579)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangf1122 authored Dec 24, 2024
1 parent da294f7 commit 9d3e585
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
import org.jdom.Element;
import org.jdom.input.JDOMParseException;
import org.jdom.output.XMLOutputter;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -1261,9 +1263,29 @@ private String getValidatedStateText(MetadataStatus metadataStatus, State state,
checkCanViewStatus(stateText, httpSession);
}

if (isValidJSON(stateText)) {
JSONObject json = new JSONObject(stateText);
String xmlRecord = json.getString("xmlRecord");
return xmlRecord;
}

return stateText;
}

/**
* Check if the input string is valid JSON format string
* @param json input string
* @return boolean if string is JSON format
*/
private boolean isValidJSON(String json) {
try {
new JSONObject(json);
} catch (JSONException e) {
return false;
}
return true;
}

/**
* Checks if the metadata workflow is enabled.
*
Expand Down

0 comments on commit 9d3e585

Please sign in to comment.