Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.Result


            final String uuid = getIdentifier(tree);
            String reference = weak ? PropertyType.TYPENAME_WEAKREFERENCE : PropertyType.TYPENAME_REFERENCE;
            String pName = propertyName == null ? "*" : propertyName;   // TODO: sanitize against injection attacks!?
            Map<String, ? extends PropertyValue> bindings = Collections.singletonMap("uuid", PropertyValues.newString(uuid));

            Result result = root.getQueryEngine().executeQuery(
                    "SELECT * FROM [nt:base] WHERE PROPERTY([" + pName + "], '" + reference + "') = $uuid",
                    Query.JCR_SQL2, Long.MAX_VALUE, 0, bindings, new NamePathMapper.Default());

            Iterable<String> paths = Iterables.transform(result.getRows(),
                    new Function<ResultRow, String>() {
                @Override
                public String apply(ResultRow row) {
                    String pName = propertyName == null
                            ? findProperty(row.getPath(), uuid)
View Full Code Here


    }

    private String resolveUUID(PropertyState uuid) {
        try {
            Map<String, PropertyValue> bindings = Collections.singletonMap("id", PropertyValues.create(uuid));
            Result result = root.getQueryEngine().executeQuery(
                    "SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id", Query.JCR_SQL2,
                    Long.MAX_VALUE, 0, bindings, new NamePathMapper.Default());

            String path = null;
            for (ResultRow rr : result.getRows()) {
                if (path != null) {
                    log.error("multiple results for identifier lookup: " + path + " vs. " + rr.getPath());
                    return null;
                } else {
                    path = rr.getPath();
View Full Code Here

        }
    }

    private List<String> executeQuery(String query) throws ParseException {
        List<String> lines = new ArrayList<String>();
        Result result = qe.executeQuery(query, QueryEngineImpl.SQL2, null);
        for (ResultRow row : result.getRows()) {
            lines.add(readRow(row));
        }
        if (!query.contains("order by")) {
            Collections.sort(lines);
        }
View Full Code Here

    public QueryResult executeQuery(String statement, String language,
            HashMap<String, Value> bindVariableMap, long limit, long offset) throws RepositoryException {
        try {
            HashMap<String, CoreValue> bindMap = convertMap(bindVariableMap);
            Result r = queryEngine.executeQuery(statement, language, bindMap);
            return new QueryResultImpl(r, sessionContext.getValueFactory());
        } catch (ParseException e) {
            throw new InvalidQueryException(e);
        }
    }
View Full Code Here

    protected List<String> executeQuery(String query, String language, boolean pathsOnly) {
        long time = System.currentTimeMillis();
        List<String> lines = new ArrayList<String>();
        try {
            Result result = executeQuery(query, language, null);
            for (ResultRow row : result.getRows()) {
                lines.add(readRow(row, pathsOnly));
            }
            if (!query.contains("order by")) {
                Collections.sort(lines);
            }
View Full Code Here

    public QueryResult executeQuery(String statement, String language,
            long limit, long offset, HashMap<String, Value> bindVariableMap) throws RepositoryException {
        try {
            Map<String, PropertyValue> bindMap = convertMap(bindVariableMap);
            Result r = queryEngine.executeQuery(
                    statement, language, limit, offset, bindMap,
                    sessionContext.getSessionLocalMappings());
            return new QueryResultImpl(sessionContext, r);
        } catch (IllegalArgumentException e) {
            throw new InvalidQueryException(e);
View Full Code Here

        try {
            StringBuilder stmt = new StringBuilder();
            stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']');
            stmt.append("WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName");

            Result result = root.getQueryEngine().executeQuery(stmt.toString(),
                    Query.JCR_SQL2, 1, 0,
                    Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())),
                    NO_MAPPINGS);

            Iterator<? extends ResultRow> rows = result.getRows().iterator();
            if (rows.hasNext()) {
                String path = rows.next().getPath();
                return root.getTree(path);
            }
        } catch (ParseException ex) {
View Full Code Here

    }

    private List<String> executeQuery(String query) {
        List<String> lines = new ArrayList<String>();
        try {
            Result result = executeQuery(query, null);
            for (ResultRow row : result.getRows()) {
                lines.add(readRow(row));
            }
            if (!query.contains("order by")) {
                Collections.sort(lines);
            }
View Full Code Here

    NodeDelegate findByJcrUuid(String id) {
        try {
            Map<String, CoreValue> bindings = Collections.singletonMap("id", getValueFactory().getCoreValueFactory()
                    .createValue(id));

            Result result = getQueryEngine().executeQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id", Query.JCR_SQL2,
                    getContentSession(), Long.MAX_VALUE, 0, bindings, namePathMapper);

            String path = null;

            for (ResultRow rr : result.getRows()) {
                if (path != null) {
                    log.error("multiple results for identifier lookup: " + path + " vs. " + rr.getPath());
                    return null;
                } else {
                    path = rr.getPath();
View Full Code Here

    NodeDelegate findByJcrUuid(String id) {
        try {
            Map<String, CoreValue> bindings = Collections.singletonMap("id", getValueFactory().getCoreValueFactory()
                    .createValue(id));

            Result result = getQueryEngine().executeQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id", Query.JCR_SQL2,
                    getContentSession(), Long.MAX_VALUE, 0, bindings, namePathMapper);

            String path = null;

            for (ResultRow rr : result.getRows()) {
                if (path != null) {
                    log.error("multiple results for identifier lookup: " + path + " vs. " + rr.getPath());
                    return null;
                } else {
                    path = rr.getPath();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.Result

Copyright © 2018 www.massapicom. 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.