Refactor Argeo APIs
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / docbook / DbkAcrUtils.java
index d956069f5b9be91545996df10c4f075e21e7a39f..fed027d7477c904ebd81c9107b2ddfbf4e769770 100644 (file)
@@ -1,13 +1,39 @@
 package org.argeo.app.docbook;
 
 import org.argeo.api.acr.Content;
+import org.argeo.api.app.EntityType;
 
+/** Utilities when using ACR to access DocBook. */
 public class DbkAcrUtils {
        /** Whether this DocBook element is of this type. */
        public static boolean isDbk(Content content, DbkType type) {
                return content.isContentClass(type.qName());
        }
 
+       public static String getMediaFileref(Content node) {
+               Content mediadata;
+               if (node.hasChild(DbkType.imageobject)) {
+                       mediadata = node.child(DbkType.imageobject).child(DbkType.imagedata);
+               } else {
+                       mediadata = node.child(DbkType.videoobject).child(DbkType.videodata);
+               }
+
+               if (mediadata.containsKey(DbkAttr.fileref)) {
+                       return mediadata.attr(DbkAttr.fileref);
+               } else {
+                       return null;
+               }
+       }
+
+       public static Content getMetadata(Content infoContainer) {
+               if (!infoContainer.hasChild(DbkType.info))
+                       return null;
+               Content info = infoContainer.child(DbkType.info);
+               if (!info.hasChild(EntityType.local))
+                       return null;
+               return info.child(EntityType.local);
+       }
+
        /** singleton */
        private DbkAcrUtils() {
        }