use of org.apache.geode.rest.internal.web.controllers.support.UpdateOp in project geode by apache.
the class AbstractBaseController method updateSingleKey.
ResponseEntity<String> updateSingleKey(final String region, final String key, final String json, final String opValue) {
final JSONTypes jsonType = validateJsonAndFindType(json);
final UpdateOp op = UpdateOp.valueOf(opValue.toUpperCase());
String existingValue = null;
switch(op) {
case CAS:
PdxInstance existingPdxObj = casValue(region, key, json);
existingValue = convert(existingPdxObj);
break;
case REPLACE:
replaceValue(region, key, convert(json));
break;
case PUT:
default:
if (JSONTypes.JSON_ARRAY.equals(jsonType)) {
putValue(region, key, convertJsonArrayIntoPdxCollection(json));
// putValue(region, key, convertJsonIntoPdxCollection(json));
} else {
putValue(region, key, convert(json));
}
}
final HttpHeaders headers = new HttpHeaders();
headers.setLocation(toUri(region, key));
return new ResponseEntity<String>(existingValue, headers, (existingValue == null ? HttpStatus.OK : HttpStatus.CONFLICT));
}
Aggregations