really splitting log
[mir.git] / source / mircoders / entity / EntityContent.java
index 7468801..68e4a77 100755 (executable)
@@ -166,6 +166,8 @@ public class EntityContent extends Entity
       }
       if (key.equals("to_media_content")) {
         try {
+          /** @todo why this loggin to System.err and not
+           *  theLog.printDebugInfo() ? / rk */
           System.err.println("ASKED FOR MEDIA");
           SimpleList t = getUploadedMediaForContent();
           //SimpleHash o = t.next();
@@ -176,7 +178,7 @@ public class EntityContent extends Entity
             SimpleHash o = (SimpleHash)t.next();
             System.err.println("SCALAR: "+o.get("url"));
           }
-            
+
           t.rewind();
           //return getUploadedMediaForContent();
           return t;
@@ -277,7 +279,7 @@ public class EntityContent extends Entity
         *
         * @return freemarker.template.SimpleList
         */
-       public SimpleList getComments() throws StorageObjectException {
+       private SimpleList getComments() throws StorageObjectException {
                return ((DatabaseContent)theStorageObject).getComments(this);
        }
 
@@ -362,7 +364,7 @@ public class EntityContent extends Entity
         upMedia = currentMediaList.elementAt(n);
         //upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia);
         mediaType = ((EntityMedia)upMedia).getMediaType();
-        
+
         try {
           // ############### TODO: merge these and the getURL call into one
           // getURL helper call that just takes the Entity as a parameter
@@ -416,60 +418,16 @@ public class EntityContent extends Entity
   private SimpleList getUploadedMediaForContent()
     throws StorageObjectException, TemplateModelException
   {
-    SimpleList returnList=null;
-    EntityList currentMediaList =
-        DatabaseContentToMedia.getInstance().getUploadedMedia(this);
-    if (currentMediaList!=null && currentMediaList.getCount()>=1)
-    {
-      System.err.println("LIST NOT NULL "+this.getId());
-      Entity              upMedia,mediaType;
-      SimpleHash          upMediaSimpleHash;
-      MirMedia            mediaHandler=null;
-      Database            mediaStorage=null;
-
-      returnList = new SimpleList();
-
-      for (int n=0; n < currentMediaList.size();n++) {
-        upMedia = currentMediaList.elementAt(n);
-        //upMediaSimpleHash = HTMLTemplateProcessor.makeSimpleHash(upMedia);
-        mediaType = ((EntityMedia)upMedia).getMediaType();
-        try {
-          // ############### TODO: merge these and the getURL call into one
-          // getURL helper call that just takes the Entity as a parameter
-          // along with media_type
-          mediaHandler = MediaHelper.getHandler( mediaType );
-          mediaStorage = MediaHelper.getStorage( mediaType,
-                                                "mircoders.storage.Database");
-        } catch (MirMediaException ex) {
-          throw new TemplateModelException(ex.toString());
-        }
-    
-        // ########## TODO: this should be transparent
-        //we most likely need further info
-        upMedia = mediaStorage.selectById(upMedia.getId());
-        SimpleHash modelRoot = new SimpleHash();
-        try {
-          //upMediaSimpleHash.put("url", mediaHandler.getURL(upMedia, mediaType));
-          // ################# TODO: this is broken cause of field checking
-          // in Entity. must find a workaround
-          modelRoot.put("url", new SimpleScalar(mediaHandler.getURL(upMedia, mediaType)));
-          modelRoot.put("is_published", upMedia.getValue("is_published"));
-          //upMedia.setValueForProperty("url",
-                                    //mediaHandler.getURL(upMedia, mediaType));
-          System.err.println("URL "+mediaHandler.getURL(upMedia, mediaType));
-          System.err.println("URK'ED? "+modelRoot.get("url"));
-          System.err.println("PUB'ED? "+modelRoot.get("is_published"));
-        }
-        catch (Exception ex) {
-          throw new TemplateModelException(ex.toString());
-        }
-        //upMediaSimpleHash.put("type",mediaType.getValue("classname"));
-        //upMedia.setValueForProperty("type",mediaType.getValue("classname"));
-        modelRoot.put("type",mediaType.getValue("classname"));
-        returnList.add(modelRoot);
-      } //end for
-    } //end if currentMediaList != null
-    return returnList;
+    /** @todo all logic related to uploaded media should be moved
+     *  to EntityUploadedMedia, selection should just take place
+     *  on published media! .. will fix it later / rk
+     *
+     * ok i moved it... let's see what happens...
+     *
+     *  */
+
+    return HTMLTemplateProcessor.makeSimpleList(
+             DatabaseContentToMedia.getInstance().getUploadedMedia(this) );
   }
 
 }