Return-Path: X-Original-To: apmail-abdera-commits-archive@www.apache.org Delivered-To: apmail-abdera-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE5C77B23 for ; Tue, 20 Sep 2011 15:59:15 +0000 (UTC) Received: (qmail 85192 invoked by uid 500); 20 Sep 2011 15:59:15 -0000 Delivered-To: apmail-abdera-commits-archive@abdera.apache.org Received: (qmail 85157 invoked by uid 500); 20 Sep 2011 15:59:15 -0000 Mailing-List: contact commits-help@abdera.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@abdera.apache.org Delivered-To: mailing list commits@abdera.apache.org Received: (qmail 85148 invoked by uid 99); 20 Sep 2011 15:59:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 15:59:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 15:58:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 82DD92388BEF for ; Tue, 20 Sep 2011 15:58:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1173209 [13/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 -0000 To: commits@abdera.apache.org From: jmsnell@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110920155801.82DD92388BEF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,247 @@ +/* + * 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.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.abdera2.common.misc.Resolver; + +/** + *

+ * Provides a utility class helpful for determining which type of resource the client is requesting. Each resource type + * (e.g. service doc, collection, entry, edit uri, media resource, etc) is assigned a regex pattern. Given the request + * URI (path and querystring), this will determine which resource was selected and return an appropriate TargetMatcher. + * TargetMatcher is essentially just a simplified version of the java.util.regex.Matcher that also specifies the + * Resource Type. + *

+ * + *
+ *  RequestContext request = ...
+ *  RegexTargetResolver tr = new RegexTargetResolver();
+ *  tr.setPattern("/atom",ResourceType.INTROSPECTION)
+ *    .setPattern("/atom/([^/#?]+)",ResourceType.COLLECTION)
+ *    .setPattern("/atom/([^/#?]+)/([^/#?]+)",ResourceType.ENTRY)
+ *    .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?edit",ResourceType.ENTRY_EDIT)
+ *    .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?media",ResourceType.MEDIA)
+ *    .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?edit-media",ResourceType.MEDIA_EDIT);
+ *  
+ *  Target target = tr.resolve(request);
+ *  System.out.println(target.getType());
+ *  System.out.println(targer.getParameter("foo"));
+ * 
+ */ +public class RegexTargetResolver + implements Resolver { + + protected final Map patterns; + protected final Map fields; + + public RegexTargetResolver() { + this.patterns = new HashMap(); + this.fields = new HashMap(); + } + + public RegexTargetResolver(Map patterns) { + this.patterns = new HashMap(); + this.fields = new HashMap(); + for (String p : patterns.keySet()) { + TargetType type = patterns.get(p); + setPattern(p, type); + } + } + + public RegexTargetResolver setPattern(String pattern, TargetType type) { + return setPattern(pattern, type, new String[0]); + } + + public RegexTargetResolver setPattern(String pattern, TargetType type, String... fields) { + Pattern p = Pattern.compile(pattern); + this.patterns.put(p, type); + this.fields.put(p, fields); + return this; + } + + public Target resolve(R request) { + String uri = request.getTargetPath(); + for (Pattern pattern : patterns.keySet()) { + Matcher matcher = pattern.matcher(uri); + if (matcher.matches()) { + TargetType type = this.patterns.get(pattern); + String[] fields = this.fields.get(pattern); + return getTarget(type, request, matcher, fields); + } + } + return null; + } + + protected Target getTarget(TargetType type, RequestContext request, Matcher matcher, String[] fields) { + return new RegexTarget(type, request, matcher, fields); + } + + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append("Regex Target Resolver:\n"); + for (Pattern pattern : patterns.keySet()) { + TargetType type = this.patterns.get(pattern); + String[] fields = this.fields.get(pattern); + buf.append(pattern.toString() + ", Type: " + type + ", Fields: " + Arrays.toString(fields)); + } + return buf.toString(); + } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fields == null) ? 0 : fields.hashCode()); + result = prime * result + ((patterns == null) ? 0 : patterns.hashCode()); + return result; + } + + @SuppressWarnings("unchecked") + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final RegexTargetResolver other = (RegexTargetResolver)obj; + if (fields == null) { + if (other.fields != null) + return false; + } else if (!fields.equals(other.fields)) + return false; + if (patterns == null) { + if (other.patterns != null) + return false; + } else if (!patterns.equals(other.patterns)) + return false; + return true; + } + + public static class RegexTarget + extends SimpleTarget + implements Target { + + private static final long serialVersionUID = 165211244926064449L; + protected Matcher matcher; + protected String[] fields; + + public RegexTarget(TargetType type, RequestContext context, Matcher matcher, String[] fields) { + super(type, context); + this.matcher = matcher; + this.fields = fields; + } + + public String getParameter(String name) { + if (fields == null) + return super.getParameter(name); + int idx = 0; + for (int n = 0; n < fields.length; n++) + if (fields[n].equalsIgnoreCase(name)) + idx = n + 1; + return idx > 0 && idx <= matcher.groupCount() ? matcher.group(idx) : super.getParameter(name); + } + + public Iterable getParameterNames() { + Iterable names = super.getParameterNames(); + Set list = new HashSet(); + for (String name : names) + list.add(name); + if (fields != null) + list.addAll(Arrays.asList(fields)); + return list; + } + + @SuppressWarnings("unchecked") + @Override + public T getMatcher() { + return (T)matcher.pattern(); + } + + @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + String m = matcher.group(0); + String p = matcher.pattern().pattern(); + result = PRIME * result + super.hashCode(); + result = PRIME * result + ((m == null) ? 0 : m.hashCode()); + result = PRIME * result + ((p == null) ? 0 : p.hashCode()); + result = PRIME * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final RegexTarget other = (RegexTarget)obj; + String m = matcher.group(0); + String p = matcher.pattern().pattern(); + String m2 = other.matcher.group(0); + String p2 = other.matcher.pattern().pattern(); + if (!super.equals(obj)) + return false; + if (m == null) { + if (m2 != null) + return false; + } else if (!m.equals(m2)) + return false; + if (p == null) { + if (p2 != null) + return false; + } else if (!p.equals(p2)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + + public String toString() { + String m = matcher.group(0); + String p = matcher.pattern().pattern(); + StringBuilder buf = new StringBuilder(); + buf.append("RegexTarget[").append(p).append(" ==> ").append(m).append("] = ").append(type.toString()) + .append("\n"); + for (String param : getParameterNames()) { + buf.append(" ").append(param).append(" = ").append(getParameter(param)).append("\n"); + } + return buf.toString(); + } + + public String getIdentity() { + return context.getUri().toString(); + } + + } + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Request.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Request.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Request.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Request.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,69 @@ +/* + * 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.Date; + +import org.apache.abdera2.common.http.EntityTag; + +/** + * A protocol request. This is used as a base for both server and client requests + */ +public interface Request extends Message { + + /** + * Get the value of the Accept header + */ + String getAccept(); + + /** + * Get the value of the Accept-Charset header + */ + String getAcceptCharset(); + + /** + * Get the value of the Accept-Encoding header + */ + String getAcceptEncoding(); + + /** + * Get the value of the Accept-Language header + */ + String getAcceptLanguage(); + + /** + * Get a listing of Etags from the If-Match header + */ + Iterable getIfMatch(); + + /** + * Get the value of the If-Modified-Since header + */ + Date getIfModifiedSince(); + + /** + * Get a listing of ETags from the If-None-Match header + */ + Iterable getIfNoneMatch(); + + /** + * Get the value of the If-Unmodified-Since header + */ + Date getIfUnmodifiedSince(); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Request.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,211 @@ +/* + * 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.List; +import java.util.Locale; + +import javax.security.auth.Subject; + +import org.apache.abdera2.common.iri.IRI; + +/** + * The RequestContext provides access to every detail of the Request. + */ +public interface RequestContext + extends Request, Iterable { + + /** + * RequestContext attributes can either have Session or Request scope. Request scope attributes are only valid + * within the context of the current request. Session scope attributes, however, will remain valid as long as the + * Session is active. Container scope attributes are set on the Web container (e.g. the ServletContext) + */ + public enum Scope { + REQUEST, SESSION, CONTAINER + }; + + /** + * Special properties provided by the server + */ + public enum Property { + SESSIONID, + SESSIONCREATED, + SESSIONACCESSED, + SESSIONTIMEOUT, + CHARACTERENCODING, + LOCALES, + PROTOCOL, + REMOTEADDRESS, + REMOTEHOST, + REMOTEUSER, + SCHEME, + PRINCIPAL, + AUTHTYPE, + CONTENTLENGTH, + CONTENTTYPE, + CONTEXTPATH, + LOCALADDR, + LOCALNAME, + SERVERNAME, + SERVERPORT, + SECURE, + PARTS, + }; + + /** + * Get the Provider associated with this request + */ +

P getProvider(); + + /** + * Get this requests resolved Target + */ + Target getTarget(); + + /** + * Get this requests resolved Subject + */ + Subject getSubject(); + + /** + * Get this requests authenticated Principal object + */ + Principal getPrincipal(); + + /** + * Get the client's preferred locale as specified in the request + */ + Locale getPreferredLocale(); + + /** + * Get a listing of the client's preferred locales as specified in the request. The listing will be sorted in order + * of preference. + */ + Iterable getPreferredLocales(); + + /** + * Get the HTTP method + */ + String getMethod(); + + /** + * Get the request URI + */ + IRI getUri(); + + /** + * Get the absolute request URI (includes server name, port, etc) + */ + IRI getResolvedUri(); + + /** + * Get the absolute base URI ... this is the request URI up to the Context Path of the web application within which + * the Abdera Servlet is deployed + */ + IRI getBaseUri(); + + /** + * Get the specified system property + */ + T getProperty(Property property); + + /** + * Get the specified request parameter + */ + String getParameter(String name); + + /** + * Return the listing of parameter names + */ + Iterable getParameterNames(); + + /** + * Return all the values for the specified parameter + */ + List getParameters(String name); + + /** + * Get the named attribute from the specified scope + */ + Object getAttribute(Scope scope, String name); + + /** + * Return the list of attribute names in the specified scope + */ + Iterable getAttributeNames(Scope scope); + + /** + * Set the named attribute in the request scope + */ + T setAttribute(String name, Object value); + + /** + * Set the named attribute in the specified scope. If Session scope is specific, a new session will be created if + * one does not already exist + */ + T setAttribute(Scope scope, String name, Object value); + + /** + * Get the InputStream containing the request entity + */ + InputStream getInputStream() throws IOException; + + /** + * Get a Reader containing the request entity + */ + Reader getReader() throws IOException; + + /** + * Check to see if the authenticated user is in the specified role + */ + boolean isUserInRole(String role); + + /** + * Return the web applications context path + */ + String getContextPath(); + + /** + * Returns the subset of the request URI that is to be used to resolve the Target (everything after the context + * path) + */ + String getTargetPath(); + + /** + * Returns the subset of the request URI that is the base of the target path (e.g. + * HttpServletRequest.getServletPath()) + * + * @return + */ + String getTargetBasePath(); + + /** + * Construct a URL using the Provider's Target Builder + */ + String urlFor(Object key, Object param); + + /** + * Construct an absolute URL using the Provider's Target Builder. Relative URL's are resolved against the base URI + */ + String absoluteUrlFor(Object key, Object param); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.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.common.protocol; + +/** + * Request processors implement the actual business logic for handling requests to the Atompub server and producing the + * related response. + */ +public interface RequestProcessor { + + /** + * Provide the actual request processing logic. + * + * @param requestContext The {@link AtompubRequestContext} object, holding information about the request to process. + * @param workspaceManager The {@link AtompubWorkspaceManager} object, holding information useful for request processing. + * @param collectionAdapter The {@link AtompubCollectionAdapter} object, holding information useful for request processing; + * may be null if not needed. + * @return A {@link AtompubResponseContext} object, as resulted from the request processing. + */ + S process(RequestContext requestContext, + WorkspaceManager workspaceManager, + CollectionAdapter collectionAdapter); +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,155 @@ +package org.apache.abdera2.common.protocol; + +import java.security.Principal; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Set; + +import org.apache.abdera2.common.protocol.RequestContext.Scope; +import org.apache.abdera2.common.templates.Context; +import org.apache.abdera2.common.templates.DelegatingContext; + +public class RequestTemplateContext extends DelegatingContext { + + private static final long serialVersionUID = 4332356546022014897L; + + private final RequestContext request; + + public RequestTemplateContext(RequestContext request, Context subcontext) { + super(subcontext); + this.request = request; + } + + private String[] split(String val) { + if (val.equals("")) + return null; + String[] segments = val.split("/"); + return segments.length > 0 ? segments : null; + } + + @Override + public boolean contains(String var) { + if (super.contains(var)) return true; + return resolveActual(var) != null; + } + + @Override + @SuppressWarnings("unchecked") + protected T resolveActual(String var) { + Variable variable = Variable.get(var); + if (variable == null) + return subcontext != null ? (T)subcontext.resolve(var) : null; + switch (variable) { + case REQUEST_URI: + return (T)request.getUri().toString(); + case REQUEST_RESOLVED_URI: + return (T)request.getResolvedUri().toString(); + case REQUEST_CONTENT_TYPE: + return (T)request.getContentType().toString(); + case REQUEST_CONTEXT_PATH: + return (T)split(request.getContextPath()); + case REQUEST_PARAMETER: + String name = Variable.REQUEST_PARAMETER.label(var); + return (T)request.getParameter(name); + case REQUEST_LANGUAGE: + return (T)request.getAcceptLanguage(); + case REQUEST_CHARSET: + return (T)request.getAcceptCharset(); + case REQUEST_USER: + Principal p = request.getPrincipal(); + return p != null ? (T)p.getName() : null; + case SESSION_ATTRIBUTE: + name = Variable.SESSION_ATTRIBUTE.label(var); + return (T)request.getAttribute(Scope.SESSION, name); + case REQUEST_ATTRIBUTE: + name = Variable.REQUEST_ATTRIBUTE.label(var); + return (T)request.getAttribute(Scope.REQUEST, name); + case REQUEST_HEADER: + name = Variable.REQUEST_HEADER.label(var); + return (T)request.getHeader(name); + case TARGET_PARAMETER: + name = Variable.TARGET_PARAMETER.label(var); + return (T)request.getTarget().getParameter(name); + case TARGET_IDENTITY: + return (T)request.getTarget().getIdentity(); + case TARGET_PATH: + return (T)split(request.getTargetPath()); + case TARGET_BASE: + return (T)split(request.getTargetBasePath()); + default: + return subcontext != null ? (T)subcontext.resolve(var) : null; + } + } + + @Override + public Iterator iterator() { + Set vars = new HashSet(); + for (String var : subcontext) + vars.add(var); + for (String var : request.getParameterNames()) + vars.add(toVar(Variable.REQUEST_PARAMETER, var)); + for (String var : request.getAttributeNames(Scope.SESSION)) + vars.add(toVar(Variable.SESSION_ATTRIBUTE, var)); + for (String var : request.getAttributeNames(Scope.REQUEST)) + vars.add(toVar(Variable.REQUEST_ATTRIBUTE, var)); + for (String var : request.getHeaderNames()) + vars.add(toVar(Variable.REQUEST_HEADER, var)); + Target target = request.getTarget(); + for (String var : target.getParameterNames()) + vars.add(toVar(Variable.TARGET_PARAMETER, var)); + vars.add(Variable.REQUEST_CONTEXT_PATH.name().toLowerCase()); + vars.add(Variable.REQUEST_CONTENT_TYPE.name().toLowerCase()); + vars.add(Variable.REQUEST_URI.name().toLowerCase()); + vars.add(Variable.REQUEST_RESOLVED_URI.name().toLowerCase()); + vars.add(Variable.REQUEST_LANGUAGE.name().toLowerCase()); + vars.add(Variable.REQUEST_CHARSET.name().toLowerCase()); + vars.add(Variable.REQUEST_USER.name().toLowerCase()); + vars.add(Variable.TARGET_IDENTITY.name().toLowerCase()); + vars.add(Variable.TARGET_PATH.name().toLowerCase()); + vars.add(Variable.TARGET_BASE.name().toLowerCase()); + return vars.iterator(); + } + + private static String toVar(Variable variable, String label) { + return String.format("%s_%s", variable.name().toLowerCase(), label); + } + + public static enum Variable { + REQUEST_CONTEXT_PATH, + REQUEST_CONTENT_TYPE, + REQUEST_URI, + REQUEST_RESOLVED_URI, + REQUEST_PARAMETER, + REQUEST_LANGUAGE, + REQUEST_CHARSET, + REQUEST_USER, + SESSION_ATTRIBUTE, + REQUEST_ATTRIBUTE, + REQUEST_HEADER, + TARGET_PARAMETER, + TARGET_IDENTITY, + TARGET_PATH, + TARGET_BASE; + + static Variable get(String var) { + if (var == null) return null; + var = var.toUpperCase(Locale.US); + for (Variable variable : Variable.values()) + if (var.startsWith(variable.name())) + return variable; + return null; + } + + boolean match(String var) { + if (var == null) return false; + var = var.toUpperCase(Locale.US); + return var.startsWith(name()); + } + + String label(String var) { + return var.substring(name().length() + 1); + } + } + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Response.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Response.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Response.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Response.java Tue Sep 20 15:56:46 2011 @@ -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.Date; + +import org.apache.abdera2.common.iri.IRI; +import org.apache.abdera2.common.http.EntityTag; +import org.apache.abdera2.common.http.ResponseType; + +/** + * Base interface for an Atompub protocol response message + */ +public interface Response extends Message { + + /** + * Get the Entity Tag returned by the server + */ + EntityTag getEntityTag(); + + /** + * Get the response type classification + */ + ResponseType getType(); + + /** + * Get the specific response status code + */ + int getStatus(); + + /** + * Get the response status text + */ + String getStatusText(); + + /** + * Get the value of the Last-Modified response header + */ + Date getLastModified(); + + /** + * Get the value of the Content-Length response header + */ + long getContentLength(); + + /** + * Get the value of the Allow response header + */ + String getAllow(); + + /** + * Get the value of the Location response header + */ + IRI getLocation(); + + /** + * Get the age of this response as specified by the server + */ + long getAge(); + + /** + * Get the date/time this response expires + */ + Date getExpires(); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Response.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,209 @@ +/* + * 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 java.util.Date; + +import org.apache.abdera2.common.text.CharUtils.Profile; +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; + +/** + * The ResponseContext encapsulates a server response + */ +public interface ResponseContext extends Response { + + /** + * True if the response contains a binary entity as opposed to a character based entity. Default is false. If true, + * the AbderaServlet will pass in the OutputStream for writing out, if false, the AbderaServlet will pass in the + * Writer. + */ + boolean isBinary(); + + /** + * True if the response contains a binary entity as opposed to a character based entity. Default is false. If true, + * the AbderaServlet will pass in the OutputStream for writing out, if false, the AbderaServlet will pass in the + * Writer. + */ + B setBinary(boolean binary); + + /** + * True if the response contains an entity + */ + boolean hasEntity(); + + /** + * Write the response out to the specified OutputStream + */ + void writeTo(OutputStream out) throws IOException; + + /** + * Write the response out to the specified Writer + */ + void writeTo(java.io.Writer javaWriter) throws IOException; + + /** + * Remove the specified header from the response + */ + B removeHeader(String name); + + /** + * Set an RFC 2047 encoded header in the response + */ + B setEncodedHeader(String name, String charset, String value); + + /** + * Set an RFC 2047 encoded header in the response + */ + B setEncodedHeader(String name, String charset, String... vals); + + /** + * Set a pct-encoded header in the response + */ + B setEscapedHeader(String name, Profile profile, String value); + + /** + * Set the value of a header in the response + */ + B setHeader(String name, Object value); + + /** + * Set the value of a header in the response + */ + B setHeader(String name, Object... vals); + + /** + * Add an RFC 2047 encoded header in the response + */ + B addEncodedHeader(String name, String charset, String value); + + /** + * Add an RFC 2047 encoded header in the response + */ + B addEncodedHeaders(String name, String charset, String... vals); + + /** + * Add a header to the response + */ + B addHeader(String name, Object value); + + /** + * Add a header to the response + */ + B addHeaders(String name, Object... vals); + + /** + * Set the value of the Age header + */ + B setAge(long age); + + /** + * Set the value of the Content-Language header + */ + B setContentLanguage(String language); + + /** + * Set the value of the Content-Length header + */ + B setContentLength(long length); + + /** + * Set the value of the Content-Location header + */ + B setContentLocation(String uri); + + /** + * Set the value of the Slug header + */ + B setSlug(String slug); + + /** + * Set the value of the Content-Type header + */ + B setContentType(String type); + + /** + * Set the value of the Content-Type header + */ + B setContentType(String type, String charset); + + /** + * Set the value of the ETag header + */ + B setEntityTag(String etag); + + /** + * Set the value of the ETag header + */ + B setEntityTag(EntityTag etag); + + /** + * Set the value of the Expires header + */ + B setExpires(Date date); + + /** + * Set the value of the Last-Modified header + */ + B setLastModified(Date date); + + /** + * Set the value of the Location header + */ + B setLocation(String uri); + + /** + * Set the response status code + */ + B setStatus(int status); + + /** + * Set the response status text + */ + B setStatusText(String text); + + /** + * Specify the HTTP methods allowed + */ + B setAllow(String method); + + /** + * Specify the HTTP methods allowed + */ + B setAllow(String... methods); + + /** + * Specify the CacheControl header + */ + B setCacheControl(CacheControl cc); + + /** + * Specify the CacheControl header + */ + B setCacheControl(String cc); + + B setWebLinks(WebLink link, WebLink... links); + + B setPrefer(Preference pref, Preference... prefs); + + B setPreferApplied(Preference pref, Preference... prefs); +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,63 @@ +/* + * 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; + + +public class ResponseContextException extends RuntimeException { + + private static final long serialVersionUID = -3031651143835987024L; + + private ResponseContext responseContext; + + public ResponseContextException(ResponseContext responseContext, Throwable t) { + super(t); + this.responseContext = responseContext; + } + + public ResponseContextException(ResponseContext responseContext) { + super(); + this.responseContext = responseContext; + } + + public ResponseContextException(int responseCode) { + this(new EmptyResponseContext(responseCode)); + } + + public ResponseContextException(int responseCode, Throwable t) { + this(new EmptyResponseContext(responseCode), t); + } + + public ResponseContextException(String msg, int responseCode) { + this.responseContext = new EmptyResponseContext(responseCode); + this.responseContext.setStatusText(msg); + } + + @SuppressWarnings("unchecked") + public T getResponseContext() { + return (T)responseContext; + } + + @Override + public String getMessage() { + return responseContext.getStatusText(); + } + + public int getStatusCode() { + return responseContext.getStatus(); + } +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java ------------------------------------------------------------------------------ svn:executable = * Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContextException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,233 @@ +/* + * 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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.abdera2.common.misc.Resolver; +import org.apache.abdera2.common.templates.CachingContext; +import org.apache.abdera2.common.templates.Context; +import org.apache.abdera2.common.templates.MapContext; +import org.apache.abdera2.common.templates.ObjectContext; +import org.apache.abdera2.common.templates.Route; + +/** + * This is a largely experimental implementation of a Target Resolver and Target Builder based on URL patterns similar + * (but not identical) to Ruby on Rails style routes. For instance: + * + *

+ * RouteManager rm =
+ *     new RouteManager().addRoute("entry", ":collection/:entry", TargetType.TYPE_ENTRY)
+ *         .addRoute("feed", ":collection", TargetType.TYPE_COLLECTION);
+ * 
+ * + * The RouteManager can be used by Provider implementations as the target resolver and target builder + */ +public class RouteManager + implements Resolver, + TargetBuilder { + + protected class RouteTargetType { + protected Route route; + protected TargetType targetType; + + RouteTargetType(Route route, TargetType targetType) { + this.route = route; + this.targetType = targetType; + } + + public Route getRoute() { + return route; + } + + public TargetType getTargetType() { + return targetType; + } + } + + protected List targets = new ArrayList(); + + protected Map> routes = new HashMap>(); + + protected Map, CollectionAdapter> route2CA = new HashMap, CollectionAdapter>(); + + public RouteManager addRoute(Route route) { + return addRoute(route, null); + } + + public RouteManager addRoute(T key, String pattern) { + return addRoute(key, pattern, null); + } + + public RouteManager addRoute(Route route, TargetType type) { + routes.put(route.getKey(), route); + if (type != null) + targets.add(new RouteTargetType(route, type)); + return this; + } + + public RouteManager addRoute(T key, String pattern, TargetType type) { + return addRoute(new Route(key, pattern), type); + } + + public RouteManager addRoute(T key, String pattern, TargetType type, CollectionAdapter collectionAdapter) { + + Route route = new Route(key, pattern); + route2CA.put(route, collectionAdapter); + return addRoute(route, type); + } + + public Target resolve(X request) { + String uri = request.getTargetPath(); + int idx = uri.indexOf('?'); + if (idx != -1) { + uri = uri.substring(0, idx); + } + + RouteTargetType target = get(uri); + if (target == null) { + target = match(uri); + } + + if (target != null) { + return getTarget(request, target, uri); + } + + return null; + } + + private RouteTargetType get(String uri) { + for (RouteTargetType target : targets) { + if (target.route.getPattern().equals(uri)) { + return target; + } + } + return null; + } + + private RouteTargetType match(String uri) { + for (RouteTargetType target : targets) { + if (target.route.match(uri)) { + return target; + } + } + return null; + } + + private Target getTarget(RequestContext context, RouteTargetType target, String uri) { + CollectionAdapter ca = route2CA.get(target.route); + if (ca != null) { + context.setAttribute(AbstractWorkspaceManager.COLLECTION_ADAPTER_ATTRIBUTE, ca); + } + return getTarget(context, target.route, uri, target.targetType); + } + + private Target getTarget(RequestContext context, Route route, String uri, TargetType type) { + return new RouteTarget(type, context, route, uri); + } + + public String urlFor(Request context, T key, Object param) { + RequestContext rc = (RequestContext) context; + Route route = routes.get(key); + return route != null ? rc.getContextPath() + route.expand(getContext(param)) : null; + } + + private Context getContext(Object param) { + Context context = new EmptyContext(); + if (param != null) { + if (param instanceof Map) { + context = new MapContext(cleanMapCtx(param), true); + } else if (param instanceof Context) { + context = (Context)param; + } else { + context = new ObjectContext(param, true); + } + } + return context; + } + + @SuppressWarnings("unchecked") + private Map cleanMapCtx(Object param) { + Map map = new HashMap(); + for (Map.Entry entry : ((Map)param).entrySet()) { + map.put(entry.getKey().replaceFirst("^:", ""), entry.getValue()); + } + ((Map)param).clear(); + ((Map)param).putAll(map); + return (Map)param; + } + + private static class EmptyContext extends CachingContext { + private static final long serialVersionUID = 4681906592987534451L; + + public boolean contains(String var) { + return false; + } + + protected T resolveActual(String var) { + return null; + } + + public Iterator iterator() { + List list = Arrays.asList(new String[0]); + return list.iterator(); + } + } + + public static class RouteTarget extends SimpleTarget { + private final Map params; + private final Route route; + + public RouteTarget(TargetType type, RequestContext context, Route route, String uri) { + super(type, context); + this.route = route; + this.params = route.parse(uri); + } + + public Route getRoute() { + return route; + } + + @SuppressWarnings("unchecked") + @Override + public T getMatcher() { + return (T)getRoute(); + } + + public String getParameter(String name) { + return params.containsKey(name) ? params.get(name) : super.getParameter(name); + } + + public Iterable getParameterNames() { + Iterable ns = super.getParameterNames(); + Set names = new HashSet(); + for (String name : ns) + names.add(name); + for (String name : params.keySet()) + names.add(name); + return names; + } + } +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,60 @@ +/* + * 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 org.apache.abdera2.common.Discover; +import org.apache.abdera2.common.anno.DefaultImplementation; +import org.apache.abdera2.common.protocol.servlet.async.ProcessorQueue; +import org.apache.abdera2.common.protocol.servlet.async.TaskExecutor; +import org.apache.abdera2.common.pusher.ChannelManager; + +@DefaultImplementation("org.apache.abdera2.protocol.server.AtompubServiceManager") +public interface ServiceManager

{ + + public static final String PROVIDER = Provider.class.getName(); + public static final String PROCESSORQUEUE = ProcessorQueue.class.getName(); + public static final String TASKEXECUTOR = TaskExecutor.class.getName(); + public static final String CHANNELMANAGER = ChannelManager.class.getName(); + + + public abstract P newProvider(Map properties); + + public abstract ProcessorQueue newProcessorQueue( + Map properties); + + public abstract TaskExecutor newTaskExecutor(Map properties); + + public abstract ChannelManager newChannelManager( + Map properties); + + @SuppressWarnings({"rawtypes" }) + public static class Factory { + + @SuppressWarnings("unchecked") + public static ServiceManager getInstance() { + return getInstance("org.apache.abdera2.protocol.server.AtompubServiceManager"); + } + + public static ServiceManager getInstance(String impl) { + return Discover.locate(ServiceManager.class, impl); + } + + } +} \ No newline at end of file Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleResponseContext.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleResponseContext.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleResponseContext.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleResponseContext.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,69 @@ +/* + * 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 java.io.OutputStreamWriter; +import java.io.Writer; + + +/** + * A simple base implementation of AbstractResponseContext that makes it a bit easier to create custom ResponseContext + * implementations e.g. new SimpleResponseContext() { public boolean hasEntity() { return true; } public void + * writeEntity(Writer writer) { ... } } + */ +public abstract class SimpleResponseContext extends AbstractResponseContext { + + protected String encoding = "UTF-8"; + + protected SimpleResponseContext() { + this(null); + } + + protected SimpleResponseContext(String encoding) { + if (encoding != null) { + this.encoding = encoding; + } + } + + protected SimpleResponseContext setEncoding(String encoding) { + this.encoding = encoding; + return this; + } + + protected String getEncoding() { + return this.encoding; + } + + public void writeTo(OutputStream out) throws IOException { + if (hasEntity()) { + OutputStreamWriter writer = new OutputStreamWriter(out, encoding); + writeTo(writer); + writer.flush(); + } + } + + public void writeTo(Writer writer) throws IOException { + if (hasEntity()) + writeEntity(writer); + } + + protected abstract void writeEntity(Writer writer) throws IOException; + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleResponseContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,120 @@ +/* + * 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.security.Principal; + +import javax.security.auth.Subject; + +import org.apache.abdera2.common.misc.Resolver; + +/** + * The default subject resolver implementation + */ +public class SimpleSubjectResolver + implements Resolver { + + public static final Principal ANONYMOUS = new AnonymousPrincipal(); + + public Subject resolve(Request request) { + RequestContext context = (RequestContext)request; + return resolve(context.getPrincipal()); + } + + public Subject resolve(Principal principal) { + Subject subject = new Subject(); + subject.getPrincipals().add((principal != null) ? principal : ANONYMOUS); + return subject; + } + + public Subject resolve(String userid) { + if (userid == null) + return resolve(ANONYMOUS); + return resolve(new SimplePrincipal(userid)); + } + + static class SimplePrincipal implements Principal, Serializable { + private static final long serialVersionUID = 7161420960293729670L; + final String name; + + SimplePrincipal(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String toString() { + return name; + } + + @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final SimplePrincipal other = (SimplePrincipal)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + } + + public static final class AnonymousPrincipal implements Principal, Serializable { + private static final long serialVersionUID = -5050930075733261944L; + final String name = "Anonymous"; + + public String getName() { + return name; + } + + public String toString() { + return name; + } + + public boolean equals(Object other) { + if (other == null) + return false; + return this == other; + } + + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + } +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,99 @@ +/* + * 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.Iterator; + + + +@SuppressWarnings("unchecked") +public class SimpleTarget + implements Target { + + protected final TargetType type; + protected final RequestContext context; + + public SimpleTarget(TargetType type, RequestContext context) { + this.type = type; + this.context = context; + } + + public String getIdentity() { + return context.getUri().toString(); + } + + public String getParameter(String name) { + return context.getParameter(name); + } + + public Iterable getParameterNames() { + return context.getParameterNames(); + } + + public Iterator iterator() { + return getParameterNames().iterator(); + } + + public TargetType getType() { + return type; + } + + public T getRequestContext() { + return (T)context; + } + + public String toString() { + return getType() + " - " + getIdentity(); + } + + public T getMatcher() { + return (T)null; + } + + @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((context == null) ? 0 : context.hashCode()); + result = PRIME * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final SimpleTarget other = (SimpleTarget)obj; + if (context == null) { + if (other.context != null) + return false; + } else if (!context.equals(other.context)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java ------------------------------------------------------------------------------ svn:executable = * Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Target.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Target.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Target.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Target.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,53 @@ +/* + * 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; + + +/** + * Identifies the target of the request. + */ +public interface Target extends Iterable { + + /** + * Return the resolved Target Type + */ + TargetType getType(); + + /** + * Return the identity of this target. Usually this will just be the request URI + */ + String getIdentity(); + + /** + * Return the named target parameter + */ + String getParameter(String name); + + /** + * Return a listing of all parameter names + */ + Iterable getParameterNames(); + + /** + * Return the object that matches with the uri + * + * @return + */ + public T getMatcher(); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Target.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetBuilder.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetBuilder.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetBuilder.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetBuilder.java Tue Sep 20 15:56:46 2011 @@ -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; + +/** + * The TargetBuilder component is responsible for constructing appropriate IRIs/URIs for various kinds of targets based + * on specified input parameters. The input params are specific to the Target Manager implementation. + */ +public interface TargetBuilder { + + /** + * Construct a URL for the specified key + */ + String urlFor(Request context, T key, Object param); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetBuilder.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,144 @@ +/* + * 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 java.util.concurrent.ConcurrentHashMap; + +/** + * Identifies the type of resource being requests. + */ +public final class TargetType { + + public static final String UNKNOWN = "UNKNOWN"; + public static final String NOT_FOUND = "NOT_FOUND"; + public static final String SERVICE = "SERVICE"; + public static final String COLLECTION = "COLLECTION"; + public static final String ENTRY = "ENTRY"; + public static final String MEDIA = "MEDIA"; + public static final String CATEGORIES = "CATEGORIES"; + + private static final Map types = + new ConcurrentHashMap(); + + /** + * An unknown target type + */ + public static final TargetType TYPE_UNKNOWN = new TargetType(UNKNOWN); + /** + * A not found target type + */ + public static final TargetType TYPE_NOT_FOUND = new TargetType(NOT_FOUND); + /** + * An Atompub Service Document + */ + public static final TargetType TYPE_SERVICE = new TargetType(SERVICE); + /** + * An Atom Feed Document representing an Atompub Collection + */ + public static final TargetType TYPE_COLLECTION = new TargetType(COLLECTION); + /** + * An Atompub Collection member entry + */ + public static final TargetType TYPE_ENTRY = new TargetType(ENTRY); + /** + * An Atompub Collection media resource + */ + public static final TargetType TYPE_MEDIA = new TargetType(MEDIA); + /** + * An Atompub Categories Document + */ + public static final TargetType TYPE_CATEGORIES = new TargetType(CATEGORIES); + + /** + * Return a listing of TargetTypes + */ + public static Iterable values() { + return types.values(); + } + + /** + * Get the specified target type + */ + public static TargetType get(String name) { + return types.get(name.toUpperCase()); + } + + /** + * Get the specified target type. If the target type does not currently exist, and create = true, a new type will be + * created. + */ + public static TargetType get(String name, boolean create) { + if (name == null) + return null; + TargetType type = get(name); + return type != null ? type : create ? create(name) : null; + } + + private static synchronized TargetType create(String name) { + TargetType type = new TargetType(name.toUpperCase()); + types.put(type.name(), type); + return type; + } + + private final String name; + + private TargetType(String name) { + if (name == null || name.length() == 0) + throw new IllegalArgumentException(); + if (get(name) != null) + throw new IllegalArgumentException(); + this.name = name.toUpperCase(); + types.put(name, this); + } + + /** + * Return the target name + */ + public String name() { + return name; + } + + public String toString() { + return name; + } + + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final TargetType other = (TargetType)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TemplateManagerTargetBuilder.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TemplateManagerTargetBuilder.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TemplateManagerTargetBuilder.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TemplateManagerTargetBuilder.java Tue Sep 20 15:56:46 2011 @@ -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.util.Map; + +import org.apache.abdera2.common.iri.IRI; +import org.apache.abdera2.common.templates.Context; +import org.apache.abdera2.common.templates.MapContext; +import org.apache.abdera2.common.templates.ObjectContext; +import org.apache.abdera2.common.templates.TemplateManager; + +public class TemplateManagerTargetBuilder + extends TemplateManager + implements TargetBuilder { + + public TemplateManagerTargetBuilder() { + super(); + } + + public TemplateManagerTargetBuilder(boolean iri) { + super(iri); + } + + public TemplateManagerTargetBuilder(Context defaults) { + super(defaults); + } + + public TemplateManagerTargetBuilder(IRI base, boolean iri) { + super(base, iri); + } + + public TemplateManagerTargetBuilder(IRI base, Context defaults) { + super(base, defaults); + } + + public TemplateManagerTargetBuilder(IRI base, Object defaults, boolean isiri) { + super(base, defaults, isiri); + } + + public TemplateManagerTargetBuilder(IRI base, Object defaults) { + super(base, defaults); + } + + public TemplateManagerTargetBuilder(IRI base) { + super(base); + } + + public TemplateManagerTargetBuilder(Object defaults, boolean isiri) { + super(defaults, isiri); + } + + public TemplateManagerTargetBuilder(Object defaults) { + super(defaults); + } + + public TemplateManagerTargetBuilder(String base, boolean iri) { + super(base, iri); + } + + public TemplateManagerTargetBuilder(String base, Context defaults) { + super(base, defaults); + } + + public TemplateManagerTargetBuilder(String base, Object defaults, + boolean isiri) { + super(base, defaults, isiri); + } + + public TemplateManagerTargetBuilder(String base, Object defaults) { + super(base, defaults); + } + + public TemplateManagerTargetBuilder(String base) { + super(base); + } + + public String urlFor(Request request, T key, Object param) { + RequestContext rc = (RequestContext) request; + if (param == null) param = new MapContext(true); + return expand(key,getContext(rc,param)); + } + + @SuppressWarnings("unchecked") + public static Context getContext(RequestContext request, Object param) { + Context context = null; + if (param != null) { + if (param instanceof Map) { + context = new MapContext((Map)param, true); + } else if (param instanceof Context) { + context = (Context)param; + } else { + context = new ObjectContext(param, true); + } + } + return new RequestTemplateContext(request, context); + } +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TemplateManagerTargetBuilder.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.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.common.protocol; + +/** + * CollectionAdapter implementations can implement the Transactional interface in order to support start/end/compensate + * behaviors. Providers will invoke the start/end methods before/after calling the appropriate CollectionAdapter methods + * and will call compensate if an error occurs + */ +public interface Transactional { + + /** + * Called by the provider before dispatching the request to the adapter + */ + void start(RequestContext request); + + /** + * Called by the provider after dispatching the request to the adapter + */ + void end(RequestContext request, ResponseContext response); + + /** + * Called by the provider when a processing error occurs + */ + void compensate(RequestContext request, Throwable t); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceInfo.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceInfo.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceInfo.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceInfo.java Tue Sep 20 15:56:46 2011 @@ -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.util.Collection; + + +/** + * Metadata interface used by WorkspaceManager and Provider implementations to construct Atompub Service Documents. The + * WorkspaceInfo interface provides information used to construct an app:workspace element + */ +public interface WorkspaceInfo { + + /** + * Return the value of the app:workspace element's atom:title. This assumes that the atom:title element uses + * type="text". This must not be null + */ + String getTitle(RequestContext requsest); + + /** + * Return the listing of collections available as part of the workspace + */ + Collection getCollections(RequestContext request); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceInfo.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceManager.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceManager.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceManager.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceManager.java Tue Sep 20 15:56:46 2011 @@ -0,0 +1,45 @@ +/* + * 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.Collection; +import java.util.Date; + +import org.apache.abdera2.common.http.EntityTag; + +/** + * The Workspace Manager is used by a Provider to access metadata used to construct Atompub service documents and to + * determine the appropriate CollectionAdapter to handle a particular request + */ +public interface WorkspaceManager { + + /** + * Get the Collection Adapter that will handle this request + */ + CollectionAdapter getCollectionAdapter(RequestContext request); + + /** + * Return the list of available workspaces + */ + Collection getWorkspaces(RequestContext request); + + Date getLastModified(); + + EntityTag getEntityTag(); + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/WorkspaceManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbderaServlet.java URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbderaServlet.java?rev=1173209&view=auto ============================================================================== --- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbderaServlet.java (added) +++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbderaServlet.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.common.protocol.servlet; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class AbderaServlet + extends AbstractAbderaServlet { + + private static final long serialVersionUID = 2393643907128535158L; + + @Override + protected void service( + HttpServletRequest request, + HttpServletResponse response) + throws ServletException,IOException { + process(request,response,getServletContext()); + } + +} Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbderaServlet.java ------------------------------------------------------------------------------ svn:mime-type = text/plain