use of com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource in project ma-modules-public by infiniteautomation.
the class EventDetectorsRestController method getBulkDataPointOperations.
@ApiOperation(value = "Get a list of current bulk event detector operations", notes = "User can only get their own bulk operations unless they are an admin")
@RequestMapping(method = RequestMethod.GET, value = "/bulk")
public MappingJacksonValue getBulkDataPointOperations(ASTNode query, Translations translations) {
List<TemporaryResource<EventDetectorBulkResponse, AbstractRestException>> preFiltered = this.bulkResourceManager.list();
// hide result property by setting a view
MappingJacksonValue resultWithView = new MappingJacksonValue(new FilteredStreamWithTotal<>(preFiltered, query, translations));
resultWithView.setSerializationView(Object.class);
return resultWithView;
}
use of com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource in project ma-modules-public by infiniteautomation.
the class DataPointTagsRestController method getBulkDataPointTagOperations.
@ApiOperation(value = "Get a list of current bulk tag operations", notes = "User can only get their own bulk tag operations unless they are an admin")
@RequestMapping(method = RequestMethod.GET, value = "/bulk")
public MappingJacksonValue getBulkDataPointTagOperations(ASTNode query, Translations translations) {
List<TemporaryResource<TagBulkResponse, AbstractRestException>> preFiltered = this.bulkResourceManager.list();
// hide result property by setting a view
MappingJacksonValue resultWithView = new MappingJacksonValue(new FilteredStreamWithTotal<>(preFiltered, query, translations));
resultWithView.setSerializationView(Object.class);
return resultWithView;
}
use of com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource in project ma-modules-public by infiniteautomation.
the class SystemActionTemporaryResourceManager method create.
/**
* Create the task
* @param permissionTypeName - To get from system settings
*/
public <T extends SystemActionResult> ResponseEntity<TemporaryResource<T, AbstractRestException>> create(SystemActionModel requestBody, PermissionHolder user, UriComponentsBuilder builder, String permissionTypeName, String resourceType, ResourceTask<SystemActionResult, AbstractRestException> task) {
requestBody.ensureValid();
Long expiration = requestBody.getExpiration();
Long timeout = requestBody.getTimeout();
if (permissionTypeName != null) {
PermissionDefinition def = ModuleRegistry.getPermissionDefinition(permissionTypeName);
if (def == null) {
throw new NotFoundException();
} else {
service.ensurePermission(user, def.getPermission());
}
} else {
service.ensureAdminRole(user);
}
@SuppressWarnings("unchecked") TemporaryResource<T, AbstractRestException> responseBody = (TemporaryResource<T, AbstractRestException>) resourceManager.newTemporaryResource(resourceType, null, expiration, timeout, task);
HttpHeaders headers = new HttpHeaders();
headers.setLocation(builder.path("/system-actions/status/{id}").buildAndExpand(responseBody.getId()).toUri());
return new ResponseEntity<TemporaryResource<T, AbstractRestException>>(responseBody, headers, HttpStatus.CREATED);
}
Aggregations