abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r680749 [1/2] - in /incubator/abdera/java/trunk/extensions/opensearch: ./ src/main/java/org/apache/abdera/ext/opensearch/ src/main/java/org/apache/abdera/ext/opensearch/model/ src/main/java/org/apache/abdera/ext/opensearch/server/ src/main/...
Date Tue, 29 Jul 2008 16:07:36 GMT
Author: calavera
Date: Tue Jul 29 09:07:28 2008
New Revision: 680749

URL: http://svn.apache.org/viewvc?rev=680749&view=rev
Log:
[ABDERA-188]: OpenSearch support improvement. Thanks to Sergio Bossa.

This new implementation cover all openSearch use cases:

* Abdera model elements for both the Atom extension and the Open Search Description document (package org.apache.abdera.ext.opensearch.model).
* Metadata (*Info) classes for representing the Open Search server model (package org.apache.abdera.ext.opensearch.server).
* Adapter interface to implement for actually handling search urls (package org.apache.abdera.ext.opensearch.server).
* Two new target types (package org.apache.abdera.ext.opensearch.server.processors).
* Two new request processors for handling requests to the Open Search description document and the Open Search urls (package org.apache.abdera.ext.opensearch.server.processors). 

Added:
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/IntegerElement.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchDescription.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchExtensionFactory.java
      - copied, changed from r680738, incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Query.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/StringElement.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Url.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchQueryInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlAdapter.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlParameterInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapter.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchQueryInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlParameterInfo.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessor.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchTargetTypes.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchUrlRequestProcessor.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/OpenSearchAtomTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/model/OpenSearchDescriptionTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/AbstractOpenSearchServerTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/JettyServer.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapterTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/impl/SimpleOpenSearchInfoTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessorTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/server/processors/OpenSearchUrlRequestProcessorTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/resources/atomResponse.xml
    incubator/abdera/java/trunk/extensions/opensearch/src/test/resources/opensearchDescription.xml
Removed:
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/IntegerElement.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/Query.java
Modified:
    incubator/abdera/java/trunk/extensions/opensearch/pom.xml
    incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java
    incubator/abdera/java/trunk/extensions/opensearch/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/OpenSearchTest.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/java/org/apache/abdera/test/ext/opensearch/TestSuite.java
    incubator/abdera/java/trunk/extensions/opensearch/src/test/resources/opensearch.xml

Modified: incubator/abdera/java/trunk/extensions/opensearch/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/pom.xml?rev=680749&r1=680748&r2=680749&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/pom.xml (original)
+++ incubator/abdera/java/trunk/extensions/opensearch/pom.xml Tue Jul 29 09:07:28 2008
@@ -14,33 +14,55 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <parent>
-    <groupId>org.apache.abdera</groupId>
-    <artifactId>abdera</artifactId>
-    <version>0.5.0-incubating-SNAPSHOT</version>
-  </parent>  
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>abdera-extensions-opensearch</artifactId>
-  <packaging>jar</packaging>
-  <name>Abdera Extensions - OpenSearch</name>
-  <version>0.5.0-incubating-SNAPSHOT</version>
-  <description>Atom Specification Extensions - OpenSearch</description>
-  
-  <properties>
-    <topDir>${basedir}/../..</topDir>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.abdera</groupId>
-      <artifactId>abdera-client</artifactId>
-      <version>0.5.0-incubating-SNAPSHOT</version>
-      <scope>compile</scope>
-    </dependency>  
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-  </dependencies>
-</project>
\ No newline at end of file
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.abdera</groupId>
+        <artifactId>abdera</artifactId>
+        <version>0.5.0-incubating-SNAPSHOT</version>
+    </parent>  
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>abdera-extensions-opensearch</artifactId>
+    <packaging>jar</packaging>
+    <name>Abdera Extensions - OpenSearch</name>
+    <version>0.5.0-incubating-SNAPSHOT</version>
+    <description>Atom Specification Extensions - OpenSearch</description>
+    <properties>
+        <topDir>${basedir}/../..</topDir>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.abdera</groupId>
+            <artifactId>abdera-client</artifactId>
+            <version>0.5.0-incubating-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.abdera</groupId>
+            <artifactId>abdera-server</artifactId>
+            <version>0.5.0-incubating-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <version>2.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+            <version>1.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <version>6.1.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Modified: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java?rev=680749&r1=680748&r2=680749&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java (original)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchConstants.java Tue Jul 29 09:07:28 2008
@@ -1,44 +1,62 @@
 /*
-* 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.
-*/
+ * 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.abdera.ext.opensearch;
 
 import javax.xml.namespace.QName;
 
+/**
+ * Simple container of Open Search XML model constants. 
+ */
 public interface OpenSearchConstants {
 
-  public static final String OPENSEARCH_V10_NS = "http://a9.com/-/spec/opensearchrss/1.0/";
-  public static final String OPENSEARCH_NS = "http://a9.com/-/spec/opensearch/1.1/";
-
-  public static final String TOTAL_RESULTS_LN  = "totalResults";
-  public static final String ITEMS_PER_PAGE_LN = "itemsPerPage";
-  public static final String START_INDEX_LN    = "startIndex";
-  public static final String QUERY_LN          = "Query";
-
-  public static final String OS_PREFIX = "os";
-  
-  public static final QName TOTAL_RESULTS_V10  = new QName(OPENSEARCH_V10_NS, TOTAL_RESULTS_LN);
-  public static final QName ITEMS_PER_PAGE_V10 = new QName(OPENSEARCH_V10_NS, ITEMS_PER_PAGE_LN);
-  public static final QName START_INDEX_V10    = new QName(OPENSEARCH_V10_NS, START_INDEX_LN);
-  public static final QName QUERY_V10          = new QName(OPENSEARCH_V10_NS, QUERY_LN, OS_PREFIX);
-  
-  public static final QName TOTAL_RESULTS  = new QName(OPENSEARCH_NS, TOTAL_RESULTS_LN, OS_PREFIX);
-  public static final QName ITEMS_PER_PAGE = new QName(OPENSEARCH_NS, ITEMS_PER_PAGE_LN, OS_PREFIX);
-  public static final QName START_INDEX    = new QName(OPENSEARCH_NS, START_INDEX_LN, OS_PREFIX);
-  public static final QName QUERY          = new QName(OPENSEARCH_NS, QUERY_LN, OS_PREFIX);
-
+    public static final String OPENSEARCH_DESCRIPTION_CONTENT_TYPE = "application/opensearchdescription+xml";
+    public static final String OPENSEARCH_NS = "http://a9.com/-/spec/opensearch/1.1/";
+    public static final String OS_PREFIX = "os";
+    public static final String TOTAL_RESULTS_LN = "totalResults";
+    public static final String ITEMS_PER_PAGE_LN = "itemsPerPage";
+    public static final String START_INDEX_LN = "startIndex";
+    public static final String QUERY_LN = "Query";
+    public static final String QUERY_ROLE_LN = "role";
+    public static final String QUERY_TITLE_LN = "title";
+    public static final String QUERY_TOTALRESULTS_LN = "totalResult";
+    public static final String QUERY_SEARCHTERMS_LN = "searchTerms";
+    public static final String QUERY_COUNT_LN = "count";
+    public static final String QUERY_STARTINDEX_LN = "startIndex";
+    public static final String QUERY_STARTPAGE_LN = "startPage";
+    public static final String QUERY_LANGUAGE_LN = "language";
+    public static final String QUERY_INPUTENCODING_LN = "inputEncoding";
+    public static final String QUERY_OUTPUTENCODING_LN = "outputEncoding";
+    public static final QName TOTAL_RESULTS = new QName(OPENSEARCH_NS, TOTAL_RESULTS_LN, OS_PREFIX);
+    public static final QName ITEMS_PER_PAGE = new QName(OPENSEARCH_NS, ITEMS_PER_PAGE_LN, OS_PREFIX);
+    public static final QName START_INDEX = new QName(OPENSEARCH_NS, START_INDEX_LN, OS_PREFIX);
+    public static final QName QUERY = new QName(OPENSEARCH_NS, QUERY_LN, OS_PREFIX);
+    public static final String OPENSEARCH_DESCRIPTION_LN = "OpenSearchDescription";
+    public static final String DESCRIPTION_LN = "Description";
+    public static final String SHORT_NAME_LN = "ShortName";
+    public static final String TAGS_LN = "Tags";
+    public static final String URL_LN = "Url";
+    public static final String URL_TYPE_LN = "type";
+    public static final String URL_TEMPLATE_LN = "template";
+    public static final String URL_INDEXOFFSET_LN = "indexOffset";
+    public static final String URL_PAGEOFFSET_LN = "pageOffset";
+    public static final QName OPENSEARCH_DESCRIPTION = new QName(OPENSEARCH_NS, OPENSEARCH_DESCRIPTION_LN, OS_PREFIX);
+    public static final QName DESCRIPTION = new QName(OPENSEARCH_NS, DESCRIPTION_LN, OS_PREFIX);
+    public static final QName SHORT_NAME = new QName(OPENSEARCH_NS, SHORT_NAME_LN, OS_PREFIX);
+    public static final QName TAGS = new QName(OPENSEARCH_NS, TAGS_LN, OS_PREFIX);
+    public static final QName URL = new QName(OPENSEARCH_NS, URL_LN, OS_PREFIX);
 }

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/IntegerElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/IntegerElement.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/IntegerElement.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/IntegerElement.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.ext.opensearch.model;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+/**
+ * A generic integer element.
+ */
+public class IntegerElement extends ElementWrapper {
+
+    public IntegerElement(Factory factory, QName qname) {
+        super(factory, qname);
+    }
+    
+    public IntegerElement(Element internal) {
+        super(internal);
+    }
+
+    public int getValue() {
+        String val = getText();
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+
+    public void setValue(int value) {
+        this.setText(String.valueOf(value));
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchDescription.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchDescription.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchDescription.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchDescription.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,119 @@
+/*
+ * 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.abdera.ext.opensearch.model;
+
+import java.util.List;
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import javax.xml.namespace.QName;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+
+/**
+ * Open Search 1.1 Description Document element: used to describe the web interface of an Open Search based search engine.<br>
+ * Currently, this supports only a subset of the Open Search 1.1 Description Document element specification.
+ */
+public class OpenSearchDescription extends ExtensibleElementWrapper {
+
+    public OpenSearchDescription(Factory factory) {
+        super(factory, OpenSearchConstants.OPENSEARCH_DESCRIPTION);
+    }
+
+    public OpenSearchDescription(Abdera abdera) {
+        this(abdera.getFactory());
+    }
+    
+    public OpenSearchDescription(Element internal) {
+        super(internal);
+    }
+
+    public void setShortName(String shortName) {
+        if (shortName == null) {
+            shortName = "";
+        }
+        this.setExtensionStringValue(OpenSearchConstants.SHORT_NAME, shortName);
+    }
+    
+    public String getShortName() {
+        StringElement element = this.getExtension(OpenSearchConstants.SHORT_NAME);
+        return element.getValue();
+    }
+    
+    public void setDescription(String description) {
+        if (description == null) {
+            description = "";
+        }
+        this.setExtensionStringValue(OpenSearchConstants.DESCRIPTION, description);
+    }
+    
+    public String getDescription() {
+        StringElement element = this.getExtension(OpenSearchConstants.DESCRIPTION);
+        return element.getValue();
+    }
+
+    public void setTags(String... tags) {
+        if (tags.length > 0) {
+            StringBuilder builder = new StringBuilder();
+            for (int i = 0; i < tags.length - 1; i++) {
+                builder.append(tags[i]).append(" ");
+            }
+            builder.append(tags[tags.length - 1]);
+            this.setExtensionStringValue(OpenSearchConstants.TAGS, builder.toString());
+        } else {
+            this.setExtensionStringValue(OpenSearchConstants.TAGS, "");
+        }
+    }
+    
+    public String getTags() {
+        StringElement element = this.getExtension(OpenSearchConstants.TAGS);
+        return element.getValue();
+    }
+    
+    public void addUrls(Url... urls) {
+        if (urls.length > 0) {
+            for (Url url : urls) {
+                this.addExtension(url);
+            }
+        }
+    }
+
+    public List<Url> getUrls() {
+        return this.getExtensions(OpenSearchConstants.URL);
+    }
+    
+    public void addQueries(Query... queries) {
+        if (queries.length > 0) {
+            for (Query query : queries) {
+                this.addExtension(query);
+            }
+        }
+    }
+    
+    public List<Query> getQueries() {
+        return this.getExtensions(OpenSearchConstants.QUERY);
+    }
+
+    private void setExtensionStringValue(QName extension, String value) {
+        StringElement element = this.getExtension(extension);
+        if (element == null) {
+            element = this.addExtension(extension);
+        }
+        element.setValue(value);
+    }
+}

Copied: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchExtensionFactory.java (from r680738, incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchExtensionFactory.java?p2=incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchExtensionFactory.java&p1=incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java&r1=680738&r2=680749&rev=680749&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/OpenSearchExtensionFactory.java (original)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/OpenSearchExtensionFactory.java Tue Jul 29 09:07:28 2008
@@ -1,40 +1,37 @@
 /*
-* 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.abdera.ext.opensearch;
+ * 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.abdera.ext.opensearch.model;
 
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
 import org.apache.abdera.util.AbstractExtensionFactory;
 
-public final class OpenSearchExtensionFactory 
-  extends AbstractExtensionFactory
-  implements OpenSearchConstants {
+public final class OpenSearchExtensionFactory extends AbstractExtensionFactory implements OpenSearchConstants {
 
-  public OpenSearchExtensionFactory() {
-    super(
-      OpenSearchConstants.OPENSEARCH_NS, 
-      OpenSearchConstants.OPENSEARCH_V10_NS);
-    addImpl(QUERY,Query.class);
-    addImpl(QUERY_V10,Query.class);
-    addImpl(ITEMS_PER_PAGE, IntegerElement.class);
-    addImpl(START_INDEX, IntegerElement.class);
-    addImpl(TOTAL_RESULTS, IntegerElement.class);
-    addImpl(ITEMS_PER_PAGE_V10, IntegerElement.class);
-    addImpl(START_INDEX_V10, IntegerElement.class);
-    addImpl(TOTAL_RESULTS_V10, IntegerElement.class);
-  }
-  
+    public OpenSearchExtensionFactory() {
+        super(OpenSearchConstants.OPENSEARCH_NS);
+        this.addImpl(QUERY, Query.class);
+        this.addImpl(ITEMS_PER_PAGE, IntegerElement.class);
+        this.addImpl(START_INDEX, IntegerElement.class);
+        this.addImpl(TOTAL_RESULTS, IntegerElement.class);
+        this.addImpl(OPENSEARCH_DESCRIPTION, OpenSearchDescription.class);
+        this.addImpl(SHORT_NAME, StringElement.class);
+        this.addImpl(DESCRIPTION, StringElement.class);
+        this.addImpl(TAGS, StringElement.class);
+        this.addImpl(URL, Url.class);
+    }
 }

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Query.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Query.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Query.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Query.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,189 @@
+/*
+ * 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.abdera.ext.opensearch.model;
+
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+
+/**
+ * Open Search 1.1 Query element: defines a search query that can be performed by search clients.<br>
+ * This supports all parts of the Open Search 1.1 Url specification.
+ */
+public class Query extends ExtensibleElementWrapper {
+    
+    public Query(Factory factory) {
+        super(factory, OpenSearchConstants.QUERY);
+    }
+    
+    public Query(Abdera abdera) {
+        this(abdera.getFactory());
+    }
+    
+    public Query(Element internal) {
+        super(internal);
+    }
+
+    public Role getRole() {
+        String role = this.getAttributeValue(OpenSearchConstants.QUERY_ROLE_LN);
+        if (role == null) {
+            return null;
+        }
+        try {
+            return Role.valueOf(role.toUpperCase());
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    public void setRole(Role role) {
+        if (role != null) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_ROLE_LN, role.name().toLowerCase());
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_ROLE_LN);
+        }
+    }
+
+    public String getTitle() {
+        return this.getAttributeValue(OpenSearchConstants.QUERY_TITLE_LN);
+    }
+
+    public void setTitle(String title) {
+        if (title != null) {
+            if (title.length() > 256) {
+                throw new IllegalArgumentException("Title too long (max 256 characters)");
+            }
+            this.setAttributeValue(OpenSearchConstants.QUERY_TITLE_LN, title);
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_TITLE_LN);
+        }
+    }
+
+    public int getTotalResults() {
+        String val = this.getAttributeValue(OpenSearchConstants.QUERY_TOTALRESULTS_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+
+    public void setTotalResults(int totalResults) {
+        if (totalResults > -1) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_TOTALRESULTS_LN, String.valueOf(totalResults));
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_TOTALRESULTS_LN);
+        }
+    }
+
+    public String getSearchTerms() {
+        return this.getAttributeValue(OpenSearchConstants.QUERY_SEARCHTERMS_LN);
+    }
+
+    public void setSearchTerms(String terms) {
+        if (terms != null) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_SEARCHTERMS_LN, terms);
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_SEARCHTERMS_LN);
+        }
+    }
+
+    public int getCount() {
+        String val = this.getAttributeValue(OpenSearchConstants.QUERY_COUNT_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+
+    public void setCount(int count) {
+        if (count > -1) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_COUNT_LN, String.valueOf(count));
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_COUNT_LN);
+        }
+    }
+
+    public int getStartIndex() {
+        String val = this.getAttributeValue(OpenSearchConstants.QUERY_STARTINDEX_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+
+    public void setStartIndex(int startIndex) {
+        if (startIndex > -1) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_STARTINDEX_LN, String.valueOf(startIndex));
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_STARTINDEX_LN);
+        }
+    }
+
+    public int getStartPage() {
+        String val = this.getAttributeValue(OpenSearchConstants.QUERY_STARTPAGE_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+
+    public void setStartPage(int startPage) {
+        if (startPage > -1) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_STARTPAGE_LN, String.valueOf(startPage));
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_STARTPAGE_LN);
+        }
+    }
+
+    public String getResultsLanguage() {
+        return this.getAttributeValue(OpenSearchConstants.QUERY_LANGUAGE_LN);
+    }
+
+    public void setResultsLanguage(String language) {
+        if (language != null) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_LANGUAGE_LN, language);
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_LANGUAGE_LN);
+        }
+    }
+
+    public String getInputEncoding() {
+        return this.getAttributeValue(OpenSearchConstants.QUERY_INPUTENCODING_LN);
+    }
+
+    public void setInputEncoding(String encoding) {
+        if (encoding != null) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_INPUTENCODING_LN, encoding);
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_INPUTENCODING_LN);
+        }
+    }
+
+    public String getOutputEncoding() {
+        return this.getAttributeValue(OpenSearchConstants.QUERY_OUTPUTENCODING_LN);
+    }
+
+    public void setOutputEncoding(String encoding) {
+        if (encoding != null) {
+            this.setAttributeValue(OpenSearchConstants.QUERY_OUTPUTENCODING_LN, encoding);
+        } else {
+            this.removeAttribute(OpenSearchConstants.QUERY_OUTPUTENCODING_LN);
+        }
+    }
+    
+    public enum Role {
+
+        CORRECTION,
+        EXAMPLE,
+        RELATED,
+        REQUEST,
+        SUBSET,
+        SUPERSET;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/StringElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/StringElement.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/StringElement.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/StringElement.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.ext.opensearch.model;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+/**
+ * A generic string element.
+ */
+public class StringElement extends ElementWrapper {
+
+    public StringElement(Factory factory, QName qname) {
+        super(factory, qname);
+    }
+    
+    public StringElement(Element internal) {
+        super(internal);
+    }
+
+    public String getValue() {
+        String value = this.getText();
+        return (value != null) ? value : "";
+    }
+
+    public void setValue(String value) {
+        this.setText(value);
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Url.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Url.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Url.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/model/Url.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,96 @@
+/*
+ * 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.abdera.ext.opensearch.model;
+
+
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+/**
+ * Open Search 1.1 Url element: describes an interface by which a search client can make search requests.<br>
+ * This supports all parts of the Open Search 1.1 Url specification.
+ */
+public class Url extends ElementWrapper {
+
+    public Url(Factory factory) {
+        super(factory, OpenSearchConstants.URL);
+        this.setAttributeValue(OpenSearchConstants.URL_INDEXOFFSET_LN, Integer.valueOf(1).toString());
+        this.setAttributeValue(OpenSearchConstants.URL_PAGEOFFSET_LN, Integer.valueOf(1).toString());
+    }
+
+    public Url(Abdera abdera) {
+        this(abdera.getFactory());
+    }
+    
+    public Url(Element internal) {
+        super(internal);
+    }
+
+    public void setType(String type) {
+        if (type != null) {
+            this.setAttributeValue(OpenSearchConstants.URL_TYPE_LN, type);
+        } else {
+            this.removeAttribute(OpenSearchConstants.URL_TYPE_LN);
+        }
+    }
+
+    public String getType() {
+        return this.getAttributeValue(OpenSearchConstants.URL_TYPE_LN);
+    }
+    
+    public void setTemplate(String template) {
+        if (template != null) {
+            this.setAttributeValue(OpenSearchConstants.URL_TEMPLATE_LN, template);
+        } else {
+            this.removeAttribute(OpenSearchConstants.URL_TEMPLATE_LN);
+        }
+    }
+    
+    public String getTemplate() {
+        return this.getAttributeValue(OpenSearchConstants.URL_TEMPLATE_LN);
+    }
+    
+    public void setIndexOffset(int offset) {
+        if (offset > -1) {
+            this.setAttributeValue(OpenSearchConstants.URL_INDEXOFFSET_LN, String.valueOf(offset));
+        } else {
+            this.removeAttribute(OpenSearchConstants.URL_INDEXOFFSET_LN);
+        }
+    }
+    
+    public int getIndexOffset() {
+        String val = this.getAttributeValue(OpenSearchConstants.URL_INDEXOFFSET_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+    
+    public void setPageOffset(int offset) {
+        if (offset > -1) {
+            this.setAttributeValue(OpenSearchConstants.URL_PAGEOFFSET_LN, String.valueOf(offset));
+        } else {
+            this.removeAttribute(OpenSearchConstants.URL_PAGEOFFSET_LN);
+        }
+    }
+    
+    public int getPageOffset() {
+        String val = this.getAttributeValue(OpenSearchConstants.URL_PAGEOFFSET_LN);
+        return (val != null) ? Integer.parseInt(val) : -1;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchInfo.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,57 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.opensearch.server;
+
+import org.apache.abdera.ext.opensearch.model.OpenSearchDescription;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Metadata interface holding information about the Open Search Description document.
+ */
+public interface OpenSearchInfo {
+    
+    /**
+     * Get the Open Search document short name.
+     */
+    String getShortName();
+    
+    /**
+     * Get the Open Search document description.
+     */
+    String getDescription();
+    
+    /**
+     * Get the Open Search document tags.
+     */
+    String[] getTags();
+    
+    /**
+     * Get the Open Search queries.
+     */
+    OpenSearchQueryInfo[] getQueries();
+    
+    /**
+     * Get the Open Search URLs metadata.
+     */
+    OpenSearchUrlInfo[] getUrls();
+    
+    /**
+     * Create the related {@link org.apache.abdera.ext.opensearch.model.OpenSearchDescription} element.
+     */
+    OpenSearchDescription asOpenSearchDescriptionElement(RequestContext request);
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchQueryInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchQueryInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchQueryInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchQueryInfo.java Tue Jul 29 09:07:28 2008
@@ -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.abdera.ext.opensearch.server;
+
+import org.apache.abdera.ext.opensearch.model.Query;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Metadata interface holding (limited) information about the Open Search query element.
+ */
+public interface OpenSearchQueryInfo {
+
+    /**
+     * Get the query role type.
+     */
+    Query.Role getRole();
+    
+    /**
+     * Get the query search terms.
+     */
+    String getSearchTerms();
+    
+    /**
+     * Create the related {@link org.apache.abdera.ext.opensearch.model.Query} element.
+     */
+    Query asQueryElement(RequestContext request);
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlAdapter.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlAdapter.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlAdapter.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.abdera.ext.opensearch.server;
+
+import java.util.Map;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+
+/**
+ * The OpenSearchUrlAdapter interface provides the business logic for executing search operations
+ * and getting back Atom-based responses augmented with Open Search metadata.
+ */
+public interface OpenSearchUrlAdapter {
+
+    /**
+     * Make the actual search operation based on passed parameters.
+     * @param request The {@link org.apache.abdera.protocol.server.RequestContext} object.
+     * @param parameters Search parameters extracted from the request: 
+     * they are the same parameters reported into the Open Search URL template.
+     */
+    ResponseContext search(RequestContext request, Map<String, String> parameters);
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlInfo.java Tue Jul 29 09:07:28 2008
@@ -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.abdera.ext.opensearch.server;
+
+import org.apache.abdera.ext.opensearch.model.Url;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Metadata interface holding information about the Open Search URLs.
+ */
+public interface OpenSearchUrlInfo {
+
+    /**
+     * Get the URL content type.
+     */
+    String getType();
+    
+    /**
+     * Get the URL search path as appear after the servlet context path, and without the query string.
+     */
+    String getSearchPath();
+    
+    /**
+     * Get the URL search parameters.
+     */
+    OpenSearchUrlParameterInfo[] getSearchParameters();
+    
+    /**
+     * Get the {@link OpenSearchUrlAdapter} which will implement the actual search operation.
+     */
+    OpenSearchUrlAdapter getOpenSearchUrlAdapter();
+    
+    /**
+     * Create the related {@link org.apache.abdera.ext.opensearch.model.Url} element.
+     */
+    Url asUrlElement(RequestContext request);
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlParameterInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlParameterInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlParameterInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/OpenSearchUrlParameterInfo.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,39 @@
+/*
+* 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.abdera.ext.opensearch.server;
+
+/**
+ * Metadata interface holding information about an Open Search URL parameter.
+ */
+public interface OpenSearchUrlParameterInfo {
+    
+    /**
+     * Get the parameter name.
+     */
+    String getName();
+    
+    /**
+     * Get the parameter value.
+     */
+    String getValue();
+    
+    /**
+     * Return true if the parameter is optional, false otherwise.
+     */
+    boolean isOptional();
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapter.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapter.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/AbstractOpenSearchUrlAdapter.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,148 @@
+/*
+ * 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.abdera.ext.opensearch.server.impl;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.ext.opensearch.model.IntegerElement;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Person;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+
+/**
+ * Abstract {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter}
+ * providing explicit methods to implement and/or override for executing the actual search and
+ * creating the Atom feed containing search results.
+ * 
+ * @param <T> The generic object type representing a search result.
+ */
+public abstract class AbstractOpenSearchUrlAdapter<T> implements OpenSearchUrlAdapter {
+
+    public ResponseContext search(RequestContext request, Map<String, String> parameters) {
+        List<T> searchResults = this.doSearch(request, parameters);
+        Feed feed = this.createFeed(request, parameters, searchResults);
+        Document<Feed> document = feed.getDocument();
+        ResponseContext response = new BaseResponseContext<Document<Feed>>(document);
+        return response;
+    }
+
+    /**
+     * Get the identifier of the feed containing this search results.
+     */
+    protected abstract String getOpenSearchFeedId(RequestContext request);
+
+    /**
+     * Get the title of the feed containing this search results.
+     */
+    protected abstract String getOpenSearchFeedTitle(RequestContext request);
+
+    /**
+     * Get the author of the feed containing this search results.
+     */
+    protected abstract Person getOpenSearchFeedAuthor(RequestContext request);
+
+    /**
+     * Get the update date of the feed containing this search results.
+     */
+    protected abstract Date getOpenSearchFeedUpdatedDate(RequestContext request);
+    
+    /**
+     * Do the actual search, returning a list of search results as generic objects.
+     */
+    protected abstract List<T> doSearch(RequestContext request, Map<String, String> parameters);
+    
+    /**
+     * Fill the given empty Atom entry from the given search result object.<br>
+     * This method is called once for every search result returned by the {#doSearch(RequestContext, Map<String, String>)} method.
+     */
+    protected abstract void fillEntry(Entry entry, T entity);
+    
+    /**
+     * Get the total number of results of this search.<br>
+     * By default, it's equal to the number of search results: override to provide a different behavior.<br>
+     * This element can be explicitly omitted from the feed by returning a negative value.
+     */
+    protected int getOpenSearchFeedTotalResults(RequestContext request, Map<String, String> parameters, List<T> searchResults) {
+        return searchResults.size();
+    }
+    
+    /**
+     * Get the number of items (entries) contained into this page (feed).<br>
+     * By default, it's equal to the number of search results: override to provide a different behavior.<br>
+     * This element can be explicitly omitted from the feed by returning a negative value.
+     */
+    protected int getOpenSearchFeedItemsPerPage(RequestContext request, Map<String, String> parameters, List<T> searchResults) {
+        return searchResults.size();
+    }
+
+    /**
+     * Get the index number of the first result contained into this feed.<br>
+     * By default, this element is omitted: override to provide a different behavior.<br>
+     * This element can be explicitly omitted from the feed by returning a negative value.
+     */
+    protected int getOpenSearchFeedStartIndex(RequestContext request, Map<String, String> parameters, List<T> searchResults) {
+        return -1;
+    }
+    
+    /**
+     * Post process this feed in order to make custom modifications.<br>
+     * By default, this method does nothing: override to provide a different behavior.
+     */
+    protected void postProcess(Feed feed, RequestContext request, Map<String, String> parameters, List<T> searchResults) {
+    }
+
+    private Feed createFeed(RequestContext searchRequest, Map<String, String> parameters, List<T> searchResults) {
+        Factory factory = searchRequest.getAbdera().getFactory();
+        Feed feed = factory.newFeed();
+        feed.setId(this.getOpenSearchFeedId(searchRequest));
+        feed.setTitle(this.getOpenSearchFeedTitle(searchRequest));
+        feed.addAuthor(this.getOpenSearchFeedAuthor(searchRequest));
+        feed.setUpdated(this.getOpenSearchFeedUpdatedDate(searchRequest));
+        feed.addLink(searchRequest.getUri().toString(), "self");
+        int totalResults = this.getOpenSearchFeedTotalResults(searchRequest, parameters, searchResults);
+        if (totalResults > -1) {
+        ((IntegerElement) feed.addExtension(OpenSearchConstants.TOTAL_RESULTS))
+                .setValue(totalResults);
+        }
+        int itemsPerPage = this.getOpenSearchFeedItemsPerPage(searchRequest, parameters, searchResults);
+        if (itemsPerPage > -1) {
+        ((IntegerElement) feed.addExtension(OpenSearchConstants.ITEMS_PER_PAGE))
+                .setValue(itemsPerPage);
+        }
+        int startIndex = this.getOpenSearchFeedStartIndex(searchRequest, parameters, searchResults);
+        if (startIndex > -1) {
+        ((IntegerElement) feed.addExtension(OpenSearchConstants.START_INDEX))
+                .setValue(startIndex);
+        }
+        for (T entity : searchResults) {
+            Entry entry = factory.newEntry();
+            this.fillEntry(entry, entity);
+            feed.addEntry(entry);
+        }
+        this.postProcess(feed, searchRequest, parameters, searchResults);
+        return feed;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchInfo.java Tue Jul 29 09:07:28 2008
@@ -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.abdera.ext.opensearch.server.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.abdera.ext.opensearch.model.OpenSearchDescription;
+import org.apache.abdera.ext.opensearch.model.Query;
+import org.apache.abdera.ext.opensearch.model.Url;
+import org.apache.abdera.ext.opensearch.server.OpenSearchInfo;
+import org.apache.abdera.ext.opensearch.server.OpenSearchQueryInfo;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlInfo;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Simple {@link org.apache.abdera.ext.opensearch.server.OpenSearchInfo} implementation.
+ */
+public class SimpleOpenSearchInfo implements OpenSearchInfo {
+
+    private String shortName;
+    private String description;
+    private String[] tags;
+    private OpenSearchQueryInfo[] queries;
+    private OpenSearchUrlInfo[] urls;
+
+    public String getShortName() {
+        return this.shortName;
+    }
+
+    public void setShortName(String shortName) {
+        this.shortName = shortName;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String[] getTags() {
+        return this.tags;
+    }
+
+    public void setTags(String... tags) {
+        this.tags = tags;
+    }
+
+    public OpenSearchQueryInfo[] getQueries() {
+        return this.queries;
+    }
+
+    public void setQueries(OpenSearchQueryInfo... queries) {
+        this.queries = queries;
+    }
+
+    public OpenSearchUrlInfo[] getUrls() {
+        return this.urls;
+    }
+
+    public void setUrls(OpenSearchUrlInfo... urls) {
+        this.urls = urls;
+    }
+
+    public OpenSearchDescription asOpenSearchDescriptionElement(RequestContext request) {
+        OpenSearchDescription document = new OpenSearchDescription(request.getAbdera());
+        document.setShortName(this.shortName);
+        document.setDescription(this.description);
+        document.setTags(this.tags);
+
+        if (this.urls != null) {
+            List<Url> urlElements = new ArrayList<Url>(this.urls.length);
+            for (OpenSearchUrlInfo urlInfo : this.urls) {
+                urlElements.add(urlInfo.asUrlElement(request));
+            }
+            document.addUrls(urlElements.toArray(new Url[this.urls.length]));
+        }
+
+        if (this.queries != null) {
+            List<Query> queryElements = new ArrayList<Query>(this.queries.length);
+            for (OpenSearchQueryInfo queryInfo : this.queries) {
+                queryElements.add(queryInfo.asQueryElement(request));
+            }
+            document.addQueries(queryElements.toArray(new Query[this.queries.length]));
+        }
+
+        return document;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchQueryInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchQueryInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchQueryInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchQueryInfo.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.abdera.ext.opensearch.server.impl;
+
+import org.apache.abdera.ext.opensearch.model.Query;
+import org.apache.abdera.ext.opensearch.model.Query.Role;
+import org.apache.abdera.ext.opensearch.server.OpenSearchQueryInfo;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Simple {@link org.apache.abdera.ext.opensearch.server.OpenSearchQueryInfo} implementation.
+ */
+public class SimpleOpenSearchQueryInfo implements OpenSearchQueryInfo {
+
+    private Query.Role role;
+    private String searchTerms;
+
+    public void setRole(Role role) {
+        this.role = role;
+    }
+
+    public Query.Role getRole() {
+        return this.role;
+    }
+
+    public void setSearchTerms(String searchTerms) {
+        this.searchTerms = searchTerms;
+    }
+
+    public String getSearchTerms() {
+        return this.searchTerms;
+    }
+
+    public Query asQueryElement(RequestContext request) {
+        Query query = new Query(request.getAbdera());
+        query.setRole(this.role);
+        query.setSearchTerms(this.searchTerms);
+        return query;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlInfo.java Tue Jul 29 09:07:28 2008
@@ -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.abdera.ext.opensearch.server.impl;
+
+import org.apache.abdera.ext.opensearch.model.Url;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlInfo;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlParameterInfo;
+import org.apache.abdera.protocol.server.RequestContext;
+
+/**
+ * Simple {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlInfo} implementation.
+ */
+public class SimpleOpenSearchUrlInfo implements OpenSearchUrlInfo {
+
+    private static final String ATOM_CONTENT_TYPE = "application/atom+xml";
+    private String searchPath;
+    private OpenSearchUrlParameterInfo[] searchParameters;
+    private OpenSearchUrlAdapter openSearchUrlAdapter;
+
+    public String getType() {
+        return ATOM_CONTENT_TYPE;
+    }
+
+    public String getSearchPath() {
+        return this.searchPath;
+    }
+
+    public void setSearchPath(String searchPath) {
+        this.searchPath = searchPath;
+    }
+
+    public OpenSearchUrlParameterInfo[] getSearchParameters() {
+        return this.searchParameters;
+    }
+
+    public void setSearchParameters(OpenSearchUrlParameterInfo... searchParameters) {
+        this.searchParameters = searchParameters;
+    }
+
+    public OpenSearchUrlAdapter getOpenSearchUrlAdapter() {
+        return this.openSearchUrlAdapter;
+    }
+
+    public void setOpenSearchUrlAdapter(OpenSearchUrlAdapter openSearchUrlAdapter) {
+        this.openSearchUrlAdapter = openSearchUrlAdapter;
+    }
+
+    public Url asUrlElement(RequestContext request) {
+        Url element = new Url(request.getAbdera());
+        element.setType(ATOM_CONTENT_TYPE);
+
+        StringBuilder template = new StringBuilder();
+        template.append(this.getTemplateUrl(request));
+        if (this.searchParameters != null) {
+            template.append("?");
+            for (int i = 0; i < this.searchParameters.length; i++) {
+                OpenSearchUrlParameterInfo param = this.searchParameters[i];
+                template.append(param.getName()).append("=").append("{").append(param.getValue());
+                if (param.isOptional()) {
+                    template.append("?");
+                }
+                template.append("}");
+                if (i < this.searchParameters.length - 1) {
+                    template.append("&");
+                }
+            }
+        }
+        element.setTemplate(template.toString());
+
+        return element;
+    }
+
+    private String getTemplateUrl(RequestContext request) {
+        String base = request.getBaseUri().toString();
+        String path = this.searchPath;
+        if (base.endsWith("/")) {
+            base = base.substring(0, base.length() - 1);
+        }
+        if (path.startsWith("/")) {
+            path = path.substring(1);
+        }
+        return base + "/" + path;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlParameterInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlParameterInfo.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlParameterInfo.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/impl/SimpleOpenSearchUrlParameterInfo.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,54 @@
+/*
+* 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.abdera.ext.opensearch.server.impl;
+
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlParameterInfo;
+
+/**
+ * Simple {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlParameterInfo} implementation.
+ */
+public class SimpleOpenSearchUrlParameterInfo implements OpenSearchUrlParameterInfo {
+    
+    private String name;
+    private String value;
+    private boolean optional;
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public boolean isOptional() {
+        return this.optional;
+    }
+
+    public void setOptional(boolean optional) {
+        this.optional = optional;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessor.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessor.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchDescriptionRequestProcessor.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.ext.opensearch.server.processors;
+
+import org.apache.abdera.ext.opensearch.OpenSearchConstants;
+import org.apache.abdera.ext.opensearch.model.OpenSearchDescription;
+import org.apache.abdera.ext.opensearch.server.OpenSearchInfo;
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.RequestProcessor;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+
+/**
+ * {@link org.apache.abdera.protocol.server.RequestProcessor} implementation for processing Open Search Description document
+ * GET requests.<br>
+ * This request processor needs an {@link org.apache.abdera.ext.opensearch.server.OpenSearchInfo} in order to provide
+ * information about the Open Search service.
+ * 
+ * @see {@link #setOpenSearchInfo(OpenSearchInfo)}
+ */
+public class OpenSearchDescriptionRequestProcessor implements RequestProcessor {
+
+    private OpenSearchInfo openSearchInfo;
+
+    public ResponseContext process(RequestContext requestContext, WorkspaceManager workspaceManager, CollectionAdapter collectionAdapter) {
+        String method = requestContext.getMethod();
+        if (method.equalsIgnoreCase("GET")) {
+            OpenSearchDescription description = this.openSearchInfo.asOpenSearchDescriptionElement(requestContext);
+            ResponseContext response = new BaseResponseContext(description);
+            response.setContentType(OpenSearchConstants.OPENSEARCH_DESCRIPTION_CONTENT_TYPE);
+            return response;
+        } else {
+            return null;
+        }
+    }
+
+    public void setOpenSearchInfo(OpenSearchInfo openSearchInfo) {
+        this.openSearchInfo = openSearchInfo;
+    }
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchTargetTypes.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchTargetTypes.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchTargetTypes.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchTargetTypes.java Tue Jul 29 09:07:28 2008
@@ -0,0 +1,12 @@
+package org.apache.abdera.ext.opensearch.server.processors;
+
+import org.apache.abdera.protocol.server.TargetType;
+
+/**
+ * Simple container of {@link org.apache.abdera.protocol.server.TargetType}s related to Open Search.
+ */
+public interface OpenSearchTargetTypes {
+
+    public static final TargetType OPENSEARCH_DESCRIPTION = TargetType.get("OPENSEARCH_DESCRIPTION", true);
+    public static final TargetType OPENSEARCH_URL = TargetType.get("OPENSEARCH_URL", true);
+}

Added: incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchUrlRequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchUrlRequestProcessor.java?rev=680749&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchUrlRequestProcessor.java (added)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/java/org/apache/abdera/ext/opensearch/server/processors/OpenSearchUrlRequestProcessor.java Tue Jul 29 09:07:28 2008
@@ -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.abdera.ext.opensearch.server.processors;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.abdera.ext.opensearch.server.OpenSearchInfo;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlInfo;
+import org.apache.abdera.ext.opensearch.server.OpenSearchUrlParameterInfo;
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.ProviderHelper;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.RequestProcessor;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+
+/**
+ * {@link org.apache.abdera.protocol.server.RequestProcessor} implementation for processing GET requests to Open Search urls
+ * and then delegating the actual search to the proper {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter}.<br>
+ * The proper {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlAdapter} is selected by searching the configured
+ * {@link org.apache.abdera.ext.opensearch.server.OpenSearchInfo} for an {@link org.apache.abdera.ext.opensearch.server.OpenSearchUrlInfo}
+ * with a matching search path.
+ * 
+ * @see {@link #setOpenSearchInfo(OpenSearchInfo)}
+ */
+public class OpenSearchUrlRequestProcessor implements RequestProcessor {
+
+    private OpenSearchInfo openSearchInfo;
+
+    public ResponseContext process(final RequestContext requestContext, final WorkspaceManager workspaceManager, final CollectionAdapter collectionAdapter) {
+        String method = requestContext.getMethod();
+        if (method.equalsIgnoreCase("GET")) {
+            OpenSearchUrlInfo urlInfo = this.getMatchingUrlInfo(requestContext);
+            if (urlInfo != null) {
+                OpenSearchUrlAdapter adapter = urlInfo.getOpenSearchUrlAdapter();
+                if (adapter != null) {
+                    Map<String, String> params = this.getUrlParametersFromRequest(requestContext, urlInfo);
+                    return adapter.search(requestContext, params);
+                } else {
+                    return ProviderHelper.notfound(requestContext);
+                }
+            } else {
+                return ProviderHelper.notfound(requestContext);
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public void setOpenSearchInfo(OpenSearchInfo openSearchInfo) {
+        this.openSearchInfo = openSearchInfo;
+    }
+
+    private OpenSearchUrlInfo getMatchingUrlInfo(RequestContext request) {
+        String targetSearchPath = this.stripSlashes(request.getTargetPath().substring(0, request.getTargetPath().indexOf("?")));
+        OpenSearchUrlInfo result = null;
+        for (OpenSearchUrlInfo urlInfo : this.openSearchInfo.getUrls()) {
+            String searchPath = this.stripSlashes(urlInfo.getSearchPath());
+            if (searchPath.equals(targetSearchPath)) {
+                result = urlInfo;
+                break;
+            }
+        }
+        return result;
+    }
+
+    private Map<String, String> getUrlParametersFromRequest(RequestContext request, OpenSearchUrlInfo urlInfo) {
+        Map<String, String> result = new HashMap<String, String>();
+        for (OpenSearchUrlParameterInfo paramInfo : urlInfo.getSearchParameters()) {
+            // TODO : enforce mandatory parameters?
+            String name = paramInfo.getName();
+            String value = request.getParameter(name);
+            if (value != null) {
+                result.put(name, value);
+            }
+        }
+        return result;
+    }
+
+    private String stripSlashes(String path) {
+        if (path.startsWith("/")) {
+            path = path.substring(1);
+        }
+        if (path.endsWith("/")) {
+            path = path.substring(0, path.length() - 1);
+        }
+        return path;
+    }
+}

Modified: incubator/abdera/java/trunk/extensions/opensearch/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/opensearch/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory?rev=680749&r1=680748&r2=680749&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/opensearch/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory (original)
+++ incubator/abdera/java/trunk/extensions/opensearch/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory Tue Jul 29 09:07:28 2008
@@ -1 +1 @@
-org.apache.abdera.ext.opensearch.OpenSearchExtensionFactory
+org.apache.abdera.ext.opensearch.model.OpenSearchExtensionFactory



Mime
View raw message