throw new WebApplicationException(HttpStatus.METHOD_NOT_ALLOWED.getCode());
}
// obtain data object from the memory store
// if the defect was deleted, it cannot be updated anymore.
DataStore store = DataStore.getInstance();
String defectId = segement.getPath();
DefectBean defect = store.getDefect(defectId);
if (defect == null) {
throw new WebApplicationException(new RuntimeException("Defect " + defectId
+ " not found"), Response.Status.NOT_FOUND);
}
// validate that user didn't send deleted flag, since it will mark
// defect as deleted.
// to delete a defect, DELETE http method should be used
defect = asset.getDefect();
defect.setDeleted(false);
// set Id in the asset for cases that element <id> is missing
// in the request body
defect.setId(defectId);
// update defect legacy bean to the memory store
store.putDefect(defectId, defect);
return asset;
}