Examples of ValueFactory


Examples of javax.jcr.ValueFactory

    @Reference
    private SlingRepository repository;

    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_ASYNC)) {
            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();
        }
View Full Code Here

Examples of javax.jcr.ValueFactory

    /*
     * Test method for 'org.springmodules.jcr.JcrTemplate.getValueFactory()'
     */
    public void testGetValueFactory() throws RepositoryException{
        MockControl resultMock = MockControl.createControl(ValueFactory.class);
        ValueFactory result = (ValueFactory) resultMock.getMock();
       
        sessionControl.expectAndReturn(session.getValueFactory(), result);
        sessionControl.replay();
        sfControl.replay();

View Full Code Here

Examples of javax.jcr.ValueFactory

        Node hello2 = session.getRootNode().addNode("hello2");
        hello2.setProperty("id""2");
        hello2.setProperty("text""hello world");
        session.save();

        ValueFactory vf = session.getValueFactory();

        QueryManager qm = session.getWorkspace().getQueryManager();

        // SQL-2

        Query q = qm.createQuery("select text from [nt:base] where id = $id", Query.JCR_SQL2);
        q.bindValue("id", vf.createValue("1"));
        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        assertTrue(it.hasNext());
        Row row = it.nextRow();
        assertEquals("hello_world", row.getValue("text").getString());
View Full Code Here

Examples of javax.jcr.ValueFactory

        session.save();
        Node hello2 = hello3.addNode("hello2");
        hello2.setProperty("id""2");
        hello2.setProperty("data""y");
        session.save();
        ValueFactory vf = session.getValueFactory();
        QueryManager qm = session.getWorkspace().getQueryManager();
        Query q = qm.createQuery("select id from [nt:base] where data >= $data order by id", Query.JCR_SQL2);
        q.bindValue("data", vf.createValue("x"));
        for (int i = -1; i < 5; i++) {
            QueryResult r = q.execute();
            RowIterator it = r.getRows();
            assertEquals(3, r.getRows().getSize());
            assertEquals(3, r.getNodes().getSize());
View Full Code Here

Examples of javax.jcr.ValueFactory

        session.save();
        Node hello2 = session.getRootNode().addNode("hello2");
        hello2.setProperty("id""2");
        hello2.setProperty("data""y");
        session.save();
        ValueFactory vf = session.getValueFactory();
        QueryManager qm = session.getWorkspace().getQueryManager();
        Query q = qm.createQuery("select id from [nt:base] where data >= $data order by id", Query.JCR_SQL2);
        q.bindValue("data", vf.createValue("x"));
        for (int limit = 0; limit < 5; limit++) {
            q.setLimit(limit);
            for (int offset = 0; offset < 3; offset++) {
                q.setOffset(offset);
                QueryResult r = q.execute();
View Full Code Here

Examples of javax.jcr.ValueFactory

    }
   
    @Test
    public void noLiterals() throws RepositoryException {
        Session session = getAdminSession();
        ValueFactory vf = session.getValueFactory();
        QueryManager qm = session.getWorkspace().getQueryManager();
       
        // insecure
        try {
            Query q = qm.createQuery(
                    "select text from [nt:base] where password = 'x'",
                    Query.JCR_SQL2 + "-noLiterals");
            q.execute();
            fail();
        } catch (InvalidQueryException e) {
            assertTrue(e.toString(), e.toString().indexOf(
                    "literals of this type not allowed") > 0);
        }

        // secure
        Query q = qm.createQuery(
                "select text from [nt:base] where password = $p",
                Query.JCR_SQL2 + "-noLiterals");
        q.bindValue("p", vf.createValue("x"));
        q.execute();
    }
View Full Code Here

Examples of javax.jcr.ValueFactory

    }
   
    @SuppressWarnings("deprecation")
    @Nonnull
    protected GenericDescriptors createDescriptors() {
        final ValueFactory valueFactory = new SimpleValueFactory();
        final Value trueValue = valueFactory.createValue(true);
        final Value falseValue = valueFactory.createValue(false);

        GenericDescriptors gd = new GenericDescriptors()
                .put(IDENTIFIER_STABILITY, valueFactory.createValue(Repository.IDENTIFIER_STABILITY_METHOD_DURATION), true, true)
                .put(LEVEL_1_SUPPORTED, trueValue, true, true)
                .put(LEVEL_2_SUPPORTED, trueValue, true, true)
                .put(OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_INHERITANCE, valueFactory.createValue(NODE_TYPE_MANAGEMENT_INHERITANCE_SINGLE), true, true)
                .put(NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_PROPERTY_TYPES,
                new Value[]{
                        valueFactory.createValue(PropertyType.TYPENAME_STRING),
                        valueFactory.createValue(PropertyType.TYPENAME_BINARY),
                        valueFactory.createValue(PropertyType.TYPENAME_LONG),
                        valueFactory.createValue(PropertyType.TYPENAME_LONG),
                        valueFactory.createValue(PropertyType.TYPENAME_DOUBLE),
                        valueFactory.createValue(PropertyType.TYPENAME_DECIMAL),
                        valueFactory.createValue(PropertyType.TYPENAME_DATE),
                        valueFactory.createValue(PropertyType.TYPENAME_BOOLEAN),
                        valueFactory.createValue(PropertyType.TYPENAME_NAME),
                        valueFactory.createValue(PropertyType.TYPENAME_PATH),
                        valueFactory.createValue(PropertyType.TYPENAME_REFERENCE),
                        valueFactory.createValue(PropertyType.TYPENAME_WEAKREFERENCE),
                        valueFactory.createValue(PropertyType.TYPENAME_URI),
                        valueFactory.createValue(PropertyType.TYPENAME_UNDEFINED)
                }, false, true)
                .put(NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, trueValue, true, true)
                // SNS are not supported (OAK-1224)
                .put(NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, falseValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, trueValue, true, true)
                .put(NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, falseValue, true, true)
                .put(OPTION_ACCESS_CONTROL_SUPPORTED, trueValue, true, true)
                .put(OPTION_JOURNALED_OBSERVATION_SUPPORTED, falseValue, true, true)
                .put(OPTION_LIFECYCLE_SUPPORTED, falseValue, true, true)
                // locking support added via JCR layer
                .put(OPTION_LOCKING_SUPPORTED, falseValue, true, true)
                .put(OPTION_OBSERVATION_SUPPORTED, trueValue, true, true)
                .put(OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED,
                        supportsSameNameNodeAndProperties() ? trueValue : falseValue, true, true)
                .put(OPTION_QUERY_SQL_SUPPORTED, falseValue, true, true)
                .put(OPTION_RETENTION_SUPPORTED, falseValue, true, true)
                .put(OPTION_SHAREABLE_NODES_SUPPORTED, falseValue, true, true)
                // todo: let plugin set the descriptor
                .put(OPTION_SIMPLE_VERSIONING_SUPPORTED, falseValue, true, true)
                .put(OPTION_TRANSACTIONS_SUPPORTED, falseValue, true, true)
                .put(OPTION_UNFILED_CONTENT_SUPPORTED, falseValue, true, true)
                .put(OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, trueValue, true, true)
                .put(OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, trueValue, true, true)
                .put(OPTION_VERSIONING_SUPPORTED, trueValue, true, true)
                .put(OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, trueValue, true, true)
                // xml export support added via JCR layer
                .put(OPTION_XML_EXPORT_SUPPORTED, falseValue, true, true)
                // xml import support added via JCR layer
                .put(OPTION_XML_IMPORT_SUPPORTED, falseValue, true, true)
                .put(OPTION_ACTIVITIES_SUPPORTED, falseValue, true, true)
                .put(OPTION_BASELINES_SUPPORTED, falseValue, true, true)
                .put(QUERY_FULL_TEXT_SEARCH_SUPPORTED, falseValue, true, true)
                .put(QUERY_JOINS, valueFactory.createValue(QUERY_JOINS_NONE), true, true)
                .put(QUERY_LANGUAGES, new Value[0], false, true)
                .put(QUERY_STORED_QUERIES_SUPPORTED, falseValue, true, true)
                .put(QUERY_XPATH_DOC_ORDER, falseValue, true, true)
                .put(QUERY_XPATH_POS_INDEX, falseValue, true, true)
                .put(REP_NAME_DESC, valueFactory.createValue("Apache Jackrabbit Oak"), true, true)
                .put(REP_VERSION_DESC, valueFactory.createValue(getVersion()), true, true)
                .put(REP_VENDOR_DESC, valueFactory.createValue("The Apache Software Foundation"), true, true)
                .put(REP_VENDOR_URL_DESC, valueFactory.createValue("http://www.apache.org/"), true, true)
                .put(SPEC_NAME_DESC, valueFactory.createValue("Content Repository for Java Technology API"), true, true)
                .put(SPEC_VERSION_DESC, valueFactory.createValue("2.0"), true, true)
                .put(WRITE_SUPPORTED, trueValue, true, true);
        // jackrabbit API specific descriptors
        gd.put(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED, falseValue, true, false);
        gd.put(JackrabbitRepository.OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED, falseValue, true, false);
        gd.put(JackrabbitRepository.OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED, falseValue, true, false);
View Full Code Here

Examples of javax.jcr.ValueFactory

        node.setProperty("double", Math.PI);
        node.setProperty("long", 90834953485278298L);
        Calendar c = Calendar.getInstance();
        c.set(2005, 6, 18, 17, 30);
        node.setProperty("calendar", c);
        ValueFactory factory = node.getSession().getValueFactory();
        node.setProperty("path", factory.createValue("/", PropertyType.PATH));
        node.setProperty("multi", new String[] { "one", "two", "three" });
    }
View Full Code Here

Examples of javax.jcr.ValueFactory

    @Override
    public void setValue(String[] strings) throws RepositoryException {
        if (strings == null) {
            remove();
        } else {
            ValueFactory factory = getValueFactory();
            Value[] values = new Value[strings.length];
            for (int i = 0; i < strings.length; i++) {
                if (strings[i] != null) {
                    values[i] = factory.createValue(strings[i]);
                }
            }
            internalSetValue(values);
        }
    }
View Full Code Here

Examples of org.apache.batik.css.value.ValueFactory

      throws CSSException {
      CSSOMStyleDeclaration sd;
      sd = (CSSOMStyleDeclaration)
                ((CSSOMStyleRule)currentRule).getStyle();
      String imp = (important) ? "!important" : "";
      ValueFactory f = getValueFactoryMap().get(name);
      f.createCSSValue(value, sd, imp);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.