Package org.syncany.operations.init

Examples of org.syncany.operations.init.ConnectOperationOptions


    ConfigTO connectionConfigToB = initOperationOptionsA.getConfigTO();
    connectionConfigToB.setMachineName("clientB" + Math.abs(new Random().nextInt()));
    connectionConfigToB.setMasterKey(null);

    ConnectOperationOptions connectOperationOptionsB = new ConnectOperationOptions();
    connectOperationOptionsB.setStrategy(ConnectOptionsStrategy.CONNECTION_TO);
    connectOperationOptionsB.setConfigTO(connectionConfigToB);
    connectOperationOptionsB.setPassword(initOperationOptionsA.getPassword());
    connectOperationOptionsB.setLocalDir(localDirB);

    ConnectOperation connectOperationB = new ConnectOperation(connectOperationOptionsB, null);
    ConnectOperationResult connectOperationResultB = connectOperationB.execute();

    assertEquals(ConnectResultCode.OK, connectOperationResultB.getResultCode());
View Full Code Here


    ConfigTO connectionConfigToB = initOperationOptionsA.getConfigTO();
    ((LocalTransferSettings) connectionConfigToB.getTransferSettings()).setPath(new File("/does/not/exist")); // <<< Point to non-existing repo
    connectionConfigToB.setMachineName("client-B" + Math.abs(new Random().nextInt()));
    connectionConfigToB.setMasterKey(null);

    ConnectOperationOptions connectOperationOptionsB = new ConnectOperationOptions();
    connectOperationOptionsB.setStrategy(ConnectOptionsStrategy.CONNECTION_TO);
    connectOperationOptionsB.setConfigTO(connectionConfigToB);
    connectOperationOptionsB.setPassword(initOperationOptionsA.getPassword());
    connectOperationOptionsB.setLocalDir(localDirB);

    ConnectOperation connectOperationB = new ConnectOperation(connectOperationOptionsB, null);
    ConnectOperationResult connectOperationResultB = connectOperationB.execute();

    assertEquals(ConnectResultCode.NOK_TEST_FAILED, connectOperationResultB.getResultCode());
View Full Code Here

  @Override
  public int execute(String[] operationArgs) throws Exception {
    boolean retryNeeded = true;
    boolean performOperation = true;

    ConnectOperationOptions operationOptions = parseOptions(operationArgs);

    while (retryNeeded && performOperation) {
      ConnectOperationResult operationResult = client.connect(operationOptions, this);
      printResults(operationResult);

      retryNeeded = operationResult.getResultCode() != ConnectResultCode.OK
          && operationResult.getResultCode() != ConnectResultCode.NOK_DECRYPT_ERROR;

      if (retryNeeded) {
        performOperation = isInteractive && askRetryConnection();

        if (performOperation) {
          updateTransferSettings(operationOptions.getConfigTO().getTransferSettings());
        }
      }
    }

    return 0;
View Full Code Here

    return 0;
  }

  @Override
  public ConnectOperationOptions parseOptions(String[] operationArgs) throws Exception {
    ConnectOperationOptions operationOptions = new ConnectOperationOptions();

    OptionParser parser = new OptionParser();
    OptionSpec<String> optionPlugin = parser.acceptsAll(asList("P", "plugin")).withRequiredArg();
    OptionSpec<String> optionPluginOpts = parser.acceptsAll(asList("o", "plugin-option")).withRequiredArg();
    OptionSpec<Void> optionAddDaemon = parser.acceptsAll(asList("n", "add-daemon"));
    OptionSpec<String> optionPassword = parser.acceptsAll(asList("password")).withRequiredArg();

    OptionSet options = parser.parse(operationArgs);
    List<?> nonOptionArgs = options.nonOptionArguments();

    // Set interactivity mode 
    isInteractive = !options.has(optionPlugin) && !options.has(optionPassword);
   
    // Plugin
    TransferSettings transferSettings = null;

    if (nonOptionArgs.size() == 1) {
      String connectLink = (String) nonOptionArgs.get(0);

      operationOptions.setStrategy(ConnectOptionsStrategy.CONNECTION_LINK);
      operationOptions.setConnectLink(connectLink);

      transferSettings = null;
    }
    else if (nonOptionArgs.size() == 0) {
      operationOptions.setStrategy(ConnectOptionsStrategy.CONNECTION_TO);
      operationOptions.setConnectLink(null);

      transferSettings = createTransferSettingsFromOptions(options, optionPlugin, optionPluginOpts);
    }
    else {
      throw new Exception("Invalid syntax.");
    }

    ConfigTO configTO = createConfigTO(transferSettings);

    operationOptions.setLocalDir(localDir);
    operationOptions.setConfigTO(configTO);
    operationOptions.setDaemon(options.has(optionAddDaemon));
    operationOptions.setPassword(validateAndGetPassword(options, optionPassword));

    return operationOptions;
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.init.ConnectOperationOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.