worksheet = workspace.getWorksheet(worksheetId);
JSONObject propertiesJson = null;
try {
propertiesJson = new JSONObject(properties);
WorksheetProperties props = worksheet.getMetadataContainer().getWorksheetProperties();
if (props == null) {
props = new WorksheetProperties();
worksheet.getMetadataContainer().setWorksheetProperties(props);
}
// Parse the properties and set WorksheetProperties data structure
String graphLabel = propertiesJson.getString(Property.graphLabel.name());
if (!graphLabel.trim().isEmpty()) {
props.setPropertyValue(Property.graphLabel, graphLabel);
props.setPropertyValue(Property.graphName, WorksheetProperties.createDefaultGraphName(graphLabel));
}
if (propertiesJson.getBoolean(Property.hasServiceProperties.name())) {
props.setHasServiceProperties(true);
// Service URL
props.setPropertyValue(Property.serviceUrl,
propertiesJson.getString(Property.serviceUrl.name()));
// Service method
props.setPropertyValue(Property.serviceRequestMethod,
propertiesJson.getString(Property.serviceRequestMethod.name()));
// Set the service invocation style if http method is POST
if (propertiesJson.getString(Property.serviceRequestMethod.name())
.equals(HttpMethods.POST.name())) {
props.setPropertyValue(Property.serviceDataPostMethod,
propertiesJson.getString(Property.serviceDataPostMethod.name()));
}
}
if (propertiesJson.getBoolean("hasPrefix")) {
props.setPropertyValue(Property.prefix,
propertiesJson.getString(Property.prefix.name()));
}
if (propertiesJson.getBoolean("hasBaseURI")) {
props.setPropertyValue(Property.baseURI,
propertiesJson.getString(Property.baseURI.name()));
}
} catch (JSONException e) {
e.printStackTrace();
return new UpdateContainer(new ErrorUpdate("Malformed properties object received"));