2016-03-05 44 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个文件。