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

Java RuntimeRepositoryException类代码示例

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

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



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

示例1: read

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
/**
 * Read the state of the resource data at a particular point in time
 * @param directory the directory
 * @param identifier the identifier
 * @param time the time
 * @return the resource data, if it exists
 */
public static Optional<ResourceData> read(final File directory, final IRI identifier, final Instant time) {
    LOGGER.debug("Reading journal to generate the resource data");
    return of(new File(directory, RESOURCE_JOURNAL)).filter(File::exists).flatMap(file -> {
        final List<Instant> mementos = new ArrayList<>();
        final List<VersionRange> ranges = asTimeMap(file);
        ranges.stream().map(VersionRange::getFrom).findFirst().ifPresent(mementos::add);
        ranges.stream().map(VersionRange::getUntil).forEachOrdered(mementos::add);

        try (final Stream<Quad> stream = asStream(rdf, file, identifier, time)) {
            try (final Dataset dataset = stream.filter(isResourceTriple).collect(toDataset())) {
                LOGGER.debug("Creating resource: {} at {}", identifier, time);
                return from(identifier, dataset, mementos);
            } catch (final Exception ex) {
                throw new RuntimeRepositoryException("Error processing dataset", ex);
            }
        }
    });
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:26,代码来源:VersionedResource.java


示例2: getAllAuthorizationsFor

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
private Stream<Authorization> getAllAuthorizationsFor(final Resource resource, final Boolean top) {
    LOGGER.debug("Checking ACL for: {}", resource.getIdentifier());
    final Optional<IRI> parent = resourceService.getContainer(resource.getIdentifier());
    if (resource.hasAcl()) {
        try (final Graph graph = resource.stream(Trellis.PreferAccessControl).collect(toGraph())) {
            final List<Authorization> authorizations = getAuthorizationFromGraph(graph);

            if (!top && authorizations.stream().anyMatch(getInheritedAuth(resource.getIdentifier()))) {
                return authorizations.stream().filter(getInheritedAuth(resource.getIdentifier()));
            }
            return authorizations.stream().filter(getAccessToAuth(resource.getIdentifier()));
        } catch (final Exception ex) {
            throw new RuntimeRepositoryException(ex);
        }
    }
    // Nothing here, check the parent
    LOGGER.debug("No ACL for {}; looking up parent resource", resource.getIdentifier());
    return parent.flatMap(resourceService::get).map(res -> getAllAuthorizationsFor(res, false))
        .orElseGet(Stream::empty);
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-webac,代码行数:21,代码来源:WebACService.java


示例3: DefaultBinaryService

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
/**
 * Create a binary service
 * @param idService the identifier service
 * @param partitions the identifier suppliers for each partition
 * @param resolvers the resolves
 */
public DefaultBinaryService(final IdentifierService idService, final Map<String, Properties> partitions,
        final List<BinaryService.Resolver> resolvers) {
    this.idService = idService;
    resolvers.forEach(resolver ->
            resolver.getUriSchemes().forEach(scheme ->
                this.resolvers.put(scheme, resolver)));
    partitions.forEach((k, v) -> {
        final String prefix = v.getProperty("prefix");
        if (isNull(prefix)) {
            throw new RuntimeRepositoryException("No prefix value defined for partition: " + k);
        }
        if (!this.resolvers.containsKey(prefix.split(":", 2)[0])) {
            throw new RuntimeRepositoryException("No binary resolver defined to handle prefix " +
                    prefix + " in partition " + k);
        }
        this.partitions.put(k, new IdentifierConfiguration(prefix,
                    parseInt(v.getProperty("levels", DEFAULT_LEVELS)),
                    parseInt(v.getProperty("length", DEFAULT_LENGTH))));
    });
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-binary,代码行数:27,代码来源:DefaultBinaryService.java


示例4: write

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Override
public void write(final Stream<? extends Triple> triples, final OutputStream output, final RDFSyntax syntax,
        final IRI... profiles) {
    requireNonNull(triples, "The triples stream may not be null!");
    requireNonNull(output, "The output stream may not be null!");
    requireNonNull(syntax, "The RDF syntax value may not be null!");

    try {
        if (RDFA_HTML.equals(syntax)) {
            htmlSerializer.write(output, triples, profiles.length > 0 ? profiles[0] : null);
        } else {
            final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                    new RuntimeRepositoryException("Invalid content type: " + syntax.mediaType));

            final RDFFormat format = defaultSerialization(lang);

            if (nonNull(format)) {
                LOGGER.debug("Writing stream-based RDF: {}", format);
                final StreamRDF stream = getWriterStream(output, format);
                stream.start();
                ofNullable(nsService).ifPresent(svc -> svc.getNamespaces().forEach(stream::prefix));
                triples.map(rdf::asJenaTriple).forEachOrdered(stream::triple);
                stream.finish();
            } else {
                LOGGER.debug("Writing buffered RDF: {}", lang);
                final org.apache.jena.graph.Graph graph = createDefaultGraph();
                ofNullable(nsService).map(NamespaceService::getNamespaces)
                    .ifPresent(graph.getPrefixMapping()::setNsPrefixes);
                triples.map(rdf::asJenaTriple).forEachOrdered(graph::add);
                if (JSONLD.equals(lang)) {
                    writeJsonLd(output, DatasetGraphFactory.create(graph), profiles);
                } else {
                    RDFDataMgr.write(output, graph, lang);
                }
            }
        }
    } catch (final AtlasException ex) {
        throw new RuntimeRepositoryException(ex);
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:41,代码来源:JenaIOService.java


示例5: read

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Override
public Stream<? extends Triple> read(final InputStream input, final String base, final RDFSyntax syntax) {
    requireNonNull(input, "The input stream may not be null!");
    requireNonNull(syntax, "The syntax value may not be null!");

    try {
        final org.apache.jena.graph.Graph graph = createDefaultGraph();
        final Lang lang = rdf.asJenaLang(syntax).orElseThrow(() ->
                new RuntimeRepositoryException("Unsupported RDF Syntax: " + syntax.mediaType));

        RDFParser.source(input).lang(lang).base(base).parse(graph);

        // Check the graph for any new namespace definitions
        if (nonNull(nsService)) {
            final Set<String> namespaces = nsService.getNamespaces().entrySet().stream().map(Map.Entry::getValue)
                .collect(toSet());
            graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> {
                if (!namespaces.contains(namespace)) {
                    LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace);
                    nsService.setPrefix(prefix, namespace);
                }
            });
        }
        return rdf.asGraph(graph).stream();
    } catch (final RiotException | AtlasException ex) {
        throw new RuntimeRepositoryException(ex);
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:29,代码来源:JenaIOService.java


示例6: testUpdateError

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testUpdateError() {
    final Graph graph = rdf.createGraph();
    getTriples().forEach(graph::add);
    assertEquals(3L, graph.size());
    assertThrows(RuntimeRepositoryException.class, () -> service.update(graph, "blah blah blah blah blah", null));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:8,代码来源:IOServiceTest.java


示例7: getAuthorizationFromGraph

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
private List<Authorization> getAuthorizationFromGraph(final Graph graph) {
    return graph.stream().map(Triple::getSubject).distinct().map(subject -> {
            try (final Graph subGraph = graph.stream(subject, null, null).collect(toGraph())) {
                return Authorization.from(subject, subGraph);
            } catch (final Exception ex) {
                throw new RuntimeRepositoryException("Error Processing graph", ex);
            }
        }).collect(toList());
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-webac,代码行数:10,代码来源:WebACService.java


示例8: getIdentifierSupplier

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Override
public Supplier<String> getIdentifierSupplier(final String partition) {
    if (partitions.containsKey(partition)) {
        final IdentifierConfiguration config = partitions.get(partition);
        return idService.getSupplier(config.getPrefix(), config.getHierarchy(), config.getLength());
    }
    throw new RuntimeRepositoryException("Invalid partition: " + partition);
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-binary,代码行数:9,代码来源:DefaultBinaryService.java


示例9: testServiceNoPrefix

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testServiceNoPrefix() {
    final Properties props = new Properties();
    final Map<String, Properties> config = new HashMap<>();
    config.put("repository", props);

    assertThrows(RuntimeRepositoryException.class, () -> new DefaultBinaryService(mockIdService, config,
            asList(new FileResolver(emptyMap()))));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-binary,代码行数:10,代码来源:DefaultBinaryServiceTest.java


示例10: testServiceNoMatch

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testServiceNoMatch() {
    final Properties props = new Properties();
    props.setProperty("prefix", "foo:");
    final Map<String, Properties> config = new HashMap<>();
    config.put("repository", props);

    assertThrows(RuntimeRepositoryException.class, () -> new DefaultBinaryService(mockIdService, config,
            asList(new FileResolver(emptyMap()))));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-binary,代码行数:11,代码来源:DefaultBinaryServiceTest.java


示例11: testUnknownPartition

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testUnknownPartition() {
    final Properties props = new Properties();
    props.setProperty("prefix", "file:");
    final Map<String, Properties> config = new HashMap<>();
    config.put("repository", props);

    final BinaryService service = new DefaultBinaryService(mockIdService, config,
            asList(new FileResolver(emptyMap())));

    assertThrows(RuntimeRepositoryException.class, () -> service.getIdentifierSupplier("nonexistent"));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-binary,代码行数:13,代码来源:DefaultBinaryServiceTest.java


示例12: testMalformedInput

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testMalformedInput() {
    final ByteArrayInputStream in = new ByteArrayInputStream("<> <ex:test> a Literal\" . ".getBytes(UTF_8));
    assertThrows(RuntimeRepositoryException.class, () -> service.read(in, null, TURTLE));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:6,代码来源:IOServiceTest.java


示例13: testReadError

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testReadError() throws IOException {
    doThrow(new IOException()).when(mockInputStream).read(any(byte[].class), anyInt(), anyInt());
    assertThrows(RuntimeRepositoryException.class, () -> service.read(mockInputStream, "context", TURTLE));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:6,代码来源:IOServiceTest.java


示例14: testWriteError

import org.trellisldp.api.RuntimeRepositoryException; //导入依赖的package包/类
@Test
public void testWriteError() throws IOException {
    doThrow(new IOException()).when(mockOutputStream).write(any(byte[].class), anyInt(), anyInt());
    assertThrows(RuntimeRepositoryException.class, () -> service.write(getTriples(), mockOutputStream, TURTLE));
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-io-jena,代码行数:6,代码来源:IOServiceTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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