abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [41/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ ...
Date Tue, 20 Sep 2011 15:57:20 GMT
Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.multipart;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.mail.Header;
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetHeaders;
+
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.io.MultipartInputStream;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.commons.codec.binary.Base64;
+
+@SuppressWarnings("unchecked")
+public abstract class AbstractMultipartCollectionAdapter extends AbstractAtompubCollectionAdapter implements
+    MultipartRelatedCollectionInfo {
+
+    private static final String CONTENT_TYPE_HEADER = "content-type";
+    private static final String CONTENT_ID_HEADER = "content-id";
+    private static final String START_PARAM = "start";
+    private static final String TYPE_PARAM = "type";
+    private static final String BOUNDARY_PARAM = "boundary";
+
+    protected Map<String, String> accepts;
+
+    public String[] getAccepts(RequestContext request) {
+        Collection<String> acceptKeys = getAlternateAccepts(request).keySet();
+        return acceptKeys.toArray(new String[acceptKeys.size()]);
+    }
+
+    protected MultipartRelatedPost getMultipartRelatedData(RequestContext request) throws IOException, ParseException,
+        MessagingException {
+
+        MultipartInputStream multipart = getMultipartStream(request);
+        multipart.skipBoundary();
+
+        String start = request.getContentType().getParameter(START_PARAM);
+
+        Document<Entry> entry = null;
+        Map<String, String> entryHeaders = new HashMap<String, String>();
+        InputStream data = null;
+        Map<String, String> dataHeaders = new HashMap<String, String>();
+
+        Map<String, String> headers = getHeaders(multipart);
+
+        // check if the first boundary is the media link entry
+        if (start == null || start.length() == 0
+            || (headers.containsKey(CONTENT_ID_HEADER) && start.equals(headers.get(CONTENT_ID_HEADER)))
+            || (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper.isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
+            entry = getEntry(multipart, request);
+            entryHeaders.putAll(headers);
+        } else {
+            data = getDataInputStream(multipart);
+            dataHeaders.putAll(headers);
+        }
+
+        multipart.skipBoundary();
+
+        headers = getHeaders(multipart);
+
+        if (start != null && (headers.containsKey(CONTENT_ID_HEADER) && start.equals(headers.get(CONTENT_ID_HEADER)))
+            && (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper.isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
+            entry = getEntry(multipart, request);
+            entryHeaders.putAll(headers);
+        } else {
+            data = getDataInputStream(multipart);
+            dataHeaders.putAll(headers);
+        }
+
+        checkMultipartContent(entry, dataHeaders, request);
+
+        return new MultipartRelatedPost(entry, data, entryHeaders, dataHeaders);
+    }
+
+    private MultipartInputStream getMultipartStream(RequestContext request) throws IOException, ParseException,
+        IllegalArgumentException {
+        String boundary = request.getContentType().getParameter(BOUNDARY_PARAM);
+
+        if (boundary == null) {
+            throw new IllegalArgumentException("multipart/related stream invalid, boundary parameter is missing.");
+        }
+
+        boundary = "--" + boundary;
+
+        String type = request.getContentType().getParameter(TYPE_PARAM);
+        if (!(type != null && MimeTypeHelper.isAtom(type))) {
+            throw new ParseException(
+                                     "multipart/related stream invalid, type parameter should be " + Constants.ATOM_MEDIA_TYPE);
+        }
+
+        PushbackInputStream pushBackInput = new PushbackInputStream(request.getInputStream(), 2);
+        pushBackInput.unread("\r\n".getBytes());
+
+        return new MultipartInputStream(pushBackInput, boundary.getBytes());
+    }
+
+    private void checkMultipartContent(Document<Entry> entry, Map<String, String> dataHeaders, RequestContext request)
+        throws ParseException {
+        if (entry == null) {
+            throw new ParseException("multipart/related stream invalid, media link entry is missing");
+        }
+        if (!dataHeaders.containsKey(CONTENT_TYPE_HEADER)) {
+            throw new ParseException("multipart/related stream invalid, data content-type is missing");
+        }
+        if (!isContentTypeAccepted(dataHeaders.get(CONTENT_TYPE_HEADER), request)) {
+            throw new ParseException("multipart/related stream invalid, content-type " + dataHeaders
+                .get(CONTENT_TYPE_HEADER)
+                + " not accepted into this multipart file");
+        }
+    }
+
+    private Map<String, String> getHeaders(MultipartInputStream multipart) throws IOException, MessagingException {
+        Map<String, String> mapHeaders = new HashMap<String, String>();
+        moveToHeaders(multipart);
+        InternetHeaders headers = new InternetHeaders(multipart);
+
+        Enumeration<Header> allHeaders = headers.getAllHeaders();
+        if (allHeaders != null) {
+            while (allHeaders.hasMoreElements()) {
+                Header header = allHeaders.nextElement();
+                mapHeaders.put(header.getName().toLowerCase(), header.getValue());
+            }
+        }
+
+        return mapHeaders;
+    }
+
+    private boolean moveToHeaders(InputStream stream) throws IOException {
+        boolean dash = false;
+        boolean cr = false;
+        int byteReaded;
+
+        while ((byteReaded = stream.read()) != -1) {
+            switch (byteReaded) {
+                case '\r':
+                    cr = true;
+                    dash = false;
+                    break;
+                case '\n':
+                    if (cr == true)
+                        return true;
+                    dash = false;
+                    break;
+                case '-':
+                    if (dash == true) { // two dashes
+                        stream.close();
+                        return false;
+                    }
+                    dash = true;
+                    cr = false;
+                    break;
+                default:
+                    dash = false;
+                    cr = false;
+            }
+        }
+        return false;
+    }
+
+    private InputStream getDataInputStream(InputStream stream) throws IOException {
+        Base64 base64 = new Base64();
+        ByteArrayOutputStream bo = new ByteArrayOutputStream();
+
+        byte[] buffer = new byte[1024];
+        while (stream.read(buffer) != -1) {
+            bo.write(buffer);
+        }
+        return new ByteArrayInputStream(base64.decode(bo.toByteArray()));
+    }
+
+    private <T extends Element> Document<T> getEntry(InputStream stream, RequestContext request) throws ParseException,
+        IOException {
+        Parser parser = AbstractAtompubProvider.getAbdera(request).getParser();
+        if (parser == null)
+            throw new IllegalArgumentException("No Parser implementation was provided");
+        Document<?> document =
+            parser.parse(stream, request.getResolvedUri().toString(), parser.getDefaultParserOptions());
+        return (Document<T>)document;
+    }
+
+    private boolean isContentTypeAccepted(String contentType, RequestContext request) {
+        if (getAlternateAccepts(request) == null) {
+            return false;
+        }
+        for (Map.Entry<String, String> accept : getAlternateAccepts(request).entrySet()) {
+            if (accept.getKey().equalsIgnoreCase(contentType) && accept.getValue() != null
+                && accept.getValue().equalsIgnoreCase(Constants.LN_ALTERNATE_MULTIPART_RELATED)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected class MultipartRelatedPost {
+        private final Document<Entry> entry;
+        private final InputStream data;
+        private final Map<String, String> entryHeaders;
+        private final Map<String, String> dataHeaders;
+
+        public MultipartRelatedPost(Document<Entry> entry,
+                                    InputStream data,
+                                    Map<String, String> entryHeaders,
+                                    Map<String, String> dataHeaders) {
+            this.entry = entry;
+            this.data = data;
+            this.entryHeaders = entryHeaders;
+            this.dataHeaders = dataHeaders;
+        }
+
+        public Document<Entry> getEntry() {
+            return entry;
+        }
+
+        public InputStream getData() {
+            return data;
+        }
+
+        public Map<String, String> getEntryHeaders() {
+            return entryHeaders;
+        }
+
+        public Map<String, String> getDataHeaders() {
+            return dataHeaders;
+        }
+
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/MultipartRelatedCollectionInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/MultipartRelatedCollectionInfo.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/MultipartRelatedCollectionInfo.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/MultipartRelatedCollectionInfo.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.multipart;
+
+import java.util.Map;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
+
+public interface MultipartRelatedCollectionInfo extends AtompubCollectionInfo {
+
+    /**
+     * Returns a map of MIME media types for the app:collection element's app:accept elements. These tell a client which
+     * media types the collection will accept on a POST. The key element is the default media type and the value element
+     * is the alternate type or null if it doesn't accept alternates.
+     */
+    public Map<String, String> getAlternateAccepts(RequestContext request);
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/MultipartRelatedCollectionInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/CategoriesRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/CategoriesRequestProcessor.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/CategoriesRequestProcessor.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/CategoriesRequestProcessor.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.processors;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.CollectionAdapter;
+import org.apache.abdera2.common.protocol.ProviderHelper;
+import org.apache.abdera2.common.protocol.RequestProcessor;
+import org.apache.abdera2.common.protocol.WorkspaceManager;
+import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for categories
+ * documents.
+ */
+public class CategoriesRequestProcessor implements RequestProcessor {
+
+    @SuppressWarnings("unchecked")
+    public <S extends ResponseContext>S process(RequestContext context,
+                                   WorkspaceManager workspaceManager,
+                                   CollectionAdapter collectionAdapter) {
+        if (collectionAdapter == null || !(collectionAdapter instanceof AtompubCollectionAdapter)) {
+            return (S)ProviderHelper.notfound(context);
+        } else {
+            return this.processCategories(context, collectionAdapter);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <S extends ResponseContext>S processCategories(RequestContext context, CollectionAdapter adapter) {
+          return (S)(context.getMethod().equalsIgnoreCase("GET") ? 
+            ((AtompubCollectionAdapter)adapter).getCategories(context) : null);
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/CategoriesRequestProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.processors;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.CollectionInfo;
+import org.apache.abdera2.common.protocol.WorkspaceInfo;
+import org.apache.abdera2.common.protocol.WorkspaceManager;
+import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
+import org.apache.abdera2.protocol.server.model.AtompubCategoryInfo;
+import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
+import org.apache.abdera2.protocol.server.multipart.MultipartRelatedCollectionInfo;
+import org.apache.abdera2.writer.StreamWriter;
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for service
+ * documents. It writes multipart/related accept attributes when is enabled.
+ */
+public class MultipartRelatedServiceRequestProcessor 
+  extends ServiceRequestProcessor {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected <S extends ResponseContext>S getServiceDocument(
+      final RequestContext request, 
+      final WorkspaceManager workspaceManager) {
+        return (S)new StreamWriterResponseContext(
+            AbstractAtompubProvider.getAbdera(request)) {
+
+            @Override
+            protected void writeTo(StreamWriter sw) throws IOException {
+                sw.startDocument().startService();
+                for (WorkspaceInfo wi : workspaceManager.getWorkspaces(request)) {
+                    sw.startWorkspace().writeTitle(wi.getTitle(request));
+                    Collection<CollectionInfo> collections = wi.getCollections(request);
+
+                    if (collections != null) {
+                        for (CollectionInfo c : collections) {
+                            AtompubCollectionInfo ci = (AtompubCollectionInfo) c;
+                            sw.startCollection(ci.getHref(request)).writeTitle(ci.getTitle(request));
+                            if (ci instanceof MultipartRelatedCollectionInfo) {
+                                MultipartRelatedCollectionInfo multipartCi = (MultipartRelatedCollectionInfo)ci;
+                                for (Map.Entry<String, String> accept : multipartCi.getAlternateAccepts(request)
+                                    .entrySet()) {
+                                    sw.startElement(Constants.ACCEPT);
+                                    if (accept.getValue() != null && accept.getValue().length() > 0) {
+                                        sw.writeAttribute(Constants.LN_ALTERNATE, accept.getValue());
+                                    }
+                                    sw.writeElementText(accept.getKey()).endElement();
+                                }
+                            } else {
+                                sw.writeAccepts(ci.getAccepts(request));
+                            }
+                            AtompubCategoriesInfo[] catinfos = ci.getCategoriesInfo(request);
+                            if (catinfos != null) {
+                                for (AtompubCategoriesInfo catinfo : catinfos) {
+                                    String cathref = catinfo.getHref(request);
+                                    if (cathref != null) {
+                                        sw.startCategories().writeAttribute("href",
+                                                                            request.getTargetBasePath() + cathref)
+                                            .endCategories();
+                                    } else {
+                                        sw.startCategories(catinfo.isFixed(request), catinfo.getScheme(request));
+                                        for (AtompubCategoryInfo cat : catinfo) {
+                                            sw.writeCategory(cat.getTerm(request), cat.getScheme(request), cat
+                                                .getLabel(request));
+                                        }
+                                        sw.endCategories();
+                                    }
+                                }
+                            }
+                            sw.endCollection();
+                        }
+                    }
+                    sw.endWorkspace();
+                }
+                sw.endService().endDocument();
+            }
+        }.setStatus(200).setContentType(Constants.APP_MEDIA_TYPE);
+    }
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.processors;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.CollectionAdapter;
+import org.apache.abdera2.common.protocol.CollectionInfo;
+import org.apache.abdera2.common.protocol.RequestProcessor;
+import org.apache.abdera2.common.protocol.WorkspaceInfo;
+import org.apache.abdera2.common.protocol.WorkspaceManager;
+import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
+import org.apache.abdera2.protocol.server.model.AtompubCategoryInfo;
+import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
+import org.apache.abdera2.writer.StreamWriter;
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for service
+ * documents.
+ */
+public class ServiceRequestProcessor 
+  implements RequestProcessor {
+
+    public <S extends ResponseContext> S process(
+        RequestContext request, WorkspaceManager workspaceManager,
+        CollectionAdapter collectionAdapter) {
+      return this.processService(request, workspaceManager);
+    }
+  
+    private <S extends ResponseContext>S processService(
+        RequestContext context, 
+        WorkspaceManager workspaceManager) {
+        String method = context.getMethod();
+        if (method.equalsIgnoreCase("GET")) {
+            return this.getServiceDocument(context, workspaceManager);
+        } else {
+            return null;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <S extends ResponseContext>S getServiceDocument(
+        final RequestContext request, 
+        final WorkspaceManager workspaceManager) {
+ 
+        return (S)new StreamWriterResponseContext(
+            AbstractAtompubProvider.getAbdera(request)) {
+
+          // JIRA: https://issues.apache.org/jira/browse/ABDERA-255
+          @Override
+          public EntityTag getEntityTag() {
+            EntityTag etag = workspaceManager.getEntityTag();
+            return etag != null ? etag : super.getEntityTag();
+          }
+
+          // JIRA: https://issues.apache.org/jira/browse/ABDERA-255
+          @Override
+          public Date getLastModified() {
+            Date lm = workspaceManager.getLastModified();
+            return lm != null ? lm : super.getLastModified();
+          }
+
+            protected void writeTo(StreamWriter sw) throws IOException {
+                sw.startDocument().startService();
+                for (WorkspaceInfo wi : workspaceManager.getWorkspaces(request)) {
+                    sw.startWorkspace().writeTitle(wi.getTitle(request));
+                    Collection<CollectionInfo> collections = wi.getCollections(request);
+                    if (collections != null) {
+                        for (CollectionInfo c : collections) {
+                            AtompubCollectionInfo ci = (AtompubCollectionInfo) c;
+                            sw.startCollection(ci.getHref(request)).writeTitle(ci.getTitle(request)).writeAccepts(ci
+                                .getAccepts(request));
+                            AtompubCategoriesInfo[] catinfos = ci.getCategoriesInfo(request);
+                            if (catinfos != null) {
+                                for (AtompubCategoriesInfo catinfo : catinfos) {
+                                    String cathref = catinfo.getHref(request);
+                                    if (cathref != null) {
+                                        sw.startCategories().writeAttribute("href",
+                                                                            request.getTargetBasePath() + cathref)
+                                            .endCategories();
+                                    } else {
+                                        sw.startCategories(catinfo.isFixed(request), catinfo.getScheme(request));
+                                        for (AtompubCategoryInfo cat : catinfo) {
+                                            sw.writeCategory(cat.getTerm(request), cat.getScheme(request), cat
+                                                .getLabel(request));
+                                        }
+                                        sw.endCategories();
+                                    }
+                                }
+                            }
+                            sw.endCollection();
+                        }
+                    }
+                    sw.endWorkspace();
+                }
+                sw.endService().endDocument();
+            }
+        }.setStatus(200).setContentType(Constants.APP_MEDIA_TYPE);
+    }
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.basic;
+
+import java.util.Date;
+import java.util.logging.Logger;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.protocol.server.provider.managed.FeedConfiguration;
+import org.apache.abdera2.protocol.server.provider.managed.ManagedCollectionAdapter;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContext;
+import org.apache.abdera2.common.protocol.ProviderHelper;
+import org.apache.abdera2.common.protocol.Target;
+
+/**
+ * The BasicAdapter provides a simplistic interface for working with Atompub collections with a restricted set of
+ * options/features. The idea of the basic adapter is to make it easy to provide a minimally capable Atompub server
+ */
+@SuppressWarnings("unchecked")
+public abstract class BasicAdapter extends ManagedCollectionAdapter {
+
+    public static Logger logger = Logger.getLogger(BasicAdapter.class.getName());
+
+    protected BasicAdapter(Abdera abdera, FeedConfiguration config) {
+        super(abdera,config);
+    }
+
+    public String getProperty(String key) throws Exception {
+        Object val = config.getProperty(key);
+        if (val == null) {
+            logger.warning("Cannot find property " + key + "in Adapter properties file for feed " + config.getFeedId());
+            throw new RuntimeException();
+        }
+        if (val instanceof String)
+            return (String)val;
+        throw new RuntimeException();
+    }
+
+    protected Feed createFeed() throws Exception {
+        Feed feed = abdera.newFeed();
+        feed.setId(config.getFeedUri());
+        feed.setTitle(config.getFeedTitle());
+        feed.setUpdated(new Date());
+        feed.addAuthor(config.getFeedAuthor());
+        return feed;
+    }
+
+    protected void addEditLinkToEntry(Entry entry) throws Exception {
+        if (AbstractAtompubProvider.getEditUriFromEntry(entry) == null) {
+            entry.addLink(entry.getId().toString(), "edit");
+        }
+    }
+
+    protected void setEntryIdIfNull(Entry entry) throws Exception {
+        // if there is no id in Entry, assign one.
+        if (entry.getId() != null) {
+            return;
+        }
+        String uuidUri = abdera.getFactory().newUuidUri();
+        String[] segments = uuidUri.split(":");
+        String entryId = segments[segments.length - 1];
+        entry.setId(createEntryIdUri(entryId));
+    }
+
+    protected String createEntryIdUri(String entryId) throws Exception {
+        return config.getFeedUri() + "/" + entryId;
+    }
+
+    private <S extends ResponseContext>S createOrUpdateEntry(RequestContext context, boolean createFlag) {
+        try {
+            AtompubRequestContext request = (AtompubRequestContext) context;
+            MimeType mimeType = request.getContentType();
+            String contentType = mimeType == null ? null : mimeType.toString();
+            if (contentType != null && !MimeTypeHelper.isAtom(contentType) && !MimeTypeHelper.isXml(contentType))
+                return (S)ProviderHelper.notsupported(request);
+            Abdera abdera = request.getAbdera();
+            Parser parser = abdera.getParser();
+            Entry inputEntry = (Entry)request.getDocument(parser).getRoot();
+            Target target = request.getTarget();
+            String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY) : null;
+            Entry newEntry = createFlag ? createEntry(inputEntry) : updateEntry(entryId, inputEntry);
+            if (newEntry != null) {
+                Document<Entry> newEntryDoc = newEntry.getDocument();
+                String loc = newEntry.getEditLinkResolvedHref().toString();
+                return (S)AbstractAtompubProvider.returnBase(newEntryDoc, createFlag ? 201 : 200, null).setLocation(loc);
+            } else {
+                return (S)ProviderHelper.notfound(request);
+            }
+        } catch (Exception e) {
+            return (S)ProviderHelper.servererror(context, e.getMessage(), e);
+        }
+    }
+
+    public <S extends ResponseContext>S postItem(RequestContext request) {
+        return createOrUpdateEntry(request, true);
+    }
+
+    public <S extends ResponseContext>S deleteItem(RequestContext request) {
+        Target target = request.getTarget();
+        String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+        try {
+            return (S)(deleteEntry(entryId) ? ProviderHelper.nocontent() : ProviderHelper.notfound(request));
+        } catch (Exception e) {
+            return (S)ProviderHelper.servererror(request, e.getMessage(), e);
+        }
+    }
+
+    public <S extends ResponseContext>S putItem(RequestContext request) {
+        return createOrUpdateEntry(request, false);
+    }
+
+    public <S extends ResponseContext>S getItem(RequestContext request) {
+        Target target = request.getTarget();
+        String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+        try {
+            Entry entry = getEntry(entryId);
+            return (S)(entry != null ? AbstractAtompubProvider.returnBase(entry.getDocument(), 200, null) : ProviderHelper
+                .notfound(request));
+        } catch (Exception e) {
+            return (S)ProviderHelper.servererror(request, e.getMessage(), e);
+        }
+    }
+
+    public <S extends ResponseContext>S getItemList(RequestContext request) {
+        try {
+            Feed feed = getFeed();
+            return feed != null ? (S)AbstractAtompubProvider.returnBase(feed.getDocument(), 200, null) : 
+              (S)ProviderHelper.notfound(request);
+        } catch (Exception e) {
+            return (S)ProviderHelper.servererror(request, e.getMessage(), e);
+        }
+    }
+
+    public <S extends ResponseContext>S extensionRequest(RequestContext request) {
+        return (S)ProviderHelper.notallowed(request, ProviderHelper.getDefaultMethods(request));
+    }
+
+    public <S extends ResponseContext>S getCategories(RequestContext request) {
+        return (S)ProviderHelper.notfound(request);
+    }
+
+    public abstract Feed getFeed() throws Exception;
+
+    public abstract Entry getEntry(Object entryId) throws Exception;
+
+    public abstract Entry createEntry(Entry entry) throws Exception;
+
+    public abstract Entry updateEntry(Object entryId, Entry entry) throws Exception;
+
+    public abstract boolean deleteEntry(Object entryId) throws Exception;
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.basic;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.CollectionAdapter;
+import org.apache.abdera2.common.protocol.RouteManager;
+import org.apache.abdera2.common.protocol.TargetType;
+import org.apache.abdera2.protocol.server.provider.managed.BasicServerConfiguration;
+import org.apache.abdera2.protocol.server.provider.managed.ManagedProvider;
+import org.apache.abdera2.protocol.server.provider.managed.ServerConfiguration;
+
+/**
+ * Provider implementation intended to be used with BasicAdapter implementations
+ */
+public class BasicProvider extends ManagedProvider {
+
+    public static final String PARAM_FEED = "feed";
+    public static final String PARAM_ENTRY = "entry";
+
+    public BasicProvider() {
+        super();
+        init();
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    private void init() {
+        RouteManager routeManager =
+            new RouteManager().addRoute(
+                "service", 
+                "/", 
+                TargetType.TYPE_SERVICE)
+                  .addRoute(
+                      "feed",
+                      "/:feed",
+                      TargetType.TYPE_COLLECTION)
+                  .addRoute(
+                      "entry", 
+                      "/:feed/:entry", 
+                      TargetType.TYPE_ENTRY);
+        setTargetBuilder(
+            routeManager);
+        setTargetResolver(
+            routeManager);
+    }
+
+    public CollectionAdapter getCollectionAdapter(RequestContext request) {
+        try {
+            return getCollectionAdapterManager(request)
+              .getAdapter(request.getTarget().getParameter(PARAM_FEED));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    protected ServerConfiguration getServerConfiguration(RequestContext request) {
+        return new BasicServerConfiguration(request);
+    }
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/AbstractServerConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/AbstractServerConfiguration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/AbstractServerConfiguration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/AbstractServerConfiguration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+
+public abstract class AbstractServerConfiguration extends ServerConfiguration {
+
+    private final String host;
+    private final int port;
+    private final boolean secure;
+
+    protected AbstractServerConfiguration(RequestContext request) {
+        Object ohost = request.getProperty(RequestContext.Property.SERVERNAME);
+        Object oport = request.getProperty(RequestContext.Property.SERVERPORT);
+        Object osec = request.getProperty(RequestContext.Property.SECURE);
+        host = ohost != null ? (String)ohost : "localhost";
+        port = oport != null ? ((Integer)oport).intValue() : 9002;
+        secure = osec != null ? ((Boolean)osec).booleanValue() : false;
+    }
+
+    @Override
+    public String getAdapterConfigLocation() {
+        return "abdera/adapter/config/";
+    }
+
+    @Override
+    public String getFeedConfigLocation() {
+        return "abdera/adapter/";
+    }
+
+    @Override
+    public String getFeedConfigSuffix() {
+        return ".properties";
+    }
+
+    @Override
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    public String getServerUri() {
+        StringBuilder buf = new StringBuilder();
+        buf.append(secure ? "https://" : "http://");
+        buf.append(host);
+        if (port != 80) {
+            buf.append(":");
+            buf.append(port);
+        }
+        return buf.toString();
+    }
+
+    @Override
+    public FeedConfiguration loadFeedConfiguration(String feedId) throws IOException {
+        String fileName = getFeedConfigLocation() + feedId + getFeedConfigSuffix();
+        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
+        if (in == null)
+            throw new FileNotFoundException();
+        Properties props = new Properties();
+        props.load(in);
+        in.close();
+        return FeedConfiguration.getFeedConfiguration(feedId, props, this);
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/AbstractServerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/BasicServerConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/BasicServerConfiguration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/BasicServerConfiguration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/BasicServerConfiguration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.anno.Version;
+import org.apache.abdera2.common.protocol.RequestContext;
+
+public class BasicServerConfiguration extends AbstractServerConfiguration {
+
+    public BasicServerConfiguration(RequestContext request) {
+        super(request);
+    }
+
+    @Override
+    public String getFeedNamespace() {
+      Version version = AnnoUtil.getVersion(Abdera.class);
+        return version.uri() + "/" + version.value() + "/";
+    }
+
+    @Override
+    public String getFeedNamespacePrefix() {
+        return "a";
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/BasicServerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+public class CollectionAdapterConfiguration extends Configuration {
+
+    private final String fileLocation;
+    private final ServerConfiguration serverConfiguration;
+
+    public CollectionAdapterConfiguration(ServerConfiguration serverConfiguration, String fileLocation) {
+        this.fileLocation = fileLocation;
+        this.serverConfiguration = serverConfiguration;
+    }
+
+    public InputStream getConfigAsFileInputStream() throws IOException {
+        String filePath = serverConfiguration.getAdapterConfigLocation() + fileLocation;
+        return Configuration.loadFileAsInputStream(filePath);
+    }
+
+    public Reader getAdapterConfigAsReader() throws IOException {
+        return new InputStreamReader(getConfigAsFileInputStream());
+    }
+
+    public ServerConfiguration getServerConfiguration() {
+        return serverConfiguration;
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
+
+public class CollectionAdapterManager {
+
+    public static Logger logger = Logger.getLogger(CollectionAdapterManager.class.getName());
+
+    // maps a feed id to an adapter instance
+    protected static Map<String, AtompubCollectionAdapter> adapterInstanceMap = new HashMap<String, AtompubCollectionAdapter>();
+
+    protected final Abdera abdera;
+    protected final ServerConfiguration config;
+
+    public CollectionAdapterManager(Abdera abdera, ServerConfiguration config) {
+        this.abdera = abdera;
+        this.config = config;
+    }
+
+    public AtompubCollectionAdapter getAdapter(String feedId) throws Exception {
+        FeedConfiguration feedConfiguration = config.loadFeedConfiguration(feedId);
+        return createAdapterInstance(feedConfiguration, abdera);
+    }
+
+    public Map<String, FeedConfiguration> listAdapters() throws Exception {
+        Map<String, FeedConfiguration> results = new HashMap<String, FeedConfiguration>();
+        Enumeration<URL> e =
+            Thread.currentThread().getContextClassLoader().getResources(config.getFeedConfigLocation());
+        while (e.hasMoreElements()) {
+            URL url = e.nextElement();
+            File file = new File(url.toURI());
+            if (!file.exists()) {
+                throw new RuntimeException("Could not convert properties path to a File! \"" + file.getAbsolutePath()
+                    + "\" does not exist.");
+            }
+            File[] files = file.listFiles(new FileFilter() {
+                public boolean accept(File file) {
+                    return !file.isDirectory();
+                }
+            });
+            if (files != null) {
+                for (File _file : files) {
+                    String name = _file.getName();
+                    int i = name.indexOf(config.getFeedConfigSuffix());
+                    String id = i > -1 ? name.substring(0, i) : null;
+                    if (id != null) {
+                        FeedConfiguration feedConfiguration = loadFeedInfo(id);
+                        if (null != feedConfiguration)
+                            results.put(id, feedConfiguration);
+                    }
+                }
+            }
+        }
+        return results;
+    }
+
+    protected FeedConfiguration loadFeedInfo(String feedId) throws Exception {
+        return config.loadFeedConfiguration(feedId);
+    }
+
+    protected static synchronized AtompubCollectionAdapter createAdapterInstance(FeedConfiguration config, Abdera abdera)
+        throws Exception {
+        AtompubCollectionAdapter basicAdapter = adapterInstanceMap.get(config.getFeedId());
+        if (basicAdapter != null) {
+            return basicAdapter;
+        }
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        Class<?> adapterClass = cl.loadClass(config.getAdapterClassName());
+        Constructor<?>[] ctors = adapterClass.getConstructors();
+        for (Constructor<?> element : ctors) {
+            logger.finest("Public constructor found: " + element.toString());
+        }
+        Constructor<?> c = adapterClass.getConstructor(new Class[] {Abdera.class, FeedConfiguration.class});
+        c.setAccessible(true);
+        AtompubCollectionAdapter adapterInstance = (AtompubCollectionAdapter)c.newInstance(abdera, config);
+
+        // put this adapter instance in adapterInstanceMap
+        adapterInstanceMap.put(config.getFeedId(), adapterInstance);
+        return adapterInstance;
+    }
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/Configuration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/Configuration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/Configuration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/Configuration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public abstract class Configuration {
+
+    static Properties loadFileAsProperties(String fileLocation) throws IOException {
+        Properties props = new Properties();
+        props.load(new FileInputStream(fileLocation));
+        return props;
+    }
+
+    static InputStream loadFileAsInputStream(String fileLocation) throws IOException {
+        return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileLocation);
+    }
+
+    static String getProperty(Properties prop, String key) {
+        String val = prop.getProperty(key);
+        if (val == null)
+            throw new RuntimeException();
+        return val;
+    }
+
+    protected Configuration() {
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/Configuration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
+import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
+
+public class FeedConfiguration extends Configuration implements AtompubCollectionInfo {
+    public static final String PROP_NAME_ADAPTER_CLASS = "adapterClassName";
+    public static final String PROP_SUB_URI_NAME = "subUri";
+    public static final String PROP_AUTHOR_NAME = "author";
+    public static final String PROP_TITLE_NAME = "title";
+    public static final String PROP_ACCEPTS = "accepts";
+    public static final String PROP_ENTRY_TITLE_NAME = "entryTitle";
+    public static final String PROP_FEED_CONFIG_LOCATION_NAME = "configFile";
+
+    public static final String ENTRY_ELEM_NAME_ID = "id";
+    public static final String ENTRY_ELEM_NAME_TITLE = "title";
+    public static final String ENTRY_ELEM_NAME_CONTENT = "content";
+    public static final String ENTRY_ELEM_NAME_AUTHOR = "author";
+    public static final String ENTRY_ELEM_NAME_UPDATED = "updated";
+    public static final String ENTRY_ELEM_NAME_LINK = "link";
+
+    private final String feedId;
+    private final String subUri;
+    private final String adapterClassName;
+    private final String feedConfigLocation;
+    private final ServerConfiguration serverConfiguration;
+    private String feedTitle = "unknown";
+    private String feedAuthor = "unknown";
+    private Map<Object, Object> optionalProperties;
+    private final CollectionAdapterConfiguration adapterConfiguration;
+
+    public FeedConfiguration(String feedId,
+                             String subUri,
+                             String adapterClassName,
+                             String feedConfigLocation,
+                             ServerConfiguration serverConfiguration) {
+        this.feedId = feedId;
+        this.subUri = subUri;
+        this.adapterClassName = adapterClassName;
+        this.feedConfigLocation = feedConfigLocation;
+        this.adapterConfiguration = new CollectionAdapterConfiguration(serverConfiguration, feedConfigLocation);
+        this.serverConfiguration = serverConfiguration;
+    }
+
+    public static FeedConfiguration getFeedConfiguration(String feedId,
+                                                         Properties properties,
+                                                         ServerConfiguration serverConfiguration) {
+        FeedConfiguration feedConfiguration =
+            new FeedConfiguration(feedId, Configuration.getProperty(properties, PROP_SUB_URI_NAME), Configuration
+                .getProperty(properties, PROP_NAME_ADAPTER_CLASS), Configuration
+                .getProperty(properties, PROP_FEED_CONFIG_LOCATION_NAME), serverConfiguration);
+        if (properties.containsKey(PROP_AUTHOR_NAME)) {
+            feedConfiguration.setFeedAuthor(Configuration.getProperty(properties, PROP_AUTHOR_NAME));
+        }
+
+        if (properties.containsKey(PROP_TITLE_NAME)) {
+            feedConfiguration.setFeedTitle(Configuration.getProperty(properties, PROP_TITLE_NAME));
+        }
+        feedConfiguration.optionalProperties = properties;
+        return feedConfiguration;
+    }
+
+    public String getAdapterClassName() {
+        return adapterClassName;
+    }
+
+    public String getFeedAuthor() {
+        return feedAuthor;
+    }
+
+    public String getFeedConfigLocation() {
+        return feedConfigLocation;
+    }
+
+    public String getFeedId() {
+        return feedId;
+    }
+
+    public String getFeedTitle() {
+        return feedTitle;
+    }
+
+    public String getSubUri() {
+        return subUri;
+    }
+
+    public void setFeedAuthor(String feedAuthor) {
+        this.feedAuthor = feedAuthor;
+    }
+
+    public void setFeedTitle(String feedTitle) {
+        this.feedTitle = feedTitle;
+    }
+
+    public String getFeedUri() {
+        return serverConfiguration.getServerUri() + "/" + getSubUri();
+    }
+
+    public boolean hasProperty(String key) {
+        return optionalProperties.containsKey(key);
+    }
+
+    public Object getProperty(String key) {
+        return optionalProperties.get(key);
+    }
+
+    public CollectionAdapterConfiguration getAdapterConfiguration() {
+        return adapterConfiguration;
+    }
+
+    public Collection asCollectionElement(RequestContext request) {
+        Collection collection = AbstractAtompubProvider.getAbdera(request).getFactory().newCollection();
+        collection.setHref(getHref(request));
+        collection.setTitle(getTitle(request));
+        collection.setAccept(getAccepts(request));
+        for (AtompubCategoriesInfo catsinfo : getCategoriesInfo(request)) {
+            collection.addCategories(catsinfo.asCategoriesElement(request));
+        }
+        return collection;
+    }
+
+    public String[] getAccepts(RequestContext request) {
+        Object accepts = optionalProperties.get(PROP_ACCEPTS);
+        if (accepts == null || !(accepts instanceof String))
+            return new String[] {"application/atom+xml;type=entry"};
+        return ((String)accepts).split("\\s*,\\s*");
+    }
+
+    public AtompubCategoriesInfo[] getCategoriesInfo(RequestContext request) {
+        return new AtompubCategoriesInfo[0];
+    }
+
+    public String getHref(RequestContext request) {
+        return getFeedUri();
+    }
+
+    public String getTitle(RequestContext request) {
+        return getFeedTitle();
+    }
+
+    public ServerConfiguration getServerConfiguration() {
+        return adapterConfiguration.getServerConfiguration();
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContextException;
+import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
+
+public abstract class ManagedCollectionAdapter 
+  extends AbstractAtompubCollectionAdapter 
+  implements AtompubCollectionAdapter {
+
+    protected final FeedConfiguration config;
+    protected final Abdera abdera;
+
+    protected ManagedCollectionAdapter(Abdera abdera, FeedConfiguration config) {
+        this.config = config;
+        this.abdera = abdera;
+    }
+
+    public Abdera getAbdera() {
+        return this.abdera;
+    }
+
+    public FeedConfiguration getConfiguration() {
+        return this.config;
+    }
+
+    public String getAuthor(RequestContext request) throws ResponseContextException {
+        return config.getFeedAuthor();
+    }
+
+    public String getId(RequestContext request) {
+        return config.getFeedId();
+    }
+
+    public String getTitle(RequestContext request) {
+        return config.getFeedTitle();
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedProvider.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedProvider.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedProvider.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubWorkspaceProvider;
+
+/**
+ * The ManagedProvider uses *.properties files discovered in the webapp classpath to configure CollectionAdapter
+ * instances. The ManagedWorkspace implementation will automatically discover the *.properties files and will use those
+ * to create the appropriate CollectionAdapter objects. Properties files must be located in the classpath at
+ * /abdera/adapter/*.properties. Refer to the Abdera Server Implementation Guide for additional details
+ */
+public abstract class ManagedProvider 
+  extends AbstractAtompubWorkspaceProvider {
+  
+    protected abstract ServerConfiguration getServerConfiguration(RequestContext request);
+
+    protected ManagedProvider() {
+        addWorkspace(new ManagedWorkspace(this));
+    }
+
+    public CollectionAdapterManager getCollectionAdapterManager(RequestContext request) {
+      return new CollectionAdapterManager(abdera, getServerConfiguration(request));
+  }
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedWorkspace.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedWorkspace.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedWorkspace.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedWorkspace.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.CollectionInfo;
+import org.apache.abdera2.model.Workspace;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
+import org.apache.abdera2.protocol.server.model.AtompubWorkspaceInfo;
+
+public class ManagedWorkspace implements AtompubWorkspaceInfo {
+
+    private final ManagedProvider provider;
+
+    private String title = "Abdera";
+
+    public ManagedWorkspace(ManagedProvider provider) {
+        this.provider = provider;
+    }
+
+    public Collection<CollectionInfo> getCollections(RequestContext request) {
+        CollectionAdapterManager cam = provider.getCollectionAdapterManager(request);
+        List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
+        try {
+            Map<String, FeedConfiguration> map = cam.listAdapters();
+            for (FeedConfiguration config : map.values())
+                collections.add(config);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return collections;
+    }
+    
+    public String getTitle(RequestContext request) {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public Workspace asWorkspaceElement(RequestContext request) {
+        Workspace workspace = AbstractAtompubProvider.getAbdera(request).getFactory().newWorkspace();
+        workspace.setTitle(getTitle(null));
+        for (CollectionInfo c : getCollections(request)) {
+            AtompubCollectionInfo collection = (AtompubCollectionInfo) c;
+            workspace.addCollection(collection.asCollectionElement(request));
+        }
+        return workspace;
+    }
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedWorkspace.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ServerConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ServerConfiguration.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ServerConfiguration.java (added)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ServerConfiguration.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.server.provider.managed;
+
+public abstract class ServerConfiguration extends Configuration {
+
+    public abstract int getPort();
+
+    public abstract String getServerUri();
+
+    public abstract String getFeedNamespace();
+
+    public abstract String getFeedNamespacePrefix();
+
+    public abstract String getFeedConfigLocation();
+
+    public abstract String getFeedConfigSuffix();
+
+    public abstract String getAdapterConfigLocation();
+
+    public abstract FeedConfiguration loadFeedConfiguration(String feedId) throws Exception;
+
+}

Propchange: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ServerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/pom.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/pom.xml (added)
+++ abdera/abdera2/test/pom.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,122 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.abdera2</groupId>
+    <artifactId>abdera2</artifactId>
+    <version>2.0-SNAPSHOT</version>  
+  </parent>  
+
+  <artifactId>abdera2-test</artifactId>
+  <packaging>bundle</packaging>
+  <name>Abdera2 Tests</name>
+  <version>2.0-SNAPSHOT</version>  
+  <description>Abdera Tests</description>
+
+  <properties>
+    <topDir>${basedir}/..</topDir>
+    <!-- 
+    <abdera.osgi.default.exports>
+		org.apache.abdera.protocol.client.*
+	</abdera.osgi.default.exports>
+    <abdera.osgi.default.imports>
+      org.apache.commons.codec*;version="[1.5,2)",
+      *
+    </abdera.osgi.default.imports>
+  -->
+  </properties>
+
+  <build>
+  <testSourceDirectory>src/main/java</testSourceDirectory>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-core</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-common</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-server</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-client</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-security</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-activities</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-ext</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.easymock</groupId>
+        <artifactId>easymock</artifactId>
+    </dependency> 
+    
+    <dependency>
+      <groupId>xalan</groupId>
+      <artifactId>xalan</artifactId>
+      <version>2.7.1</version>
+      <scope>test</scope>
+    </dependency>
+       
+  </dependencies>
+</project>

Propchange: abdera/abdera2/test/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/AbderaTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/AbderaTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/AbderaTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/AbderaTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+package org.apache.abdera2.test;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.writer.StreamWriter;
+import org.junit.Test;
+
+public class AbderaTest {
+
+  @Test
+  public void abderaTest() {
+    Abdera abdera = Abdera.getInstance();
+    assertNotNull(abdera);
+    assertNotNull(abdera.getConfiguration());
+    assertNotNull(abdera.getFactory());
+    assertNotNull(abdera.getParser());
+    assertNotNull(abdera.getParserFactory());
+    assertNotNull(abdera.getWriter());
+    assertNotNull(abdera.getWriterFactory());
+    assertNotNull(abdera.getXPath());
+    assertNotNull(abdera.newCategories());
+    assertNotNull(abdera.newEntry());
+    assertNotNull(abdera.newError());
+    assertNotNull(abdera.newFeed());
+    assertNotNull(abdera.newService());
+    assertNotNull(abdera.create(StreamWriter.class));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/AbderaTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/JettyUtil.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/JettyUtil.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/JettyUtil.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/JettyUtil.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class JettyUtil {
+
+    private static final String PORT_PROP = "abdera.test.client.port";
+
+    private static int PORT = 9002;
+    private static Server server = null;
+    private static ServletContextHandler handler = null;
+
+    public static int getPort() {
+        if (System.getProperty(PORT_PROP) != null) {
+            PORT = Integer.parseInt(System.getProperty(PORT_PROP));
+        }
+        return PORT;
+    }
+
+    private static void initServer() throws Exception {
+        server = new Server(getPort());      
+        handler = 
+          new ServletContextHandler(ServletContextHandler.SESSIONS);
+        handler.setContextPath("/");
+        server.setHandler(handler);
+    }
+
+    public static ServletContextHandler getSch() {
+      return (ServletContextHandler) server.getHandler();
+    }
+    
+    public static void addServlet(String _class, String path) {
+        try {
+            if (server == null)
+                initServer();
+        } catch (Exception e) {
+        }
+        handler.addServlet(_class, path);
+    }
+    
+    public static void addServlet(ServletHolder holder, String path) {
+      try {
+        if (server == null)
+          initServer();
+      } catch (Exception e) {
+        
+      }
+      handler.addServlet(holder, path);
+    }
+    
+    public static void setContextPath(String path) {
+      handler.setContextPath(path);
+    }
+
+    public static void start() throws Exception {
+        if (server == null)
+            initServer();
+        if (server.isRunning())
+            return;
+        server.start();
+    }
+
+    public static void stop() throws Exception {
+        if (server == null)
+            return;
+        server.stop();
+        server = null;
+    }
+
+    public static boolean isRunning() {
+        return (server != null);
+    }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/JettyUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message