Refactor to return request body as response if success for export policy
@@ -272,14 +272,14 @@ public class Dataset extends Controller {
public static Promise<Result> updateExportPolicy(String datasetUrn) {
final String username = session("user");
- final DatasetExportPolicy exportPolicy;
+ JsonNode requestBody = request().body().asJson();
if (StringUtils.isBlank(username)) {
return Promise.promise(() -> unauthorized(_EMPTY_RESPONSE));
}
try {
- exportPolicy = Json.mapper().convertValue(request().body().asJson(), DatasetExportPolicy.class);
+ final DatasetExportPolicy exportPolicy = Json.mapper().convertValue(requestBody, DatasetExportPolicy.class);
EXPORT_POLICY_DAO.updateDatasetExportPolicy(datasetUrn, exportPolicy, username);
} catch (Exception e) {
@@ -287,7 +287,7 @@ public class Dataset extends Controller {
return Promise.promise(() -> internalServerError(errorResponse(e)));
}
- return Promise.promise(() -> ok(Json.newObject().set("exportPolicy", Json.toJson(exportPolicy))));
+ return Promise.promise(() -> ok(Json.newObject().set("exportPolicy", Json.toJson(requestBody))));
}
public static Promise<Result> getDatasetOwners(String datasetUrn) {
