当前位置: 首页>>代码示例>>Java>>正文


Java ValueFactory类代码示例

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


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

示例1: setUp

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    Session session = openSession();
    Node node = session.getRootNode().addNode("home").addNode("test");
    node.setProperty("content.approved", APPROVED);
    node.setProperty("my.contents.property", CONTENT);
    
    
    ValueFactory valFact = session.getValueFactory();
    Value[] vals = new Value[] {valFact.createValue("value-1"), valFact.createValue("value-2")};
    node.setProperty("my.multi.valued", vals);
    
    identifier = node.getIdentifier();

    session.save();
    session.logout();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrGetNodeByIdTest.java

示例2: mapSerializedFieldToProperty

import javax.jcr.ValueFactory; //导入依赖的package包/类
private void mapSerializedFieldToProperty(Field field, Object obj, Node node, int depth, NodeFilter nodeFilter) throws IllegalAccessException, RepositoryException, IOException {

        String propertyName = getSerializedPropertyName(field);
        Object fieldValue = getObject(field, obj);
        // make sure that this property is supposed to be updated
        if (nodeFilter == null || nodeFilter.isIncluded(NodeFilter.PROPERTY_PREFIX + field.getName(), node, depth)) {
            if (fieldValue != null) {
                // serialize and store
                //node.setProperty(propertyName, new ByteArrayInputStream(serialize(fieldValue)));
                ValueFactory valueFactory = node.getSession().getValueFactory();
                Binary binary = valueFactory.createBinary(new ByteArrayInputStream(serialize(fieldValue)));
                node.setProperty(propertyName, binary);
            } else {
                // remove the value
                node.setProperty(propertyName, (Value) null);
            }
        }
    }
 
开发者ID:dooApp,项目名称:jcromfx,代码行数:19,代码来源:PropertyMapper.java

示例3: testMvRestrictions

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Test
public void testMvRestrictions() throws Exception {

    ValueFactory vf = getValueFactory();
    Value[] vs = new Value[] {
            vf.createValue(JcrConstants.NT_FILE, PropertyType.NAME),
            vf.createValue(JcrConstants.NT_FOLDER, PropertyType.NAME)
    };
    Map<String, Value[]> mvRestrictions = Collections.singletonMap(REP_NT_NAMES, vs);
    Map<String, Value> restrictions = Collections.singletonMap(REP_GLOB, vf.createValue("/.*"));

    assertTrue(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
    assertFalse(acl.addEntry(testPrincipal, testPrivileges, false, restrictions, mvRestrictions));
    assertEquals(1, acl.getAccessControlEntries().length);
    JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry) acl.getAccessControlEntries()[0];
    try {
        ace.getRestriction(REP_NT_NAMES);
        fail();
    } catch (ValueFormatException e) {
        // success
    }
    Value[] vvs = ace.getRestrictions(REP_NT_NAMES);
    assertArrayEquals(vs, vvs);
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:25,代码来源:ACLTest.java

示例4: before

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Override
@Before
public void before() throws Exception {
    super.before();

    acMgr = getAccessControlManager(root);
    testPrincipal = new Principal() {
        public String getName() {
            return "TestPrincipal";
        }
    };
    ValueFactory valueFactory = new ValueFactoryImpl(root, namePathMapper);
    globValue = valueFactory.createValue("*");
    nameValue = valueFactory.createValue("nt:file", PropertyType.NAME);
    nameValues = new Value[] {
            valueFactory.createValue("nt:folder", PropertyType.NAME),
            valueFactory.createValue("nt:file", PropertyType.NAME)
    };
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:20,代码来源:ACETest.java

示例5: testAddPropertyToNode

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Test
public void testAddPropertyToNode() throws IOException, RepositoryException {
    List<String> propValues = new ArrayList<String>();
    propValues.add("value1");

    MockNode mockRootNode = new MockNode("/", "jcr:root");
    Session mockSession = mock(Session.class);
    mockRootNode.setSession(mockSession);
    Node testNode = mockRootNode.addNode("/test", "hippo:document");
    testNode.setProperty("hippostdpubwf:createdBy", "admin");

    JcrProperty jcrProperty = new JcrProperty();
    jcrProperty.setName("propname");
    jcrProperty.setValues(propValues);
    jcrProperty.setType("String");
    jcrProperty.setMultiple(false);
    final ValueFactory valueFactory = mock(ValueFactory.class);
    when(mockRootNode.getSession().getValueFactory()).thenReturn(valueFactory);
    when(valueFactory.createValue("value1", 1)).thenReturn(new MockValue("value1"));
    JcrDataBindingHelper.addPropertyToNode(mockRootNode, jcrProperty);
    assertTrue(mockRootNode.hasProperty("propname"));
}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:23,代码来源:JcrDataBindingHelperTest.java

示例6: mapSerializedFieldToProperty

import javax.jcr.ValueFactory; //导入依赖的package包/类
private void mapSerializedFieldToProperty(Field field, Object obj, Node node, int depth, NodeFilter nodeFilter) throws IllegalAccessException,
        RepositoryException, IOException
{

    String propertyName = getSerializedPropertyName(field);
    Object fieldValue = field.get(obj);
    // make sure that this property is supposed to be updated
    if (nodeFilter == null || nodeFilter.isIncluded(NodeFilter.PROPERTY_PREFIX + field.getName(), node, depth))
    {
        if (fieldValue != null)
        {
            // serialize and store
            // node.setProperty(propertyName, new ByteArrayInputStream(serialize(fieldValue)));
            ValueFactory valueFactory = node.getSession().getValueFactory();
            Binary binary = valueFactory.createBinary(new ByteArrayInputStream(serialize(fieldValue)));
            node.setProperty(propertyName, binary);
        }
        else
        {
            // remove the value
            node.setProperty(propertyName, (Value) null);
        }
    }
}
 
开发者ID:sbrinkmann,项目名称:jcrom-extended,代码行数:25,代码来源:PropertyMapper.java

示例7: createValues

import javax.jcr.ValueFactory; //导入依赖的package包/类
/**
 * @param factory
 *        the factory used to perform the conversion (cannot be <code>null</code>)
 * @param values
 *        the values being converted to a JCR value holders (cannot be <code>null</code>)
 * @param jcrPropType
 *        the JCR {@link PropertyType property type}
 * @return the JCR value holders (never <code>null</code>)
 * @throws Exception
 *         if an error occurs
 */
public static Value[] createValues( final ValueFactory factory,
                                    final Object[] values,
                                    final int jcrPropType ) throws Exception {
    final List< Value > result = new ArrayList<>();

    if ( ( values == null ) || ( values.length == 0 ) ) {
        return NO_VALUES;
    }

    for ( final Object value : values ) {
        result.add( createValue( factory, value, jcrPropType ) );
    }

    return result.toArray( new Value[ result.size() ] );
}
 
开发者ID:Polyglotter,项目名称:chrysalix,代码行数:27,代码来源:ModelProperty.java

示例8: createOrUpdateIndex

import javax.jcr.ValueFactory; //导入依赖的package包/类
private void createOrUpdateIndex(Node indexNode, IndexDefinition def) throws RepositoryException {
    ValueFactory valueFactory = indexNode.getSession().getValueFactory();

    indexNode.setProperty(PN_TYPE, TYPE_PROPERTY);
    indexNode.setProperty(PN_PROPERTY_NAMES,
            new Value[] { valueFactory.createValue(def.propertyName, PropertyType.NAME) });
    if (def.async) {
        indexNode.setProperty(PN_ASYNC, PN_ASYNC);
    } else if (indexNode.hasProperty(PN_ASYNC)) {
        indexNode.getProperty(PN_ASYNC).remove();
    }
    if (def.unique) {
        indexNode.setProperty(PN_UNIQUE, true);
    } else if (indexNode.hasProperty(PN_UNIQUE)) {
        indexNode.getProperty(PN_UNIQUE).remove();
    }
    if (def.declaringNodeTypes != null && def.declaringNodeTypes.length > 0) {
        Value[] values = new Value[def.declaringNodeTypes.length];
        for (int i = 0; i < def.declaringNodeTypes.length; i++) {
            values[i] = valueFactory.createValue(def.declaringNodeTypes[0], PropertyType.NAME);
        }
        indexNode.setProperty(PN_DECLARING_NODE_TYPES, values);
    } else if (indexNode.hasProperty(PN_DECLARING_NODE_TYPES)) {
        indexNode.getProperty(PN_DECLARING_NODE_TYPES).remove();
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:EnsurePropertyIndex.java

示例9: getArtifactsByChecksum

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Override
public List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
    throws MetadataRepositoryException
{
    List<ArtifactMetadata> artifacts;

    String q = getArtifactQuery( repositoryId ) + " AND ([sha1] = $checksum OR [md5] = $checksum)";

    try
    {
        Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
        ValueFactory valueFactory = getJcrSession().getValueFactory();
        query.bindValue( "checksum", valueFactory.createValue( checksum ) );
        QueryResult result = query.execute();

        artifacts = new ArrayList<>();
        for ( Node n : JcrUtils.getNodes( result ) )
        {
            artifacts.add( getArtifactFromNode( repositoryId, n ) );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
    return artifacts;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:28,代码来源:JcrMetadataRepository.java

示例10: runJcrQuery

import javax.jcr.ValueFactory; //导入依赖的package包/类
private List<ArtifactMetadata> runJcrQuery( String repositoryId, String q, Map<String, String> bindings )
    throws MetadataRepositoryException
{
    List<ArtifactMetadata> artifacts;
    if ( repositoryId != null )
    {
        q += " AND ISDESCENDANTNODE(artifact,'/" + getRepositoryContentPath( repositoryId ) + "')";
    }

    log.info( "Running JCR Query: {}", q );

    try
    {
        Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
        ValueFactory valueFactory = getJcrSession().getValueFactory();
        for ( Entry<String, String> entry : bindings.entrySet() )
        {
            query.bindValue( entry.getKey(), valueFactory.createValue( entry.getValue() ) );
        }
        long start = Calendar.getInstance().getTimeInMillis();
        QueryResult result = query.execute();
        long end = Calendar.getInstance().getTimeInMillis();
        log.info( "JCR Query ran in {} milliseconds: {}", end - start , q );

        artifacts = new ArrayList<>();
        RowIterator rows = result.getRows();
        while ( rows.hasNext() )
        {
            Row row = rows.nextRow();
            Node node = row.getNode( "artifact" );
            artifacts.add( getArtifactFromNode( repositoryId, node ) );
        }
    }
    catch ( RepositoryException e )
    {
        throw new MetadataRepositoryException( e.getMessage(), e );
    }
    return artifacts;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:40,代码来源:JcrMetadataRepository.java

示例11: setUp

import javax.jcr.ValueFactory; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    Session session = openSession();

    ValueFactory valFact = session.getValueFactory();
    multiValued = new Value[]{valFact.createValue("value-1"),
            valFact.createValue("value-2")};

    session.logout();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JcrNodePathCreationTest.java

示例12: PermissionActionHelper

import javax.jcr.ValueFactory; //导入依赖的package包/类
public PermissionActionHelper(final ValueFactory valueFactory, final String path, final String glob,
		final List<String> permissions) {

	this.valueFactory = valueFactory;
	this.path = path;
	this.glob = glob;
	this.permissions = permissions;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:9,代码来源:PermissionActionHelper.java

示例13: saveScript

import javax.jcr.ValueFactory; //导入依赖的package包/类
private Script saveScript(ResourceResolver resolver, final String fileName, final InputStream input,
		final boolean overwrite) {
	Script result = null;
	final Session session = resolver.adaptTo(Session.class);
	final ValueFactory valueFactory;
	try {
		valueFactory = session.getValueFactory();
		final Binary binary = valueFactory.createBinary(input);
		final Node saveNode = session.getNode(getSavePath());

		final Node fileNode, contentNode;
		if (overwrite && saveNode.hasNode(fileName)) {
			fileNode = saveNode.getNode(fileName);
			contentNode = fileNode.getNode(JcrConstants.JCR_CONTENT);
		} else {
			fileNode = saveNode.addNode(generateFileName(fileName, saveNode), JcrConstants.NT_FILE);
			contentNode = fileNode.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
		}

		contentNode.setProperty(JcrConstants.JCR_DATA, binary);
		contentNode.setProperty(JcrConstants.JCR_ENCODING, SCRIPT_ENCODING.name());
		JcrUtils.setLastModified(contentNode, Calendar.getInstance());
		session.save();
		result = scriptFinder.find(fileNode.getPath(), resolver);
	} catch (RepositoryException e) {
		LOG.error(e.getMessage(), e);
	}
	return result;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:30,代码来源:ScriptStorageImpl.java

示例14: createGroups

import javax.jcr.ValueFactory; //导入依赖的package包/类
/**
 * Create user groups for authors and testers.
 *
 * @param bundleContext The bundle context provided by the component.
 */
private void createGroups(BundleContext bundleContext){
    ServiceReference SlingRepositoryFactoryReference = bundleContext.getServiceReference(SlingRepository.class.getName());
    SlingRepository repository = (SlingRepository)bundleContext.getService(SlingRepositoryFactoryReference);

    Session session = null;

    if (repository != null) {
        try {
            session = repository.loginAdministrative(null);

            if (session != null && session instanceof JackrabbitSession) {
                UserManager userManager = ((JackrabbitSession)session).getUserManager();
                ValueFactory valueFactory = session.getValueFactory();

                Authorizable authors = userManager.getAuthorizable(PublickConstants.GROUP_ID_AUTHORS);

                if (authors == null) {
                    authors = userManager.createGroup(PublickConstants.GROUP_ID_AUTHORS);
                    authors.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_AUTHORS));
                }

                Authorizable testers = userManager.getAuthorizable(PublickConstants.GROUP_ID_TESTERS);

                if (testers == null) {
                    testers = userManager.createGroup(PublickConstants.GROUP_ID_TESTERS);
                    testers.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_TESTERS));
                }
            }
        } catch (RepositoryException e) {
            LOGGER.error("Could not get session", e);
        } finally {
            if (session != null && session.isLive()) {
                session.logout();
                session = null;
            }
        }
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:44,代码来源:Activator.java

示例15: getValueFactory

import javax.jcr.ValueFactory; //导入依赖的package包/类
/**
 * @see org.springframework.extensions.jcr.JcrOperations#getValueFactory()
 */
@Override
public ValueFactory getValueFactory() {
    return execute(new JcrCallback<ValueFactory>() {
        /**
         * @see JcrCallback#doInJcr(javax.jcr.Session)
         */
        @Override
        public ValueFactory doInJcr(Session session) throws RepositoryException {
            return session.getValueFactory();
        }
    }, true);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:16,代码来源:JcrTemplate.java


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