Updates for handling single and double quotes in html and sparql data getters
This commit is contained in:
parent
8225bcf91f
commit
059094be4c
6 changed files with 73 additions and 4 deletions
|
@ -282,6 +282,8 @@ public class ManagePageGenerator extends BaseEditConfigurationGenerator implemen
|
|||
private void addJSONArrayToFormSpecificData(JSONArray jsonArray, EditConfigurationVTwo editConfig) {
|
||||
HashMap<String, Object> data = editConfig.getFormSpecificData();
|
||||
data.put("existingPageContentUnits", jsonArray.toString());
|
||||
//Experimenting with putting actual array in
|
||||
data.put("existingPageContentUnitsJSONArray", jsonArray);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -199,10 +199,14 @@ public class ManagePagePreprocessor extends
|
|||
if(jsonValue instanceof String) {
|
||||
//TODO: Deal with multiple submission values
|
||||
//This retrieves the value for this particular json object
|
||||
literalValues.add(jsonObject.getString(literalLabel));
|
||||
String jsonString = jsonObject.getString(literalLabel);
|
||||
jsonString = pn.replaceEncodedQuotesWithEscapedQuotes(jsonString);
|
||||
literalValues.add(jsonString);
|
||||
} else if(jsonValue instanceof JSONArray) {
|
||||
JSONArray values = jsonObject.getJSONArray(literalLabel);
|
||||
literalValues = (List<String>) JSONSerializer.toJava(values);
|
||||
//Replacing encoded quotes here as well
|
||||
this.replaceEncodedQuotesInList(pn, literalValues);
|
||||
} else if(jsonValue instanceof Boolean) {
|
||||
Boolean booleanValue = jsonObject.getBoolean(literalLabel);
|
||||
//Adds string version
|
||||
|
@ -232,6 +236,7 @@ public class ManagePagePreprocessor extends
|
|||
//multiple values
|
||||
JSONArray values = jsonObject.getJSONArray(uriLabel);
|
||||
uriValues = (List<String>) JSONSerializer.toJava(values);
|
||||
|
||||
} else {
|
||||
//This may include JSON Objects but no way to deal with these right now
|
||||
}
|
||||
|
@ -254,7 +259,17 @@ public class ManagePagePreprocessor extends
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void replaceEncodedQuotesInList(ProcessDataGetterN3 pn, List<String> values) {
|
||||
int i;
|
||||
int len = values.size();
|
||||
for(i = 0; i < len; i++) {
|
||||
String value = values.get(i);
|
||||
if(value.contains(""") || value.contains("'")) {
|
||||
value = pn.replaceEncodedQuotesWithEscapedQuotes(value);
|
||||
values.set(i,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addFields(ProcessDataGetterN3 pn, int counter) {
|
||||
|
|
|
@ -54,6 +54,13 @@ public abstract class ProcessDataGetterAbstract implements ProcessDataGetterN3 {
|
|||
return "?" + getVarName(base, counter);
|
||||
}
|
||||
|
||||
//For handling encoded single and double quotes
|
||||
//For fixed html and sparql data getters, replaces encoded quotes with escaped quotes
|
||||
//Can be overridden in other processors if need be
|
||||
public String replaceEncodedQuotesWithEscapedQuotes(String inputStr) {
|
||||
return inputStr.replaceAll("'", "\'").replaceAll(""", "\"");
|
||||
}
|
||||
|
||||
//Return name of new resources
|
||||
public List<String> getNewResources(int counter) {
|
||||
//Each data getter requires a new resource
|
||||
|
|
|
@ -36,5 +36,6 @@ public interface ProcessDataGetterN3 {
|
|||
public Map<String, List<String>> retrieveExistingUriValues();
|
||||
public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel);
|
||||
public JSONObject getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context);
|
||||
public String replaceEncodedQuotesWithEscapedQuotes(String inputStr);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue