Search in sources :

Example 1 with PermissionDetails

use of com.serotonin.m2m2.vo.permission.PermissionDetails in project ma-modules-public by infiniteautomation.

the class UserRestController method getUserPermissions.

@ApiOperation(value = "Get User Permissions Information for all users", notes = "", response = PermissionDetails.class, responseContainer = "Array")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok", response = PermissionDetails.class), @ApiResponse(code = 403, message = "User does not have access", response = ResponseEntity.class) })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/permissions")
public ResponseEntity<List<PermissionDetails>> getUserPermissions(HttpServletRequest request) {
    RestProcessResult<List<PermissionDetails>> result = new RestProcessResult<List<PermissionDetails>>(HttpStatus.OK);
    User currentUser = this.checkUser(request, result);
    if (result.isOk()) {
        List<PermissionDetails> ds = new ArrayList<>();
        for (User user : UserDao.instance.getActiveUsers()) {
            PermissionDetails deets = Permissions.getPermissionDetails(currentUser, null, user);
            if (deets != null)
                ds.add(deets);
        }
        return result.createResponseEntity(ds);
    }
    return result.createResponseEntity();
}
Also used : RestProcessResult(com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult) User(com.serotonin.m2m2.vo.User) PermissionDetails(com.serotonin.m2m2.vo.permission.PermissionDetails) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PermissionDetails

use of com.serotonin.m2m2.vo.permission.PermissionDetails in project ma-modules-public by infiniteautomation.

the class UserRestController method getUserPermissions.

@ApiOperation(value = "Get User Permissions Information for all users, exclude provided groups in query", notes = "", response = PermissionDetails.class, responseContainer = "Array")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok", response = PermissionDetails.class), @ApiResponse(code = 403, message = "User does not have access", response = ResponseEntity.class) })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/permissions/{query}")
public ResponseEntity<List<PermissionDetails>> getUserPermissions(@ApiParam(value = "Query of permissions to show as already added", required = true, allowMultiple = false) @PathVariable String query, HttpServletRequest request) {
    RestProcessResult<List<PermissionDetails>> result = new RestProcessResult<List<PermissionDetails>>(HttpStatus.OK);
    User currentUser = this.checkUser(request, result);
    if (result.isOk()) {
        List<PermissionDetails> ds = new ArrayList<>();
        for (User user : UserDao.instance.getActiveUsers()) {
            PermissionDetails deets = Permissions.getPermissionDetails(currentUser, query, user);
            if (deets != null)
                ds.add(deets);
        }
        return result.createResponseEntity(ds);
    }
    return result.createResponseEntity();
}
Also used : RestProcessResult(com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult) User(com.serotonin.m2m2.vo.User) PermissionDetails(com.serotonin.m2m2.vo.permission.PermissionDetails) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PermissionDetails

use of com.serotonin.m2m2.vo.permission.PermissionDetails in project ma-core-public by infiniteautomation.

the class BaseDwr method getUserPermissionInfo.

/**
 * Power tools for user permissions.
 */
@DwrPermission(user = true)
public List<PermissionDetails> getUserPermissionInfo(String query) {
    List<PermissionDetails> ds = new ArrayList<>();
    User currentUser = Common.getUser();
    for (User user : UserDao.instance.getActiveUsers()) {
        PermissionDetails deets = Permissions.getPermissionDetails(currentUser, query, user);
        if (deets != null)
            ds.add(deets);
    }
    return ds;
}
Also used : User(com.serotonin.m2m2.vo.User) PermissionDetails(com.serotonin.m2m2.vo.permission.PermissionDetails) ArrayList(java.util.ArrayList) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

User (com.serotonin.m2m2.vo.User)3 PermissionDetails (com.serotonin.m2m2.vo.permission.PermissionDetails)3 ArrayList (java.util.ArrayList)3 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)2 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)2 List (java.util.List)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1