-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the api Readme.md file (issue #930)
- Loading branch information
1 parent
092c0b6
commit 47a7deb
Showing
9 changed files
with
53 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,50 +79,16 @@ public Response deleteRole( @PathParam("id") Long id, @PathParam("key") String k | |
} | ||
} | ||
|
||
@POST | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
michbarsinai
via email
Author
Member
|
||
@Path("assignments") | ||
public Response assignRole( @FormParam("username") String username, | ||
@FormParam("roleId") Long roleId, | ||
@FormParam("definitionPointId") Long dvObjectId, | ||
@QueryParam("key") String key ) { | ||
|
||
User issuer = findUserByApiToken(key); | ||
if ( issuer == null ) return errorResponse( Status.UNAUTHORIZED, "invalid api key '" + key +"'" ); | ||
|
||
RoleAssignee ras = findAssignee(username); | ||
if ( ras == null ) return errorResponse( Status.BAD_REQUEST, "no user with username " + username ); | ||
|
||
|
||
DvObject d = null; | ||
if ( dvObjectId != null ) { | ||
d = dvSvc.find( dvObjectId ); | ||
if ( d == null ) return errorResponse( Status.BAD_REQUEST, "no DvObject with id " + dvObjectId ); | ||
} | ||
DataverseRole r = rolesSvc.find(roleId); | ||
if ( r == null ) return errorResponse( Status.BAD_REQUEST, "no role with id " + roleId ); | ||
|
||
try { | ||
return okResponse( json(execCommand( new AssignRoleCommand(ras,r,d, issuer), "Assign Role")) ); | ||
|
||
} catch (WrappedResponse ex) { | ||
logger.log( Level.WARNING, "Error Assigning role", ex ); | ||
return ex.getResponse(); | ||
} | ||
} | ||
|
||
@POST | ||
public Response createNewRole( RoleDTO roleDto, | ||
@QueryParam("dvo") String dvoIdtf, | ||
@QueryParam("key") String key ) { | ||
|
||
User issuer = usersSvc.findByIdentifier(key); | ||
if ( issuer == null ) return errorResponse( Status.UNAUTHORIZED, "invalid api key '" + key +"'" ); | ||
|
||
Dataverse d = findDataverse(dvoIdtf); | ||
Dataverse d = findDataverse(dvoIdtf); | ||
if ( d == null ) return errorResponse( Status.BAD_REQUEST, "no dataverse with id " + dvoIdtf ); | ||
|
||
try { | ||
return okResponse(json(execCommand(new CreateRoleCommand(roleDto.asRole(), issuer, d), "Create New Role"))); | ||
return okResponse(json(execCommand(new CreateRoleCommand(roleDto.asRole(), findUserOrDie(key), d), "Create New Role"))); | ||
} catch ( WrappedResponse ce ) { | ||
return ce.getResponse(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bummer. I've been using the "assignments" endpoint to grant roles to users on definition points as part of search testing: https://github.com/IQSS/dataverse/blob/master/scripts/search/tests/grant-spruce-admin-on-birds
@michbarsinai is there any plan to re-introduce this at some point? Maybe under the "/s" secure area?