本文整理汇总了Java中com.github.sardine.Sardine类的典型用法代码示例。如果您正苦于以下问题:Java Sardine类的具体用法?Java Sardine怎么用?Java Sardine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sardine类属于com.github.sardine包,在下文中一共展示了Sardine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: listFolderContent
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* List all file names and subfolders of the specified path traversing into subfolders to the given depth.
*
* @param path path of the folder
* @param depth depth of recursion while listing folder contents
* @return found file names and subfolders
*/
public List<String> listFolderContent(String path, int depth)
{
String url = (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+path ;
List<String> retVal= new LinkedList<>();
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
List<DavResource> resources;
try {
resources = sardine.list(url, depth);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
for (DavResource res : resources)
{
retVal.add(res.getName());
}
return retVal;
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:27,代码来源:Folders.java
示例2: uploadFile
import com.github.sardine.Sardine; //导入依赖的package包/类
/** Uploads a file at the specified path with the data from the InputStream
*
* @param inputStream InputStream of the file which should be uploaded
* @param remotePath path where the file should be uploaded to
*/
public void uploadFile(InputStream inputStream, String remotePath)
{
String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + remotePath;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());
try {
sardine.put(path, inputStream);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:21,代码来源:Files.java
示例3: put
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void put(InputStream in, long length, String remotePath)
throws Throwable {
String url = PathUtil.join(_serverAddress, remotePath);
String uri = URIEncoder.encode(url);
Sardine sardine = getSardineInstance();
try {
if (length >= 0) {
try {
((SardineImpl) sardine).put(uri, new InputStreamEntity(in,
length), null, false);
} catch (SardineException e) {
// log it in the server log.
System.out.println("WebDav Error: " + e.getMessage());
throw e;
}
} else {
// unknown length. It will fail if the server requires
// Content-Length.
sardine.put(uri, in);
}
} finally {
sardine.shutdown();
}
}
开发者ID:uom-daris,项目名称:daris,代码行数:26,代码来源:WebdavClientImpl.java
示例4: deleteDocument
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void deleteDocument(String filePath)throws Exception
{
if(filePath == null)
{
throw new Exception("The filepath is not vaild");
}
else
{
try {
String fileUrl = "" + apiRepositoryUrl + filePath;
if(projectExists(fileUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
method.delete(fileUrl);
}
}
catch (IOException ioe)
{
String error = "Could not delete the document in the repository because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:27,代码来源:ECCConfigAPIImpl.java
示例5: ingest
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void ingest() {
long failedRecordsCount = 0;
Sardine sardine = null;
try {
sardine = SardineFactory.begin();
failedRecordsCount = processWebdavFolder(sardine, ingest.getActualUrl());
} catch (Exception e) {
saveException(e, IngestReportErrorType.SYSTEM_ERROR);
} finally {
if (sardine != null) {
sardine.shutdown();
}
}
report.setFailedRecordsCount(failedRecordsCount);
}
开发者ID:OpenGeoportal,项目名称:ogpHarvester,代码行数:17,代码来源:WebdavIngestJob.java
示例6: exists
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* Checks if the folder at the specified path exists
*
* @param rootPath path of the folder
* @return true if the folder exists
*/
public boolean exists(String rootPath)
{
String path= (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
try {
return sardine.exists(path);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:19,代码来源:Folders.java
示例7: createFolder
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* Creates a folder at the specified path
*
* @param rootPath path of the folder
*/
public void createFolder(String rootPath)
{
String path= (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
try {
sardine.createDirectory(path);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Folders.java
示例8: deleteFolder
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* Deletes the folder at the specified path
*
* @param rootPath path of the folder
*/
public void deleteFolder(String rootPath)
{
String path= (_serverConfig.isUseHTTPS() ? "https" : "http") +"://"+_serverConfig.getServerName()+"/"+WEB_DAV_BASE_PATH+rootPath ;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
try {
sardine.delete(path);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Folders.java
示例9: fileExists
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* method to check if a file already exists
*
* @param rootPath path of the file
* @return boolean value if the given file exists or not
*/
public boolean fileExists(String rootPath){
String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + rootPath;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());
try {
return sardine.exists(path);
} catch (IOException e) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:21,代码来源:Files.java
示例10: removeFile
import com.github.sardine.Sardine; //导入依赖的package包/类
/**
* method to remove files
* @param rootPath path of the file which should be removed
*/
public void removeFile(String rootPath) {
String path = (_serverConfig.isUseHTTPS() ? "https" : "http") + "://" + _serverConfig.getServerName() + "/" + WEB_DAV_BASE_PATH + rootPath;
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(_serverConfig.getUserName(), _serverConfig.getPassword());
sardine.enablePreemptiveAuthentication(_serverConfig.getServerName());
try {
sardine.delete(path);
} catch ( IOException e ) {
throw new NextcloudApiException(e);
}
}
开发者ID:a-schild,项目名称:nextcloud-java-api,代码行数:18,代码来源:Files.java
示例11: get
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public InputStream get(String remotePath) throws Throwable {
String url = PathUtil.join(_serverAddress, remotePath);
String uri = URIEncoder.encode(url);
Sardine sardine = getSardineInstance();
InputStream in = null;
try {
in = sardine.get(uri);
} finally {
sardine.shutdown();
}
return in;
}
开发者ID:uom-daris,项目名称:daris,代码行数:14,代码来源:WebdavClientImpl.java
示例12: mkdir
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void mkdir(String remotePath, boolean parents) throws Throwable {
if (remotePath == null) {
return;
}
remotePath = remotePath.trim();
if (remotePath.isEmpty() || remotePath.equals("/")) {
return;
}
remotePath = PathUtil.trimTrailingSlash(remotePath);
String url = PathUtil.join(_serverAddress,
PathUtil.appendSlash(remotePath));
String uri = URIEncoder.encode(url);
if (exists(uri)) {
// already exists
return;
}
Sardine sardine = getSardineInstance();
if (parents) {
// create parent directories. If parent directories do not exist and
// you will not be able to create the child directory.
mkdir(PathUtil.getParentDirectory(remotePath, true), true);
}
try {
sardine.createDirectory(uri);
} catch (SardineException e) {
String msg = e.getMessage();
if (msg != null && msg.contains("405 Method Not Allowed")) {
// NOTE: if http response 405, means the directory already
// exists. That might be created by other threads.
System.out
.println("WebDAV Sink: HTTP Response: '405 Method Not Allowed' when creating directory "
+ uri
+ ". It indicates the directory already exists.");
} else {
// log it in the server log.
System.out.println("WebDav Error: " + e.getMessage());
throw e;
}
}
}
开发者ID:uom-daris,项目名称:daris,代码行数:42,代码来源:WebdavClientImpl.java
示例13: delete
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void delete(String remotePath) throws Throwable {
String url = PathUtil.join(_serverAddress, remotePath);
String uri = URIEncoder.encode(url);
Sardine sardine = getSardineInstance();
sardine.delete(uri);
}
开发者ID:uom-daris,项目名称:daris,代码行数:8,代码来源:WebdavClientImpl.java
示例14: deleteComponentFeatureConfig
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void deleteComponentFeatureConfig ( String component, String feature) throws Exception
{
if(component == null)
{
throw new Exception("Component is invalid");
}
else if(feature == null)
{
throw new Exception("Feature is not valid");
}
else
{
String configUrl = "" + getProjectUrl() + "/" + component + "/" + feature + "/config.json";
if(projectExists(configUrl))
{
try
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
method.delete( configUrl );
}
catch (IOException ioe)
{
String error = "Could not delete the document in the repository because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:32,代码来源:ECCConfigAPIImpl.java
示例15: createComponentFeature
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void createComponentFeature (String component, String feature) throws Exception
{
if(component == null)
{
throw new Exception("The component is invalid");
}
else if(feature == null)
{
throw new Exception("The feature is invalid");
}
else
{
String componentUrl = "" + getProjectUrl() + "/" + component + "/";
String componentFeatureUrl = "" + getProjectUrl() + "/" + component + "/" + feature + "/";
if(!projectExists(componentFeatureUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
try
{
if(!projectExists(componentUrl))
{
method.createDirectory(componentUrl);
}
method.createDirectory( componentFeatureUrl );
}
catch (IOException ioe)
{
String error = "Could add a new component feature because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:40,代码来源:ECCConfigAPIImpl.java
示例16: createDefaultComponentFeature
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void createDefaultComponentFeature (String component, String feature) throws Exception
{
if(component == null)
{
throw new Exception("The component is invalid");
}
else if(feature == null)
{
throw new Exception("The feature is invalid");
}
else
{
String componentUrl = "" + apiDefaultPath + "/" + component + "/";
String componentFeatureUrl = "" + apiDefaultPath + "/" + component + "/" + feature + "/";
if(!projectExists(componentFeatureUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
try
{
if(!projectExists(componentUrl))
{
method.createDirectory(componentUrl);
}
method.createDirectory( componentFeatureUrl );
}
catch (IOException ioe)
{
String error = "Could add a new component feature because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:40,代码来源:ECCConfigAPIImpl.java
示例17: addDirectory
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void addDirectory(String directoryName) throws Exception
{
if(directoryName == null)
{
throw new Exception("The directory name is invalid");
}
else
{
try {
String directoryUrl = "" + apiRepositoryUrl + directoryName + "/";
if(!projectExists(directoryUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
method.createDirectory(directoryUrl);
}
else
{
throw new Exception("A directory with this name already exists");
}
}
catch (IOException ioe)
{
String error = "Could add a new directory because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:33,代码来源:ECCConfigAPIImpl.java
示例18: deleteDirectory
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void deleteDirectory(String directoryName)throws Exception
{
if(directoryName == null)
{
throw new Exception("The directory name is invalid");
}
else
{
try {
String directoryUrl = "" + apiRepositoryUrl + directoryName + "/";
if(projectExists(directoryUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
method.delete(directoryUrl);
}
else
{
throw new Exception("This directory does not exist");
}
}
catch (IOException ioe)
{
String error = "Could not delete the directory because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:33,代码来源:ECCConfigAPIImpl.java
示例19: putDocument
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void putDocument(String sourceFilePath, String destinationFilePath )throws Exception
{
if(sourceFilePath == null)
{
throw new Exception("The source file path is invalid");
}
else if(destinationFilePath == null)
{
throw new Exception("The destination file path is invalid");
}
else
{
String fileUrl = "" + apiRepositoryUrl + destinationFilePath;
try {
if(!projectExists(fileUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
byte[] data = FileUtils.readFileToByteArray(new File(sourceFilePath));
method.put(fileUrl, data);
}
else
{
throw new Exception("The configuration document exists");
}
}
catch (IOException ioe)
{
String error = "Could not upload the document to the repository because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:36,代码来源:ECCConfigAPIImpl.java
示例20: moveDocument
import com.github.sardine.Sardine; //导入依赖的package包/类
@Override
public void moveDocument(String sourceFilePath, String destinationFilePath) throws Exception
{
if(sourceFilePath == null)
{
throw new Exception("The source filepath is not valid");
}
else if (destinationFilePath == null)
{
throw new Exception("The destination filepath is not valid");
}
else
{
try {
String sourceUrl = "" + apiRepositoryUrl + sourceFilePath;
String destinationUrl = "" + apiRepositoryUrl + destinationFilePath;
if(projectExists(sourceUrl))
{
Sardine method = SardineFactory.begin(apiUserName, apiPassword);
method.move(sourceUrl, destinationUrl);
}
}
catch (IOException ioe)
{
String error = "Could not move the document because : " + ioe.getMessage();
throw new Exception( error, ioe );
}
}
}
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:32,代码来源:ECCConfigAPIImpl.java
注:本文中的com.github.sardine.Sardine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论