You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2008/05/27 07:40:33 UTC

svn commit: r660391 - in /incubator/abdera/trunk/extensions/features: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/abdera/ src/main/java/org/apache/abdera/ext/ src/main/java/org/apache/abdera/ex...

Author: jmsnell
Date: Mon May 26 22:40:25 2008
New Revision: 660391

URL: http://svn.apache.org/viewvc?rev=660391&view=rev
Log:
separate features extension into it's own folder

Added:
    incubator/abdera/trunk/extensions/features/pom.xml
    incubator/abdera/trunk/extensions/features/src/
    incubator/abdera/trunk/extensions/features/src/main/
    incubator/abdera/trunk/extensions/features/src/main/java/
    incubator/abdera/trunk/extensions/features/src/main/java/org/
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AbstractSelector.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AcceptSelector.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Feature.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeatureSelector.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Features.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesExtensionFactory.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesHelper.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Selector.java
    incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/XPathSelector.java

Added: incubator/abdera/trunk/extensions/features/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/pom.xml?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/pom.xml (added)
+++ incubator/abdera/trunk/extensions/features/pom.xml Mon May 26 22:40:25 2008
@@ -0,0 +1,52 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <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-features</artifactId>
+  <packaging>jar</packaging>
+  <name>Abdera Extensions - Features</name>
+  <version>0.5.0-incubating-SNAPSHOT</version>
+  <description>Atom Specification Extensions - Features</description>
+  
+  <properties>
+    <topDir>${basedir}/../..</topDir>
+  </properties>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.5.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>    
+    <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

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AbstractSelector.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AbstractSelector.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AbstractSelector.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AbstractSelector.java Mon May 26 22:40:25 2008
@@ -0,0 +1,36 @@
+/*
+* 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.features;
+
+public abstract class AbstractSelector
+    implements Selector {
+
+  public Selector clone() {
+    try {
+      return (Selector) super.clone();
+    } catch (CloneNotSupportedException e) {
+      return copy();
+    }
+  }
+
+  protected Selector copy() {
+    throw new RuntimeException(
+      new CloneNotSupportedException());
+  }
+  
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AcceptSelector.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AcceptSelector.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AcceptSelector.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/AcceptSelector.java Mon May 26 22:40:25 2008
@@ -0,0 +1,43 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.features;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.model.Collection;
+
+public class AcceptSelector
+    extends AbstractSelector
+    implements Selector {
+
+  private static final long serialVersionUID = -1289924342084041384L;
+  private final List<String> accepts = new ArrayList<String>();
+  
+  public AcceptSelector(String... accepts) {
+    for (String accept : accepts) this.accepts.add(accept);
+  }
+  
+  public boolean select(Collection collection) {
+    for (String accept : accepts) {
+      if (collection.accepts(accept)) return true;
+    }
+    return false;
+  }
+
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Feature.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Feature.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Feature.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Feature.java Mon May 26 22:40:25 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.features;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+import org.apache.abdera.util.MimeTypeHelper;
+
+public class Feature 
+  extends ExtensibleElementWrapper {
+  
+  public Feature(Element internal) {
+    super(internal);
+  }
+  
+  public Feature(Factory factory) {
+    super(factory, FeaturesHelper.FEATURE);
+  }
+  
+  public IRI getRef()  {
+      String ref = getAttributeValue("ref");
+      return (ref != null) ? new IRI(ref) : null;
+  }
+  
+  public IRI getHref()  {
+      String href = getAttributeValue("href");
+      return (href != null) ? new IRI(href) : null;
+  }
+  
+  public String getLabel() {
+    return getAttributeValue("label");
+  }
+  
+  public void setRef(String ref) {
+      if (ref == null) throw new IllegalArgumentException();
+      setAttributeValue("ref", (new IRI(ref)).toString());
+  }
+  
+  public void setHref(String href)  {
+      if (href != null)
+        setAttributeValue("href", (new IRI(href)).toString());
+      else 
+        removeAttribute(new QName("href"));
+  }
+  
+  public void setLabel(String label) {
+    if (label != null)
+      setAttributeValue("label", label);
+    else 
+      removeAttribute(new QName("label"));
+  }
+  
+  
+  public void addType(String mediaRange) {
+    addType(new String[] {mediaRange});
+  }
+  
+  public void addType(String... mediaRanges) {
+    mediaRanges = MimeTypeHelper.condense(mediaRanges);
+    for (String mediaRange : mediaRanges) {
+      try {
+        addSimpleExtension(FeaturesHelper.TYPE, new MimeType(mediaRange).toString());
+      } catch (MimeTypeParseException e) {}
+    }
+  }
+  
+  public String[] getTypes() {
+    List<String> list = new ArrayList<String>();
+    for (Element type : getExtensions(FeaturesHelper.TYPE)) {
+      String value = type.getText();
+      if (value != null) {
+        value = value.trim();
+        try {
+          list.add(new MimeType(value).toString());
+        } catch (MimeTypeParseException e) {}
+      }
+    }
+    return list.toArray(new String[list.size()]);
+  }
+
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeatureSelector.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeatureSelector.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeatureSelector.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeatureSelector.java Mon May 26 22:40:25 2008
@@ -0,0 +1,73 @@
+/*
+* 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.features;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.ext.features.FeaturesHelper.Status;
+import org.apache.abdera.model.Collection;
+
+public class FeatureSelector
+  extends AbstractSelector
+  implements Selector {
+
+  private static final long serialVersionUID = -8943638085557912175L;
+  private final List<String> features = new ArrayList<String>();
+  
+  public FeatureSelector(String... features) {
+    for (String feature : features) this.features.add(feature);
+  }
+  
+  public boolean select(Collection collection) {
+    for (String feature : features) {
+      Status status = FeaturesHelper.getFeatureStatus(collection, feature);
+      if (status == Status.SPECIFIED) return true;
+    }
+    return false;
+  }
+
+  public String[] getFeatures() {
+    return features.toArray(new String[features.size()]);
+  }
+
+  @Override
+  public int hashCode() {
+    final int PRIME = 31;
+    int result = 1;
+    result = PRIME * result + ((features == null) ? 0 : features.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 FeatureSelector other = (FeatureSelector) obj;
+    if (features == null) {
+      if (other.features != null) return false;
+    } else if (!features.equals(other.features)) return false;
+    return true;
+  }
+
+  @Override
+  protected Selector copy() {
+    return new FeatureSelector(getFeatures());
+  }  
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Features.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Features.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Features.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Features.java Mon May 26 22:40:25 2008
@@ -0,0 +1,98 @@
+/*
+* 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.features;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+
+public class Features 
+  extends ExtensibleElementWrapper {
+  
+  public Features(
+    Element internal) {
+      super(internal);
+  }
+  
+  public Features(
+    Factory factory, 
+    QName qname) {
+      super(factory, qname);
+  }
+
+  public IRI getResolvedHref() {
+    IRI base = getResolvedBaseUri();
+    IRI href = getHref();
+    return base != null ? base.resolve(href) : href;
+  }
+  
+  public IRI getHref() {
+    String href = getAttributeValue("href");
+    return href != null ? new IRI(href) : null;
+  }
+  
+  public void setHref(String href) {
+    setAttributeValue("href", (new IRI(href)).toString());
+  }
+  
+  public String getName() {
+    return getAttributeValue("name");
+  }
+  
+  public void setName(String name) {
+    setAttributeValue("name",name);
+  }
+  
+  public void addFeature(Feature feature) {
+    addExtension(feature);
+  }
+  
+  public void addFeature(Feature... features) {
+    for (Feature feature : features) addFeature(feature);
+  }
+  
+  public Feature addFeature(String feature) {
+    Feature f = addExtension(FeaturesHelper.FEATURE);
+    f.setRef(feature);
+    return f;
+  }
+
+  public Feature addFeature(String feature, String href, String label) {
+    Feature f = addExtension(FeaturesHelper.FEATURE);
+    f.setRef(feature);
+    f.setHref(href);
+    f.setLabel(label);
+    return f;
+  }
+  
+  public Feature[] addFeatures(String... features) {
+    List<Feature> list = new ArrayList<Feature>();
+    for (String feature : features) list.add(addFeature(feature));
+    return list.toArray(new Feature[list.size()]);
+  }
+  
+  public List<Feature> getFeatures() {
+    return getExtensions(FeaturesHelper.FEATURE);
+  }
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesExtensionFactory.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesExtensionFactory.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesExtensionFactory.java Mon May 26 22:40:25 2008
@@ -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.abdera.ext.features;
+
+import org.apache.abdera.util.AbstractExtensionFactory;
+
+public final class FeaturesExtensionFactory 
+  extends AbstractExtensionFactory {
+
+  public FeaturesExtensionFactory() {
+    super(FeaturesHelper.FNS);
+    addImpl(FeaturesHelper.FEATURE,Feature.class);
+    addImpl(FeaturesHelper.FEATURES,Features.class);
+  }
+  
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesHelper.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesHelper.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/FeaturesHelper.java Mon May 26 22:40:25 2008
@@ -0,0 +1,366 @@
+/*
+* 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.features;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.protocol.Response.ResponseType;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+
+/**
+ * Implementation of the current APP Features Draft
+ * (http://www.ietf.org/internet-drafts/draft-snell-atompub-feature-08.txt)
+ */
+public final class FeaturesHelper {
+
+  public enum Status {
+    UNSPECIFIED,
+    SPECIFIED 
+  }
+  
+  public static final String FNS = "http://purl.org/atompub/features/1.0";
+  public static final QName FEATURE = new QName(FNS, "feature","f");
+  public static final QName FEATURES = new QName(FNS, "features","f");
+  public static final QName TYPE = new QName(FNS, "type", "f");
+  
+  private static final String FEATURE_BASE                   = "http://www.w3.org/2007/app/";
+  private static final String ABDERA_FEATURE_BASE            = "http://incubator.apache.org/abdera/features/";
+  private static final String BLOG_FEATURE_BASE              = "http://incubator.apache.org/abdera/features/blog/";
+  public static final String FEATURE_SUPPORTS_DRAFTS         = FEATURE_BASE + "supportsDraft";
+  public static final String FEATURE_IGNORES_DRAFTS          = FEATURE_BASE + "ignoresDraft";
+   
+  public static final String FEATURE_SUPPORTS_XHTML_CONTENT  = ABDERA_FEATURE_BASE + "supportsXhtmlContent";
+  public static final String FEATURE_REQUIRES_XHTML_CONTENT  = ABDERA_FEATURE_BASE + "requiresXhtmlContent";
+  public static final String FEATURE_SUPPORTS_HTML_CONTENT   = ABDERA_FEATURE_BASE + "supportsHtmlContent";
+  public static final String FEATURE_REQUIRES_HTML_CONTENT   = ABDERA_FEATURE_BASE + "requiresHtmlContent";
+  public static final String FEATURE_SUPPORTS_TEXT_CONTENT   = ABDERA_FEATURE_BASE + "supportsTextContent";
+  public static final String FEATURE_REQUIRES_TEXT_CONTENT   = ABDERA_FEATURE_BASE + "requiresTextContent";
+  public static final String FEATURE_SUPPORTS_XML_CONTENT    = ABDERA_FEATURE_BASE + "supportsXmlContent";
+  public static final String FEATURE_REQUIRES_XML_CONTENT    = ABDERA_FEATURE_BASE + "requiresXmlContent";
+  public static final String FEATURE_SUPPORTS_BINARY_CONTENT = ABDERA_FEATURE_BASE + "supportsBinaryContent";
+  public static final String FEATURE_REQUIRES_BINARY_CONTENT = ABDERA_FEATURE_BASE + "requiresBinaryContent";
+  public static final String FEATURE_SUPPORTS_REF_CONTENT    = ABDERA_FEATURE_BASE + "supportsRefContent";
+  public static final String FEATURE_REQUIRES_REF_CONTENT    = ABDERA_FEATURE_BASE + "requiresRefContent";
+  public static final String FEATURE_SUPPORTS_XHTML_TEXT     = ABDERA_FEATURE_BASE + "supportsXhtmlText";
+  public static final String FEATURE_REQUIRES_XHTML_TEXT     = ABDERA_FEATURE_BASE + "requiresXhtmlText";
+  public static final String FEATURE_SUPPORTS_HTML_TEXT      = ABDERA_FEATURE_BASE + "supportsHtmlText";
+  public static final String FEATURE_REQUIRES_HTML_TEXT      = ABDERA_FEATURE_BASE + "requiresHtmlText";
+  public static final String FEATURE_SUPPORTS_TEXT_TEXT      = ABDERA_FEATURE_BASE + "supportsTextText";
+  public static final String FEATURE_REQUIRES_TEXT_TEXT      = ABDERA_FEATURE_BASE + "requiresTextText";
+  public static final String FEATURE_PRESERVES_SUMMARY       = ABDERA_FEATURE_BASE + "preservesSummary";
+  public static final String FEATURE_IGNORES_SUMMARY         = ABDERA_FEATURE_BASE + "ignoresSummary";
+  public static final String FEATURE_PRESERVES_RIGHTS        = ABDERA_FEATURE_BASE + "preservesRights";
+  public static final String FEATURE_IGNORES_RIGHTS          = ABDERA_FEATURE_BASE + "ignoresRights";
+  public static final String FEATURE_PRESERVES_AUTHORS       = ABDERA_FEATURE_BASE + "preservesAuthors";
+  public static final String FEATURE_IGNORES_AUTHORS         = ABDERA_FEATURE_BASE + "ignoresAuthors";
+  public static final String FEATURE_PRESERVES_CONTRIBUTORS  = ABDERA_FEATURE_BASE + "preservesContributors";
+  public static final String FEATURE_IGNORES_CONTRIBUTORS    = ABDERA_FEATURE_BASE + "ignoresContributors";
+  public static final String FEATURE_USES_SLUG               = ABDERA_FEATURE_BASE + "usesSlug";
+  public static final String FEATURE_IGNORES_SLUG            = ABDERA_FEATURE_BASE + "ignoresSlug";
+  public static final String FEATURE_PRESERVES_CATEGORIES    = ABDERA_FEATURE_BASE + "preservesCategories";
+  public static final String FEATURE_MULTIPLE_CATEGORIES     = ABDERA_FEATURE_BASE + "multipleCategories";
+  public static final String FEATURE_IGNORES_CATEGORIES      = ABDERA_FEATURE_BASE + "ignoresCategories";
+  public static final String FEATURE_PRESERVES_LINKS         = ABDERA_FEATURE_BASE + "preservesLinks";
+  public static final String FEATURE_IGNORES_LINKS           = ABDERA_FEATURE_BASE + "ignoresLinks";
+  public static final String FEATURE_PRESERVES_INFOSET       = ABDERA_FEATURE_BASE + "preservesInfoset";
+  public static final String FEATURE_PRESERVES_ID            = ABDERA_FEATURE_BASE + "preservesId";
+  public static final String FEATURE_PRESERVES_DATES         = ABDERA_FEATURE_BASE + "preservesDates";
+  public static final String FEATURE_PRESERVES_EXTENSIONS    = ABDERA_FEATURE_BASE + "preservesExtensions";
+  public static final String FEATURE_SCHEDULED_PUBLISHING    = ABDERA_FEATURE_BASE + "scheduledPublishing";
+  public static final String FEATURE_REQUIRES_PERSON_EMAIL   = ABDERA_FEATURE_BASE + "requiresPersonEmail";
+  public static final String FEATURE_HIDES_PERSON_EMAIL      = ABDERA_FEATURE_BASE + "hidesPersonEmail";
+  public static final String FEATURE_REQUIRES_PERSON_URI     = ABDERA_FEATURE_BASE + "requiresPersonUri";
+  public static final String FEATURE_HIDES_PERSON_URI        = ABDERA_FEATURE_BASE + "hidesPersonUri";
+  public static final String FEATURE_PRESERVES_LANGUAGE      = ABDERA_FEATURE_BASE + "preservesXmlLang";
+  public static final String FEATURE_IGNORES_LANGUAGE        = ABDERA_FEATURE_BASE + "ignoresXmlLang";  
+  public static final String FEATURE_SUPPORTS_CONDITIONALS   = ABDERA_FEATURE_BASE + "supportsConditionalUpdates";
+  public static final String FEATURE_REQUIRES_CONDITIONALS   = ABDERA_FEATURE_BASE + "requiresConditionalUpdates";
+  public static final String FEATURE_PRESERVES_THREADING     = ABDERA_FEATURE_BASE + "preservesThreading";
+  public static final String FEATURE_REQUIRES_THREADING      = ABDERA_FEATURE_BASE + "requiresThreading";
+  public static final String FEATURE_IGNORES_THREADING       = ABDERA_FEATURE_BASE + "ignoresThreading";
+  
+  
+  /**
+   * Indicates that the collection will preserve XML digital signatures contained
+   * in member resources 
+   */
+  public static final String FEATURE_PRESERVE_SIGNATURE = ABDERA_FEATURE_BASE + "preservesSignature";
+
+  /**
+   * Indicates that the collection will support XML digital signatures contained
+   * in member resources but may not preserve those signatures
+   */
+  public static final String FEATURE_SUPPORTS_SIGNATURE = ABDERA_FEATURE_BASE + "supportsSignature";
+  
+  /**
+   * Indicates that the collection will ignore XML digital signatures contained
+   * in member resources 
+   */
+  public static final String FEATURE_IGNORES_SIGNATURE = ABDERA_FEATURE_BASE + "ignoresSignature";
+  
+  /**
+   * Indicates that the collection requires member resources to contain valid XML digital signatures
+   */
+  public static final String FEATURE_REQUIRES_SIGNATURE = ABDERA_FEATURE_BASE + "requiresSignature";
+
+  /**
+   * Indicates that the collection will add it's own digital signature to the 
+   * collection feed and member resources
+   */
+  public static final String FEATURE_SIGNED_RESPONSE = ABDERA_FEATURE_BASE + "responseSignature";
+
+  
+  /**
+   * Indicates that the collection supports the use of the Atom Bidi Attribute.
+   */
+  public static final String FEATURE_SUPPORTS_BIDI = ABDERA_FEATURE_BASE + "supportsBidi";
+  
+  /**
+   * Indicates that the collection requires the use of the Atom Bidi Attribute.
+   */
+  public static final String FEATURE_REQUIRES_BIDI = ABDERA_FEATURE_BASE + "requiresBidi";
+  
+  /**
+   * Indicates that the collection ignores the use of the Atom Bidi Attribute.
+   */
+  public static final String FEATURE_IGNORES_BIDI = ABDERA_FEATURE_BASE + "ignoresBidi";
+  
+  
+  /**
+   * Indicates that the collection supports the use of Geo extensions (see the
+   * org.apache.abdera.ext.geo Package)
+   */
+  public static final String FEATURE_SUPPORTS_GEO = ABDERA_FEATURE_BASE + "supportsGeo";
+
+  /**
+   * Indicates that the collection requires the use of Geo extensions (see the
+   * org.apache.abdera.ext.geo Package)
+   */
+  public static final String FEATURE_REQUIRES_GEO = ABDERA_FEATURE_BASE + "requiresGeo";
+
+  /**
+   * Indicates that the collection ignores the use of Geo extensions (see the
+   * org.apache.abdera.ext.geo Package)
+   */
+  public static final String FEATURE_IGNORES_GEO = ABDERA_FEATURE_BASE + "ignoresGeo";
+  
+  /**
+   * Indicates that the collection supports the use of the Simple Sharing Extensions
+   * (see the org.apache.abdera.ext.sharing Package)
+   */
+  public static final String FEATURE_SUPPORTS_SHARING = ABDERA_FEATURE_BASE + "supportsSharing";
+
+  /**
+   * Indicates that the collection requires the use of the Simple Sharing Extensions
+   * (see the org.apache.abdera.ext.sharing Package)
+   */
+  public static final String FEATURE_REQUIRES_SHARING = ABDERA_FEATURE_BASE + "requiresSharing";
+  
+  /**
+   * Indicates that the collection ignores the use of the Simple Sharing Extensions
+   * (see the org.apache.abdera.ext.sharing Package)
+   */
+  public static final String FEATURE_IGNORES_SHARING = ABDERA_FEATURE_BASE + "ignoresSharing";
+  
+  /**
+   * Indicates that the collection requires the GoogleLogin auth scheme
+   * (see the org.apache.abdera.ext.gdata Package)
+   */
+  public static final String FEATURE_REQUIRES_GOOGLELOGIN = ABDERA_FEATURE_BASE + "requiresGoogleLogin";
+
+  /**
+   * Indicates that the collection supports the GoogleLogin auth scheme
+   * (see the org.apache.abdera.ext.gdata Package)
+   */
+  public static final String FEATURE_SUPPORTS_GOOGLELOGIN = ABDERA_FEATURE_BASE + "supportsGoogleLogin";
+  
+  /**
+   * Indicates that the collection requires the WSSE auth scheme
+   * (see the org.apache.abdera.ext.wsse Package)
+   */
+  public static final String FEATURE_REQUIRES_WSSE = ABDERA_FEATURE_BASE + "requiresWsse";
+  
+  /**
+   * Indicates that the collection supports the WSSE auth scheme
+   * (see the org.apache.abdera.ext.wsse Package)
+   */
+  public static final String FEATURE_SUPPORTS_WSSE = ABDERA_FEATURE_BASE + "supportsWsse";  
+  
+  /**
+   * Indicates that the collection will remove markup that is considered potentially unsafe from the entry
+   * examples of the type of markup that would be removed include scripts and embed 
+   */
+  public static final String FEATURE_FILTERS_MARKUP = BLOG_FEATURE_BASE + "filtersUnsafeMarkup";
+    
+  private FeaturesHelper() {}
+  
+  private static Map<String,Features> featuresCache = 
+    Collections.synchronizedMap(new WeakHashMap<String,Features>());
+  
+  private static Features getCachedFeatures(String iri) {
+    return featuresCache.get(iri);
+  }
+  
+  private static void setCachedFeatures(String iri, Features features) {
+    featuresCache.put(iri,features);
+  }
+  
+  public static void flushCachedFeatures() {
+    featuresCache.clear();
+  }
+  
+  public static Features newFeatures(Abdera abdera) {
+    Factory factory = abdera.getFactory();
+    Document<Features> doc = factory.newDocument();
+    Features features = factory.newElement(FEATURES,doc);
+    doc.setRoot(features);
+    return features;
+  }
+  
+  public static Features getFeaturesElement(Collection collection) {
+    return getFeaturesElement(collection,true);
+  }
+  
+  public static Features getFeaturesElement(Collection collection, boolean outofline) {
+    Features features = collection.getExtension(FEATURES);
+    if (features != null && outofline) {
+      if (features.getHref() != null) {
+        String iri = features.getResolvedHref().toASCIIString();
+        features = getCachedFeatures(iri);
+        if (features == null) {
+          Abdera abdera = collection.getFactory().getAbdera();
+          AbderaClient client = new AbderaClient(abdera);
+          ClientResponse resp = client.get(iri);
+          if(resp.getType() == ResponseType.SUCCESS) {
+            Document<Features> doc = resp.getDocument();
+            features = doc.getRoot();
+            setCachedFeatures(iri,features);
+          } else {
+            features = null;
+          }
+        }
+      }
+    }
+    return features;
+  }
+  
+  public static Feature getFeature(
+    Collection collection,
+    String feature) {
+      return getFeature(getFeaturesElement(collection), feature);
+  }
+  
+  /**
+   * Returns the specified feature element or null
+   */
+  public static Feature getFeature(
+    Features features,
+    String feature) {
+      if (features == null) return null;
+      List<Element> list = features.getExtensions(FEATURE);
+      for (Element el : list) {
+        if (el.getAttributeValue("ref").equals(feature))
+          return (Feature) el;
+      }
+      return null;
+  }
+  
+  public static Status getFeatureStatus(Collection collection, String feature) {
+    return getFeatureStatus(getFeaturesElement(collection), feature);
+  }
+  
+  public static Status getFeatureStatus(Features features, String feature) {
+    if (features == null) return Status.UNSPECIFIED;
+    Feature f = getFeature(features,feature);
+    return f != null ? Status.SPECIFIED : Status.UNSPECIFIED;
+  }
+  
+  public static Feature[] getFeatures(Collection collection) {
+    Features features = getFeaturesElement(collection);
+    if (features == null) return null;
+    List<Feature> list = features.getExtensions(FEATURE);
+    return list.toArray(new Feature[list.size()]);
+  }
+  
+  public static Features addFeaturesElement(Collection collection) {
+    if (getFeaturesElement(collection,false) != null) 
+      throw new IllegalArgumentException(
+        "A collection element can only contain one features element");
+    return collection.addExtension(FEATURES);
+  }  
+  
+  /**
+   * Select a Collection from the service document
+   */
+  public static Collection[] select(Service service, Selector selector) {
+    return select(service, new Selector[] {selector});
+  }
+  
+  /**
+   * Select a Collection from the service document
+   */
+  public static Collection[] select(Service service, Selector... selectors) {
+    List<Collection> list = new ArrayList<Collection>();
+    for (Workspace workspace : service.getWorkspaces()) {
+      Collection[] collections = select(workspace, selectors);
+      for (Collection collection : collections)
+        list.add(collection);
+    }
+    return list.toArray(new Collection[list.size()]);
+  }
+  
+  /**
+   * Select a Collection from the Workspace
+   */
+  public static Collection[] select(Workspace workspace, Selector selector) {
+    return select(workspace, new Selector[] {selector});
+  }
+  
+  /**
+   * Select a Collection from the Workspace
+   */
+  public static Collection[] select(Workspace workspace, Selector... selectors) {
+    List<Collection> list = new ArrayList<Collection>();
+    for (Collection collection : workspace.getCollections()) {
+      boolean accept = true;
+      for (Selector selector : selectors) {
+        if (!selector.select(collection)) {
+          accept = false;
+          break;
+        }
+      }
+      if (accept) list.add(collection);
+    }
+    return list.toArray(new Collection[list.size()]);
+  }
+   
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Selector.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Selector.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Selector.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/Selector.java Mon May 26 22:40:25 2008
@@ -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.abdera.ext.features;
+
+import java.io.Serializable;
+
+import org.apache.abdera.model.Collection;
+
+public interface Selector
+  extends Cloneable, Serializable {
+
+  boolean select(Collection collection);
+  
+  Selector clone(); 
+  
+}

Added: incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/XPathSelector.java
URL: http://svn.apache.org/viewvc/incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/XPathSelector.java?rev=660391&view=auto
==============================================================================
--- incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/XPathSelector.java (added)
+++ incubator/abdera/trunk/extensions/features/src/main/java/org/apache/abdera/ext/features/XPathSelector.java Mon May 26 22:40:25 2008
@@ -0,0 +1,89 @@
+/*
+* 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.features;
+
+import java.util.Map;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.xpath.XPath;
+
+/**
+ * Selects a collection based on a boolean XPath expression
+ */
+public class XPathSelector
+    extends AbstractSelector
+    implements Selector {
+
+  private static final long serialVersionUID = 7751803876821166591L;
+  
+  private final XPath xpath;
+  private final Map<String,String> namespaces;
+  private final String path;
+  
+  public XPathSelector(
+    String path) {
+      this(path,(new Abdera()).getXPath());
+  }
+  
+  public XPathSelector(
+    String path, 
+    XPath xpath) {
+      this(path,xpath,xpath.getDefaultNamespaces());
+  }
+  
+  public XPathSelector(
+    String path, 
+    XPath xpath, 
+    Map<String,String> namespaces) {
+      this.path = path;
+      this.xpath = xpath;
+      this.namespaces = namespaces;
+      if (!this.namespaces.containsValue(FeaturesHelper.FNS)) {
+        int c = 0;
+        String p = "f";
+        if (!this.namespaces.containsKey(p)) {
+          this.namespaces.put(p, FeaturesHelper.FNS);
+        } else {
+          String s = p + c;
+          while (this.namespaces.containsKey(s)) {
+            c++; s = p + c;
+          }
+          this.namespaces.put(s, FeaturesHelper.FNS);
+        }
+      }
+  }
+  
+  public String getFeaturesPrefix() {
+    for (Map.Entry<String,String> entry : namespaces.entrySet()) {
+      if (entry.getValue().equals(FeaturesHelper.FNS)) return entry.getKey();
+    }
+    return null;
+  }
+  
+  public boolean select(Collection collection) {
+    if (xpath.booleanValueOf(path, collection, namespaces)) {
+      return true;
+    }
+    return false;
+  }
+
+  public void addNamespace(String prefix, String uri) {
+    namespaces.put(prefix, uri);
+  }
+}