• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DavResource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.sardine.DavResource的典型用法代码示例。如果您正苦于以下问题:Java DavResource类的具体用法?Java DavResource怎么用?Java DavResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DavResource类属于com.github.sardine包,在下文中一共展示了DavResource类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listFolderContent

import com.github.sardine.DavResource; //导入依赖的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: getChildrenAttributes

import com.github.sardine.DavResource; //导入依赖的package包/类
@Override
protected List<ServerFileAttributes> getChildrenAttributes(ServerPath folder) throws IOException {
	List<DavResource> resources = getSardine().list(folder.toUri().toString(), 1);
	
	/*
	 * Older lighttpd servers seems NOT to include the parent as first element!
	 * We therefore check if the first resource matches the parent folder.
	 */
	if (resources.isEmpty()) {
		return Collections.emptyList();
	}
	int start = 1; // collection includes parent folder
	if (resources.get(0).isDirectory()) {
		if (fileSystem.getPath(resources.get(0).getPath()).toRealPath().getNameCount() == folder.toRealPath().getNameCount() + 1) {
			start = 0;
		}
	} else {
		start = 0;
	}
	List<ServerFileAttributes> attributes = new ArrayList<>(resources.size() - start);
	for (int i = start; i < resources.size(); i++) {
		attributes.add(new DAVFileAttributes(resources.get(i)));
	}
	return attributes;
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:26,代码来源:DAVResourceProvider.java


示例3: getAttributes

import com.github.sardine.DavResource; //导入依赖的package包/类
private PathAttributes getAttributes(Path path, DavResource p) {
    PathAttributesImplementation attributes = new PathAttributesImplementation();

    attributes.setPath(path);
    attributes.setDirectory(p.isDirectory());
    attributes.setRegular(!p.isDirectory());

    attributes.setCreationTime(p.getCreation().getTime());
    attributes.setLastModifiedTime(p.getModified().getTime());
    attributes.setLastAccessTime(attributes.getLastModifiedTime());
    attributes.setSize(p.getContentLength());

    // Not sure if this is right ?
    attributes.setReadable(true);
    attributes.setWritable(false);

    return attributes;
}
 
开发者ID:NLeSC,项目名称:Xenon,代码行数:19,代码来源:WebdavFileSystem.java


示例4: listDirectory

import com.github.sardine.DavResource; //导入依赖的package包/类
@Override
protected List<PathAttributes> listDirectory(Path path) throws XenonException {

    List<DavResource> list = null;

    try {
        list = client.list(getDirectoryPath(path), 1);
    } catch (Exception e) {
        throw new XenonException(ADAPTOR_NAME, "Failed to list directory: " + path, e);
    }

    ArrayList<PathAttributes> result = new ArrayList<>(list.size());

    String dirPath = path.toString() + "/";

    for (DavResource d : list) {
        // The list also returns the directory itself, so ensure we don't
        // return it!
        if (!dirPath.equals(d.getPath())) {
            String filename = d.getName();
            result.add(getAttributes(path.resolve(filename), d));
        }
    }

    return result;
}
 
开发者ID:NLeSC,项目名称:Xenon,代码行数:27,代码来源:WebdavFileSystem.java


示例5: hasToProcessFile

import com.github.sardine.DavResource; //导入依赖的package包/类
/**
 * Checks if the file has to be processed, verifying the content type
 * (application/xml) and the date filter configured in the the Ingest.
 *
 * @param res WebDav resource.
 * @return <code>true</code> is the file has to be processed,
 * <code>false</code> otherwise.
 */
private boolean hasToProcessFile(DavResource res) {
    if (res.isDirectory()) {
        return false;
    }
    if (!res.getContentType().equalsIgnoreCase("application/xml")) {
        return false;
    }

    IngestWebDav ingestWebdav = (IngestWebDav) ingest;
    Date beginFilterDate = ingestWebdav.getDateFrom();
    Date endFilterDate = ingestWebdav.getDateTo();
    Date resourceDate = res.getModified();

    if ((beginFilterDate != null) && (resourceDate.before(beginFilterDate))) {
        return false;
    }
    return (endFilterDate == null) || (resourceDate.after(endFilterDate));
}
 
开发者ID:OpenGeoportal,项目名称:ogpHarvester,代码行数:27,代码来源:WebdavIngestJob.java


示例6: toAttributes

import com.github.sardine.DavResource; //导入依赖的package包/类
protected PathAttributes toAttributes(final DavResource resource) {
    final PathAttributes attributes = new PathAttributes();
    final Map<QName, String> properties = resource.getCustomPropsNS();
    if(properties.containsKey(DAVTimestampFeature.LAST_MODIFIED)) {
        final String value = properties.get(DAVTimestampFeature.LAST_MODIFIED);
        try {
            attributes.setModificationDate(
                new RFC1123DateFormatter().parse(value).getTime());
        }
        catch(InvalidDateException e) {
            log.warn(String.format("Failure parsing property %s", value));
            if(resource.getModified() != null) {
                attributes.setModificationDate(resource.getModified().getTime());
            }
        }
    }
    else if(resource.getModified() != null) {
        attributes.setModificationDate(resource.getModified().getTime());
    }
    if(resource.getCreation() != null) {
        attributes.setCreationDate(resource.getCreation().getTime());
    }
    if(resource.getContentLength() != null) {
        attributes.setSize(resource.getContentLength());
    }
    if(StringUtils.isNotBlank(resource.getEtag())) {
        attributes.setETag(resource.getEtag());
    }
    if(StringUtils.isNotBlank(resource.getDisplayName())) {
        attributes.setDisplayname(resource.getDisplayName());
    }
    if(StringUtils.isNotBlank(resource.getDisplayName())) {
        attributes.setDisplayname(resource.getDisplayName());
    }
    return attributes;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:37,代码来源:DAVAttributesFinderFeature.java


示例7: listFolder

import com.github.sardine.DavResource; //导入依赖的package包/类
private List<String> listFolder(String url) throws IOException {
	List<String> files = new ArrayList<>();
	List<DavResource> resources = getSardine().list(url);
	for (DavResource res : resources) {
	     files.add(res.getName());
	}
	return files;		
}
 
开发者ID:petrsmid,项目名称:unicredit-connector,代码行数:9,代码来源:UnicreditConnectorImpl.java


示例8: testNewFileIsInDir

import com.github.sardine.DavResource; //导入依赖的package包/类
@Test
public void testNewFileIsInDir() throws IOException {
    sardine.put( getMethodUrl() + "newFile", content );

    boolean found = false;
    List<DavResource> resources = sardine.list( getMethodUrl() );
    for( DavResource res : resources ) {
        if( res.toString().endsWith( "newFile" ) ) {
            found = true;
        }
    }

    assertThat( found ).isEqualTo( true );
}
 
开发者ID:openCage,项目名称:niodav,代码行数:15,代码来源:NiodavTest.java


示例9: testSetLastModified

import com.github.sardine.DavResource; //导入依赖的package包/类
@Test
public void testSetLastModified() throws IOException {

    DavResource dir = sardine.list( getMethodUrl() ).get( 0 );
    long modi = dir.getModified().getTime() - 4000;

    String theLastModified = IOUtil.getLastModified( modi );

    HashMap<QName, String> patch = new HashMap<>();
    patch.put( SardineUtil.createQNameWithDefaultNamespace( "getlastmodified" ), theLastModified );//format.format(now.getTime()));
    DavResource resource = sardine.patch( getMethodUrl(), patch ).get( 0 );

    assertThat( resource.getModified() ).isCloseTo( Date.from( Instant.ofEpochMilli( modi ) ), 1000 );
}
 
开发者ID:openCage,项目名称:niodav,代码行数:15,代码来源:NiodavTest.java


示例10: testCreationDate

import com.github.sardine.DavResource; //导入依赖的package包/类
@Test
public void testCreationDate() throws IOException {
    List<DavResource> dir = sardine.list( getMethodUrl() );

    Date created = dir.get( 0 ).getCreation();

    assertThat( created ).isCloseTo( new Date(), 2000 );
}
 
开发者ID:openCage,项目名称:niodav,代码行数:9,代码来源:NiodavTest.java


示例11: putInputStream

import com.github.sardine.DavResource; //导入依赖的package包/类
@Override
public long putInputStream(InputStream sourceInputStream, ContentReference targetContentReference)
        throws ContentIOException
{
    if (!isContentReferenceSupported(targetContentReference))
    {
        throw new ContentIOException("ContentReference not supported");
    }
    
    try
    {
        String remoteFileUrl = getRemoteFileUrl(targetContentReference);
        
        logger.debug("Putting input stream to " + remoteFileUrl);
        sardine.put(remoteFileUrl, sourceInputStream);
        
        List<DavResource> resources = sardine.list(remoteFileUrl);
        if (resources == null || resources.size() > 1)
        {
            throw new ContentIOException("Unable to determine result of transfer");
        }
        DavResource davResource = resources.iterator().next();
        return davResource.getContentLength();
    }
    catch (IOException e)
    {
        logger.error(e.getMessage(), e);
        throw new ContentIOException("Failed to write content: " + e.getMessage(), e);
    }
}
 
开发者ID:Alfresco,项目名称:gytheio,代码行数:31,代码来源:WebDavContentReferenceHandlerImpl.java


示例12: getFileAttributes

import com.github.sardine.DavResource; //导入依赖的package包/类
@Override
protected BasicFileAttributes getFileAttributes(ServerPath path) throws IOException {
	List<DavResource> list = getSardine().list(path.toUri().toString(), 0);
	if (list.size() != 1) {
		throw new IOException("Could not get file attributes for path: " + path);
	}
	return new DAVFileAttributes(list.get(0));
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:9,代码来源:DAVResourceProvider.java


示例13: processFile

import com.github.sardine.DavResource; //导入依赖的package包/类
/**
 * Process the remote WebDav file, validating it and ingesting in the
 * system.
 *
 * @param res WebDav resource.
 * @param baseUrl Base url of the WebDav resource.
 * @return count of invalid records processed.
 */
private long processFile(DavResource res, String baseUrl) {
    long failedRecordsCount = 0;
    Document document = null;
    try {
        // Retrieve file content
        String absoluteHrefPath = getResourceAbsoluteUrl(res, baseUrl);

        document = XmlUtil.load(absoluteHrefPath);
        MetadataParser parser = parserProvider.getMetadataParser(document);
        MetadataParserResponse parserResult = parser.parse(document);

        Metadata metadata = parserResult.getMetadata();
        metadata.setInstitution(ingest.getNameOgpRepository());

        boolean valid = metadataValidator.validate(metadata, report);
        if (valid) {
            metadataIngester.ingest(ImmutableList.of(metadata),
                    getIngestReport());
        } else {
            failedRecordsCount++;
        }

    } catch (Exception e) {
        failedRecordsCount++;
        logger.error("Error in Webdav Ingest: " + this.ingest.getName()
                + " (processing file:" + baseUrl + ")", e);
        saveException(e, IngestReportErrorType.SYSTEM_ERROR, document);
    }
    return failedRecordsCount;
}
 
开发者ID:OpenGeoportal,项目名称:ogpHarvester,代码行数:39,代码来源:WebdavIngestJob.java


示例14: DAVFileAttributes

import com.github.sardine.DavResource; //导入依赖的package包/类
DAVFileAttributes(DavResource res) {
	this.resource = res;
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:4,代码来源:DAVFileAttributes.java


示例15: init

import com.github.sardine.DavResource; //导入依赖的package包/类
/**
     * Initialises the service: checks if default configuration is available.
     */
    @PostConstruct
    public void init() {

        logger.debug("Initialising configuration service");

        if (localConfiguration == null) {
            logger.error("Failed to get local configuration, check 'application.properties' file is on classpath");
        } else {
            EccConfiguration eccConfiguration = localConfiguration.getConfiguration();
            if (eccConfiguration == null) {
                logger.error("Failed to get default ECC configuration from local configuration, check 'application.properties' file contains ecc.configuration.* entries");
            } else {
//                logger.debug("Found default ECC configuration:\n" + eccConfiguration.toJson().toString(2));
                ProjectConfigAccessorConfiguration projectConfigAccessorConfiguration = localConfiguration.getProjectconfig();

                if (projectConfigAccessorConfiguration == null) {
                    logger.error("Failed to get default ProjectConfigAccessorConfiguration from local configuration, check 'application.properties' file contains ecc.projectconfig.* entries");
                } else {
                    logger.debug("Found default ProjectConfigAccessorConfiguration configuration:\n" + projectConfigAccessorConfiguration.toJson().toString(2));

                    // TODO: validate eccConfiguration, projectConfigAccessorConfiguration
                    localEccConfiguration = eccConfiguration;
                    configUsername = projectConfigAccessorConfiguration.getUsername();
                    configPassword = projectConfigAccessorConfiguration.getPassword();

                    initialised = true;
                    logger.debug("Configuration service initialised successfully, checking webdav service availability");

                    Sardine sardine = SardineFactory.begin(projectConfigAccessorConfiguration.getUsername(), projectConfigAccessorConfiguration.getPassword());
                    try {
                        List<DavResource> resources = sardine.getResources(projectConfigAccessorConfiguration.getEndpoint());
                        for (DavResource res : resources) {
                            if (projectConfigAccessorConfiguration.getSortedWhiteList().contains(res.getName())) {
                                logger.debug("Adding project '" + res.getName() + "' to the list of online configurations");
                                whiteListedOnlineProjects.add(res.getName());
                            }
                        }
                        if (whiteListedOnlineProjects.size() > 1) {
                            Collections.sort(whiteListedOnlineProjects);
                        }
                        webdavServiceOnline = true;
                    } catch (IOException ex) {
                        logger.error("Failed to connect to webdav service", ex.getMessage());
                    }
                }
            }
        }
    }
 
开发者ID:it-innovation,项目名称:EXPERImonitor,代码行数:52,代码来源:ConfigurationService.java


示例16: getResourceAbsoluteUrl

import com.github.sardine.DavResource; //导入依赖的package包/类
/**
 * DavResource contains only the relative path. This method uses the base
 * url to return the absolute url of the resource.
 *
 * @param res WebDav resource.
 * @param baseUrl Base url of the WebDav resource.
 * @return Absolute url of the WebDav resource.
 * @throws MalformedURLException thrown when baseUrl param is nota valid
 * URL.
 */
private String getResourceAbsoluteUrl(DavResource res, String baseUrl)
        throws MalformedURLException {
    URL urlR = new URL(baseUrl);

    return urlR + res.getHref().toString().replace(urlR.getPath(), "");
}
 
开发者ID:OpenGeoportal,项目名称:ogpHarvester,代码行数:17,代码来源:WebdavIngestJob.java



注:本文中的com.github.sardine.DavResource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModuleLevelBuilder类代码示例发布时间:2022-05-22
下一篇:
Java TokenRequestBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap