use of com.infiniteautomation.mango.rest.latest.exception.ModuleRestException in project ma-modules-public by infiniteautomation.
the class ModulesRestController method markModuleForDeletion.
@ApiOperation(value = "Set Marked For Deletion state of Module", notes = "Marking a module for deletion will un-install it upon restart")
@RequestMapping(method = RequestMethod.PUT, value = "/deletion-state")
public ModuleModel markModuleForDeletion(@ApiParam(value = "Deletion State", required = true, defaultValue = "false", allowMultiple = false) @RequestParam(name = "delete", required = true) boolean delete, @ApiParam(value = "Module model") @RequestBody() ModuleModel model, @AuthenticationPrincipal PermissionHolder user, HttpServletRequest request) {
permissionService.ensureAdminRole(user);
Module module = ModuleRegistry.getModule(model.getName());
if (module == null)
throw new NotFoundException();
module.setMarkedForDeletion(delete);
if (module.isMarkedForDeletion() != delete)
throw new ModuleRestException(HttpStatus.BAD_REQUEST, new TranslatableMessage("rest.modules.error.dependencyFailure"));
return new ModuleModel(module);
}
use of com.infiniteautomation.mango.rest.latest.exception.ModuleRestException in project ma-modules-public by infiniteautomation.
the class ModulesRestController method markForDeletion.
@ApiOperation(value = "Set Marked For Deletion state of Module", notes = "Marking a module for deletion will un-install it upon restart")
@RequestMapping(method = RequestMethod.PUT, value = "/deletion-state/{moduleName}")
public ResponseEntity<ModuleModel> markForDeletion(@PathVariable String moduleName, @ApiParam(value = "Deletion State", required = true, defaultValue = "false", allowMultiple = false) @RequestParam(name = "delete", required = true) boolean delete, @AuthenticationPrincipal PermissionHolder user, HttpServletRequest request) {
Module module = ModuleRegistry.getModule(moduleName);
if (module == null)
throw new NotFoundException();
module.setMarkedForDeletion(delete);
if (module.isMarkedForDeletion() != delete)
throw new ModuleRestException(HttpStatus.BAD_REQUEST, new TranslatableMessage("rest.modules.error.dependencyFailure"));
return ResponseEntity.ok(new ModuleModel(module));
}
Aggregations