use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class PointLinksDwr method init.
@DwrPermission(user = true)
public Map<String, Object> init() {
User user = Common.getUser();
Map<String, Object> data = new HashMap<String, Object>();
// Get the points that this user can access.
List<DataPointVO> allPoints = DataPointDao.instance.getDataPoints(DataPointExtendedNameComparator.instance, false);
List<IntStringPair> sourcePoints = new ArrayList<IntStringPair>();
List<IntStringPair> targetPoints = new ArrayList<IntStringPair>();
final boolean admin = Permissions.hasAdmin(user);
for (DataPointVO point : allPoints) {
if (admin || Permissions.hasDataPointReadPermission(user, point))
sourcePoints.add(new IntStringPair(point.getId(), point.getExtendedName()));
if (point.getPointLocator().isSettable() && (admin || Permissions.hasDataPointSetPermission(user, point)))
targetPoints.add(new IntStringPair(point.getId(), point.getExtendedName()));
}
data.put("sourcePoints", sourcePoints);
data.put("targetPoints", targetPoints);
// Get the existing point links.
List<PointLinkVO> pointLinks = new ArrayList<PointLinkVO>();
for (PointLinkVO pointLink : PointLinkDao.instance.getPointLinks()) {
if (containsPoint(sourcePoints, pointLink.getSourcePointId()) && containsPoint(targetPoints, pointLink.getTargetPointId()))
pointLinks.add(pointLink);
}
data.put("pointLinks", pointLinks);
return data;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class WatchListDwr method exportCurrentWatchlist.
@DwrPermission(user = true)
public ProcessResult exportCurrentWatchlist() {
ProcessResult result = new ProcessResult();
WatchListVO wl = getWatchList();
Map<String, Object> data = new LinkedHashMap<>();
// Get the Full VO for the export
List<WatchListVO> vos = new ArrayList<>();
vos.add(wl);
data.put(WatchListEmportDefinition.elementId, vos);
result.addData("json", EmportDwr.export(data, 3));
return result;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class WatchListDwr method moveUp.
@DwrPermission(user = true)
public void moveUp(int pointId) {
User user = Common.getUser();
WatchListVO watchList = getWatchList(user);
WatchListCommon.ensureWatchListEditPermission(user, watchList);
List<DataPointVO> points = watchList.getPointList();
DataPointVO point;
for (int i = 0; i < points.size(); i++) {
point = points.get(i);
if (point.getId() == pointId) {
points.set(i, points.get(i - 1));
points.set(i - 1, point);
break;
}
}
WatchListDao.instance.saveWatchList(watchList);
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class WatchListDwr method resetWatchListState.
@DwrPermission(anonymous = true)
public void resetWatchListState(int pollSessionId) {
LongPollData data = getLongPollData(pollSessionId, false);
synchronized (data.getState()) {
WatchListCommon.getWatchListStates(data).clear();
WatchListVO wl = getWatchList();
for (DataPointVO dp : wl.getPointList()) dp.resetLastValue();
}
notifyLongPollImpl(data.getRequest());
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.
the class MangoApiSystemSettingsDwr method loadHeaders.
@DwrPermission(admin = true)
public ProcessResult loadHeaders() {
ProcessResult result = new ProcessResult();
List<StringStringPair> headersList = new ArrayList<StringStringPair>();
String header = Common.envProps.getString("rest.cors.allowedOrigins", "");
if (!StringUtils.isEmpty(header))
headersList.add(new StringStringPair("Access-Control-Allow-Origin", header));
header = Common.envProps.getString("rest.cors.allowedMethods", "");
if (!StringUtils.isEmpty(header))
headersList.add(new StringStringPair("Access-Control-Allow-Methods", header));
header = Common.envProps.getString("rest.cors.allowedHeaders", "");
if (!StringUtils.isEmpty(header))
headersList.add(new StringStringPair("Access-Control-Allow-Headers", header));
header = Common.envProps.getString("rest.cors.exposedHeaders", "");
if (!StringUtils.isEmpty(header))
headersList.add(new StringStringPair("Access-Control-Expose-Headers", header));
headersList.add(new StringStringPair("Access-Control-Allow-Credentials", Boolean.toString(Common.envProps.getBoolean("rest.cors.allowCredentials", false))));
header = Common.envProps.getString("rest.cors.maxAge", "");
if (!StringUtils.isEmpty(header))
headersList.add(new StringStringPair("Access-Control-Max-Age", header));
result.addData("enabled", Common.envProps.getBoolean("rest.cors.enabled", false));
result.addData("headers", headersList);
return result;
}
Aggregations