Author: michiel
Date: 2009-07-06 23:28:35 +0200 (Mon, 06 Jul 2009)
New Revision: 36597

Modified:
   
mmbase/trunk/applications/streams/src/main/java/org/mmbase/streams/CreateCachesProcessor.java
Log:
initial support for mimetype matchings (work in progress)

Modified: 
mmbase/trunk/applications/streams/src/main/java/org/mmbase/streams/CreateCachesProcessor.java
===================================================================
--- 
mmbase/trunk/applications/streams/src/main/java/org/mmbase/streams/CreateCachesProcessor.java
       2009-07-06 21:11:11 UTC (rev 36596)
+++ 
mmbase/trunk/applications/streams/src/main/java/org/mmbase/streams/CreateCachesProcessor.java
       2009-07-06 21:28:35 UTC (rev 36597)
@@ -24,6 +24,7 @@
 import org.mmbase.applications.media.State;
 import org.mmbase.applications.media.Format;
 import org.mmbase.applications.media.Codec;
+import org.mmbase.applications.media.MimeType;
 import org.mmbase.servlet.FileServlet;
 import org.mmbase.core.event.*;
 
@@ -105,8 +106,9 @@
                                     if (in.length() > 0) {
                                         transcoder.setInId(in);
                                     }
+                                    MimeType mimeType = new 
MimeType(el.getAttribute("mimetype"));
                                     LOG.debug("Created " + transcoder);
-                                    JobDefinition def = new 
JobDefinition(transcoder);
+                                    JobDefinition def = new 
JobDefinition(transcoder, mimeType);
                                     org.w3c.dom.NodeList childs = 
el.getChildNodes();
                                     for (int j = 0; j <= childs.getLength(); 
j++) {
                                         if (childs.item(j) instanceof Element) 
{
@@ -370,16 +372,19 @@
         public final List<Analyzer> analyzers;
         public final URI in;
         public final URI out;
-        JobDefinition(Transcoder t) {
+        public final MimeType mimeType;
+        JobDefinition(Transcoder t, MimeType mt) {
             transcoder = t;
             analyzers = new ArrayList<Analyzer>();
             dest = null;
             in = null;
             out = null;
+            mimeType = mt;
         }
         JobDefinition(JobDefinition jd, Node dest, URI in, URI out) {
             transcoder = jd.transcoder.clone();
             analyzers  = jd.analyzers;
+            mimeType   = jd.mimeType;
             this.dest = dest;
             this.in = in;
             this.out = out;
@@ -402,6 +407,10 @@
             return out;
         }
 
+        public MimeType getMimeType() {
+            return mimeType;
+        }
+
         @Override
         public String toString() {
             return "" + transcoder + " " + analyzers;
@@ -451,7 +460,7 @@
                     for (Map.Entry<String, JobDefinition> entry : 
list.entrySet()) {
                         JobDefinition jd = entry.getValue();
                         String id = entry.getKey();
-                        if (jd.transcoder.getFormat() != null) {
+                        if (jd.transcoder.getKey() != null) {
                             Node resultNode = 
getCacheNode(jd.transcoder.getKey());
 
                             StringBuilder buf = new StringBuilder();
@@ -488,7 +497,7 @@
                         } else {
 
                             JobDefinition clone = new JobDefinition(jd, null, 
inFile.toURI(), null);
-                            logger.info("Cachenode less job" + clone);
+                            logger.info("Cachenodeless job" + clone);
                             clones.put(id, clone);
 
                         }
@@ -507,23 +516,21 @@
 
                     // TODO check only create if always must be created or, if 
mimetype matches with input.
                     JobDefinition jd = entry.getValue();
-                    Node resultNode = getCacheNode(jd.transcoder.getKey());
-                    resultNode.setIntValue("state",  State.REQUEST.getValue());
-                    resultNode.setStringValue("key", jd.transcoder.getKey());
-                    Format f = jd.transcoder.getFormat();
-                    if (f == null) {
-                        resultNode.setValue("format", null);
-                    } else {
+                    if (jd.transcoder.getKey() != null) {
+                        Node resultNode = getCacheNode(jd.transcoder.getKey());
+                        resultNode.setIntValue("state",  
State.REQUEST.getValue());
+                        resultNode.setStringValue("key", 
jd.transcoder.getKey());
+                        Format f = jd.transcoder.getFormat();
                         resultNode.setIntValue("format", f.toInt());
+                        Codec c = jd.transcoder.getCodec();
+                        if (c == null) {
+                            resultNode.setValue("codec", null);
+                        } else {
+                            resultNode.setIntValue("codec", c.toInt());
+                        }
+                        resultNode.setNodeValue("id",    node);
+                        resultNode.commit();
                     }
-                    Codec c = jd.transcoder.getCodec();
-                    if (c == null) {
-                        resultNode.setValue("codec", null);
-                    } else {
-                        resultNode.setIntValue("codec", c.toInt());
-                    }
-                    resultNode.setNodeValue("id",    node);
-                    resultNode.commit();
                 }
             }
         }
@@ -568,6 +575,7 @@
                     busy++;
                     if (current.getResultNode() != null) {
                         current.getResultNode().setIntValue("state", 
State.BUSY.getValue());
+                        current.getResultNode().commit();
                     }
                     return current;
                 }

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to