Search in sources :

Example 1 with UpdateOperationResult

use of org.syncany.operations.update.UpdateOperationResult in project syncany by syncany.

the class UpdateCommand method execute.

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

Example 2 with UpdateOperationResult

use of org.syncany.operations.update.UpdateOperationResult in project syncany by syncany.

the class UpdateManagementRequestHandler method handleRequest.

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

        @Override
        public void run() {
            try {
                UpdateOperation updateOperation = new UpdateOperation(null, concreteRequest.getOptions());
                UpdateOperationResult operationResult = updateOperation.execute();
                switch(operationResult.getResultCode()) {
                    case OK:
                        eventBus.post(new UpdateManagementResponse(UpdateManagementResponse.OK, operationResult, request.getId()));
                        break;
                    case NOK:
                        eventBus.post(new UpdateManagementResponse(UpdateManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId()));
                        break;
                }
            } catch (Exception e) {
                logger.log(Level.WARNING, "Error executing update management request.", e);
                eventBus.post(new UpdateManagementResponse(UpdateManagementResponse.NOK_OPERATION_FAILED, new UpdateOperationResult(), request.getId()));
            }
        }
    }, "UpdRq/" + concreteRequest.getOptions().getAction());
    updateThread.start();
    return null;
}
Also used : UpdateOperationResult(org.syncany.operations.update.UpdateOperationResult) UpdateOperation(org.syncany.operations.update.UpdateOperation)

Example 3 with UpdateOperationResult

use of org.syncany.operations.update.UpdateOperationResult in project syncany by syncany.

the class UpdateOperationTest method testUpdateCheck.

@Test
public void testUpdateCheck() throws Exception {
    UpdateOperationOptions updateOptions = new UpdateOperationOptions();
    updateOptions.setAction(UpdateOperationAction.CHECK);
    // Run
    UpdateOperationResult updateResult = new UpdateOperation(null, updateOptions).execute();
    // Test
    assertNotNull(updateResult);
    assertEquals(UpdateResultCode.OK, updateResult.getResultCode());
    assertEquals(UpdateOperationAction.CHECK, updateResult.getAction());
    assertNotNull(updateResult.getAppInfo());
    assertNotNull(updateResult.getAppInfo().getAppVersion());
    assertNotNull(updateResult.getAppInfo().getArchitecture());
    assertNotNull(updateResult.getAppInfo().getDate());
    assertNotNull(updateResult.getAppInfo().getDist());
    assertNotNull(updateResult.getAppInfo().getDownloadUrl());
    assertNotNull(updateResult.getAppInfo().getOperatingSystem());
    assertNotNull(updateResult.getAppInfo().getType());
}
Also used : UpdateOperationOptions(org.syncany.operations.update.UpdateOperationOptions) UpdateOperationResult(org.syncany.operations.update.UpdateOperationResult) UpdateOperation(org.syncany.operations.update.UpdateOperation) Test(org.junit.Test)

Aggregations

UpdateOperation (org.syncany.operations.update.UpdateOperation)3 UpdateOperationResult (org.syncany.operations.update.UpdateOperationResult)3 UpdateOperationOptions (org.syncany.operations.update.UpdateOperationOptions)2 Test (org.junit.Test)1