tiny fixes here and there
[mir.git] / source / mircoders / producer / MediaGeneratingProducerNode.java
index 042a10d..192ca2b 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 
 package mircoders.producer;
 
-import java.util.Map;
-
 import mir.entity.Entity;
 import mir.entity.adapter.EntityAdapter;
 import mir.log.LoggerWrapper;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
+import mir.media.MediaHandler;
+import mir.producer.AbstractProducerNode;
 import mir.producer.ProducerExc;
-import mir.producer.ProducerNode;
 import mir.util.ParameterExpander;
 import mircoders.entity.EntityUploadedMedia;
+import mircoders.media.MediaHelper;
 import mircoders.storage.DatabaseUploadedMedia;
 
-public class MediaGeneratingProducerNode implements ProducerNode {
+import java.util.Map;
+
+public class MediaGeneratingProducerNode extends AbstractProducerNode {
   private String mediaEntityKey;
 
   public MediaGeneratingProducerNode(String aMediaEntityKey) {
@@ -55,19 +55,21 @@ public class MediaGeneratingProducerNode implements ProducerNode {
     Entity entity;
     EntityUploadedMedia uploadedMediaEntity = null;
     Entity mediaType = null;
-    MirMedia currentMediaHandler;
+    MediaHandler currentMediaHandler;
 
     try {
-
       data = ParameterExpander.findValueForKey( aValueMap, mediaEntityKey );
 
       if (!(data instanceof EntityAdapter)) {
-        throw new ProducerExc("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an EntityAdapter, but an " + data.getClass().getName());
+        throw new ProducerExc("MediaGeneratingProducerNode: value of '" +
+            mediaEntityKey + "' is not an EntityAdapter, but an " + data.getClass().getName());
       }
 
       entity = ((EntityAdapter) data).getEntity();
-      if (! (entity instanceof EntityUploadedMedia)) {
-        throw new ProducerExc("MediaGeneratingProducerNode: value of '"+mediaEntityKey+"' is not an uploaded media EntityAdapter, but a " + entity.getClass().getName() + " adapter");
+      if (!(entity instanceof EntityUploadedMedia)) {
+        throw new ProducerExc("MediaGeneratingProducerNode: value of '" +
+            mediaEntityKey + "' is not an uploaded media EntityAdapter, but a " +
+            entity.getClass().getName() + " adapter");
       }
 
       uploadedMediaEntity = (EntityUploadedMedia) entity;
@@ -76,20 +78,21 @@ public class MediaGeneratingProducerNode implements ProducerNode {
 
       currentMediaHandler = MediaHelper.getHandler( mediaType );
       currentMediaHandler.produce(entity, mediaType);
-      entity.setValueForProperty("publish_server", currentMediaHandler.getPublishHost());
-      entity.setValueForProperty("icon_is_produced", "1");
-      entity.setValueForProperty("is_produced", "1");
+      entity.setFieldValue("publish_server", currentMediaHandler.getPublishHost());
+      entity.setFieldValue("icon_is_produced", "1");
+      entity.setFieldValue("is_produced", "1");
       entity.update();
 
-      aLogger.info("media with id "+uploadedMediaEntity.getValue("id") + ", mediaType " + mediaType.getValue("name") + " successfully produced");
+      aLogger.info("media with id " + uploadedMediaEntity.getFieldValue("id") +
+          ", mediaType " + mediaType.getFieldValue("name") + " successfully produced");
     }
     catch (Throwable t) {
       String message = "Error while generating media";
       try {
         if (uploadedMediaEntity!=null)
-          message = message +  " with id "+uploadedMediaEntity.getValue("id");
+          message = message +  " with id "+uploadedMediaEntity.getFieldValue("id");
         if (mediaType!=null) {
-          message = message + ", mediaType " + mediaType.getValue("name");
+          message = message + ", mediaType " + mediaType.getFieldValue("name");
         }
       }
       catch (Throwable s) {