Modify ACL routes (#1025)

This commit is contained in:
Yi (Alan) Wang 2018-03-12 14:15:18 -07:00 committed by GitHub
parent 8b846ecf96
commit fb2b478885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -351,18 +351,20 @@ public class Dataset extends Controller {
return Promise.promise(() -> unauthorized(_EMPTY_RESPONSE));
}
String accessType = request().getQueryString("accessType");
String businessJustification = request().getQueryString("businessJustification");
Long expireAt = NumberUtils.toLong(request().getQueryString("expireAt"), 0);
if (businessJustification == null) {
JsonNode record = request().body().asJson();
String accessType = record.hasNonNull("accessType") ? record.get("accessType").asText() : null;
Long expiresAt = record.hasNonNull("expiresAt") ? record.get("expiresAt").asLong() : null;
if (!record.hasNonNull("businessJustification")) {
return Promise.promise(() -> badRequest(errorResponse("Missing business justification")));
}
String businessJustification = request().getQueryString("businessJustification");
try {
if (accessType == null) {
ACL_DAO.addUserToDatasetAcl(datasetUrn, username, businessJustification);
} else {
ACL_DAO.addUserToDatasetAcl(datasetUrn, username, accessType, businessJustification, expireAt);
ACL_DAO.addUserToDatasetAcl(datasetUrn, username, accessType, businessJustification, expiresAt);
}
} catch (Exception e) {
Logger.error("Add user to ACL error", e);

View File

@ -308,9 +308,9 @@ GET /api/v2/datasets/:urn/compliance/suggestion
GET /api/v2/datasets/:urn/acl controllers.api.v2.Dataset.getDatasetAcls(urn: String)
POST /api/v2/datasets/:urn/acl/add controllers.api.v2.Dataset.addUserToDatasetAcl(urn: String)
PUT /api/v2/datasets/:urn/acl/add controllers.api.v2.Dataset.addUserToDatasetAcl(urn: String)
PUT /api/v2/datasets/:urn/acl/remove controllers.api.v2.Dataset.removeUserFromDatasetAcl(urn: String)
DELETE /api/v2/datasets/:urn/acl/remove controllers.api.v2.Dataset.removeUserFromDatasetAcl(urn: String)
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)