use of com.serotonin.m2m2.web.mvc.rest.v1.model.user.UserAccessModel in project ma-modules-public by infiniteautomation.
the class UserAccessRestController method getDataSourceAccess.
@ApiOperation(value = "Get Data Source Access List", notes = "Returns a list of users and thier access")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json", "text/csv" }, value = "/data-source/{xid}")
public ResponseEntity<List<UserAccessModel>> getDataSourceAccess(@ApiParam(value = "Valid data point xid", required = true, allowMultiple = false) @PathVariable String xid, HttpServletRequest request) {
RestProcessResult<List<UserAccessModel>> result = new RestProcessResult<List<UserAccessModel>>(HttpStatus.OK);
this.checkUser(request, result);
if (result.isOk()) {
DataSourceVO<?> vo = DataSourceDao.instance.getByXid(xid);
if (vo != null) {
List<UserAccessModel> models = new ArrayList<UserAccessModel>();
List<User> allUsers = UserDao.instance.getUsers();
for (User mangoUser : allUsers) {
if (Permissions.hasDataSourcePermission(mangoUser, vo)) {
models.add(new UserAccessModel(Permissions.ACCESS_TYPE_CODES.getCode(DataPointAccessTypes.DATA_SOURCE), new UserModel(mangoUser)));
}
}
return result.createResponseEntity(models);
}
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.web.mvc.rest.v1.model.user.UserAccessModel in project ma-modules-public by infiniteautomation.
the class UserAccessRestController method getDataPointAccess.
@ApiOperation(value = "Get Data Point Access List", notes = "Returns a list of users and thier access")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json", "text/csv" }, value = "/data-point/{xid}")
public ResponseEntity<List<UserAccessModel>> getDataPointAccess(@ApiParam(value = "Valid data point xid", required = true, allowMultiple = false) @PathVariable String xid, HttpServletRequest request) {
RestProcessResult<List<UserAccessModel>> result = new RestProcessResult<List<UserAccessModel>>(HttpStatus.OK);
this.checkUser(request, result);
if (result.isOk()) {
DataPointVO vo = DataPointDao.instance.getByXid(xid);
if (vo != null) {
List<UserAccessModel> models = new ArrayList<UserAccessModel>();
List<User> allUsers = UserDao.instance.getUsers();
int accessType;
for (User mangoUser : allUsers) {
accessType = Permissions.getDataPointAccessType(mangoUser, vo);
if (accessType != Permissions.DataPointAccessTypes.NONE) {
models.add(new UserAccessModel(Permissions.ACCESS_TYPE_CODES.getCode(accessType), new UserModel(mangoUser)));
}
}
return result.createResponseEntity(models);
}
}
return result.createResponseEntity();
}
Aggregations