restructuring producer
authorrk <rk>
Tue, 5 Feb 2002 14:21:23 +0000 (14:21 +0000)
committerrk <rk>
Tue, 5 Feb 2002 14:21:23 +0000 (14:21 +0000)
source/mircoders/entity/EntityComment.java
source/mircoders/entity/EntityContent.java
source/mircoders/producer/ProducerContent.java
source/mircoders/producer/ProducerList.java
source/mircoders/producer/ProducerStartPage.java
source/mircoders/producer/ProducerTopics.java

index 7b535be..b99e30a 100755 (executable)
@@ -56,5 +56,34 @@ public class EntityComment extends Entity
     super.setValues(theStringValues);
   }
 
+       /**
+        * overridden method getValue to include formatted date into every
+        * entityContent
+        */
+
+       public String getValue(String field)
+  {
+    String returnField = null;
+    if (field!=null)
+    {
+      if (field.equals("date_formatted"))
+      {
+                 if (hasValueForField("date"))
+       returnField = StringUtil.webdbDate2readableDate(getValue("date"));
+               }
+      else if (field.equals("description_parsed")) {
+        /** @todo the config stuff should be moved to StringUtil */
+        String extLinkName = MirConfig.getProp("Producer.ExtLinkName");
+        String intLinkName = MirConfig.getProp("Producer.IntLinkName");
+        String mailLinkName = MirConfig.getProp("Producer.MailLinkName");
+        String imageRoot = MirConfig.getProp("Producer.ImageRoot");
+        returnField = StringUtil.createHTML(getValue("description"),imageRoot,mailLinkName,extLinkName,intLinkName);
+      }
+      else
+        return super.getValue(field);
+    }
+    return returnField;
+       }
+
 
 }
index 8eac2db..80cc7c6 100755 (executable)
@@ -127,14 +127,24 @@ public class EntityContent extends Entity
 
        public String getValue(String field)
   {
-    if (field!=null && field.equals("date_formatted"))
+    String returnField = null;
+    if (field!=null)
     {
-               if (hasValueForField("date"))
-       return StringUtil.webdbDate2readableDate(getValue("date"));
-      else return null;
-               }
-    else
-      return super.getValue(field);
+      if (field.equals("date_formatted"))
+      {
+                 if (hasValueForField("date"))
+       returnField = StringUtil.webdbDate2readableDate(getValue("date"));
+               }
+      else if (field.equals("description_parsed"))
+        returnField = getDescriptionParsed();
+      else if (field.equals("content_data_parsed"))
+        returnField = getContentDataParsed();
+      else
+        return super.getValue(field);
+    }
+    return returnField;
+
+
        }
 
        /**
@@ -153,35 +163,42 @@ public class EntityContent extends Entity
                super.setValues(theStringValues);
        }
 
-       /**
-        * return the content_data as string
-        * is obsolete, because content_data is now sql-type text
-
-  public String getContentData()
-       {
-               Connection con=null;Statement stmt=null;
-               byte[] content_data=null;
-
-               try {
-                       con = theStorageObject.getPooledCon();
-                       con.setAutoCommit(false);
-                       stmt = con.createStatement();
-                       ResultSet rs = theStorageObject.executeSql(stmt,"select content_data from content where id="+getId());
-                       if(rs!=null) {
-                               if (rs.next()) {
-                                        content_data = rs.getBytes(1);
-                               }
-                               rs.close();
-                       }
-               }
-               catch (Exception e) {theLog.printError("EntityContent :: getContent failed! "+e.toString());}
-               finally {
-                       try {con.setAutoCommit(true); } catch (Exception e) {;}
-                       theStorageObject.freeConnection(con,stmt); }
 
-               return StringUtil.encodeHtml(StringUtil.unquote( new  String(content_data) ));
-       }
-*/
+  private String getContentDataParsed() {
+    String returnField = getValue("content_data");
+    if (returnField!=null & returnField.length()>0 ) {
+      returnField=StringUtil.deleteForbiddenTags(returnField);
+      //create http-links and email-links
+      if (getValue("is_html").equals("0")) {
+        /** @todo the config stuff should be moved to StringUtil */
+        String extLinkName = MirConfig.getProp("Producer.ExtLinkName");
+        String intLinkName = MirConfig.getProp("Producer.IntLinkName");
+        String mailLinkName = MirConfig.getProp("Producer.MailLinkName");
+        String imageRoot = MirConfig.getProp("Producer.ImageRoot");
+        returnField = StringUtil.createHTML(returnField,imageRoot,mailLinkName,extLinkName,intLinkName);
+      }
+      returnField = StringUtil.decodeHTMLinTags(returnField);
+    }
+    return returnField;
+  }
+
+
+  private String getDescriptionParsed() {
+    String returnField = getValue("description");
+    if (returnField != null && returnField.length()>0) {
+      returnField = StringUtil.deleteForbiddenTags(returnField);
+      if (getValue("is_html").equals("0")) {
+        /** @todo the config stuff should be moved to StringUtil */
+        String extLinkName = MirConfig.getProp("Producer.ExtLinkName");
+        String intLinkName = MirConfig.getProp("Producer.IntLinkName");
+        String mailLinkName = MirConfig.getProp("Producer.MailLinkName");
+        String imageRoot = MirConfig.getProp("Producer.ImageRoot");
+        returnField = StringUtil.createHTML(returnField,imageRoot,mailLinkName,extLinkName,intLinkName);
+      }
+      returnField = StringUtil.decodeHTMLinTags(returnField);
+    }
+    return returnField;
+  }
 
        /**
         * fetches all the comments belonging to an article
index 2d4ca51..f466a3f 100755 (executable)
@@ -66,7 +66,6 @@ public class ProducerContent extends Producer {
     String              currentMediaId;
     EntityContent       currentContent;
     EntityList          batchEntityList;
-    HashMap             currentContentValues;
     SimpleHash          imageHash = new SimpleHash();
     EntityUsers         userEntity=null;
     Entity              mediaType;
@@ -103,50 +102,12 @@ public class ProducerContent extends Producer {
       for(int i=0;i<batchEntityList.size();i++) {
         currentContent = (EntityContent)batchEntityList.elementAt(i);
         try {
-            currentContentValues = currentContent.getValues();
-
-            //because of postgres 7.1.* not needed anymore
-            //currentContentValues.put("content_data",currentContent.getContentData());
-            String date = (String)currentContentValues.get("date");
+            String date = currentContent.getValue("date");
             String year = date.substring(0,4);
             String month = date.substring(4,6);
 
             htmlFileName =  producerDocRoot
-              + "/" + year + "/" + month + "/" +  currentContentValues.get("id") + ".shtml";
-
-            currentContentValues.put("content_data",StringUtil.deleteForbiddenTags((String)currentContentValues.get("content_data")));
-            currentContentValues.put("description",StringUtil.deleteForbiddenTags((String)currentContentValues.get("description")));
-
-
-            //create http-links and email-links
-            if (currentContentValues.get("is_html").equals("0")) {
-              String temp = (String)currentContentValues.get("content_data");
-              if(temp!=null && temp.length()>0){
-                temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName);
-                temp = StringUtil.decodeHTMLinTags(temp);
-                currentContentValues.put("content_data",temp);
-              }
-              temp = (String)currentContentValues.get("description");
-              if(temp!=null && temp.length()>0){
-                temp = StringUtil.createHTML(temp,imageRoot,mailLinkName,extLinkName,intLinkName);
-                temp = StringUtil.decodeHTMLinTags(temp);
-                currentContentValues.put("description",temp);
-              }
-            } else {
-              String temp = (String)currentContentValues.get("content_data");
-              if(temp!=null && temp.length()>0){
-                temp = StringUtil.decodeHTMLinTags(temp);
-                currentContentValues.put("content_data",temp);
-              }
-              temp = (String)currentContentValues.get("description");
-              if(temp!=null && temp.length()>0){
-                temp = StringUtil.decodeHTMLinTags(temp);
-                currentContentValues.put("description",temp);
-              }
-            }
-
-            //create the freemarker-model
-            SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues);
+              + "/" + year + "/" + month + "/" +  currentContent.getValue("id") + ".shtml";
 
             /** @todo all the following should take place in EntityContent */
             // get the uploaded media
@@ -177,19 +138,7 @@ public class ProducerContent extends Producer {
             } //end if currentMediaList != null
 
             // get the comments for the article
-            // and html-ize them
-
-            /** @todo currently this doesn't work
-             *  all this should be moved to Entity, and the parsed description should
-             *  be delivered via entity.get("description_parsed") */
             SimpleList commentList = currentContent.getComments();
-            if(commentList.isEmpty()==false){
-              while(commentList.hasNext()){
-                SimpleHash comment = (SimpleHash)commentList.next();
-                SimpleScalar commentText = (SimpleScalar)comment.get("description");
-                comment.put("description",new SimpleScalar(StringUtil.createHTML(commentText.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName)));
-              }
-            }
             mergeData.put("comments", commentList);
 
             // get the topics of this article
index 99d5950..a076578 100755 (executable)
@@ -149,24 +149,6 @@ abstract public class ProducerList extends Producer {
                   contentHash.put("to_media_other", mediaListOther);
                 } //end if currentMediaList != null
 
-                                                               //content to html
-                                                               if(((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ){
-                                                                       SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
-                                                                       String temp = tempScalar.getAsString();
-                                                                       if(temp!=null && temp.length()>0){
-                                                                               temp = StringUtil.createHTML(temp);
-                                                                               temp = StringUtil.decodeHTMLinTags(temp);
-                                                                               contentHash.put("description",temp);
-                                                                       }
-                                                               } else {
-                                                                       SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
-                                                                       String temp = tempScalar.getAsString();
-                                                                       if(temp!=null && temp.length()>0){
-                                                                               temp = StringUtil.decodeHTMLinTags(temp);
-                                                                               contentHash.put("description",temp);
-                                                                       }
-                                                               }
-
             } catch (Exception e) {
                 logHTML(htmlout, "Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString());
                 theLog.printError("Producer.List id " +currentContent.getId()+ " seems corrupt, skipping it :: "+e.toString());
index e9423e4..dafda02 100755 (executable)
@@ -203,13 +203,6 @@ public class ProducerStartPage extends Producer {
             contentHash.put("to_media_video", mediaListVideo);
             contentHash.put("to_media_other", mediaListOther);
           } //end if currentMediaList != null
-                                       //convert to html
-                                       if ( ((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ) {
-                                               SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
-                                               String temp = StringUtil.createHTML(tempScalar.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName);
-                                               temp = StringUtil.decodeHTMLinTags(temp);
-                                               contentHash.put("description",temp);
-                                       }
 
                        } catch (Exception e) {
         logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping");
@@ -276,14 +269,6 @@ public class ProducerStartPage extends Producer {
             contentHash.put("to_media_other", mediaListOther);
           } //end if currentMediaList != null
 
-                                       //convert to html
-          theLog.printDebugInfo("############### html conversion");
-                                       if ( ((SimpleScalar)contentHash.get("is_html")).getAsString().equals("0") ) {
-                                               SimpleScalar tempScalar = (SimpleScalar)contentHash.get("description");
-                                               String temp = StringUtil.createHTML(tempScalar.getAsString(),imageRoot,mailLinkName,extLinkName,intLinkName);
-                                               temp = StringUtil.decodeHTMLinTags(temp);
-                                               contentHash.put("description",temp);
-                                       }
                        } catch (Exception e) {
         logHTML(htmlout, "Producer.StartPage error id: " + currentContent.getId() + ", skipping");
         theLog.printError("Producer.StartPage error id: " + currentContent.getId() + ", skipping"+e.toString());
index 7fb06c0..cbe4826 100755 (executable)
@@ -144,11 +144,7 @@ public class ProducerTopics extends ProducerList {
                 specialHash.put("to_media_video", mediaListVideo);
                 specialHash.put("to_media_other", mediaListOther);
               } //end if currentMediaList != null
-                                                       //convert to html
-                                                       if ( ((SimpleScalar)specialHash.get("is_html")).getAsString().equals("0") ) {
-                                                               SimpleScalar temp = (SimpleScalar)specialHash.get("description");
-                                                               specialHash.put("description",StringUtil.createHTML(temp.getAsString()));
-                                                       }
+
               setAdditional("special",specialHash);
           } catch (Exception e) {
             theLog.printError("ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());