jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r737690 - in /jackrabbit/sandbox/jcr-cmis: api/src/main/java/org/apache/jackrabbit/cmis/ client/src/main/webapp/ cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/ server/atompub/src/test/java/org/apache/jackrabbit/cmis/
Date Mon, 26 Jan 2009 13:30:03 GMT
Author: dpfister
Date: Mon Jan 26 13:30:03 2009
New Revision: 737690

URL: http://svn.apache.org/viewvc?rev=737690&view=rev
Log:
JCRCMIS - add a query page and implementation in the server

Added:
    jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.html
    jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.jsp
Modified:
    jackrabbit/sandbox/jcr-cmis/api/src/main/java/org/apache/jackrabbit/cmis/Repository.java
    jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
    jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/SimpleRepository.java

Modified: jackrabbit/sandbox/jcr-cmis/api/src/main/java/org/apache/jackrabbit/cmis/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/api/src/main/java/org/apache/jackrabbit/cmis/Repository.java?rev=737690&r1=737689&r2=737690&view=diff
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/api/src/main/java/org/apache/jackrabbit/cmis/Repository.java
(original)
+++ jackrabbit/sandbox/jcr-cmis/api/src/main/java/org/apache/jackrabbit/cmis/Repository.java
Mon Jan 26 13:30:03 2009
@@ -100,4 +100,12 @@
      * @return entry
      */
     public Entry getEntry(String id);
+
+    /**
+     * Query elements, given a query string.
+     *
+     * @param query query string
+     * @return list of items
+     */
+    public Iterable<Entry> query(String query);
 }

Added: jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.html
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.html?rev=737690&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.html (added)
+++ jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.html Mon Jan 26 13:30:03 2009
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>CMIS v0.5+ implementation: query</title>
+<meta http-equiv="content-type" content="text/html; charset=utf-8"></meta>
+<link rel="stylesheet" type="text/css" href="main.css"></link>
+</head>
+
+<body>
+    <script src="header.js"></script>
+    <div class="content">
+        <h1>Discovery Services: query</h1>
+        <form method="GET" action="query.xml" target="result">
+            <table class="formtable">
+            <tr>
+                <td>Query</td>
+                <td><textarea class="text" rows="5" cols="40" name="query"></textarea></td>
+            </tr><tr><td>&nbsp;</td><td>
+            <input type="submit"><br></td></tr></table>
+        </form>
+        <p>
+            <iframe name="result" height="400" width="950" src="about:blank"></iframe>
+        </p>
+        <script src="footer.js"></script>
+    </div>
+</body>
+</html>
\ No newline at end of file

Added: jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.jsp?rev=737690&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.jsp (added)
+++ jackrabbit/sandbox/jcr-cmis/client/src/main/webapp/query.jsp Mon Jan 26 13:30:03 2009
@@ -0,0 +1,63 @@
+<%@ page session="false" %><%
+%><%@ page import="org.apache.jackrabbit.cmis.*,
+                   org.apache.jackrabbit.cmis.client.JCRRepositoryLocator,
+                 java.util.Iterator" %><%
+
+    response.setContentType("application/atom+xml;type=feed");
+    response.setCharacterEncoding("UTF-8");
+
+    String contextPath = request.getContextPath();
+    String query = (String) request.getParameter("query");
+    
+    Repository repository = JCRRepositoryLocator.getRepository(application);
+    String authorName = "admin";
+    
+%><?xml version="1.0" encoding="UTF-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmis="http://www.cmis.org/2008/05">
+    <author><name><%= authorName %></name></author>
+    <id></id>
+    <link rel="self" href="<%= request.getRequestURI() %>"/>
+    <link rel="cmis-source" href="<%= request.getRequestURI() %>"/>
+    <title>Query result for <%= query %></title><%
+    
+    for (Entry child : repository.query(query)) {
+        
+    %>
+    <entry><%
+        String childId = child.getId();
+        String childUrl = contextPath + "/" + childId;
+    %>
+        <author><name><%= authorName %></name></author>
+        <content><%= childId %></content>
+        <id>urn:uuid:<%= childId %></id>
+        <link rel="self" href="<%= childUrl %>"/>
+        <link rel="cmis-allowableactions" href="<%= contextPath %>/<%= childId
%>.getAllowableActions.xml"/>
+        <link rel="cmis-relationships" href="<%= contextPath %>/<%= childId %>.getRelationShips.xml"/>
+        <link rel="cmis-parent" href="<%= contextPath %>/<%= childId %>.getParent.xml"/>
+        <link rel="cmis-folderparent" href="<%= contextPath %>/<%= childId %>.getFolderParent.xml"/>
+        <link rel="cmis-children" href="<%= contextPath %>/<%= childId %>.getChildren.xml"/>
+        <link rel="cmis-descendants" href="<%= contextPath %>/<%= childId %>.getDescendants.xml"/>
+        <link rel="cmis-type" href="<%= contextPath %>/<%= childId %>.getType.xml"/>
+        <link rel="cmis-repository" href="<%= contextPath %>/<%= childId %>.getRepository.xml"/>
+        <published><%= child.getLastModificationDate().getTime() %></published>
+        <summary>Summary for <%= child.getName() %></summary>
+        <title>Title for <%= child.getName() %></title>
+        <updated><%= child.getLastModifiedBy() %></updated>
+        <cmis:object>
+            <cmis:properties>
+                <cmis:propertyId cmis:name="ObjectId"><cmis:value><%= child.getObjectId()
%></cmis:value></cmis:propertyId>
+                <cmis:propertyString cmis:name="ObjectTypeId"><cmis:value><%=
child.getObjectTypeId() %></cmis:value></cmis:propertyString>
+                <cmis:propertyString cmis:name="CreatedBy"><cmis:value><%=
child.getCreatedBy() %></cmis:value></cmis:propertyString>
+                <cmis:propertyDateTime cmis:name="CreationDate"><cmis:value><%=
child.getCreationDate().getTime() %></cmis:value></cmis:propertyDateTime>
+                <cmis:propertyString cmis:name="LastModifiedBy"><cmis:value><%=
child.getLastModifiedBy() %></cmis:value></cmis:propertyString>
+                <cmis:propertyDateTime cmis:name="LastModificationDate"><cmis:value><%=
child.getLastModificationDate().getTime() %></cmis:value></cmis:propertyDateTime>
+                <cmis:propertyString cmis:name="Name"><cmis:value><%= child.getName()
%></cmis:value></cmis:propertyString>
+                <cmis:propertyId cmis:name="ParentId"><cmis:value><%= child.getParentId()
%></cmis:value></cmis:propertyId>
+            </cmis:properties>
+        </cmis:object>
+        <cmis:terminator/>
+        <app:edited><%= child.getLastModifiedBy() %></app:edited>
+    </entry>
+    
+    <% } %>
+</feed>

Modified: jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java?rev=737690&r1=737689&r2=737690&view=diff
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
(original)
+++ jackrabbit/sandbox/jcr-cmis/cmis2jcr/src/main/java/org/apache/jackrabbit/cmis/jcr/JCRRepository.java
Mon Jan 26 13:30:03 2009
@@ -17,7 +17,11 @@
 package org.apache.jackrabbit.cmis.jcr;
 
 import java.net.URI;
+import java.util.Iterator;
 
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
 import javax.jcr.RepositoryException;
 
 import org.slf4j.Logger;
@@ -83,8 +87,11 @@
     }
 
     public Entry getEntry(String id) {
+        javax.jcr.Session session = null;
+
         try {
-            javax.jcr.Node node = repository.login(workspace).getRootNode();
+            session = repository.login(workspace);
+            javax.jcr.Node node = session.getRootNode();
             if (!id.equals("")) {
                 node = node.getNode(id);
             }
@@ -92,6 +99,47 @@
         } catch (RepositoryException e) {
             log.warn("Unable to retrieve node " + id, e);
             return null;
+        } finally {
+            /*
+            if (session != null) {
+                session.logout();
+            }
+            */
+        }
+    }
+
+    public Iterable<Entry> query(String s) {
+        javax.jcr.Session session = null;
+
+        if (!s.startsWith("select ") && !s.startsWith("SELECT ")) {
+            s = "SELECT * FROM nt:base WHERE contains(*, '" + s + "')";
+        }
+
+        try {
+            session = repository.login(workspace);
+            QueryManager qm = session.getWorkspace().getQueryManager();
+            Query query = qm.createQuery(s, Query.SQL);
+            final QueryResult result = query.execute();
+
+            return new Iterable<Entry>() {
+                public Iterator<Entry> iterator() {
+                    try {
+                        return new JCREntryIterator(result.getNodes());
+                    } catch (RepositoryException e) {
+                        log.warn("Unable to retrieve result nodes", e);
+                        return null;
+                    }
+                }
+            };
+        } catch (RepositoryException e) {
+            log.warn("Unable to execute query: " + s, e);
+            return null;
+        } finally {
+            /*
+            if (session != null) {
+                session.logout();
+            }
+            */
         }
     }
 

Modified: jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/SimpleRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/SimpleRepository.java?rev=737690&r1=737689&r2=737690&view=diff
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/SimpleRepository.java
(original)
+++ jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/SimpleRepository.java
Mon Jan 26 13:30:03 2009
@@ -151,7 +151,12 @@
     }
 
     public Entry getEntry(String id) {
-	// TODO implement
+        // TODO Auto-generated method stub
 	return null;
     }
+
+    public Iterable<Entry> query(String query) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }



Mime
View raw message