2016-03-05 113 views
0

我無法理解Apache Camel。我需要從Google雲端硬盤中刪除一個文件。以下是我的代碼。駱駝:用Google Drive刪除文件

private static List scopes = Arrays.asList(「https://www.googleapis.com/auth/drive.file」);

public static void main(String[] args) throws Exception 
{  
    CamelContext context = new DefaultCamelContext(); 

     GoogleDriveConfiguration configuration = new GoogleDriveConfiguration(); 
     configuration.setApplicationName("camel"); 
     configuration.setClientId(".."); 
     configuration.setClientSecret(".."); 
     configuration.setScopes(scopes); 
     configuration.setAccessToken(".."); 
     configuration.setRefreshToken(".."); 

     GoogleDriveComponent googleDriveComponent = new GoogleDriveComponent(); 
     googleDriveComponent.setConfiguration(configuration); 
     context.addComponent("google-drive", googleDriveComponent); 

     context.addRoutes( 
      new RouteBuilder() 
      { 
       @Override 
       public void configure() throws Exception 
       { 
        from("google-drive://drive-files/delete?fileId=..").log(LoggingLevel.INFO, "${body}"); 
       } 
      }); 
      context.start(); 
      Thread.sleep(10000); 
      context.stop(); 
     }} 

請指教一下。我究竟做錯了什麼?

堆棧跟蹤:

org.apache.camel.RuntimeCamelException:com.google.api.client.googleapis.json.GoogleJsonResponseException:404未找到 { 「代碼」:404, 「錯誤」:[ {location}「:」file「, 」locationType「:」other「, 」message「:」File not found:..「, 」reason「:」notFound「 }], 「message」:「File not found:..」 }

+0

駱駝是關於整合,或幫助他們之間的各種系統的整合。雖然你可以使用駝峯谷歌文檔組件,但如果你只是想「在谷歌文檔中刪除文件」,那麼你應該使用別的東西。 –

+0

感謝您的諮詢!我的主要任務 - 處理駱駝。我想完成這個程序。 – Tolik

回答

0

如果你不得不使用camel而不是「from」,我會在1個時間計時器上啓動一個路由,下一步路由會在我自己的類中調用一個方法,它將接受文件名並從谷歌驅動器中刪除它,然後記錄迴應。我同意@Jeremie B,你可能不應該用駱駝來刪除1個文件。