Example #1
0
  public static void main(String[] args) throws IOException {
    // Only display important log messages.
    Logger.getLogger("").setLevel(Level.WARNING);

    String argAuthFile = "token.auth";

    // Read auth info file.
    DbxAuthInfo authInfo;
    try {
      authInfo = DbxAuthInfo.Reader.readFromFile(argAuthFile);
    } catch (JsonReader.FileLoadException ex) {
      System.err.println("Error loading <auth-file>: " + ex.getMessage());
      System.exit(1);
      return;
    }

    // Create a DbxClientV1, which is what you use to make API calls.
    String userLocale = Locale.getDefault().toString();
    DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info", userLocale);
    DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.accessToken, authInfo.host);

    // Make the /account/info API call.
    DbxUsers.FullAccount dbxAccountInfo;
    DbxUsers.SpaceUsage dbxSpaceUsage;
    try {
      dbxAccountInfo = dbxClient.users.getCurrentAccount();
    } catch (DbxException ex) {
      System.err.println("Error making API call: " + ex.getMessage());
      System.exit(1);
      return;
    }

    System.out.print(dbxAccountInfo.toStringMultiline());
  }
  @Override
  protected void buildServerRequest(IServerRequest aServerRequest) {
    String code = getHttpParam(RequestConstants.CODE);
    String[] files = GsonHelper.fromGson(getHttpParam(RequestConstants.FILES), String[].class);

    List<String> paths = new ArrayList<String>();

    for (String file : files) {
      String[] splited = StringUtils.split(file, "/");
      StringBuilder pathBuilder = new StringBuilder();
      for (int i = 5; i < splited.length; i++) pathBuilder.append("/").append(splited[i]);
      paths.add(pathBuilder.toString());
    }

    long userId = Long.parseLong(getHttpParam(RequestConstants.USER_ID));

    try {
      aServerRequest.addField(
          RequestConstants.DTO_LIST, dropboxAPI.getMarkers(code, paths, userId));
    } catch (DbxException e) {
      // TODO
      e.printStackTrace();
    }
  }