Package org.syncany.operations.restore

Examples of org.syncany.operations.restore.RestoreOperationOptions


    //assertEquals("No local changes.\n", cliResponse.getOutput());
   
    // Restore file test
   
    RestoreFolderRequest restoreRequest = new RestoreFolderRequest();
    RestoreOperationOptions restoreOperationOption = new RestoreOperationOptions();
    restoreOperationOption.setFileHistoryId(files[0].getFileHistoryId());
    restoreOperationOption.setFileVersion(1);
   
    restoreRequest.setId(70);
    restoreRequest.setRoot(clientA.getConfig().getLocalDir().getAbsolutePath());
    restoreRequest.setOptions(restoreOperationOption);
   
View Full Code Here


    FileUtils.moveFile(clientA.getLocalFile("A-original"), deletedFile);
           
    clientA.upWithForceChecksum();
   
    // A restore
    RestoreOperationOptions operationOptions = new RestoreOperationOptions();
   
    operationOptions.setFileHistoryId(originalFileHistoryId);
    operationOptions.setFileVersion(1);
   
    clientA.restore(operationOptions);
   
    assertTrue(clientA.getLocalFile("A-original (restored version 1)").exists());
    assertEquals(
View Full Code Here

    FileUtils.moveFile(clientA.getLocalFile("A-original"), deletedFile);
           
    clientA.upWithForceChecksum();
   
    // A restore
    RestoreOperationOptions operationOptions = new RestoreOperationOptions();
   
    operationOptions.setFileHistoryId(originalFileHistoryId);
    operationOptions.setFileVersion(1);
    operationOptions.setRelativeTargetPath("restored-file");
   
    clientA.restore(operationOptions);
   
    assertTrue(clientA.getLocalFile("restored-file").exists());
    assertEquals(
View Full Code Here

    clientA.upWithForceChecksum();
   
    assertFalse(clientA.getLocalFile("folder").exists());

    // A restore
    RestoreOperationOptions operationOptions = new RestoreOperationOptions();
   
    operationOptions.setFileHistoryId(originalFileHistoryId);
    operationOptions.setFileVersion(1);
   
    clientA.restore(operationOptions);
   
    assertTrue(clientA.getLocalFile("folder/subfolder").exists());
    assertTrue(clientA.getLocalFile("folder/subfolder/A-original (restored version 1)").exists());
View Full Code Here

    return true;
  }
 
  @Override
  public int execute(String[] operationArgs) throws Exception {
    RestoreOperationOptions operationOptions = parseOptions(operationArgs);
    RestoreOperationResult operationResult = client.restore(operationOptions);
   
    printResults(operationResult);
   
    return 0;   
View Full Code Here

    return 0;   
  }
 
  @Override
  public RestoreOperationOptions parseOptions(String[] operationArgs) throws Exception {
    RestoreOperationOptions operationOptions = new RestoreOperationOptions();

    OptionParser parser = new OptionParser()
    parser.allowsUnrecognizedOptions();
   
    OptionSpec<Integer> optionRevision = parser.acceptsAll(asList("r", "revision")).withRequiredArg().ofType(Integer.class);
    OptionSpec<String> optionTarget = parser.acceptsAll(asList("t", "target")).withRequiredArg().ofType(String.class);
   
    OptionSet options = parser.parse(operationArgs)
   
    // --revision=<n>
    if (options.has(optionRevision)) {
      operationOptions.setFileVersion(options.valueOf(optionRevision));
    }
   
    // --target=<file>
    if (options.has(optionTarget)) {
      operationOptions.setRelativeTargetPath(options.valueOf(optionTarget));
    }
   
    // <file-history-id>
    List<?> nonOptionArgs = options.nonOptionArguments();
   
    if (nonOptionArgs.size() != 1) {
      throw new Exception("Invalid Syntax: File history ID must be specified.");
    }
       
    FileHistoryId restoreFileHistory = FileHistoryId.parseFileId(nonOptionArgs.get(0).toString());
    operationOptions.setFileHistoryId(restoreFileHistory)
   
    return operationOptions;
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.restore.RestoreOperationOptions

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.