Search in sources :

Example 1 with LinkedAccountModel

use of com.infiniteautomation.mango.rest.latest.model.user.LinkedAccountModel in project ma-modules-public by infiniteautomation.

the class UserRestController method updateLinkedAccounts.

@RequestMapping(method = RequestMethod.PUT, value = "/linked-accounts/{username}")
public void updateLinkedAccounts(@PathVariable String username, @RequestBody List<LinkedAccountModel> linkedAccountModels, @AuthenticationPrincipal PermissionHolder currentUser) {
    User userToUpdate = service.get(username);
    List<LinkedAccount> linkedAccounts = linkedAccountModels.stream().map(a -> mapper.unMap(a, LinkedAccount.class, currentUser)).collect(Collectors.toList());
    service.updateLinkedAccounts(userToUpdate.getId(), linkedAccounts);
}
Also used : BadRequestException(com.infiniteautomation.mango.rest.latest.exception.BadRequestException) PathVariable(org.springframework.web.bind.annotation.PathVariable) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) RequestParam(org.springframework.web.bind.annotation.RequestParam) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) StreamedVORqlQueryWithTotal(com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) Translations(com.serotonin.m2m2.i18n.Translations) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder) RestModelMapper(com.infiniteautomation.mango.rest.latest.model.RestModelMapper) PatchVORequestBody(com.infiniteautomation.mango.rest.latest.patch.PatchVORequestBody) ApiOperation(io.swagger.annotations.ApiOperation) Map(java.util.Map) URI(java.net.URI) UserActionAndModel(com.infiniteautomation.mango.rest.latest.model.user.UserActionAndModel) RuntimeStatusModel(com.infiniteautomation.mango.rest.latest.model.datasource.RuntimeStatusModel) TemporaryResourceStatusUpdate(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceStatusUpdate) HttpHeaders(org.springframework.http.HttpHeaders) RQLUtils(com.infiniteautomation.mango.util.RQLUtils) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) JsonStreamedArray(com.serotonin.json.type.JsonStreamedArray) List(java.util.List) UserModel(com.infiniteautomation.mango.rest.latest.model.user.UserModel) StreamedSeroJsonVORqlQuery(com.infiniteautomation.mango.rest.latest.model.StreamedSeroJsonVORqlQuery) ASTNode(net.jazdw.rql.parser.ASTNode) Environment(org.springframework.core.env.Environment) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Authentication(org.springframework.security.core.Authentication) UserIndividualRequest(com.infiniteautomation.mango.rest.latest.model.user.UserIndividualRequest) User(com.serotonin.m2m2.vo.User) PermissionService(com.infiniteautomation.mango.spring.service.PermissionService) PatchIdField(com.infiniteautomation.mango.rest.latest.patch.PatchVORequestBody.PatchIdField) FilteredStreamWithTotal(com.infiniteautomation.mango.rest.latest.model.FilteredStreamWithTotal) VoAction(com.infiniteautomation.mango.rest.latest.bulk.VoAction) TemporaryResourceStatus(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource.TemporaryResourceStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) RequestBody(org.springframework.web.bind.annotation.RequestBody) UserModelMapping(com.infiniteautomation.mango.rest.latest.model.user.UserModelMapping) HttpServletRequest(javax.servlet.http.HttpServletRequest) UsersService(com.infiniteautomation.mango.spring.service.UsersService) MappingJacksonValue(org.springframework.http.converter.json.MappingJacksonValue) StreamedArrayWithTotal(com.infiniteautomation.mango.rest.latest.model.StreamedArrayWithTotal) Api(io.swagger.annotations.Api) UserIndividualResponse(com.infiniteautomation.mango.rest.latest.model.user.UserIndividualResponse) TemporaryResourceWebSocketHandler(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceWebSocketHandler) TemporaryResource(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource) TranslatableExceptionI(com.infiniteautomation.mango.util.exception.TranslatableExceptionI) MangoSessionRegistry(com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry) MangoTaskTemporaryResourceManager(com.infiniteautomation.mango.rest.latest.temporaryResource.MangoTaskTemporaryResourceManager) Common(com.serotonin.m2m2.Common) LinkedAccount(com.serotonin.m2m2.vo.LinkedAccount) LinkedAccountModel(com.infiniteautomation.mango.rest.latest.model.user.LinkedAccountModel) BulkResponse(com.infiniteautomation.mango.rest.latest.bulk.BulkResponse) BulkRequest(com.infiniteautomation.mango.rest.latest.bulk.BulkRequest) HttpStatus(org.springframework.http.HttpStatus) ApprovedUsersModel(com.infiniteautomation.mango.rest.latest.model.user.ApprovedUsersModel) AuthenticationPrincipal(org.springframework.security.core.annotation.AuthenticationPrincipal) MediaTypes(com.serotonin.m2m2.web.MediaTypes) ResponseEntity(org.springframework.http.ResponseEntity) AbstractRestException(com.infiniteautomation.mango.rest.latest.exception.AbstractRestException) TemporaryResourceManager(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceManager) ApproveUsersModel(com.infiniteautomation.mango.rest.latest.model.user.ApproveUsersModel) PermissionException(com.serotonin.m2m2.vo.permission.PermissionException) User(com.serotonin.m2m2.vo.User) LinkedAccount(com.serotonin.m2m2.vo.LinkedAccount) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BulkRequest (com.infiniteautomation.mango.rest.latest.bulk.BulkRequest)1 BulkResponse (com.infiniteautomation.mango.rest.latest.bulk.BulkResponse)1 VoAction (com.infiniteautomation.mango.rest.latest.bulk.VoAction)1 AbstractRestException (com.infiniteautomation.mango.rest.latest.exception.AbstractRestException)1 BadRequestException (com.infiniteautomation.mango.rest.latest.exception.BadRequestException)1 FilteredStreamWithTotal (com.infiniteautomation.mango.rest.latest.model.FilteredStreamWithTotal)1 RestModelMapper (com.infiniteautomation.mango.rest.latest.model.RestModelMapper)1 StreamedArrayWithTotal (com.infiniteautomation.mango.rest.latest.model.StreamedArrayWithTotal)1 StreamedSeroJsonVORqlQuery (com.infiniteautomation.mango.rest.latest.model.StreamedSeroJsonVORqlQuery)1 StreamedVORqlQueryWithTotal (com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal)1 RuntimeStatusModel (com.infiniteautomation.mango.rest.latest.model.datasource.RuntimeStatusModel)1 ApproveUsersModel (com.infiniteautomation.mango.rest.latest.model.user.ApproveUsersModel)1 ApprovedUsersModel (com.infiniteautomation.mango.rest.latest.model.user.ApprovedUsersModel)1 LinkedAccountModel (com.infiniteautomation.mango.rest.latest.model.user.LinkedAccountModel)1 UserActionAndModel (com.infiniteautomation.mango.rest.latest.model.user.UserActionAndModel)1 UserIndividualRequest (com.infiniteautomation.mango.rest.latest.model.user.UserIndividualRequest)1 UserIndividualResponse (com.infiniteautomation.mango.rest.latest.model.user.UserIndividualResponse)1 UserModel (com.infiniteautomation.mango.rest.latest.model.user.UserModel)1 UserModelMapping (com.infiniteautomation.mango.rest.latest.model.user.UserModelMapping)1 PatchVORequestBody (com.infiniteautomation.mango.rest.latest.patch.PatchVORequestBody)1