logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

svn commit: r289249 - /lenya/trunk/src/java/org/apache/lenya/cms/metadata/M: msg#00035

Subject: svn commit: r289249 - /lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java
Author: andreas
Date: Thu Sep 15 07:51:11 2005
New Revision: 289249

URL: http://svn.apache.org/viewcvs?rev=289249&view=rev
Log:
Applied patch for bug #36657. This fixes handling of non-fixed meta data 
attribute sets.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java?rev=289249&r1=289248&r2=289249&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/metadata/MetaDataImpl.java Thu 
Sep 15 07:51:11 2005
@@ -159,8 +159,8 @@
                     } else {
                         Element[] elements = helper.getChildren(metaElement);
                         for (int i = 0; i < elements.length; i++) {
-                            loadElementValues(maps[type], 
elements[i].getTagName(), helper
-                                    .getChildren(metaElement, 
elements[i].getTagName()));
+                            loadElementValues(maps[type], 
elements[i].getTagName(),
+                                    helper.getChildren(metaElement, 
elements[i].getLocalName()));
                         }
                     }
                 }
@@ -352,13 +352,17 @@
     protected String[] getElementOrTerm(String key) throws DocumentException {
         String[] values;
 
-        if (elementList.contains(key)) {
-            values = (String[]) this.elements.get(key);
-        } else if (termList.contains(key)) {
-            values = (String[]) this.terms.get(key);
+        if (useFixedElements()) {
+            if (elementList.contains(key)) {
+                values = (String[]) this.elements.get(key);
+            } else if (termList.contains(key)) {
+                values = (String[]) this.terms.get(key);
+            } else {
+                throw new DocumentException("The key [" + key
+                        + "] does not refer to a metadata element or term!");
+            }
         } else {
-            throw new DocumentException("The key [" + key
-                    + "] does not refer to a metadata element or term!");
+            values = (String[]) this.elements.get(key);
         }
         if (values == null) {
             values = new String[0];
@@ -447,7 +451,11 @@
      * @return A boolean value.
      */
     public boolean isValidAttribute(String key) {
-        return termList.contains(key) || elementList.contains(key);
+        if (useFixedElements()) {
+            return termList.contains(key) || elementList.contains(key);
+        } else {
+            return this.elements.containsKey(key);
+        }
     }
 
     /**
@@ -459,13 +467,17 @@
         list.add(value);
         String[] newValues = (String[]) list.toArray(new String[list.size()]);
 
-        if (elementList.contains(key)) {
-            this.elements.put(key, newValues);
-        } else if (termList.contains(key)) {
-            this.terms.put(key, newValues);
+        if (useFixedElements()) {
+            if (elementList.contains(key)) {
+                this.elements.put(key, newValues);
+            } else if (termList.contains(key)) {
+                this.terms.put(key, newValues);
+            } else {
+                throw new DocumentException("The key [" + key
+                        + "] does not refer to a metadata element or term!");
+            }
         } else {
-            throw new DocumentException("The key [" + key
-                    + "] does not refer to a metadata element or term!");
+            this.elements.put(key, newValues);
         }
     }
 
@@ -486,13 +498,17 @@
      * @see 
org.apache.lenya.cms.metadata.MetaData#removeAllValues(java.lang.String)
      */
     private void removeAllValues(String key) throws DocumentException {
-        if (elementList.contains(key)) {
-            this.elements.put(key, new String[0]);
-        } else if (termList.contains(key)) {
-            this.terms.put(key, new String[0]);
+        if (useFixedElements()) {
+            if (elementList.contains(key)) {
+                this.elements.put(key, new String[0]);
+            } else if (termList.contains(key)) {
+                this.terms.put(key, new String[0]);
+            } else {
+                throw new DocumentException("The key [" + key
+                        + "] does not refer to a dublin core element or 
term!");
+            }
         } else {
-            throw new DocumentException("The key [" + key
-                    + "] does not refer to a dublin core element or term!");
+            this.elements.remove(key);
         }
     }


<Prev in Thread] Current Thread [Next in Thread>