abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r547313 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/util/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Thu, 14 Jun 2007 17:01:14 GMT
Author: jmsnell
Date: Thu Jun 14 10:01:11 2007
New Revision: 547313

URL: http://svn.apache.org/viewvc?view=rev&rev=547313
Log:
APP has an official xml namespace now: http://www.w3.org/2007/app

Because there are APP services in the wild using the old temp namespace, let's continue to
recognize it for now when parsing.  
However, when creating APP documents, let's always use the new official one

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMControl.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java Thu
Jun 14 10:01:11 2007
@@ -46,7 +46,11 @@
   public static final String MULTIPART_MEDIA_TYPE = "multipart/related";
   
   public static final String ATOM_NS              = "http://www.w3.org/2005/Atom";
-  public static final String APP_NS               = "http://purl.org/atom/app#";
+  public static final String APP_NS               = "http://www.w3.org/2007/app";
+  
+  /** @deprecated Use Constants.APP_NS instead**/
+  public static final String APP_NS_PRE_RFC       = "http://purl.org/atom/app#";
+  
   /** @deprecated **/
   public static final String CONTROL_NS           = "http://example.net/appns/";
   public static final String XML_NS               = "http://www.w3.org/XML/1998/namespace";
@@ -98,11 +102,34 @@
   public static final String LN_FIXED             = "fixed";
   
   public static final QName DIV                   = new QName(XHTML_NS, LN_DIV, "");
+  
   public static final QName CONTROL               = new QName(APP_NS, LN_CONTROL, "app");
   public static final QName DRAFT                 = new QName(APP_NS, LN_DRAFT, "app");
   public static final QName CATEGORIES            = new QName(APP_NS, LN_CATEGORIES, APP_PREFIX);
-  public static final QName FEED                  = new QName(ATOM_NS, LN_FEED, PREFIX);
   public static final QName SERVICE               = new QName(APP_NS, LN_SERVICE, APP_PREFIX);
+  public static final QName EDITED                = new QName(APP_NS, LN_EDITED, "app");
+  public static final QName ACCEPT                = new QName(APP_NS, LN_ACCEPT, APP_PREFIX);
+  public static final QName WORKSPACE             = new QName(APP_NS, LN_WORKSPACE, APP_PREFIX);
+  public static final QName COLLECTION            = new QName(APP_NS, LN_COLLECTION, APP_PREFIX);
+  
+  /** @deprecated **/
+  public static final QName PRE_RFC_CONTROL               = new QName(APP_NS_PRE_RFC, LN_CONTROL,
"app");
+  /** @deprecated **/
+  public static final QName PRE_RFC_DRAFT                 = new QName(APP_NS_PRE_RFC, LN_DRAFT,
"app");
+  /** @deprecated **/
+  public static final QName PRE_RFC_CATEGORIES            = new QName(APP_NS_PRE_RFC, LN_CATEGORIES,
APP_PREFIX);
+  /** @deprecated **/
+  public static final QName PRE_RFC_SERVICE               = new QName(APP_NS_PRE_RFC, LN_SERVICE,
APP_PREFIX);
+  /** @deprecated **/
+  public static final QName PRE_RFC_EDITED                = new QName(APP_NS_PRE_RFC, LN_EDITED,
"app");
+  /** @deprecated **/
+  public static final QName PRE_RFC_ACCEPT                = new QName(APP_NS_PRE_RFC, LN_ACCEPT,
APP_PREFIX);
+  /** @deprecated **/
+  public static final QName PRE_RFC_WORKSPACE             = new QName(APP_NS_PRE_RFC, LN_WORKSPACE,
APP_PREFIX);
+  /** @deprecated **/
+  public static final QName PRE_RFC_COLLECTION            = new QName(APP_NS_PRE_RFC, LN_COLLECTION,
APP_PREFIX);
+  
+  public static final QName FEED                  = new QName(ATOM_NS, LN_FEED, PREFIX);
   public static final QName AUTHOR                = new QName(ATOM_NS, LN_AUTHOR, PREFIX);
   public static final QName CATEGORY              = new QName(ATOM_NS, LN_CATEGORY, PREFIX);
   public static final QName CONTENT               = new QName(ATOM_NS, LN_CONTENT, PREFIX);
@@ -120,7 +147,6 @@
   public static final QName TITLE                 = new QName(ATOM_NS, LN_TITLE, PREFIX);
   public static final QName PREFIXED_TITLE        = new QName(ATOM_NS, LN_TITLE, "atom");
   public static final QName UPDATED               = new QName(ATOM_NS, LN_UPDATED, PREFIX);
-  public static final QName EDITED                = new QName(APP_NS, LN_EDITED, "app");
   public static final QName ENTRY                 = new QName(ATOM_NS, LN_ENTRY, PREFIX);
   public static final QName TERM                  = new QName(LN_TERM);
   public static final QName SCHEME                = new QName(LN_SCHEME);
@@ -128,7 +154,6 @@
   public static final QName LABEL                 = new QName(LN_LABEL);
   public static final QName ATITLE                = new QName(LN_TITLE);
   public static final QName HREF                  = new QName(LN_HREF);
-  public static final QName ACCEPT                = new QName(APP_NS, LN_ACCEPT, APP_PREFIX);
   public static final QName LANG                  = new QName(XML_NS, LN_LANG, "xml");
   public static final QName BASE                  = new QName(XML_NS, LN_BASE, "xml");
   public static final QName AURI                  = new QName(LN_URI);
@@ -140,9 +165,7 @@
   public static final QName NAME                  = new QName(ATOM_NS, LN_NAME, PREFIX);
   public static final QName EMAIL                 = new QName(ATOM_NS, LN_EMAIL, PREFIX);
   public static final QName URI                   = new QName(ATOM_NS, LN_URI, PREFIX);
-  public static final QName WORKSPACE             = new QName(APP_NS, LN_WORKSPACE, APP_PREFIX);
   public static final QName SRC                   = new QName(LN_SRC);
-  public static final QName COLLECTION            = new QName(APP_NS, LN_COLLECTION, APP_PREFIX);
   public static final QName AID                   = new QName(LN_ID);
   public static final QName CLASS                 = new QName(LN_CLASS);
   

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
Thu Jun 14 10:01:11 2007
@@ -145,7 +145,9 @@
   
   public String[] getAccept(){
     List<String> accept = new ArrayList<String>();
-    for (Iterator i = getChildrenWithName(ACCEPT); i.hasNext();) {
+    Iterator i = getChildrenWithName(ACCEPT);
+    if (i == null || !i.hasNext()) i = getChildrenWithName(PRE_RFC_ACCEPT);
+    while(i.hasNext()) {
       Element e = (Element) i.next();
       String t = e.getText();
       if (t != null) { 
@@ -167,6 +169,7 @@
   public void setAccept(String... mediaRanges) {
     if (mediaRanges != null && mediaRanges.length > 0) {
       _removeChildren(ACCEPT, true);
+      _removeChildren(PRE_RFC_ACCEPT, true);
       if (mediaRanges.length == 1 && mediaRanges[0].equals("")) {
         addExtension(ACCEPT);
       } else {
@@ -179,6 +182,7 @@
       }
     } else {
       _removeChildren(ACCEPT, true);
+      _removeChildren(PRE_RFC_ACCEPT,true);
     }
   }
   
@@ -264,7 +268,9 @@
   }
 
   public List<Categories> getCategories() {
-    return _getChildrenAsSet(CATEGORIES);
+    List<Categories> list =  _getChildrenAsSet(CATEGORIES);
+    if (list == null || list.size() == 0) list = _getChildrenAsSet(PRE_RFC_CATEGORIES);
+    return list;
   }
 
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMControl.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMControl.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMControl.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMControl.java
Thu Jun 14 10:01:11 2007
@@ -79,17 +79,18 @@
 
   public boolean isDraft() {
     String value = _getElementValue(DRAFT);
+    if (value == null) value = _getElementValue(PRE_RFC_DRAFT);
     return (value != null && YES.equalsIgnoreCase(value));
   }
 
   public void setDraft(boolean draft) {
+    _removeChildren(PRE_RFC_DRAFT, true);
     _setElementValue(DRAFT, (draft) ? YES:NO);
   }
   
   public void unsetDraft() {
-    OMElement el = getFirstChildWithName(DRAFT);
-    if (el != null)
-      el.discard();
+    _removeChildren(PRE_RFC_DRAFT, true);
+    _removeChildren(DRAFT, true);
   }
 
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMEntry.java
Thu Jun 14 10:01:11 2007
@@ -653,14 +653,17 @@
   }
 
   public DateTime getEditedElement() {
-    return (DateTime)getFirstChildWithName(EDITED);
+    DateTime dt =  (DateTime)getFirstChildWithName(EDITED);
+    if (dt == null) dt = (DateTime)getFirstChildWithName(PRE_RFC_EDITED);
+    return dt;
   }
 
   public void setEditedElement(DateTime updated) {
     declareNamespace(APP_NS, "app");
+    _removeChildren(PRE_RFC_EDITED,false);
     if (updated != null)
       _setChild(EDITED, (OMElement)updated);
-    else 
+    else
       _removeChildren(EDITED, false);
   }
 
@@ -669,9 +672,10 @@
     return (dte != null) ? dte.getDate() : null;
   }
   
-  private DateTime setModified(AtomDate value) {
+  private DateTime setEdited(AtomDate value) {
     declareNamespace(APP_NS, "app");
     if (value == null) {
+      _removeChildren(PRE_RFC_EDITED, false);
       _removeChildren(EDITED, false);
       return null;
     }
@@ -688,7 +692,7 @@
   }
   
   public DateTime setEdited(Date value) {
-    return setModified((value != null) ? AtomDate.valueOf(value) : null);
+    return setEdited((value != null) ? AtomDate.valueOf(value) : null);
   }
   
   public DateTime setEdited(String value) {
@@ -705,10 +709,13 @@
   }
   
   public Control getControl() {
-    return (Control)getFirstChildWithName(CONTROL);
+    Control control = (Control)getFirstChildWithName(CONTROL);
+    if (control == null) control = (Control)getFirstChildWithName(PRE_RFC_CONTROL);
+    return control;
   }
 
   public void setControl(Control control) {
+    _removeChildren(PRE_RFC_CONTROL,true);
     if (control != null) 
       _setChild(CONTROL, (OMElement)control);
     else 

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Thu Jun 14 10:01:11 2007
@@ -628,7 +628,7 @@
           qname.getPrefix());
       if (FEED.equals(qname)) {
         element = new FOMFeed(qname.getLocalPart(), namespace, parent, factory);
-      } else if (SERVICE.equals(qname)) {
+      } else if (SERVICE.equals(qname) || PRE_RFC_SERVICE.equals(qname)) {
         element = new FOMService(qname.getLocalPart(), namespace, parent, factory);
       } else if (ENTRY.equals(qname)) {
         element = new FOMEntry(qname.getLocalPart(), namespace, parent, factory);
@@ -669,9 +669,9 @@
         element = new FOMText(type, qname.getLocalPart(), namespace, parent, factory);
       } else if (UPDATED.equals(qname)) {
         element = new FOMDateTime(qname.getLocalPart(), namespace, parent, factory);    
     
-      } else if (WORKSPACE.equals(qname)) {
+      } else if (WORKSPACE.equals(qname) || PRE_RFC_WORKSPACE.equals(qname)) {
         element = new FOMWorkspace(qname.getLocalPart(), namespace, parent, factory);
-      } else if (COLLECTION.equals(qname)) {
+      } else if (COLLECTION.equals(qname) || PRE_RFC_COLLECTION.equals(qname)) {
         element = new FOMCollection(qname.getLocalPart(), namespace, parent, factory);
       } else if (NAME.equals(qname)) {
         element = new FOMElement(qname.getLocalPart(), namespace, parent, factory);
@@ -679,17 +679,16 @@
         element = new FOMElement(qname.getLocalPart(), namespace, parent, factory);
       } else if (URI.equals(qname)) {
         element = new FOMIRI(qname.getLocalPart(), namespace, parent, factory);
-      } else if (CONTROL.equals(qname)) {
+      } else if (CONTROL.equals(qname) || PRE_RFC_CONTROL.equals(qname)) {
         element = new FOMControl(qname.getLocalPart(), namespace, parent, factory);
       } else if (DIV.equals(qname)) {
         element = new FOMDiv(qname.getLocalPart(), namespace, parent, factory);
-      } else if (CATEGORIES.equals(qname)) {
+      } else if (CATEGORIES.equals(qname) || PRE_RFC_CATEGORIES.equals(qname)) {
         element = new FOMCategories(qname.getLocalPart(), namespace, parent, factory);
-      } else if (EDITED.equals(qname)) {
+      } else if (EDITED.equals(qname) || PRE_RFC_EDITED.equals(qname)) {
         element = new FOMDateTime(qname.getLocalPart(), namespace, parent, factory);
       } else if (parent instanceof ExtensibleElement || 
                  parent instanceof Document) {
-        //element = (OMElement) newExtensionElement(qname, parent);
         element = (OMElement) new FOMExtensibleElement(
           qname.getLocalPart(), namespace, parent, this);
       }
@@ -704,7 +703,7 @@
     OMElement element = null;    
     if (FEED.equals(qname)) {
       element = (OMElement) newFeed(qname, parent, builder);
-    } else if (SERVICE.equals(qname)) {
+    } else if (SERVICE.equals(qname) || PRE_RFC_SERVICE.equals(qname)) {
       element = (OMElement) newService(qname, parent, builder);
     } else if (ENTRY.equals(qname)) {
       element = (OMElement) newEntry(qname, parent, builder);
@@ -745,9 +744,9 @@
       element = (OMElement) newText(qname, type, parent, builder);
     } else if (UPDATED.equals(qname)) {
       element = (OMElement) newDateTimeElement(qname, parent, builder);          
-    } else if (WORKSPACE.equals(qname)) {
+    } else if (WORKSPACE.equals(qname) || PRE_RFC_WORKSPACE.equals(qname)) {
       element = (OMElement) newWorkspace(qname, parent, builder);
-    } else if (COLLECTION.equals(qname)) {
+    } else if (COLLECTION.equals(qname) || PRE_RFC_COLLECTION.equals(qname)) {
       element = (OMElement) newCollection(qname, parent, builder);
     } else if (NAME.equals(qname)) {
       element = (OMElement) new FOMElement(qname,parent,this,builder);
@@ -755,16 +754,15 @@
       element = (OMElement) new FOMElement(qname,parent,this,builder);
     } else if (URI.equals(qname)) {
       element = (OMElement) newURIElement(qname, parent, builder);
-    } else if (CONTROL.equals(qname)) {
+    } else if (CONTROL.equals(qname) || PRE_RFC_CONTROL.equals(qname)) {
       element = (OMElement) newControl(qname, parent, builder);
     } else if (DIV.equals(qname)) {
       element = (OMElement) newDiv(qname, parent, builder);
-    } else if (CATEGORIES.equals(qname)) {
+    } else if (CATEGORIES.equals(qname) || PRE_RFC_CATEGORIES.equals(qname)) {
       element = (OMElement) newCategories(qname, parent, builder);
-    } else if (EDITED.equals(qname)) {
+    } else if (EDITED.equals(qname) || PRE_RFC_EDITED.equals(qname)) {
       element = (OMElement) newDateTimeElement(qname, parent, builder);
     } else if (parent instanceof ExtensibleElement || parent instanceof Document) {
-      //element = (OMElement) newExtensionElement(qname, parent, builder);
       element = (OMElement) new FOMExtensibleElement(qname, parent, this,builder);
     }
     return element;

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
Thu Jun 14 10:01:11 2007
@@ -95,7 +95,9 @@
   }
   
   public List<Workspace> getWorkspaces() {
-    return _getChildrenAsSet(WORKSPACE);
+    List<Workspace> list = _getChildrenAsSet(WORKSPACE);
+    if (list == null || list.size() == 0) list = _getChildrenAsSet(PRE_RFC_WORKSPACE);
+    return list;
   }
 
   public Workspace getWorkspace(String title) {

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
Thu Jun 14 10:01:11 2007
@@ -573,14 +573,18 @@
   }
 
   public Collection getCollection() {
-    return getFirstChild(COLLECTION);
+    Collection coll = getFirstChild(COLLECTION);
+    if (coll == null) coll = getFirstChild(PRE_RFC_COLLECTION);
+    return coll;
   }
   
   public void setCollection(Collection collection) {
-    if (collection != null) 
+    if (collection != null) {
+      _removeChildren(PRE_RFC_COLLECTION, true);
       _setChild(COLLECTION, (OMElement)collection);
-    else 
+    } else { 
       _removeChildren(COLLECTION, false);
+    }
   }
   
   public Link getAlternateLink(

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java?view=diff&rev=547313&r1=547312&r2=547313
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
Thu Jun 14 10:01:11 2007
@@ -120,7 +120,9 @@
   }
   
   public List<Collection> getCollections() {
-    return _getChildrenAsSet(COLLECTION);
+    List<Collection> list = _getChildrenAsSet(COLLECTION);
+    if (list == null || list.size() == 0) list = _getChildrenAsSet(PRE_RFC_COLLECTION);
+    return list;
   }
 
   public Collection getCollection(String title) {



Mime
View raw message