Search in sources :

Example 1 with FileStoreModel

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

the class UserFileStoresRestController method updateUserFileStore.

@ApiOperation(value = "Update a user file store")
@RequestMapping(method = RequestMethod.PUT, value = "/{xid}")
public ResponseEntity<FileStoreModel> updateUserFileStore(@ApiParam(value = "File store XID", required = true) @PathVariable("xid") String xid, @ApiParam(value = "Updated file store", required = true) @RequestBody FileStoreModel fileStore, UriComponentsBuilder builder) {
    FileStore updated = this.fileStoreService.update(xid, fileStore.toVO());
    URI location = builder.path("/user-file-stores/{xid}").buildAndExpand(updated.getXid()).toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(location);
    return new ResponseEntity<>(new FileStoreModel(updated), headers, HttpStatus.OK);
}
Also used : FileStoreModel(com.infiniteautomation.mango.rest.latest.model.filestore.FileStoreModel) FileStore(com.serotonin.m2m2.vo.FileStore) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) URI(java.net.URI) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with FileStoreModel

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

the class UserFileStoresRestController method getUserFileStoreModel.

@ApiOperation(value = "Get a user file store model")
@RequestMapping(method = RequestMethod.GET, value = "/{xid}")
public MappingJacksonValue getUserFileStoreModel(@PathVariable("xid") String xid, @AuthenticationPrincipal PermissionHolder user) {
    FileStore fs = this.fileStoreService.get(xid);
    // Seeing the permissions fields should require write protection
    MappingJacksonValue resultWithView = new MappingJacksonValue(new FileStoreModel(fs));
    if (fileStoreService.hasEditPermission(user, fs)) {
        resultWithView.setSerializationView(RoleViews.ShowRoles.class);
    } else {
        resultWithView.setSerializationView(Object.class);
    }
    return resultWithView;
}
Also used : FileStoreModel(com.infiniteautomation.mango.rest.latest.model.filestore.FileStoreModel) FileStore(com.serotonin.m2m2.vo.FileStore) MappingJacksonValue(org.springframework.http.converter.json.MappingJacksonValue) RoleViews(com.infiniteautomation.mango.rest.latest.model.RoleViews) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with FileStoreModel

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

the class UserFileStoresRestController method createUserFileStore.

@ApiOperation(value = "Create a user file store")
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<FileStoreModel> createUserFileStore(@ApiParam(value = "File store to create", required = true) @RequestBody FileStoreModel fileStore, UriComponentsBuilder builder) {
    FileStore newStore = this.fileStoreService.insert(fileStore.toVO());
    URI location = builder.path("/user-file-stores/{xid}").buildAndExpand(newStore.getXid()).toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(location);
    return new ResponseEntity<>(new FileStoreModel(newStore), headers, HttpStatus.CREATED);
}
Also used : FileStoreModel(com.infiniteautomation.mango.rest.latest.model.filestore.FileStoreModel) FileStore(com.serotonin.m2m2.vo.FileStore) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) URI(java.net.URI) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FileStoreModel (com.infiniteautomation.mango.rest.latest.model.filestore.FileStoreModel)3 FileStore (com.serotonin.m2m2.vo.FileStore)3 ApiOperation (io.swagger.annotations.ApiOperation)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 URI (java.net.URI)2 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RoleViews (com.infiniteautomation.mango.rest.latest.model.RoleViews)1 MappingJacksonValue (org.springframework.http.converter.json.MappingJacksonValue)1