use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsService method update.
@Override
protected MaintenanceEventVO update(MaintenanceEventVO existing, MaintenanceEventVO vo) throws PermissionException, ValidationException {
PermissionHolder user = Common.getUser();
ensureEditPermission(user, existing);
vo.setId(existing.getId());
ensureValid(existing, vo);
RTMDefinition.instance.saveMaintenanceEvent(vo);
return vo;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsService method delete.
/**
* Delete an event
*/
@Override
protected MaintenanceEventVO delete(MaintenanceEventVO vo) throws PermissionException, NotFoundException {
PermissionHolder user = Common.getUser();
ensureEditPermission(user, vo);
RTMDefinition.instance.deleteMaintenanceEvent(vo.getId());
return vo;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class TemporaryResourceManager method newTemporaryResource.
/**
* Creates a new temporary resource, how the task is executed depends on the manager implementation.
*
* @param resourceType unique type string assigned to each resource type e.g. BULK_DATA_POINT
* @param id if null will be assigned a UUID
* @param expiration time after the resource completes that it will be removed (milliseconds). If null or less than zero, it will be set to the default DEFAULT_EXPIRATION_MILLISECONDS
* @param timeout time after the resource starts that it will be timeout if not complete (milliseconds). If null or less than zero, it will be set to the default DEFAULT_TIMEOUT_MILLISECONDS
* @param task the task to be run
*/
public final TemporaryResource<T, E> newTemporaryResource(String resourceType, String id, Long expiration, Long timeout, ResourceTask<T, E> task) {
if (expiration == null || expiration < 0) {
expiration = Common.getMillis(Common.TIME_PERIOD_CODES.getId(environment.getProperty("rest.temporaryResource.expirationPeriodType", "HOURS")), environment.getProperty("rest.temporaryResource.expirationPeriods", Integer.class, 4));
}
if (timeout == null || timeout < 0) {
timeout = Common.getMillis(Common.TIME_PERIOD_CODES.getId(environment.getProperty("rest.temporaryResource.timeoutPeriodType", "HOURS")), environment.getProperty("rest.temporaryResource.timeoutPeriods", Integer.class, 3));
}
PermissionHolder user = Common.getUser();
TemporaryResource<T, E> resource = new TemporaryResource<T, E>(resourceType, id, user, expiration, timeout, task, this);
synchronized (resource) {
this.add(resource);
resource.schedule();
return resource;
}
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class UserModelMapping method map.
@Override
public UserModel map(Object o, PermissionHolder currentUser, RestModelMapper mapper) {
User user = (User) o;
UserModel model = new UserModel(user);
List<LinkedAccountModel> linkedAccounts = usersService.getLinkedAccounts(user).stream().map(account -> mapper.map(account, LinkedAccountModel.class, currentUser)).collect(Collectors.toList());
model.setLinkedAccounts(linkedAccounts);
return model;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class MangoWebSocketHandler method afterConnectionEstablished.
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
PermissionHolder user = getUser(session);
if (!permissionService.hasPermission(user, requiredPermission())) {
session.close(MangoWebSocketHandler.NOT_AUTHORIZED);
return;
}
// Used to close the socket after user's HttpSession is invalidated or when the authentication token expires.
this.sessionTracker.afterConnectionEstablished(session);
if (this.pingPongTimeoutMs > 0) {
this.startPingPong(session);
}
}
Aggregations