use of com.infiniteautomation.mango.util.exception.TranslatableIllegalStateException in project ma-modules-public by infiniteautomation.
the class EventDetectorsRestController method getState.
@ApiOperation(value = "Get Event Detector's internal state", notes = "User must have read permission for the data point", response = AbstractEventDetectorRTModel.class)
@RequestMapping(method = RequestMethod.GET, value = "/runtime/{xid}")
public AbstractEventDetectorRTModel<?> getState(@ApiParam(value = "ID of Event detector", required = true, allowMultiple = false) @PathVariable String xid, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
AbstractEventDetectorVO vo = service.get(xid);
// For now all detectors are data point type
DataPointRT rt = Common.runtimeManager.getDataPoint(vo.getSourceId());
if (rt == null) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.pointNotEnabled", xid));
}
for (PointEventDetectorRT<?> edrt : rt.getEventDetectors()) {
if (edrt.getVO().getId() == vo.getId()) {
return modelMapper.map(edrt, AbstractEventDetectorRTModel.class, user);
}
}
throw new NotFoundRestException();
}
use of com.infiniteautomation.mango.util.exception.TranslatableIllegalStateException 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.infiniteautomation.mango.util.exception.TranslatableIllegalStateException 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.infiniteautomation.mango.util.exception.TranslatableIllegalStateException in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsService method getEventRT.
public MaintenanceEventRT getEventRT(String xid) throws NotFoundException, PermissionException, TranslatableIllegalStateException {
PermissionHolder user = Common.getUser();
MaintenanceEventVO existing = dao.getByXid(xid);
if (existing == null)
throw new NotFoundException();
ensureTogglePermission(existing, user);
MaintenanceEventRT rt = RTMDefinition.instance.getRunningMaintenanceEvent(existing.getId());
if (rt == null)
throw new TranslatableIllegalStateException(new TranslatableMessage("maintenanceEvents.toggle.disabled"));
return rt;
}
use of com.infiniteautomation.mango.util.exception.TranslatableIllegalStateException in project ma-modules-public by infiniteautomation.
the class RuntimeManagerRestController method resetCache.
@ApiOperation(value = "Reset the cache on a running data point", notes = "Must have edit access to the data point", response = Void.class)
@RequestMapping(method = RequestMethod.POST, value = "/reset-cache/{xid}")
public void resetCache(@ApiParam(value = "Valid Data Point XID", required = true, allowMultiple = false) @PathVariable String xid, @AuthenticationPrincipal PermissionHolder user, HttpServletRequest request) {
DataPointVO vo = service.get(xid);
service.ensureEditPermission(user, vo);
DataPointRT rt = Common.runtimeManager.getDataPoint(vo.getId());
if (rt == null) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.pointNotEnabled", xid));
}
rt.invalidateCache();
}
Aggregations