Search in sources :

Example 1 with EventUserInteractionListener

use of org.syncany.operations.daemon.EventUserInteractionListener in project syncany by syncany.

the class ConnectManagementRequestHandler method handleRequest.

@Override
public Response handleRequest(final ManagementRequest request) {
    final ConnectManagementRequest concreteRequest = (ConnectManagementRequest) request;
    logger.log(Level.SEVERE, "Executing ConnectOperation for folder " + concreteRequest.getOptions().getLocalDir() + " ...");
    Thread connectThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                ConnectOperation initOperation = new ConnectOperation(concreteRequest.getOptions(), new EventUserInteractionListener());
                ConnectOperationResult operationResult = initOperation.execute();
                switch(operationResult.getResultCode()) {
                    case OK:
                        eventBus.post(new ConnectManagementResponse(ConnectManagementResponse.OK, operationResult, request.getId()));
                        break;
                    case NOK_TEST_FAILED:
                        eventBus.post(new ConnectManagementResponse(ConnectManagementResponse.NOK_FAILED_TEST, operationResult, request.getId()));
                        break;
                    default:
                        eventBus.post(new ConnectManagementResponse(ConnectManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId()));
                        break;
                }
            } catch (Exception e) {
                logger.log(Level.WARNING, "Error adding watch to daemon config.", e);
                eventBus.post(new ConnectManagementResponse(ConnectManagementResponse.NOK_OPERATION_FAILED, new ConnectOperationResult(), request.getId()));
            }
        }
    }, "ConRq/" + concreteRequest.getOptions().getLocalDir().getName());
    connectThread.start();
    return null;
}
Also used : ConnectOperationResult(org.syncany.operations.init.ConnectOperationResult) EventUserInteractionListener(org.syncany.operations.daemon.EventUserInteractionListener) ConnectOperation(org.syncany.operations.init.ConnectOperation)

Example 2 with EventUserInteractionListener

use of org.syncany.operations.daemon.EventUserInteractionListener in project syncany by syncany.

the class InitManagementRequestHandler method handleRequest.

@Override
public Response handleRequest(final ManagementRequest request) {
    final InitManagementRequest concreteRequest = (InitManagementRequest) request;
    logger.log(Level.SEVERE, "Executing InitOperation for folder " + concreteRequest.getOptions().getLocalDir() + " ...");
    Thread initThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                InitOperation initOperation = new InitOperation(concreteRequest.getOptions(), new EventUserInteractionListener());
                InitOperationResult operationResult = initOperation.execute();
                switch(operationResult.getResultCode()) {
                    case OK:
                        eventBus.post(new InitManagementResponse(InitManagementResponse.OK, operationResult, request.getId()));
                        break;
                    case NOK_TEST_FAILED:
                        eventBus.post(new InitManagementResponse(InitManagementResponse.NOK_FAILED_TEST, operationResult, request.getId()));
                        break;
                    default:
                        eventBus.post(new InitManagementResponse(InitManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId()));
                        break;
                }
            } catch (Exception e) {
                logger.log(Level.WARNING, "Error adding watch to daemon config.", e);
                eventBus.post(new InitManagementResponse(InitManagementResponse.NOK_OPERATION_FAILED, new InitOperationResult(), request.getId()));
            }
        }
    }, "IntRq/" + concreteRequest.getOptions().getLocalDir().getName());
    initThread.start();
    return null;
}
Also used : InitOperationResult(org.syncany.operations.init.InitOperationResult) InitOperation(org.syncany.operations.init.InitOperation) EventUserInteractionListener(org.syncany.operations.daemon.EventUserInteractionListener)

Aggregations

EventUserInteractionListener (org.syncany.operations.daemon.EventUserInteractionListener)2 ConnectOperation (org.syncany.operations.init.ConnectOperation)1 ConnectOperationResult (org.syncany.operations.init.ConnectOperationResult)1 InitOperation (org.syncany.operations.init.InitOperation)1 InitOperationResult (org.syncany.operations.init.InitOperationResult)1