jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1420791 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query: QueryImpl.java QueryManagerImpl.java
Date Wed, 12 Dec 2012 15:54:05 GMT
Author: alexparvulescu
Date: Wed Dec 12 15:54:04 2012
New Revision: 1420791

URL: http://svn.apache.org/viewvc?rev=1420791&view=rev
Log:
OAK-508 Query storeAsNode cleanup

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java?rev=1420791&r1=1420790&r2=1420791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryImpl.java
Wed Dec 12 15:54:04 2012
@@ -20,21 +20,20 @@ package org.apache.jackrabbit.oak.jcr.qu
 
 import java.util.HashMap;
 import java.util.List;
-import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
+import javax.jcr.ValueFactory;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.NodeDelegate;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionDelegate;
-import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 
 /**
  * The implementation of the corresponding JCR interface.
@@ -126,23 +125,18 @@ public class QueryImpl implements Query 
         manager.ensureIsAlive();
         SessionDelegate sessionDelegate = manager.getSessionDelegate();
         String oakPath = sessionDelegate.getOakPathOrThrow(absPath);
-        // TODO query nodes should be of type nt:query
         String parent = PathUtils.getParentPath(oakPath);
-        String nodeName = PathUtils.getName(oakPath);
-        NodeDelegate parentNode = sessionDelegate.getNode(parent);
-        ValueFactoryImpl vf = sessionDelegate.getValueFactory();
-        if (parentNode == null) {
+        NodeDelegate parentDelegate = sessionDelegate.getNode(parent);
+        if (parentDelegate == null) {
             throw new PathNotFoundException("The specified path does not exist: " + parent);
         }
-        NodeDelegate node = parentNode.addChild(nodeName);
-        if (node == null) {
-            throw new ItemExistsException("Node already exists: " + absPath);
-        }
-        node.setProperty("statement", vf.createValue(statement));
-        node.setProperty("language", vf.createValue(language));
-        NodeImpl n = new NodeImpl(node);
-        n.setPrimaryType(NodeType.NT_QUERY);
-        storedQueryPath = oakPath;
+        Node parentNode = new NodeImpl(parentDelegate);
+        String nodeName = PathUtils.getName(oakPath);
+        ValueFactory vf = sessionDelegate.getValueFactory();
+        Node n = parentNode.addNode(nodeName, JcrConstants.NT_QUERY);
+        n.setProperty(JcrConstants.JCR_STATEMENT, vf.createValue(statement));
+        n.setProperty(JcrConstants.JCR_LANGUAGE, vf.createValue(language));
+        setStoredQueryPath(oakPath);
         return n;
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java?rev=1420791&r1=1420790&r2=1420791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/query/QueryManagerImpl.java
Wed Dec 12 15:54:04 2012
@@ -29,13 +29,13 @@ import java.util.Map.Entry;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.QueryObjectModelFactory;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
@@ -77,11 +77,11 @@ public class QueryManagerImpl implements
 
     @Override
     public Query getQuery(Node node) throws RepositoryException {
-        if (!node.isNodeType(NodeType.NT_QUERY)) {
+        if (!node.isNodeType(JcrConstants.NT_QUERY)) {
             throw new InvalidQueryException("Not an nt:query node: " + node.getPath());
         }
-        String statement = node.getProperty("statement").getString();
-        String language = node.getProperty("language").getString();
+        String statement = node.getProperty(JcrConstants.JCR_STATEMENT).getString();
+        String language = node.getProperty(JcrConstants.JCR_LANGUAGE).getString();
         QueryImpl query = createQuery(statement, language);
         query.setStoredQueryPath(node.getPath());
         return query;



Mime
View raw message