abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r614632 - in /incubator/abdera/java/branches/server_refactor_all/jcr/src: main/java/org/apache/abdera/jcr/ test/java/org/apache/abdera/jcr/
Date Wed, 23 Jan 2008 19:27:44 GMT
Author: dandiep
Date: Wed Jan 23 11:27:41 2008
New Revision: 614632

URL: http://svn.apache.org/viewvc?rev=614632&view=rev
Log:
Migrate JCR bits.

Added:
    incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionAdapter.java
      - copied, changed from r614629, incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionProvider.java
    incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
      - copied, changed from r614629, incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionProviderTest.java
Removed:
    incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionProvider.java
    incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionProviderTest.java
Modified:
    incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/SessionPoolManager.java

Copied: incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionAdapter.java
(from r614629, incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionProvider.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionAdapter.java?p2=incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionAdapter.java&p1=incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionProvider.java&r1=614629&r2=614632&rev=614632&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionProvider.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/JcrCollectionAdapter.java
Wed Jan 23 11:27:41 2008
@@ -30,10 +30,9 @@
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ResponseContext;
 import org.apache.abdera.protocol.server.RequestContext.Scope;
-import org.apache.abdera.protocol.server.impl.AbstractEntityCollectionProvider;
-import org.apache.abdera.protocol.server.impl.EmptyResponseContext;
-import org.apache.abdera.protocol.server.impl.ResponseContextException;
-import org.apache.abdera.protocol.util.EncodingUtil;
+import org.apache.abdera.protocol.server.context.EmptyResponseContext;
+import org.apache.abdera.protocol.server.context.ResponseContextException;
+import org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter;
 import org.apache.abdera.protocol.util.PoolManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,9 +41,9 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
 
-public class JcrCollectionProvider extends AbstractEntityCollectionProvider<Node> {
+public class JcrCollectionAdapter extends AbstractEntityCollectionAdapter<Node> {
 
-  private final static Log log = LogFactory.getLog(JcrCollectionProvider.class);
+  private final static Log log = LogFactory.getLog(JcrCollectionAdapter.class);
   
   private static final String TITLE = "title";
 
@@ -101,7 +100,7 @@
   }
 
   /**
-   * Logs into the repository and creates a node for the collection if one does not exist.
Also,
+   * Logs into the repository and posts a node for the collection if one does not exist.
Also,
    * this will set up the session pool.
    * @throws RepositoryException
    */
@@ -152,9 +151,7 @@
   }
 
   @Override
-  public void begin(RequestContext request) throws ResponseContextException {
-    super.begin(request);
-
+  public void start(RequestContext request) throws ResponseContextException {
     try {
       Session session = (Session) sessionPool.get(request);
 
@@ -175,8 +172,6 @@
         log.warn("Could not return Session to pool!", e);
       }
     }
-
-    super.end(request, response);
   }
 
 
@@ -195,19 +190,19 @@
   }
 
   @Override
-  public Node createMediaEntry(MimeType mimeType, String slug, 
+  public Node postMediaEntry(MimeType mimeType, String slug, 
                                InputStream inputStream, RequestContext request)
     throws ResponseContextException {
     if (slug == null) {
       throw new ResponseContextException("A slug header must be supplied.", 500);
     }
-    Node n = createEntry(slug, null, null, new Date(), null, null, request);
+    Node n = postEntry(slug, null, null, new Date(), null, null, request);
     
     try {
       n.setProperty(MEDIA, inputStream);
       n.setProperty(CONTENT_TYPE, mimeType.toString());
 
-      String summary = createSummaryForEntry(n);
+      String summary = postSummaryForEntry(n);
       if (summary != null) {
         n.setProperty(SUMMARY, summary);
       }
@@ -226,19 +221,19 @@
   }
   
   /**
-   * Create a summary for an entry. Used when a media entry is created
-   * so you have the chance to create a meaningful summary for consumers
+   * post a summary for an entry. Used when a media entry is postd
+   * so you have the chance to post a meaningful summary for consumers
    * of the feed.
    * 
    * @param n
    * @return
    */
-  protected String createSummaryForEntry(Node n) {
+  protected String postSummaryForEntry(Node n) {
     return null;
   }
 
   @Override
-  public Node createEntry(String title, IRI id, String summary, Date updated, List<Person>
authors,
+  public Node postEntry(String title, IRI id, String summary, Date updated, List<Person>
authors,
                           Content content, RequestContext request) throws ResponseContextException
{
     Node entry = null;
     try {
@@ -246,7 +241,7 @@
 
       Node collectionNode = session.getNodeByUUID(collectionNodeId);
       String resourceName = Sanitizer.sanitize(title, "-");
-      entry = createEntry(title, summary, updated, authors, 
+      entry = postEntry(title, summary, updated, authors, 
                           content, session, collectionNode,
                           resourceName, 0);
       
@@ -262,7 +257,7 @@
     }
   }
 
-  protected Node createEntry(String title, String summary, 
+  protected Node postEntry(String title, String summary, 
                              Date updated, List<Person> authors, 
                              Content content, Session session, 
                              Node collectionNode, String resourceName, int num)
@@ -284,7 +279,7 @@
     }
     catch (ItemExistsException e) 
     {
-      return createEntry(title, summary, updated, authors, content, session, collectionNode,
resourceName, num++);
+      return postEntry(title, summary, updated, authors, content, session, collectionNode,
resourceName, num++);
     }
   }
 
@@ -494,7 +489,6 @@
     return summary;
   }
 
-  @Override
   public String getTitle(RequestContext request) {
     return title;
   }
@@ -510,7 +504,7 @@
   }
 
   @Override
-  public void updateEntry(Node entry, String title, Date updated,
+  public void putEntry(Node entry, String title, Date updated,
                           List<Person> authors, String summary,
                           Content content, RequestContext request) throws ResponseContextException
{
     Session session = getSession(request);
@@ -533,6 +527,10 @@
       throw new RuntimeException(e);
     }
 
+    return null;
+  }
+
+  public ResponseContext getCategories(RequestContext request) {
     return null;
   }
 

Modified: incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/SessionPoolManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/SessionPoolManager.java?rev=614632&r1=614631&r2=614632&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/SessionPoolManager.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/jcr/src/main/java/org/apache/abdera/jcr/SessionPoolManager.java
Wed Jan 23 11:27:41 2008
@@ -6,7 +6,7 @@
 import javax.jcr.Session;
 
 import org.apache.abdera.protocol.Request;
-import org.apache.abdera.protocol.server.impl.AbstractItemManager;
+import org.apache.abdera.protocol.util.AbstractItemManager;
 
 public class SessionPoolManager extends AbstractItemManager<Session> {
   private Repository repository;

Copied: incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
(from r614629, incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionProviderTest.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java?p2=incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java&p1=incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionProviderTest.java&r1=614629&r2=614632&rev=614632&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionProviderTest.java
(original)
+++ incubator/abdera/java/branches/server_refactor_all/jcr/src/test/java/org/apache/abdera/jcr/JcrCollectionAdapterTest.java
Wed Jan 23 11:27:41 2008
@@ -1,11 +1,8 @@
 package org.apache.abdera.jcr;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -24,13 +21,9 @@
 import org.apache.abdera.protocol.client.AbderaClient;
 import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.server.CollectionProvider;
-import org.apache.abdera.protocol.server.ServiceContext;
-import org.apache.abdera.protocol.server.WorkspaceInfo;
-import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
-import org.apache.abdera.protocol.server.impl.ServiceProvider;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
 import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
-import org.apache.abdera.protocol.server.impl.SingletonProviderManager;
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
 import org.apache.abdera.writer.Writer;
 import org.apache.jackrabbit.core.TransientRepository;
@@ -40,49 +33,38 @@
 
 import junit.framework.TestCase;
 
-public class JcrCollectionProviderTest extends TestCase {
+public class JcrCollectionAdapterTest extends TestCase {
 
   private Server server;
-  private DefaultServiceContext abderaServiceContext;
+  private DefaultProvider jcrProvider;
   private Repository repository;
 
   @Override
   protected void setUp() throws Exception {
     super.setUp();
 
-    abderaServiceContext = new DefaultServiceContext();
-
-    SingletonProviderManager pm = new SingletonProviderManager();
-    abderaServiceContext.setProviderManager(pm);
-
-    ServiceProvider sp = new ServiceProvider();
-
-    SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
+    jcrProvider = new DefaultProvider();
 
     repository = new TransientRepository();
     
-    JcrCollectionProvider cp = new JcrCollectionProvider();
+    JcrCollectionAdapter cp = new JcrCollectionAdapter();
     cp.setTitle("My Entries");
     cp.setAuthor("Apache Abdera");
     cp.setCollectionNodePath("entries");         
     cp.setRepository(repository);
     cp.setCredentials(new SimpleCredentials("username", "pass".toCharArray()));
+    cp.setHref("acme/feed");
     cp.initialize();
-
-    Map<String, CollectionProvider> contentProviders = new HashMap<String, CollectionProvider>();
-    contentProviders.put("acme/feed", cp);
-
-    wi.setCollectionProviders(contentProviders);
-
-    List<WorkspaceInfo> workspaces = new ArrayList<WorkspaceInfo>();
-    workspaces.add(wi);
-    sp.setWorkspaces(workspaces);
-    pm.setProvider(sp);
-    abderaServiceContext.setTargetResolver(sp);
+    
+    SimpleWorkspaceInfo wkspc = new SimpleWorkspaceInfo();
+    wkspc.setTitle("JCR Workspace");
+    wkspc.addCollection(cp);
+    jcrProvider.addWorkspace(wkspc);
+    
     initializeJetty();
   }
 
-  public void testCustomerProvider() throws Exception {
+  public void testJCRAdapter() throws Exception {
     Abdera abdera = new Abdera();
     Factory factory = abdera.getFactory();
 
@@ -177,9 +159,9 @@
     root.addServlet(new ServletHolder(new AbderaServlet() {
 
       @Override
-      protected ServiceContext createServiceContext() {
-        abderaServiceContext.init(getAbdera(), getProperties(getServletConfig()));
-        return abderaServiceContext;
+      protected Provider createProvider() {
+        jcrProvider.init(getAbdera(), getProperties(getServletConfig()));
+        return jcrProvider;
       }
     }), "/*");
     server.start();



Mime
View raw message