use of com.serotonin.m2m2.web.mvc.rest.v1.model.emport.JsonEmportControlModel in project ma-modules-public by infiniteautomation.
the class JsonConfigImportWebSocketHandler method handleTextMessage.
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) {
try {
User user = this.getUser(session);
// TODO Can anyone cancel the import?
if (user == null) {
return;
} else if (!user.isAdmin()) {
if (session.isOpen()) {
session.close(MangoWebSocketPublisher.NOT_AUTHORIZED);
}
return;
}
JsonEmportControlModel model = this.jacksonMapper.readValue(message.getPayload(), JsonEmportControlModel.class);
if (model != null && model.isCancel()) {
// Cancel the task if it is running
this.controller.cancelImport(model.getResourceId());
}
} catch (Exception e) {
try {
this.sendErrorMessage(session, MangoWebSocketErrorType.SERVER_ERROR, new TranslatableMessage("rest.error.serverError", e.getMessage()));
} catch (Exception e1) {
LOG.error(e.getMessage(), e);
}
}
}
Aggregations