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

Java JcrTools类代码示例

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

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



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

示例1: importData

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see Modelspace#importData(InputStream, String)
 */
@Override
public String importData( final InputStream stream,
                          final String workspacePath ) throws ModelspaceException {
    CheckArg.isNotNull( stream, "stream" );
    CheckArg.isNotEmpty( workspacePath, "workspacePath" );
    return run( new WriteTaskWithResult< String >() {

        @Override
        public String run( final Session session ) throws Exception {
            // Ensure the path is non-null, absolute, and ends with a slash
            final Node node = new JcrTools().uploadFile( session, absolutePath( workspacePath ), stream );
            // Add unstructured mix-in to allow node to contain anything else, like models created later
            node.addMixin( ModelspaceLexicon.UNSTRUCTURED_MIXIN );
            return node.getPath();
        }
    } );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:23,代码来源:ModelspaceImpl.java


示例2: shouldSkolemizeBlankNodeSubjects

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldSkolemizeBlankNodeSubjects() throws RepositoryException {
    final Model m = createDefaultModel();
    final Resource resource = createResource();
    final Statement x = m.createStatement(resource,
            createProperty("info:x"),
            testSubjects.toDomain("/"));
    testObj.jcrTools = mock(JcrTools.class);
    when(testObj.jcrTools.findOrCreateNode(eq(mockSession), anyString(), eq(NT_FOLDER))).thenReturn(mockNode);
    when(mockNode.getPath()).thenReturn("/#/x");
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockHashNode.isNew()).thenReturn(true);
    when(FedoraTypesUtils.getClosestExistingAncestor(mockSession, anyString())).thenReturn(mockHashNode);
    final Statement statement = testObj.skolemize(testSubjects, x, "info:fedora/");

    assertTrue("Doesn't match: " + statement.getSubject().toString(),
            statement.getSubject().toString().startsWith("info:fedora/#"));
    verify(mockNode).addMixin(FEDORA_RESOURCE);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:21,代码来源:JcrRdfToolsTest.java


示例3: shouldSkolemizeBlankNodeObjects

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldSkolemizeBlankNodeObjects() throws RepositoryException {
    final Model m = createDefaultModel();
    final Statement x = m.createStatement(testSubjects.toDomain("/foo"),
            createProperty("info:x"),
            createResource());
    testObj.jcrTools = mock(JcrTools.class);
    when(testObj.jcrTools.findOrCreateNode(eq(mockSession), anyString(), eq(NT_FOLDER))).thenReturn(mockNode);
    when(mockNode.getPath()).thenReturn("/foo#abc");
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockHashNode.isNew()).thenReturn(true);
    when(FedoraTypesUtils.getClosestExistingAncestor(mockSession, anyString())).thenReturn(mockHashNode);
    final Statement statement = testObj.skolemize(testSubjects, x, x.getSubject().toString());

    assertTrue(statement.getObject().toString().startsWith("info:fedora/foo#"));
    verify(mockNode).addMixin(FEDORA_RESOURCE);
    verify(mockNode.getParent()).addMixin(FEDORA_PAIRTREE);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:20,代码来源:JcrRdfToolsTest.java


示例4: shouldSkolemizeBlankNodeSubjectsAndObjects

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldSkolemizeBlankNodeSubjectsAndObjects() throws RepositoryException {
    final Model m = createDefaultModel();
    final Resource resource = createResource();
    final Statement x = m.createStatement(resource,
            createProperty("info:x"),
            resource);
    testObj.jcrTools = mock(JcrTools.class);
    when(testObj.jcrTools.findOrCreateNode(eq(mockSession), anyString(), eq(NT_FOLDER))).thenReturn(mockNode);
    when(mockNode.getPath()).thenReturn("/#/x");
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(FedoraTypesUtils.getClosestExistingAncestor(mockSession, anyString())).thenReturn(mockHashNode);
    final Statement statement = testObj.skolemize(testSubjects, x, "info:fedora/");

    assertTrue(statement.getSubject().toString().startsWith("info:fedora/#"));
    assertTrue(statement.getObject().toString().startsWith("info:fedora/#"));
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:19,代码来源:JcrRdfToolsTest.java


示例5: shouldCreateHashUriSubjects

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldCreateHashUriSubjects() throws RepositoryException {
    final Model m = createDefaultModel();
    final Statement x = m.createStatement(testSubjects.toDomain("/some/#/abc"),
            createProperty("info:x"),
            testSubjects.toDomain("/"));
    testObj.jcrTools = mock(JcrTools.class);
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockSession.nodeExists("/some")).thenReturn(true);
    when(mockSession.getNode("/some")).thenReturn(mockChildNode);
    when(mockChildNode.isNew()).thenReturn(false);
    when(testObj.jcrTools.findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER)).thenReturn(mockNode);
    when(mockHashNode.isNew()).thenReturn(true);
    final Statement statement = testObj.skolemize(testSubjects, x, "/some/#/abc");
    assertEquals(x, statement);
    verify(testObj.jcrTools).findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER);
    verify(mockNode).addMixin(FEDORA_RESOURCE);
    verify(mockHashNode).addMixin(FEDORA_PAIRTREE);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:21,代码来源:JcrRdfToolsTest.java


示例6: shouldCreateHashUriSubjectsWithExistingHashUri

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldCreateHashUriSubjectsWithExistingHashUri() throws RepositoryException {
    final Model m = createDefaultModel();
    final Statement x = m.createStatement(testSubjects.toDomain("/some/#/abc"),
            createProperty("info:x"),
            testSubjects.toDomain("/"));
    testObj.jcrTools = mock(JcrTools.class);
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockSession.nodeExists("/some")).thenReturn(true);
    when(mockSession.getNode("/some")).thenReturn(mockChildNode);
    when(mockChildNode.isNew()).thenReturn(false);
    when(mockChildNode.hasNode("#")).thenReturn(true);
    when(mockChildNode.getNode("#")).thenReturn(mockHashNode);
    when(mockHashNode.isNew()).thenReturn(false);
    when(testObj.jcrTools.findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER)).thenReturn(mockNode);
    final Statement statement = testObj.skolemize(testSubjects, x, "/some/#/abc");
    assertEquals(x, statement);
    verify(testObj.jcrTools).findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER);
    verify(mockNode).addMixin(FEDORA_RESOURCE);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:22,代码来源:JcrRdfToolsTest.java


示例7: shouldCreateHashUriObjects

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void shouldCreateHashUriObjects() throws RepositoryException {
    final Model m = createDefaultModel();
    final Statement x = m.createStatement(
            testSubjects.toDomain("/"),
            createProperty("info:x"),
            testSubjects.toDomain("/some/#/abc"));
    testObj.jcrTools = mock(JcrTools.class);
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockSession.nodeExists("/some")).thenReturn(true);
    when(mockSession.getNode("/some")).thenReturn(mockChildNode);
    when(testObj.jcrTools.findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER)).thenReturn(mockNode);
    final Statement statement = testObj.skolemize(testSubjects, x, "/");
    assertEquals(x, statement);
    verify(testObj.jcrTools).findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER);
    verify(mockNode).addMixin(FEDORA_RESOURCE);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:19,代码来源:JcrRdfToolsTest.java


示例8: print

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.modelspace.ModelObject#print()
 */
@Override
public void print() throws ModelspaceException {
    modelspace.run( new Task() {

        @Override
        public void run( final Session session ) throws Exception {
            final JcrTools tools = new JcrTools();
            tools.setDebug( true );
            tools.printSubgraph( session.getNode( path ) );
        }
    } );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:18,代码来源:ModelObjectImpl.java


示例9: process

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.modelspace.spi.DependencyProcessor#process(java.lang.String, javax.jcr.Node,
 *      org.modelspace.Modelspace, boolean)
 */
@Override
public String process( final String dataPath,
                       final Node modelNode,
                       final Modelspace modelspace,
                       final boolean persistArtifacts ) throws ModelspaceException {
    try {
        new JcrTools().printSubgraph( modelNode );
        return null;
    } catch ( final RepositoryException e ) {
        throw new ModelspaceException( e, "Unable to resolve dependencies for \"%s\"", modelNode );
    }
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:19,代码来源:JavaDependencyProcessor.java


示例10: contentEventCollapsing

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test
public void contentEventCollapsing() throws RepositoryException, InvalidChecksumException {

    final FedoraSession session = repository.login();
    final Session se = getJcrSession(session);
    final JcrTools jcrTools = new JcrTools();

    final Node n = jcrTools.findOrCreateNode(se.getRootNode(), "/object3", NT_FOLDER, NT_FILE);
    n.addMixin(FEDORA_RESOURCE);

    final String content = "test content";
    final String checksum = "1eebdf4fdc9fc7bf283031b93f9aef3338de9052";
    ((ValueFactory) se.getValueFactory()).createBinary(new ByteArrayInputStream(content.getBytes()), null);

    final Node contentNode = jcrTools.findOrCreateChild(n, JCR_CONTENT, NT_RESOURCE);
    contentNode.addMixin(FEDORA_BINARY);
    final FedoraBinary binary = new FedoraBinaryImpl(contentNode);
    binary.setContent( new ByteArrayInputStream(content.getBytes()), "text/plain",
            new HashSet<>(asList(asURI(SHA1.algorithm, checksum))), "text.txt", null);

    try {
        session.commit();
    } finally {
        session.expire();
    }

    awaitEvent("/object3", RESOURCE_CREATION, REPOSITORY_NAMESPACE + "Binary");

    assertEquals("Node and content events not collapsed!", (Integer) 1, eventBusMessageCount);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:31,代码来源:SimpleObserverIT.java


示例11: shouldNotAllowHashUriSubjectsForResourcesThatDontExist

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
@Test(expected = PathNotFoundException.class)
public void shouldNotAllowHashUriSubjectsForResourcesThatDontExist() throws RepositoryException {
    final Model m = createDefaultModel();
    final Statement x = m.createStatement(testSubjects.toDomain("/some/#/abc"),
            createProperty("info:x"),
            testSubjects.toDomain("/"));
    testObj.jcrTools = mock(JcrTools.class);
    when(mockNode.getParent()).thenReturn(mockHashNode);
    when(mockHashNode.getParent()).thenReturn(mockChildNode);
    when(mockSession.nodeExists("/some")).thenReturn(false);
    when(testObj.jcrTools.findOrCreateNode(mockSession, "/some/#/abc", NT_FOLDER)).thenReturn(mockNode);
    when(FedoraTypesUtils.getClosestExistingAncestor(mockSession,"/some/#/abc"))
            .thenReturn(mockNode);
    testObj.skolemize(testSubjects, x, "/some");
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:16,代码来源:JcrRdfToolsTest.java


示例12: getJcrTools

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
private JcrTools getJcrTools() {
    if (null == jcrTools) {
        this.jcrTools = new JcrTools(true);
    }
    return jcrTools;
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-storage-policy,代码行数:7,代码来源:FedoraStoragePolicy.java


示例13: setJcrTools

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * Only for UNIT TESTING
 * @param jcrTools
 */
@VisibleForTesting
public void setJcrTools(final JcrTools jcrTools) {
    this.jcrTools = jcrTools;
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-storage-policy,代码行数:9,代码来源:FedoraStoragePolicy.java


示例14: generateModel

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * @param dataPath
 *        the workspace path to the data
 * @param modelPath
 *        the workspace path to the model
 * @param metamodel
 *        the model's metamodel
 * @param persistArtifact
 *        <code>true</code> if the data should be persisted after import
 * @return the model
 * @throws ModelspaceException
 *         if an error occurs
 */
public Model generateModel( final String dataPath,
                            final String modelPath,
                            final Metamodel metamodel,
                            final boolean persistArtifact ) throws ModelspaceException {
    CheckArg.isNotEmpty( dataPath, "dataPath" );
    CheckArg.isNotEmpty( modelPath, "modelPath" );

    try {
        return run( new WriteTaskWithResult< Model >() {

            @Override
            public Model run( final Session session ) throws Exception {
                final Node dataNode = dataNode( session, dataPath );
                Metamodel actualMetamodel = metamodel;
                if ( actualMetamodel == null ) {
                    // If no metamodel supplied, use default metamodel if one exists
                    final MetamodelManagerImpl manager = ( MetamodelManagerImpl ) metamodelManager();
                    actualMetamodel = manager.defaultMetamodel( dataNode, manager.metamodels( dataNode ) );
                    if ( actualMetamodel == null )
                        throw new IllegalArgumentException( ModelspaceI18n.localize( "Unable to determine default metamodel for file %s",
                                                                                  dataPath ) );
                    throw new UnsupportedOperationException( "Not yet implemented" );
                }
                // Build the model
                final ValueFactory valueFactory = ( ValueFactory ) session.getValueFactory();
                final Calendar cal = Calendar.getInstance();
                final Node modelNode = new JcrTools().findOrCreateNode( session, absolutePath( modelPath ) );
                modelNode.addMixin( ModelspaceLexicon.Model.MODEL_MIXIN );
                if ( dataNode.hasProperty( ModelspaceLexicon.Model.EXTERNAL_LOCATION ) )
                    modelNode.setProperty( ModelspaceLexicon.Model.EXTERNAL_LOCATION,
                                           dataNode.getProperty( ModelspaceLexicon.Model.EXTERNAL_LOCATION ).getString() );
                final SequencerImporter importer = ( SequencerImporter ) actualMetamodel.importer();
                final boolean save = importer.execute( dataNode.getNode( JcrLexicon.CONTENT.getString() )
                                                               .getProperty( JcrLexicon.DATA.getString() ),
                                                       modelNode,
                                                       new Sequencer.Context() {

                                                           @Override
                                                           public Calendar getTimestamp() {
                                                               return cal;
                                                           }

                                                           @Override
                                                           public ValueFactory valueFactory() {
                                                               return valueFactory;
                                                           }
                                                       } );

                if ( save ) {
                    modelNode.setProperty( ModelspaceLexicon.Model.METAMODEL, actualMetamodel.id() );
                    final ModelImpl model = new ModelImpl( ModelspaceImpl.this, modelNode.getPath() );
                    session.save();
                    processDependencies( dataPath, modelNode, model, persistArtifact );
                    return model;
                }

                throw new ModelspaceException( "Unable to create %s model \"%s\" from data at \"%s\"",
                                            actualMetamodel.name(), modelPath, dataPath );
            }
        } );
    } finally {
        if ( !persistArtifact ) {
            removeTemporaryArtifact( dataPath );
        }
    }
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:80,代码来源:ModelspaceImpl.java


示例15: newModel

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.modelspace.Modelspace#newModel(java.lang.String, java.lang.String, boolean)
 */
@Override
public Model newModel( final String modelPath,
                       final String metamodelId,
                       final boolean override ) throws ModelspaceException {
    CheckArg.isNotEmpty( modelPath, "modelPath" );
    CheckArg.isNotEmpty( metamodelId, "metamodelId" );

    return run( new TaskWithResult< Model >() {

        /**
         * {@inheritDoc}
         * 
         * @see org.modelspace.internal.task.TaskWithResult#run(javax.jcr.Session)
         */
        @Override
        public Model run( final Session session ) throws Exception {
            boolean create = true;
            final String absPath = absolutePath( modelPath );

            if ( session.nodeExists( absPath ) ) {
                if ( override ) {
                    // delete
                    session.getNode( absPath ).remove();
                } else {
                    final Node node = session.getNode( absPath );

                    // make sure it is a model with the right metamodel ID
                    if ( !node.isNodeType( ModelspaceLexicon.Model.MODEL_MIXIN )
                         || !node.hasProperty( ModelspaceLexicon.Model.METAMODEL )
                         || !metamodelId.equals( node.getProperty( ModelspaceLexicon.Model.METAMODEL ).getValue().getString() ) ) {
                        throw new ModelspaceException( ModelspaceI18n.localize( EXISTING_MODEL_HAS_WRONG_METAMODEL_TYPE,
                                                                          absPath,
                                                                          metamodelId ) );
                    }

                    create = false;
                }
            }

            if ( create ) {
                final Node modelNode = new JcrTools().findOrCreateNode( session, absPath );
                modelNode.addMixin( ModelspaceLexicon.Model.MODEL_MIXIN );
                modelNode.setProperty( ModelspaceLexicon.Model.METAMODEL, metamodelId );
            }

            return new ModelImpl( ModelspaceImpl.this, absPath );
        }
    } );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:55,代码来源:ModelspaceImpl.java


示例16: doRequest

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
private Response doRequest(final String path) throws RepositoryException {
    final JcrTools jcrTools = new JcrTools();
    final Node node = jcrTools.findOrCreateNode(getJcrSession(session.getFedoraSession()), path);
    final URI location = uriInfo.getBaseUriBuilder().path(node.getPath()).build();
    return Response.created(location).build();
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:7,代码来源:RootTestResource.java


示例17: debug

import org.modeshape.jcr.api.JcrTools; //导入依赖的package包/类
/**
 * @param node
 *        the node to debug
 * @throws RepositoryException
 *         if an error occurs
 */
public static void debug( final Node node ) throws RepositoryException {
    final JcrTools tools = new JcrTools();
    tools.setDebug( true );
    tools.printSubgraph( node );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:12,代码来源:JcrUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java UDPOutputStream类代码示例发布时间:2022-05-22
下一篇:
Java Primitive类代码示例发布时间: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