java google data transfer does not transfer data

Asked 2 years ago, Updated 2 years ago, 65 views

I'm sorry.please tell me。
Attempting to change the owner of the google drive using Google's data transfer api in java
The following code has been combined.
After running it, I received an email from Google saying that the data transfer was successful. I thought it was a success, but even if I log in with the target user's account and look at the drive,
Data does not appear to have been transferred.
Does anyone know anything wrong?

public static void main(String[]args)throws Exception {

    Directory dir=getDirectoryService();
    User user1 = dir.users().get("[email protected]").execute();
    User user2=dir.users().get("[email protected]").execute();
    DataTransfer d=getDataTransferService();

    ApplicationsListResponse l=d.applications().list().setMaxResults(100).execute();
    Application app = null;
    for (Application a:l.getApplications())
    {
        if(a.getName().equals("Drive and Docs"))
        {
            ap = a;
        }
    }

    ApplicationDataTransfer applicationdataTransfer=new ApplicationDataTransfer();
    applicationdatatransfer.setApplicationId(apl.getId());
    com.google.api.services.admin.datatransfer.model.DataTransfer=new com.google.api.services.admin.datransfer.model.DataTransfer();
    t.setOldOwnerUserId(user2.getId());
    t.setNewOwnerUserId(user1.getId());
    t.setApplicationDataTransfers (Arrays.asList(applicationdatatransfer)));

    com.google.api.services.admin.datatransfer.model.DataTransfer t=null;
    tt=d.transfers().insert(t).execute();

    System.out.println(tt.getId());
    System.out.println("---------------------------");
    System.out.println(tt.getEtag());
    System.out.println("---------------------------");
    System.out.println(tt.getOverallTransferStatusCode());
    System.out.println("=======================");
    System.out.println("#######################";



    com.google.api.services.admin.datatransfer.model.DataTransfersListResponse response=d.transfers().list().execute();
    for (com.google.api.services.admin.datatransfer.model.DataTransfertt:response.getDataTransfers())
    {
        System.out.println(ttt.getId());
        System.out.println("---------------------------");
        System.out.println(ttt.getEtag());
        System.out.println("---------------------------");
        System.out.println(ttt.getOverallTransferStatusCode());
        System.out.println("=======================");
    }
}

java google-api

2022-09-30 11:04

1 Answers

I'm sorry, but I solved myself.
I set ApplicationTransferParam and it worked.

ApplicationTransferParamp=new ApplicationTransferParam();
p.setKey("PRIVACY_LEVEL");
p.setValue(Arrays.asList("PRIVATE", "SHARED"));
applicationdatatransfer.setApplicationTransferParams (Arrays.asList(p));


2022-09-30 11:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.