Abdera's on version 1.1.2 and going to 2.x.  I sort of thought it
would be out of Alpha or Beta stage by now, and would at least satisfy
the AtomPub spec.  Not that it necessarily doesn't, or if it doesn't
in 1.1.2, it won't in 2.x.  Just, my evidence so far seems to indicate
that that it throws an NPE when adopting the naive way (perhaps the
only way) to make a workspace that has no collections.

Attached is the shortest Abdera sever I could conjure, and it hardly
does anything.  What it does do is compile, and emit a bare-bones
service document without throwing an exception when you access the
service document URI (http://localhost:8080/).  Comment out line 61,
which adds the CollectionInfo to the workspace, however, and it throws
an NPE at 
org.apache.abdera.protocol.server.impl.DefaultWorkspaceManager.getCollectionAdapter(DefaultWorkspaceManager.java:42).
 Again, this is in 1.1.2, and I don't know how it behaves in the
latest from trunk.  A little later I'll see what it does in the
latest.

Cheers,
David
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import org.apache.abdera.Abdera;
import org.apache.abdera.i18n.iri.IRI;
import org.apache.abdera.model.Content;
import org.apache.abdera.model.Person;
import org.apache.abdera.protocol.server.CollectionInfo;
import org.apache.abdera.protocol.server.Provider;
import org.apache.abdera.protocol.server.RequestContext;
import org.apache.abdera.protocol.server.context.ResponseContextException;
import org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter;
import org.apache.abdera.protocol.server.impl.DefaultProvider;
import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
import org.apache.abdera.protocol.server.servlet.AbderaServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
 
public class App {
    public static void main(String... args) throws Exception {
        Server server = new Server(8080);
        ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
        context.addServlet(new ServletHolder(new AbderaServlet(){
		protected Provider createProvider() {
		    CollectionInfo ca = new AbstractEntityCollectionAdapter<Object>() {
			public String getId(RequestContext request) {return "";}
			public String getTitle(RequestContext request) {return "";}
			public String getAuthor(RequestContext request) {return "";}
			public Iterable getEntries(RequestContext request) {return new ArrayList();}
			public Object getEntry(String resourceName, RequestContext request) 
			throws ResponseContextException {return "";}
			public String getName(Object entry) {return "";}
			public String getId(Object entry) {return "";}
			public String getTitle(Object entry) {return "";}
			public Date getUpdated(Object entry) {return new Date();}
			public List<Person> getAuthors(Object entry, RequestContext request) 
			throws ResponseContextException {return new ArrayList<Person>();}
			public Object getContent(Object entry, RequestContext request) {return "";}
			public Object postEntry(String title,
						IRI id,
						String summary,
						Date updated,
						List<Person> authors,
						Content content,
						RequestContext request) 
			throws ResponseContextException {return "";}
			public void putEntry(Object employee,
					     String title,
					     Date updated,
					     List<Person> authors,
					     String summary,
					     Content content,
					     RequestContext request) throws ResponseContextException {}
			public void deleteEntry(String resourceName, RequestContext request) 
			throws ResponseContextException {}};
		    SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
		    wi.setTitle("");
		    wi.addCollection(ca);
		    DefaultProvider provider = new DefaultProvider("/");
		    // provider.addWorkspace(wi);
		    provider.init(getAbdera(), null);
		    return provider;}
	    }), "/*");
        server.start();
        server.join();}}

Reply via email to