2013-12-11 22 views
0

我已經看到了關於使用XStorable.storeToURL和vnd.sun.star.webdav的多線程://域名:8080 //路徑/到/ document_library到OO文檔保存到WebDAV庫文件夾。不過,我還沒有看到有人在Java中成功使用過這個帖子。在使用OO Writer中的文件,保存菜單選項時,使用UCB vnd.sun.star.webdav:// domain:8080 // path/to/document_library/doc.odt時,會提示輸入用戶名並密碼。通過vnd.sun.star.webdav提供用戶名和密碼:// user:password @ domain:8080 /對我沒有幫助。我需要在Java類中使用此方法來保存OO文檔。有沒有人使用以下或類似的東西取得成功?XStorable storeToURL和WebDAV

xStorable.storeToURL("vnd.sun.star.webdav://domain:8080/path/to/document_library/doc.odt", storeProps) 

在OO開發人員指南,有一對第WebDAV身份驗證:需要進行身份驗證使用UCB的交互處理程序機制來訪問

DAV資源。 DAV內容調用客戶端提供的交互處理程序,讓它處理認證請求。交互處理程序的實現從一個位置(例如登錄對話框)收集用戶名或密碼,並將此數據作爲交互響應提供。

也許這是關係到這個問題?如果是這樣,當通過webdav嘗試storeToURL時如何使用交互處理程序進行身份驗證?

回答

0

添加InteractionHandler是個問題。這個增加,文檔可以通過storeToURL保存和傳遞處理程序作爲一個參數:

String oooExeFolder = "C:/OpenOffice/program"; 
XComponentContext xLocalContext = BootstrapSocketConnector.bootstrap(oooExeFolder); 
Object serviceManager = xLocalServiceManager.createInstanceWithContext("com.sun.star.task.InteractionHandler", xLocalContext); 
XInteractionHandler xHandler = (XInteractionHandler)UnoRuntime.queryInterface(XInteractionHandler.class, serviceManager); 
PropertyValue[] storeProps = new PropertyValue[1]; 
storeProps[0] = new PropertyValue(); 
storeProps[0].Name = "InteractionHandler"; 
storeProps[0].Value = xHandler; 
xStorable.storeToURL("vnd.sun.star.webdav://domain:8080/path/to/document_library/doc.odt", storeProps);