use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class RuntimeManagerRestController method relinquish.
@ApiOperation(value = "Relinquish the value of a data point", notes = "Only BACnet data points allow this", response = Void.class)
@RequestMapping(method = RequestMethod.POST, value = "/relinquish/{xid}")
public void relinquish(@ApiParam(value = "Valid Data Point XID", required = true, allowMultiple = false) @PathVariable String xid, @AuthenticationPrincipal PermissionHolder user, HttpServletRequest request) {
DataPointVO dataPoint = service.get(xid);
service.ensureReadPermission(user, dataPoint);
DataPointRT rt = Common.runtimeManager.getDataPoint(dataPoint.getId());
if (rt == null) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.pointNotEnabled", xid));
}
// Get the Data Source and Relinquish the point
DataSourceRT<?> dsRt = null;
try {
dsRt = Common.runtimeManager.getRunningDataSource(rt.getDataSourceId());
} catch (RTException e) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.dataSourceNotEnabled", xid));
}
dsRt.relinquish(rt);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class RuntimeManagerRestController method forceRefreshDataPoint.
@ApiOperation(value = "Force Refresh a data point", notes = "Not all data sources implement this feature", response = Void.class)
@RequestMapping(method = RequestMethod.PUT, value = "/force-refresh/{xid}")
public void forceRefreshDataPoint(@ApiParam(value = "Valid Data Point XID", required = true, allowMultiple = false) @PathVariable String xid, @AuthenticationPrincipal PermissionHolder user) {
DataPointVO vo = service.get(xid);
service.ensureReadPermission(user, vo);
DataPointRT rt = Common.runtimeManager.getDataPoint(vo.getId());
if (rt == null) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.pointNotEnabled", xid));
}
Common.runtimeManager.forcePointRead(vo.getId());
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class ServerRestController method acceptLicenseAgreement.
@ApiOperation(value = "Accept the current license agreement.", notes = "Only valid if the current license agreement has not been accepted. If you do not accept, Mango will restart in 15 seconds, giving you a 2nd chance in case you change your mind.")
@ApiResponses({ @ApiResponse(code = 400, message = "License already accepted.") })
@RequestMapping(method = { RequestMethod.POST }, value = "/accept-license-agreement")
public void acceptLicenseAgreement(@ApiParam(value = "Agree or not", required = true, allowMultiple = false) @RequestParam Boolean agree, @AuthenticationPrincipal PermissionHolder user) {
if (agree) {
systemSettingsDao.setIntValue(SystemSettingsDao.LICENSE_AGREEMENT_VERSION, Common.getLicenseAgreementVersion());
} else {
if (Common.getLicenseAgreementVersion() == systemSettingsDao.getIntValue(SystemSettingsDao.LICENSE_AGREEMENT_VERSION))
throw new BadRequestException(new TranslatableMessage("systemSettings.licenseAlreadyAgreed"));
// Start shutdown timer
log.error("Mango will restart in 15 seconds.");
Providers.get(IMangoLifecycle.class).scheduleShutdown(15000L, true, user);
}
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class PublishersWithoutPointsRestController method partialUpdate.
@ApiOperation(value = "Partially update a publisher, if points are supplied in model they will replace all existing points", notes = "Requires edit permission")
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<AbstractPublisherModel<?, ?>> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated data source", required = true) @PatchVORequestBody(service = PublisherService.class, modelClass = AbstractPublisherModel.class) AbstractPublisherModel<?, ?> model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
PublisherVO vo = service.update(xid, model.toVO());
URI location = builder.path("/publishers/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(map.apply(vo, user), headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class PublishersWithoutPointsRestController method save.
@ApiOperation(value = "Save publisher, if points are supplied in model they will replace all existing points")
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<AbstractPublisherModel<?, ?>> save(@RequestBody(required = true) AbstractPublisherModel<?, ?> model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder, HttpServletRequest request) {
PublisherVO vo = this.service.insert(model.toVO());
URI location = builder.path("/publishers/{xid}").buildAndExpand(new Object[] { vo.getXid() }).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(map.apply(vo, user), headers, HttpStatus.CREATED);
}
Aggregations