Search in sources :

Example 1 with PluginOperation

use of org.syncany.operations.plugin.PluginOperation in project syncany by syncany.

the class PluginManagementRequestHandler method handleRequest.

@Override
public Response handleRequest(final ManagementRequest request) {
    final PluginManagementRequest concreteRequest = (PluginManagementRequest) request;
    logger.log(Level.SEVERE, "Executing PluginOperation for action " + concreteRequest.getOptions().getAction() + " ...");
    Thread pluginThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                PluginOperation pluginOperation = new PluginOperation(null, concreteRequest.getOptions());
                PluginOperationResult operationResult = pluginOperation.execute();
                switch(operationResult.getResultCode()) {
                    case OK:
                        eventBus.post(new PluginManagementResponse(PluginManagementResponse.OK, operationResult, request.getId()));
                        break;
                    case NOK:
                        eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId()));
                        break;
                }
            } catch (Exception e) {
                logger.log(Level.WARNING, "Error executing plugin management request.", e);
                eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_OPERATION_FAILED, new PluginOperationResult(), request.getId()));
            }
        }
    }, "PlugRq/" + concreteRequest.getOptions().getAction());
    pluginThread.start();
    return null;
}
Also used : PluginOperation(org.syncany.operations.plugin.PluginOperation) PluginOperationResult(org.syncany.operations.plugin.PluginOperationResult)

Example 2 with PluginOperation

use of org.syncany.operations.plugin.PluginOperation in project syncany by syncany.

the class PluginCommand method execute.

@Override
public int execute(String[] operationArgs) throws Exception {
    PluginOperationOptions operationOptions = parseOptions(operationArgs);
    PluginOperationResult operationResult = new PluginOperation(config, operationOptions).execute();
    printResults(operationResult);
    return 0;
}
Also used : PluginOperation(org.syncany.operations.plugin.PluginOperation) PluginOperationResult(org.syncany.operations.plugin.PluginOperationResult) PluginOperationOptions(org.syncany.operations.plugin.PluginOperationOptions)

Aggregations

PluginOperation (org.syncany.operations.plugin.PluginOperation)2 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)2 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)1