use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class LoggingRestController method getTableModel.
@ApiOperation(value = "Get Explaination For Query", notes = "What is Query-able on this model")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok"), @ApiResponse(code = 403, message = "User does not have access") })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/explain-query")
public ResponseEntity<TableModel> getTableModel(HttpServletRequest request) {
RestProcessResult<TableModel> result = new RestProcessResult<TableModel>(HttpStatus.OK);
this.checkUser(request, result);
if (result.isOk()) {
TableModel model = new TableModel();
List<QueryAttribute> attributes = new ArrayList<QueryAttribute>();
attributes.add(new QueryAttribute("level", null, Types.VARCHAR));
attributes.add(new QueryAttribute("classname", null, Types.VARCHAR));
attributes.add(new QueryAttribute("method", null, Types.VARCHAR));
attributes.add(new QueryAttribute("time", null, Types.INTEGER));
attributes.add(new QueryAttribute("message", null, Types.VARCHAR));
model.setAttributes(attributes);
result.addRestMessage(getSuccessMessage());
return result.createResponseEntity();
}
return result.createResponseEntity();
}
use of com.wordnik.swagger.annotations.ApiResponses 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();
}
use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class UserRestController method getAllUserGroups.
@ApiOperation(value = "Get All User Groups that a user can 'see', Optionally excluding groups", notes = "", response = String.class, responseContainer = "Array")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok", response = String.class), @ApiResponse(code = 403, message = "User does not have access", response = ResponseEntity.class) })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/permissions-groups/{exclude}")
public ResponseEntity<Set<String>> getAllUserGroups(@ApiParam(value = "Exclude Groups comma separated", required = false, allowMultiple = false, defaultValue = "") @PathVariable String exclude, HttpServletRequest request) {
RestProcessResult<Set<String>> result = new RestProcessResult<Set<String>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
Set<String> groups = new TreeSet<>();
if (user.isAdmin()) {
for (User u : UserDao.instance.getActiveUsers()) groups.addAll(Permissions.explodePermissionGroups(u.getPermissions()));
} else {
groups.addAll(Permissions.explodePermissionGroups(user.getPermissions()));
}
if (!StringUtils.isEmpty(exclude)) {
for (String part : exclude.split(",")) groups.remove(part);
}
return result.createResponseEntity(groups);
}
return result.createResponseEntity();
}
use of com.wordnik.swagger.annotations.ApiResponses in project ma-modules-public by infiniteautomation.
the class UserRestController method getAllUserGroups.
@ApiOperation(value = "Get All User Groups that a user can 'see'", notes = "", response = String.class, responseContainer = "Array")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Ok", response = String.class), @ApiResponse(code = 403, message = "User does not have access", response = ResponseEntity.class) })
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/permissions-groups")
public ResponseEntity<Set<String>> getAllUserGroups(HttpServletRequest request) {
RestProcessResult<Set<String>> result = new RestProcessResult<Set<String>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
Set<String> groups = new TreeSet<>();
if (user.isAdmin()) {
for (User u : UserDao.instance.getActiveUsers()) groups.addAll(Permissions.explodePermissionGroups(u.getPermissions()));
} else {
groups.addAll(Permissions.explodePermissionGroups(user.getPermissions()));
}
return result.createResponseEntity(groups);
}
return result.createResponseEntity();
}
use of com.wordnik.swagger.annotations.ApiResponses 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();
}
Aggregations