changeset 1174:4a0dd02a61b8

still trying IndexMetaAuthLoader
author robcast
date Wed, 03 Apr 2013 10:36:07 +0200
parents 4eb69ffb8a78
children ce3105f6910a
files common/src/main/java/digilib/meta/IndexMetaAuthLoader.java
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java	Tue Apr 02 17:38:05 2013 +0200
+++ b/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java	Wed Apr 03 10:36:07 2013 +0200
@@ -101,7 +101,13 @@
                 tags.push(thisTag);
                 if (thisTag.equals(metaTag)) {
                     return true;
+                } else if (thisTag.equals(fileTag)) {
+                    // reset filenames
+                    filename = null;
+                    filepath = null;
                 }
+            } else if (event == XMLStreamConstants.CHARACTERS) {
+                text.append(reader.getText());
             } else if (event == XMLStreamConstants.END_ELEMENT) {
                 // get tag TODO: make namespace aware
                 thisTag = reader.getLocalName();
@@ -113,8 +119,6 @@
                     // path inside file tag -> record path
                     filepath = text.toString();
                 }
-            } else if (event == XMLStreamConstants.CHARACTERS) {
-                text.append(reader.getText());
             }
         }
         return false;
@@ -185,11 +189,18 @@
                         // no access type
                         return map;
                     }
-                    
+                    String access = null;
+                    if (accType.equals("free")) {
+                        access = accType;
+                    } else if (accName != null) {
+                        access = accType + ":" + accName;
+                    } else {
+                        // type != free but no name
+                        logger.error("access type="+accType+" but no name!");
+                        return map;
+                    }
+                    map.put("access", access);
                 }
-
-                // put text in map under tag name
-                map.put(thisTag, text.toString());
             }
         }
         return map;
@@ -206,7 +217,7 @@
                 if (thisTag.equals(imgTag)) {
                     map = readTagToMap(map);
                 }
-                if (thisTag.equals(this.accessConditionsTag)) {
+                if (thisTag.equals(accessConditionsTag)) {
                     map = readAccessConditionsToMap(map);
                 }
             } else if (event == XMLStreamConstants.END_ELEMENT) {
@@ -236,7 +247,7 @@
             reader = factory.createXMLStreamReader(in);
             // start reading
             tags = new LinkedList<String>();
-            if (readToMetaTag()) {
+            while (readToMetaTag()) {
                 String fn = "";
                 if (filename != null) {
                     if (filepath != null) {