abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1239237 [4/12] - in /abdera/abdera2-server: ./ .settings/ etc/ examples/ examples/src/ examples/src/main/ examples/src/main/java/ examples/src/main/java/org/ examples/src/main/java/org/apache/ examples/src/main/java/org/apache/abdera2/ exa...
Date Wed, 01 Feb 2012 17:55:02 GMT
Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,256 @@
+/*
+ * 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.common.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.activation.MimeType;
+import javax.security.auth.Subject;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.http.Authentication;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.WebLink;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Function;
+
+@SuppressWarnings("unchecked")
+public class BaseRequestContextWrapper
+  implements RequestContext{
+
+    protected final RequestContext request;
+
+    public BaseRequestContextWrapper(RequestContext request) {
+        this.request = request;
+    }
+
+    public <T>T getAttribute(Scope scope, String name) {
+        return request.<T>getAttribute(scope, name);
+    }
+
+    public Iterable<String> getAttributeNames(Scope scope) {
+        return request.getAttributeNames(scope);
+    }
+
+    public IRI getBaseUri() {
+        return request.getBaseUri();
+    }
+
+    public String getContextPath() {
+        return request.getContextPath();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return request.getInputStream();
+    }
+
+    public String getMethod() {
+        return request.getMethod();
+    }
+
+    public String getParameter(String name) {
+        return request.getParameter(name);
+    }
+
+    public Iterable<String> getParameterNames() {
+        return request.getParameterNames();
+    }
+
+    public Iterable<String> getParameters(String name) {
+        return request.getParameters(name);
+    }
+
+    public Locale getPreferredLocale() {
+        return request.getPreferredLocale();
+    }
+
+    public Iterable<Locale> getPreferredLocales() {
+        return request.getPreferredLocales();
+    }
+
+    public Principal getPrincipal() {
+        return request.getPrincipal();
+    }
+
+    public <T>T getProperty(Property property) {
+        return request.<T>getProperty(property);
+    }
+
+    public <P extends Provider>P getProvider() {
+        return request.<P>getProvider();
+    }
+
+    public Reader getReader() throws IOException {
+        return request.getReader();
+    }
+
+    public IRI getResolvedUri() {
+        return request.getResolvedUri();
+    }
+
+    public Subject getSubject() {
+        return request.getSubject();
+    }
+
+    public Target getTarget() {
+        return request.getTarget();
+    }
+
+    public String getTargetPath() {
+        return request.getTargetPath();
+    }
+
+    public IRI getUri() {
+        return request.getUri();
+    }
+
+    public boolean isUserInRole(String role) {
+        return request.isUserInRole(role);
+    }
+
+    public <T extends RequestContext>T setAttribute(Scope scope, String name, Object value) {
+        request.setAttribute(scope, name, value);
+        return (T)this;
+    }
+
+    public <T extends RequestContext>T setAttribute(String name, Object value) {
+        request.setAttribute(name, value);
+        return (T)this;
+    }
+
+    public String getAccept() {
+        return request.getAccept();
+    }
+
+    public String getAcceptCharset() {
+        return request.getAcceptCharset();
+    }
+
+    public String getAcceptEncoding() {
+        return request.getAcceptEncoding();
+    }
+
+    public String getAcceptLanguage() {
+        return request.getAcceptLanguage();
+    }
+
+    public Iterable<Authentication> getAuthentication() {
+        return request.getAuthentication();
+    }
+
+    public Iterable<EntityTag> getIfMatch() {
+        return request.getIfMatch();
+    }
+
+    public DateTime getIfModifiedSince() {
+        return request.getIfModifiedSince();
+    }
+
+    public Iterable<EntityTag> getIfNoneMatch() {
+        return request.getIfNoneMatch();
+    }
+
+    public DateTime getIfUnmodifiedSince() {
+        return request.getIfUnmodifiedSince();
+    }
+
+    public CacheControl getCacheControl() {
+        return request.getCacheControl();
+    }
+
+    public String getContentLanguage() {
+        return request.getContentLanguage();
+    }
+
+    public IRI getContentLocation() {
+        return request.getContentLocation();
+    }
+
+    public MimeType getContentType() {
+        return request.getContentType();
+    }
+
+    public DateTime getDateHeader(String name) {
+        return request.getDateHeader(name);
+    }
+
+    public String getDecodedHeader(String name) {
+        return request.getDecodedHeader(name);
+    }
+
+    public Iterable<String> getDecodedHeaders(String name) {
+        return request.getDecodedHeaders(name);
+    }
+
+    public String getHeader(String name) {
+        return request.getHeader(name);
+    }
+
+    public Iterable<String> getHeaderNames() {
+        return request.getHeaderNames();
+    }
+
+    public Iterable<Object> getHeaders(String name) {
+        return request.getHeaders(name);
+    }
+
+    public String getSlug() {
+        return request.getSlug();
+    }
+
+    public String urlFor(Object key, Object param) {
+        return getProvider().urlFor(this, key, param);
+    }
+
+    public String getTargetBasePath() {
+        return request.getTargetBasePath();
+    }
+
+    public String absoluteUrlFor(Object key, Object param) {
+        return request.getResolvedUri().resolve(urlFor(key, param)).toString();
+    }
+
+    public Iterator<Property> iterator() {
+      return request.iterator();
+    }
+
+    public Iterable<WebLink> getWebLinks() {
+      return request.getWebLinks();
+    }
+
+    public Iterable<Preference> getPrefer() {
+      return request.getPrefer();
+    }
+    
+    public <T> T getHeader(String name, Function<String, T> transform) {
+      return request.getHeader(name,transform);
+    }
+
+    public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+      return request.getHeaders(name,transform);
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,329 @@
+/*
+ * 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.common.protocol;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.text.CharUtils.Profile;
+import org.apache.abdera2.common.http.Authentication;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.ResponseType;
+import org.apache.abdera2.common.http.WebLink;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Function;
+
+@SuppressWarnings("unchecked")
+public class BaseResponseContextWrapper implements ResponseContext {
+
+    protected final ResponseContext response;
+
+    public BaseResponseContextWrapper(ResponseContext response) {
+        this.response = response;
+    }
+
+    public <T extends ResponseContext>T addEncodedHeader(String name, String charset, String value) {
+        response.addEncodedHeader(name, charset, value);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T addEncodedHeaders(String name, String charset, String... vals) {
+        response.addEncodedHeaders(name, charset, vals);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T addHeader(String name, Object value) {
+        response.addHeader(name, value);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T addHeaders(String name, Object... vals) {
+        response.addHeaders(name, vals);
+        return (T)this;
+    }
+
+    public boolean hasEntity() {
+        return response.hasEntity();
+    }
+
+    public <T extends ResponseContext>T removeHeader(String name) {
+        response.removeHeader(name);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setAge(long age) {
+        response.setAge(age);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setAllow(String method) {
+        response.setAllow(method);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setAllow(String... methods) {
+        response.setAllow(methods);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setContentLanguage(String language) {
+        response.setContentLanguage(language);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setContentLength(long length) {
+        response.setContentLength(length);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setContentLocation(String uri) {
+        response.setContentLocation(uri);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setContentType(String type) {
+        response.setContentType(type);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setContentType(String type, String charset) {
+        response.setContentType(type, charset);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setEncodedHeader(String name, String charset, String value) {
+        response.setEncodedHeader(name, charset, value);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setEncodedHeader(String name, String charset, String... vals) {
+        response.setEncodedHeader(name, charset, vals);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setEntityTag(String etag) {
+        response.setEntityTag(etag);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setEntityTag(EntityTag etag) {
+        response.setEntityTag(etag);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setEscapedHeader(String name, Profile profile, String value) {
+        response.setEscapedHeader(name, profile, value);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setExpires(DateTime date) {
+        response.setExpires(date);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setHeader(String name, Object value) {
+        response.setHeader(name, value);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setHeader(String name, Object... vals) {
+        response.setHeader(name, vals);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setLastModified(DateTime date) {
+        response.setLastModified(date);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setLocation(String uri) {
+        response.setLocation(uri);
+        return (T)this;
+    }
+    
+    public <T extends ResponseContext>T setLocation(IRI iri) {
+      response.setLocation(iri);
+      return (T)this;
+    }
+
+    public <T extends ResponseContext>T setSlug(String slug) {
+        response.setSlug(slug);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setStatus(int status) {
+        response.setStatus(status);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setStatusText(String text) {
+        response.setStatusText(text);
+        return (T)this;
+    }
+
+    public void writeTo(OutputStream out) throws IOException {
+        response.writeTo(out);
+    }
+
+    public void writeTo(java.io.Writer javaWriter) throws IOException {
+        response.writeTo(javaWriter);
+    }
+
+    public long getAge() {
+        return response.getAge();
+    }
+
+    public String getAllow() {
+        return response.getAllow();
+    }
+
+    public long getContentLength() {
+        return response.getContentLength();
+    }
+
+    public EntityTag getEntityTag() {
+        return response.getEntityTag();
+    }
+
+    public DateTime getExpires() {
+        return response.getExpires();
+    }
+
+    public DateTime getLastModified() {
+        return response.getLastModified();
+    }
+
+    public IRI getLocation() {
+        return response.getLocation();
+    }
+
+    public int getStatus() {
+        return response.getStatus();
+    }
+
+    public String getStatusText() {
+        return response.getStatusText();
+    }
+
+    public ResponseType getType() {
+        return response.getType();
+    }
+
+    public CacheControl getCacheControl() {
+        return response.getCacheControl();
+    }
+
+    public String getContentLanguage() {
+        return response.getContentLanguage();
+    }
+
+    public IRI getContentLocation() {
+        return response.getContentLocation();
+    }
+
+    public MimeType getContentType() {
+        return response.getContentType();
+    }
+
+    public DateTime getDateHeader(String name) {
+        return response.getDateHeader(name);
+    }
+
+    public String getDecodedHeader(String name) {
+        return response.getDecodedHeader(name);
+    }
+
+    public Iterable<String> getDecodedHeaders(String name) {
+        return response.getDecodedHeaders(name);
+    }
+    
+    public Iterable<Authentication> getAuthentication() {
+      return response.getAuthentication();
+    }
+
+    public String getHeader(String name) {
+        return response.getHeader(name);
+    }
+
+    public Iterable<String> getHeaderNames() {
+        return response.getHeaderNames();
+    }
+
+    public Iterable<Object> getHeaders(String name) {
+        return response.getHeaders(name);
+    }
+
+    public String getSlug() {
+        return response.getSlug();
+    }
+
+    public boolean isBinary() {
+        return response.isBinary();
+    }
+
+    public <T extends ResponseContext>T setBinary(boolean binary) {
+        response.setBinary(true);
+        return (T)this;
+    }
+
+    public <T extends ResponseContext>T setCacheControl(CacheControl cc) {
+      response.setCacheControl(cc);
+      return (T)this;
+    }
+
+    public <T extends ResponseContext>T setCacheControl(String cc) {
+      response.setCacheControl(cc);
+      return (T)this;
+    }
+
+    public Iterable<WebLink> getWebLinks() {
+      return response.getWebLinks();
+    }
+
+    public Iterable<Preference> getPrefer() {
+      return response.getPrefer();
+    }
+
+    public <T extends ResponseContext> T setWebLinks(WebLink link,
+        WebLink... links) {
+      response.setWebLinks(link, links);
+      return (T)this;
+    }
+
+    public <T extends ResponseContext> T setPrefer(Preference pref,
+        Preference... prefs) {
+      response.setPrefer(pref, prefs);
+      return (T)this;
+    }
+
+    public <T> T getHeader(String name, Function<String, T> transform) {
+      return response.getHeader(name,transform);
+    }
+
+    public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+      return response.getHeaders(name, transform);
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,113 @@
+/*
+ * 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.common.protocol;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import org.apache.abdera2.common.misc.MoreFunctions;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+
+public class BasicCollectionInfo 
+  implements CollectionInfo, 
+             Serializable {
+
+    public static Generator make() {
+      return new Generator();
+    }
+  
+    public static class Generator implements Supplier<CollectionInfo> {
+      String title;
+      String href;
+      final ImmutableSet.Builder<String> accepts = 
+        ImmutableSet.builder();
+      Generator title(String title) {
+        this.title = title;
+        return this;
+      }
+      public Generator href(String href) {
+        this.href = href;
+        return this;
+      }
+      public Generator accept(String type) {
+        this.accepts.add(type);
+        return this;
+      }
+      public CollectionInfo get() {
+        return new BasicCollectionInfo(this);
+      }
+    }
+  
+    private static final long serialVersionUID = 8026455829158149510L;
+
+    private final String title;
+    private final String href;
+    private final Set<String> accepts;
+
+    protected BasicCollectionInfo(Generator gen) {
+      this.title = gen.title;
+      this.accepts = gen.accepts.build();
+      this.href = gen.href;
+    }
+
+    public Iterable<String> getAccepts(RequestContext request) {
+        return accepts;
+    }
+
+    public String getHref(RequestContext request) {
+        return href;
+    }
+
+    public String getTitle(RequestContext request) {
+        return title;
+    }
+
+    @Override
+    public int hashCode() {
+      return MoreFunctions.genHashCode(1, accepts,href,title);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (obj == null)
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      BasicCollectionInfo other = (BasicCollectionInfo) obj;
+      if (accepts == null) {
+        if (other.accepts != null)
+          return false;
+      } else if (!accepts.equals(other.accepts))
+        return false;
+      if (href == null) {
+        if (other.href != null)
+          return false;
+      } else if (!href.equals(other.href))
+        return false;
+      if (title == null) {
+        if (other.title != null)
+          return false;
+      } else if (!title.equals(other.title))
+        return false;
+      return true;
+    }
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java Wed Feb  1 17:54:54 2012
@@ -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.common.protocol;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import org.apache.abdera2.common.misc.MoreFunctions;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+
+public class BasicWorkspaceInfo
+  implements WorkspaceInfo, 
+             Serializable {
+
+    private static final long serialVersionUID = -8459688584319762878L;
+    
+    public static class Generator implements Supplier<WorkspaceInfo> {
+      String title;
+      final ImmutableSet.Builder<CollectionInfo> collections = 
+        ImmutableSet.builder();
+      public Generator title(String title) {
+        this.title = title;
+        return this;
+      }
+      public Generator collection(CollectionInfo info) {
+        this.collections.add(info);
+        return this;
+      }
+      public WorkspaceInfo get() {
+        return new BasicWorkspaceInfo(this);
+      }
+      
+    }
+    
+    protected final String title;
+    protected final Set<CollectionInfo> collections;
+
+    protected BasicWorkspaceInfo(Generator generator) {
+      this.title = generator.title;
+      this.collections = generator.collections.build();
+    }
+
+    public BasicWorkspaceInfo(String title) {
+        this.title = title;
+        this.collections = ImmutableSet.of();
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getTitle(RequestContext request) {
+        return title;
+    }
+
+    public Iterable<CollectionInfo> getCollections(RequestContext request) {
+        return Iterables.unmodifiableIterable(collections);
+    }
+
+    public int hashCode() {
+      return MoreFunctions.genHashCode(1, collections,title);
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final BasicWorkspaceInfo other = (BasicWorkspaceInfo)obj;
+        if (collections == null) {
+            if (other.collections != null)
+                return false;
+        } else if (!collections.equals(other.collections))
+            return false;
+        if (title == null) {
+            if (other.title != null)
+                return false;
+        } else if (!title.equals(other.title))
+            return false;
+        return true;
+    }
+
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.common.protocol;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+
+
+public interface CollectionAdapter {
+
+    Function<RequestContext,ResponseContext> handlerFor(
+      Target target, 
+      String method);
+    
+    Predicate<RequestContext> acceptable();
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionInfo.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionInfo.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionInfo.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.common.protocol;
+
+
+/**
+ * Metadata interface used by WorkspaceManager and Provider implementations to construct Atompub Service Documents. The
+ * CollectionInfo interface provides information used to construct an app:collection element
+ */
+public interface CollectionInfo {
+
+    /**
+     * Get the value of the app:collection element's href attribute. This must not be null
+     */
+    String getHref(RequestContext request);
+
+    /**
+     * Get the value of the app:collection element's atom:title element. This assumes that the title will be
+     * type="text". This must not be null;
+     */
+    String getTitle(RequestContext request);
+
+    /**
+     * Returns an array 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
+     */
+    Iterable<String> getAccepts(RequestContext request);
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,43 @@
+/*
+ * 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.common.protocol;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for collection
+ * documents.
+ */
+public class CollectionRequestProcessor
+  extends TransactionalRequestProcessor {
+
+  public CollectionRequestProcessor(
+      WorkspaceManager workspaceManager,
+      CollectionAdapter adapter) {
+      super(workspaceManager,adapter);
+    }
+  
+  public CollectionRequestProcessor(
+    WorkspaceManager workspaceManager,
+    CollectionAdapter adapter,
+    Predicate<RequestContext> predicate) {
+    super(workspaceManager,adapter,predicate);
+  }
+  
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,100 @@
+/*
+ * 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.common.protocol;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.DeflaterOutputStream;
+
+import org.apache.abdera2.common.http.QualityHelper;
+import org.apache.abdera2.common.http.QualityHelper.QToken;
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.io.Compression.CompressionCodec;
+import org.apache.abdera2.common.misc.Chain;
+import org.apache.abdera2.common.misc.Task;
+
+/**
+ * Abdera Filter implementation that selectively applies compression to the response payload
+ */
+public class CompressionFilter implements Task<RequestContext,ResponseContext> {
+
+    public ResponseContext apply(
+      RequestContext request, 
+      Chain<RequestContext,ResponseContext> chain) {
+        QToken[] encodings = 
+          request.getHeader(
+            "Accept-Encoding", 
+            QualityHelper.parser);
+        for (QToken enc : encodings) {
+          try {
+              CompressionCodec codec = 
+                CompressionCodec.valueOf(
+                  enc.token().toUpperCase());
+              return new CompressingResponseContextWrapper(
+                chain.next(request), codec);
+          } catch (Exception e) {}
+        }
+        return chain.next(request);
+    }
+
+    /**
+     * A HttpServletResponseWrapper implementation that applies GZip or Deflate compression to response output.
+     */
+    public static class CompressingResponseContextWrapper 
+      extends BaseResponseContextWrapper {
+        private final CompressionCodec codec;
+        public CompressingResponseContextWrapper(
+          ResponseContext response, 
+          CompressionCodec codec) {
+            super(response);
+            this.codec = codec;
+        }
+        private OutputStream wrap(OutputStream out) {
+          return new CompressingOutputStream(codec, out);
+        }
+        public void writeTo(OutputStream out) throws IOException {
+          super.writeTo(wrap(out));
+          out.flush();
+        }
+    }
+
+    public static class CompressingOutputStream 
+      extends FilterOutputStream {
+        public CompressingOutputStream(
+          CompressionCodec codec, 
+          OutputStream out) {
+            super(initStream(codec, out));
+        }
+        public CompressingOutputStream(
+          DeflaterOutputStream dout) {
+            super(dout);
+        }
+        private static OutputStream initStream(
+          CompressionCodec codec, 
+          OutputStream out) {
+            try {
+                return Compression.wrap(out, new CompressionCodec[] {codec});
+            } catch (Exception e) {
+                return out;
+            }
+        }
+
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,68 @@
+/*
+ * 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.common.protocol;
+
+import org.apache.abdera2.common.protocol.RequestContext.Scope;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+
+/**
+ * The DefaultWorkspaceManager is used by the DefaultProvider
+ */
+public class DefaultWorkspaceManager 
+  extends AbstractWorkspaceManager  {
+    // URI reserved delimiter characters (gen-delims) from RFC 3986 section 2.2
+    private static final String URI_GEN_DELIMS = ":/?#[]@";
+    public CollectionAdapter getCollectionAdapter(RequestContext request) {
+      String path = request.getContextPath() + request.getTargetPath();
+      CollectionAdapter ca = 
+        (CollectionAdapter)request.getAttribute(
+          Scope.REQUEST, 
+          AbstractWorkspaceManager.COLLECTION_ADAPTER_ATTRIBUTE);
+      if (ca != null)
+          return ca;
+      for (WorkspaceInfo wi : workspaces) {
+        CollectionInfo ci = 
+          Iterables.<CollectionInfo>find(
+            wi.getCollections(request), 
+            CI(request,path),null);
+        if (ci != null)
+          return (CollectionAdapter)ci;
+      }
+      return null;
+    }
+    
+    private static final Predicate<CollectionInfo> CI(
+      final RequestContext rc, 
+      final String path) { 
+      return new Predicate<CollectionInfo>() {
+        public boolean apply(CollectionInfo input) {
+          String href = input.getHref(rc);
+          boolean answer = (
+            path.equals(href) || 
+            (href != null && 
+             path.startsWith(href) && 
+             URI_GEN_DELIMS.contains(
+              path.substring(href.length(), href.length() + 1))));
+          return answer;
+        }
+      }; 
+    }
+}

Propchange: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java
------------------------------------------------------------------------------
    svn:executable = *

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EmptyResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EmptyResponseContext.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EmptyResponseContext.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EmptyResponseContext.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.common.protocol;
+
+import java.io.IOException;
+
+public final class EmptyResponseContext extends SimpleResponseContext {
+
+    public EmptyResponseContext(int status) {
+        setStatus(status);
+    }
+
+    public EmptyResponseContext(int status, String text) {
+        setStatus(status);
+        setStatusText(text);
+    }
+
+    protected void writeEntity(java.io.Writer writer) throws IOException {
+    }
+
+    public boolean hasEntity() {
+        return false;
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EntryRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EntryRequestProcessor.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EntryRequestProcessor.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/EntryRequestProcessor.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,43 @@
+/*
+ * 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.common.protocol;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for entry
+ * documents.
+ */
+public class EntryRequestProcessor
+    extends TransactionalRequestProcessor {
+  
+    public EntryRequestProcessor(
+      WorkspaceManager workspaceManager, 
+      CollectionAdapter adapter) {
+        super(workspaceManager,adapter);
+    }
+
+    public EntryRequestProcessor(
+        WorkspaceManager workspaceManager, 
+        CollectionAdapter adapter,
+        Predicate<RequestContext> predicate) {
+          super(workspaceManager,adapter,predicate);
+      }
+    
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaRequestProcessor.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaRequestProcessor.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaRequestProcessor.java Wed Feb  1 17:54:54 2012
@@ -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.common.protocol;
+
+import com.google.common.base.Predicate;
+
+
+/**
+ * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for media
+ * documents.
+ */
+public class MediaRequestProcessor
+    extends TransactionalRequestProcessor {
+
+    public MediaRequestProcessor(
+      WorkspaceManager workspaceManager, 
+      CollectionAdapter adapter) {
+      super(workspaceManager, adapter);
+    }
+    
+    public MediaRequestProcessor(
+      WorkspaceManager workspaceManager, 
+      CollectionAdapter adapter,
+      Predicate<RequestContext> predicate) {
+      super(workspaceManager, adapter,predicate);
+    }
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaResponseContext.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaResponseContext.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MediaResponseContext.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,138 @@
+/*
+ * 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.common.protocol;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+
+import org.apache.abdera2.common.http.EntityTag;
+import org.joda.time.DateTime;
+
+/**
+ * ResponseContext implementation for arbitrary media resources
+ */
+public class MediaResponseContext extends SimpleResponseContext {
+
+    private InputStream in;
+    // JIRA: https://issues.apache.org/jira/browse/ABDERA-248
+    private boolean autoclose = true;
+
+    public MediaResponseContext(InputStream in, EntityTag etag, int status, boolean autoclose) {
+      this.in = in;
+      this.status = status;
+      this.autoclose = false;
+      setEntityTag(etag);
+    }
+    
+    public MediaResponseContext(InputStream in, EntityTag etag, int status) {
+        this(in,etag,status,true);
+    }
+
+    public MediaResponseContext(InputStream in, int status, boolean autoclose) {
+      this.in = in;
+      this.status = status;
+      this.autoclose = autoclose;
+    }
+    
+    public MediaResponseContext(InputStream in, int status) {
+        this(in,status,true);
+    }
+
+    public MediaResponseContext(InputStream in, DateTime lastmodified, int status, boolean autoclose) {
+      this.in = in;
+      this.status = status;
+      this.autoclose = autoclose;
+      setLastModified(lastmodified);
+    }
+    
+    public MediaResponseContext(InputStream in, DateTime lastmodified, int status) {
+        this(in,lastmodified,status,true);
+    }
+
+    public MediaResponseContext(byte[] bytes, int status) {
+        this(new ByteArrayInputStream(bytes), status);
+    }
+
+    public MediaResponseContext(byte[] bytes, DateTime lastmodified, int status) {
+        this(new ByteArrayInputStream(bytes), lastmodified, status);
+    }
+
+    public MediaResponseContext(byte[] bytes, EntityTag etag, int status) {
+        this(new ByteArrayInputStream(bytes), etag, status);
+    }
+
+    public MediaResponseContext(ReadableByteChannel channel, int status, boolean autoclose) {
+      this(Channels.newInputStream(channel), status, autoclose);
+    }
+    
+    public MediaResponseContext(ReadableByteChannel channel, int status) {
+        this(channel,status,true);
+    }
+
+    public MediaResponseContext(ReadableByteChannel channel, DateTime lastmodified, int status, boolean autoclose) {
+      this(Channels.newInputStream(channel), lastmodified,status,autoclose);
+    }
+    
+    public MediaResponseContext(ReadableByteChannel channel, DateTime lastmodified, int status) {
+        this(channel, lastmodified, status, true);
+    }
+
+    public MediaResponseContext(ReadableByteChannel channel, EntityTag etag, int status, boolean autoclose) {
+      this(Channels.newInputStream(channel), etag,status,autoclose);
+    }
+    
+    public MediaResponseContext(ReadableByteChannel channel, EntityTag etag, int status) {
+        this(channel, etag, status, true);
+    }
+
+    public boolean hasEntity() {
+        return in != null;
+    }
+
+    public void writeTo(OutputStream out) throws IOException {
+        if (hasEntity()) {
+            if (in != null) {
+                byte[] buf = new byte[500];
+                int r = -1;
+                while ((r = in.read(buf)) != -1)
+                    out.write(buf, 0, r);
+                if (autoclose)
+                  in.close();
+            }
+        }
+    }
+
+    protected void writeEntity(Writer out) throws IOException {
+        if (in != null) {
+            InputStreamReader rdr = new InputStreamReader(in);
+            char[] buf = new char[500];
+            int r = -1;
+            while ((r = rdr.read(buf)) != -1)
+                out.write(buf, 0, r);
+            if (autoclose)
+              rdr.close();
+        }
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Message.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Message.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Message.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Message.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,112 @@
+/*
+ * 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.common.protocol;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.http.Authentication;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.WebLink;
+import org.apache.abdera2.common.iri.IRI;
+import org.joda.time.DateTime;
+
+import com.google.common.base.Function;
+
+/**
+ * A protocol message. This is used as the basis for both request and response objects in order to provide a consistent
+ * interface.
+ */
+public interface Message {
+
+    <T>T getHeader(String name, Function<String,T> transform);
+  
+    <T>Iterable<T> getHeaders(String name, Function<String,T> transform);
+    
+    /**
+     * Get the value of the specified header
+     */
+    String getHeader(String name);
+
+    /**
+     * Get the decoded value of a RFC 2047 header
+     */
+    String getDecodedHeader(String name);
+
+    /**
+     * Return multiple values for the specified header
+     */
+    Iterable<Object> getHeaders(String name);
+
+    /**
+     * Return multiple decoded values for the specified header
+     */
+    Iterable<String> getDecodedHeaders(String name);
+
+    /**
+     * Return a listing of header names
+     */
+    Iterable<String> getHeaderNames();
+
+    /**
+     * Return the value of the Slug header
+     */
+    String getSlug();
+
+    /**
+     * Return the value of the Content-Type header
+     */
+    MimeType getContentType();
+
+    /**
+     * Return the value of the Content-Location header
+     */
+    IRI getContentLocation();
+
+    /**
+     * Return the value of the Content-Language header
+     */
+    String getContentLanguage();
+
+    /**
+     * Return the value of a Date header
+     */
+    DateTime getDateHeader(String name);
+
+    /**
+     * Return the Cache Control Data
+     */
+    CacheControl getCacheControl();
+    
+    /**
+     * Return the Authentication Data (WWW-Authentication or Authorization)
+     * @return
+     */
+    Iterable<Authentication> getAuthentication();
+
+    /**
+     * Return the Link header
+     */
+    Iterable<WebLink> getWebLinks();
+    
+    /**
+     * Return the Prefer header
+     */
+    Iterable<Preference> getPrefer();
+    
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.common.protocol;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.abdera2.common.misc.Chain;
+import org.apache.abdera2.common.misc.MoreFunctions;
+import org.apache.abdera2.common.misc.Task;
+
+import com.google.common.collect.ImmutableSet;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Abdera Filter implementation that supports the use of the X-HTTP-Method-Override header used by GData.
+ */
+public class MethodOverrideFilter 
+  implements Task<RequestContext,ResponseContext> {
+
+    private Set<String> methods = new HashSet<String>();
+
+    public MethodOverrideFilter() {
+        this("DELETE", "PUT", "PATCH");
+    }
+
+    public MethodOverrideFilter(String... methods) {
+      for (int n = 0; n < checkNotNull(methods).length; n++)
+        methods[n] = methods[n].toUpperCase(Locale.US);
+      this.methods = ImmutableSet.copyOf(methods);
+    }
+
+    public Iterable<String> getMethods() {
+      return methods;
+    }
+    
+    public ResponseContext apply(
+      RequestContext request, 
+      Chain<RequestContext,ResponseContext> chain) {
+        return chain.next(
+          new MethodOverrideRequestContext(
+            request,methods));
+    }
+
+    private static class MethodOverrideRequestContext 
+      extends BaseRequestContextWrapper {
+        private final String method;
+        public MethodOverrideRequestContext(
+          RequestContext request, 
+          Set<String> methods) {
+            super(request);
+            String method = super.getMethod();
+            String xheader = 
+              MoreFunctions
+                .<String>firstNonNull(
+                  getHeader("X-HTTP-Method-Override"),
+                  getHeader("X-Method-Override"));
+            if (xheader != null)
+                xheader = xheader.toUpperCase().trim();
+            if (method.equals("POST") && 
+                xheader != null && 
+                (methods.contains(method) || 
+                 methods.contains("*")))
+                  method = xheader;
+            this.method = method;
+        }
+        public String getMethod() {
+            return method;
+        }
+    }
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProtocolException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProtocolException.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProtocolException.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProtocolException.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,52 @@
+/*
+ * 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.common.protocol;
+
+import org.apache.abdera2.common.misc.MoreFunctions;
+
+public class ProtocolException 
+  extends RuntimeException {
+
+    private static final long serialVersionUID = 1017447143200419489L;
+    private final int code;
+
+    public ProtocolException(int code, String message) {
+        super(String.format("%d::%s",code,message));
+        this.code = code;
+    }
+
+    @Override
+    public int hashCode() {
+      return MoreFunctions.genHashCode(1,code);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (obj == null)
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      ProtocolException other = (ProtocolException) obj;
+      if (code != other.code)
+        return false;
+      return true;
+    }
+
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Provider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Provider.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Provider.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/Provider.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,81 @@
+/*
+ * 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.common.protocol;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+
+import org.apache.abdera2.common.misc.Initializable;
+import org.apache.abdera2.common.misc.Task;
+
+import com.google.common.base.Function;
+
+/**
+ * Providers are responsible for processing all requests to the Atompub server.<br>
+ * Actual request processing is delegated to {@link AtompubRequestProcessor} implementations, depending on the request
+ * {@link TargetType}.
+ */
+@SuppressWarnings("rawtypes")
+public interface Provider
+  extends TargetBuilder, 
+          Function<RequestContext,ResponseContext>, 
+          Initializable {
+
+    /**
+     * Get the specified property
+     */
+    String getProperty(String name);
+    
+    /**
+     * Return a listing of all available properties
+     */
+    Iterable<String> getPropertyNames();
+
+    /**
+     * Resolve the subject using the Provider's Subject Resolver
+     */
+    Subject resolveSubject(RequestContext request);
+
+    /**
+     * Resolve the target using the Provider's Target Resolver
+     */
+    Target resolveTarget(RequestContext request);
+
+    /**
+     * Return the listing of filters for this request
+     */
+    Iterable<Task<RequestContext,ResponseContext>> getFilters(RequestContext request);
+
+    ResponseContext createErrorResponse(int code, String message, Throwable t);
+    
+    /**
+     * Set a map of {@link AtompubRequestProcessor}s to register on this provider, overriding already registered ones.
+     */
+    void setRequestProcessors(Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> requestProcessors);
+
+    /**
+     * Add a map of {@link AtompubRequestProcessor}s to register on this provider, without overriding already registered ones.
+     */
+    void addRequestProcessors(Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> requestProcessors);
+
+    /**
+     * Return a map of registered {@link AtompubRequestProcessor}s with related {@link TargetType}.
+     */
+    Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> getRequestProcessors();
+}

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

Added: abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java?rev=1239237&view=auto
==============================================================================
--- abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java (added)
+++ abdera/abdera2-server/server/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java Wed Feb  1 17:54:54 2012
@@ -0,0 +1,347 @@
+/*
+ * 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.common.protocol;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.Localizer;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.text.Slug;
+import org.apache.abdera2.common.http.QualityHelper;
+import org.apache.abdera2.common.http.QualityHelper.QToken;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
+import static org.apache.abdera2.common.misc.MoreFunctions.array;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+public class ProviderHelper {
+    public final static Log log = LogFactory.getLog(ProviderHelper.class);
+
+    private ProviderHelper() {}
+
+    public static final Function<RequestContext,Integer> getPageSize(
+      final String param, 
+      final int def) {
+      return new Function<RequestContext,Integer>() {
+        public Integer apply(RequestContext input) {
+          int size = def;
+          try {
+            String _ps = input.getParameter(param);
+            size = (_ps != null) ? 
+              Math.min(
+                Math.max(Integer.parseInt(_ps), 0), def) : 
+                def;
+          } catch (Exception e) {}
+          log.debug(Localizer.sprintf("PAGE.SIZE", size));
+          return size;
+        }
+      };
+    }
+    
+    public static final Function<RequestContext,Integer> getOffset(
+      final String param, 
+      final int pagesize) {
+        return new Function<RequestContext,Integer>() {
+          public Integer apply(RequestContext input) {
+            int offset = 0;
+            try {
+              String _page = input.getParameter(param);
+              int page = (_page != null) ? 
+                Integer.parseInt(_page) : 1;
+              page = Math.max(page, 1) - 1;
+              offset = pagesize * page;
+            } catch (Exception e) {}
+            log.debug(Localizer.sprintf("OFFSET", offset));
+            return offset;
+          }
+        };
+    }
+
+    /**
+     * Returns an Error document based on the StreamWriter
+     */
+    public static ResponseContext createErrorResponse(
+      Provider provider, 
+      final int code, 
+      final String message) {
+        return createErrorResponse(provider, code, message, null);
+    }
+
+    /**
+     * Returns an Error document based on the StreamWriter
+     */
+    public static ResponseContext createErrorResponse(
+      Provider provider,
+      final int code,
+      final String message,
+      final Throwable t) {
+        return (ResponseContext)provider.createErrorResponse(code, message, t);
+    }
+
+    /**
+     * Return a server error
+     */
+    public static ResponseContext servererror(RequestContext request, String reason, Throwable t) {
+        log.info(Localizer.get("SERVER_ERROR"), t);
+        return createErrorResponse(request.getProvider(), 500, reason, t);
+    }
+
+    /**
+     * Return a server error
+     */
+    public static  ResponseContext servererror(RequestContext request, Throwable t) {;
+        return servererror(request, "Server Error", t);
+    }
+
+    /**
+     * Return an unauthorized error
+     */
+    public static  ResponseContext unauthorized(RequestContext request, String reason) {
+        log.debug(Localizer.get("UNAUTHORIZED"));
+        return createErrorResponse(request.getProvider(), 401, reason);
+    }
+
+    public static  ResponseContext unauthorized(RequestContext request) {
+        return unauthorized(request, "Unauthorized");
+    }
+
+    /**
+     * Return an unauthorized error
+     */
+    public static  ResponseContext forbidden(RequestContext request, String reason) {
+        log.debug(Localizer.get("FORBIDDEN"));
+        return createErrorResponse(request.getProvider(), 403, reason);
+    }
+
+    public static  ResponseContext forbidden(RequestContext request) {
+        return forbidden(request, "Forbidden");
+    }
+
+    /**
+     * Return a 204 No Content response
+     */
+    public static ResponseContext nocontent(String reason) {
+        return new EmptyResponseContext(204, reason);
+    }
+
+    public static ResponseContext nocontent() {
+        return nocontent("Not Content");
+    }
+
+    /**
+     * Return a 404 not found error
+     */
+    public static  ResponseContext notfound(RequestContext request, String reason) {
+        log.debug(Localizer.get("UNKNOWN"));
+        return createErrorResponse(request.getProvider(), 404, reason);
+    }
+
+    public static  ResponseContext notfound(RequestContext request) {
+        return notfound(request, "Not Found");
+    }
+
+    /**
+     * Return a 405 method not allowed error
+     */
+    public static  ResponseContext notallowed(RequestContext request, String reason, String... methods) {
+        log.debug(Localizer.get("NOT.ALLOWED"));
+        ResponseContext resp = createErrorResponse(request.getProvider(), 405, reason);
+        resp.setAllow(methods);
+        return resp;
+    }
+
+    public static  ResponseContext notallowed(RequestContext request, String... methods) {
+        return notallowed(request, "Method Not Allowed", methods);
+    }
+
+    public static  ResponseContext notallowed(RequestContext request) {
+        return notallowed(request, getDefaultMethods(request));
+    }
+
+    /**
+     * Return a 400 bad request error
+     */
+    public static  ResponseContext badrequest(RequestContext request, String reason) {
+        log.debug(Localizer.get("BAD.REQUEST"));
+        return createErrorResponse(request.getProvider(), 400, reason);
+    }
+
+    public static  ResponseContext badrequest(RequestContext request) {
+        return badrequest(request, "Bad Request");
+    }
+
+    /**
+     * Return a 409 conflict error
+     */
+    public static  ResponseContext conflict(RequestContext request, String reason) {
+        log.debug(Localizer.get("CONFLICT"));
+        return createErrorResponse(request.getProvider(), 409, reason);
+    }
+
+    public static  ResponseContext conflict(RequestContext request) {
+        return conflict(request, "Conflict");
+    }
+
+    /**
+     * Return a service unavailable error
+     */
+    public static  ResponseContext unavailable(RequestContext request, String reason) {
+        log.debug(Localizer.get("UNAVAILABLE"));
+        return createErrorResponse(request.getProvider(), 503, reason);
+    }
+
+    public static  ResponseContext unavailable(RequestContext request) {
+        return unavailable(request, "Service Unavailable");
+    }
+
+    public static  ResponseContext notmodified(RequestContext request, String reason) {
+        log.debug(Localizer.get("NOT.MODIFIED"));
+        return new EmptyResponseContext(304, reason);
+    }
+
+    public static  ResponseContext notmodified(RequestContext request) {
+        return notmodified(request, "Not Modified");
+    }
+
+    public static  ResponseContext preconditionfailed(RequestContext request, String reason) {
+        log.debug(Localizer.get("PRECONDITION.FAILED"));
+        return createErrorResponse(request.getProvider(), 412, reason);
+    }
+
+    public static  ResponseContext preconditionfailed(RequestContext request) {
+        return preconditionfailed(request, "Precondition Failed");
+    }
+
+    /**
+     * Return a 415 media type not-supported error
+     */
+    public static  ResponseContext notsupported(RequestContext request, String reason) {
+        log.debug(Localizer.get("NOT.SUPPORTED"));
+        return createErrorResponse(request.getProvider(), 415, reason);
+    }
+
+    public static  ResponseContext notsupported(RequestContext request) {
+        return notsupported(request, "Media Type Not Supported");
+    }
+
+    /**
+     * Return a 423 locked error
+     */
+    public static  ResponseContext locked(RequestContext request, String reason) {
+        log.debug(Localizer.get("LOCKED"));
+        return createErrorResponse(request.getProvider(), 423, reason);
+    }
+
+    public static  ResponseContext locked(RequestContext request) {
+        return locked(request, "Locked");
+    }
+
+    /**
+     * Sanitize the value of a Slug header. Any non alphanumeric characters in the slug are replaced with an underscore
+     */
+    public static String sanitizeSlug(String slug) {
+        if (slug == null)
+            throw new IllegalArgumentException(Localizer.get("SLUG.NOT.NULL"));
+        String sanitized = Slug.create(slug).toString();
+        log.debug(Localizer.sprintf("SLUG.SANITIZED", slug, sanitized));
+        return sanitized;
+    }
+
+    public static IRI resolveBase(RequestContext request) {
+        return request.getBaseUri().resolve(request.getUri());
+    }
+
+    public static String combine(String... vals) {
+        StringBuilder buf = new StringBuilder();
+        for (String val : vals) {
+            if (buf.length() > 0)
+                buf.append(", ");
+            buf.append(val);
+        }
+        return buf.toString();
+    }
+
+    static private final Function<TargetType,String[]> METHODS_CHOICE = 
+      MoreFunctions.<TargetType,String[]>choice()
+        .of(Predicates.<TargetType>isNull(), MoreFunctions.<String>array())
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_COLLECTION), array("GET", "HEAD", "OPTIONS", "POST"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_CATEGORIES), array("GET", "HEAD", "OPTIONS"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_ENTRY), array("DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_MEDIA), array("DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_SERVICE), array("GET", "HEAD", "OPTIONS"))
+        .otherwise(array("GET","HEAD","OPTIONS"))
+        .get();
+    
+    public static String[] getDefaultMethods(RequestContext request) {
+        TargetType type = request.getTarget().getType();
+        return METHODS_CHOICE.apply(type);
+    }
+
+    public static boolean defaultCheckMethod(RequestContext request, String[] methods) {
+        return (java.util.Arrays.binarySearch(methods, request.getMethod()) >= 0);
+    }
+    
+    public static Predicate<RequestContext> isAtom() {
+      return new Predicate<RequestContext>() {
+        public boolean apply(RequestContext input) {
+          return isAtom(input);
+        }
+      };
+    }
+    
+    public static boolean isAtom(RequestContext request) {
+        MimeType mt = request.getContentType();
+        String ctype = (mt != null) ? mt.toString() : null;
+        return ctype != null && MimeTypeHelper.isAtom(ctype);
+    }
+
+    public static String[] getAcceptableTypes(RequestContext request) {
+        String accept = request.getAccept();
+        QToken[] tokens = QualityHelper.orderByQ(accept);
+        String[] res = new String[tokens.length];
+        for (int n = 0; n < tokens.length; n++)
+          res[n] = tokens[n].token();
+        return res;
+    }
+
+    public static boolean isPreferred(RequestContext request, String s1, String s2) {
+        return isPreferred(getAcceptableTypes(request), s1, s2);
+    }
+
+    public static boolean isPreferred(String[] accepts, String s1, String s2) {
+        int i1 = accepts.length, i2 = accepts.length;
+        for (int n = 0; n < accepts.length; n++) {
+            if (MimeTypeHelper.isMatch(s1, accepts[n])) {
+                i1 = n;
+                break;
+            }
+        }
+        for (int n = 0; n < accepts.length; n++) {
+            if (MimeTypeHelper.isMatch(s2, accepts[n])) {
+                i2 = n;
+                break;
+            }
+        }
+        return i1 < i2;
+    }
+}

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



Mime
View raw message