From 635db236fe78484b5f7f0158ad8054b189bf7a79 Mon Sep 17 00:00:00 2001 From: fh Date: Tue, 28 Aug 2001 21:12:32 +0000 Subject: [PATCH] Initial revision --- source/mircoders/entity/EntityArticleType.java | 32 ++ source/mircoders/entity/EntityBreaking.java | 41 ++ source/mircoders/entity/EntityComment.java | 69 ++++ source/mircoders/entity/EntityContent.java | 205 ++++++++++ source/mircoders/entity/EntityFeature.java | 47 +++ source/mircoders/entity/EntityGruppen.java | 47 +++ source/mircoders/entity/EntityImage.java | 155 ++++++++ source/mircoders/entity/EntityImageColor.java | 32 ++ source/mircoders/entity/EntityImageFormat.java | 31 ++ source/mircoders/entity/EntityImageLayout.java | 31 ++ source/mircoders/entity/EntityImageType.java | 31 ++ source/mircoders/entity/EntityLanguage.java | 32 ++ source/mircoders/entity/EntityMediafolder.java | 50 +++ source/mircoders/entity/EntityMessage.java | 32 ++ source/mircoders/entity/EntityRights.java | 31 ++ source/mircoders/entity/EntityTopics.java | 47 +++ source/mircoders/entity/EntityUsers.java | 49 +++ source/mircoders/entity/EntityVideo.java | 115 ++++++ source/mircoders/input/XmlFilenameFilter.java | 38 ++ source/mircoders/input/XmlHandler.java | 63 ++++ source/mircoders/input/XmlInputParser.java | 189 ++++++++++ source/mircoders/module/ModuleBreaking.java | 47 +++ source/mircoders/module/ModuleComment.java | 44 +++ source/mircoders/module/ModuleContent.java | 178 +++++++++ source/mircoders/module/ModuleFeature.java | 45 +++ source/mircoders/module/ModuleGruppen.java | 64 ++++ source/mircoders/module/ModuleImages.java | 42 +++ source/mircoders/module/ModuleMediafolder.java | 51 +++ source/mircoders/module/ModuleMessage.java | 49 +++ source/mircoders/module/ModuleSchwerpunkt.java | 45 +++ source/mircoders/module/ModuleTopics.java | 43 +++ source/mircoders/module/ModuleUsers.java | 75 ++++ source/mircoders/producer/DEADJOE | 11 + source/mircoders/producer/Producer.java | 157 ++++++++ source/mircoders/producer/ProducerAll.java | 105 ++++++ source/mircoders/producer/ProducerContent.java | 157 ++++++++ source/mircoders/producer/ProducerFeature.java | 60 +++ source/mircoders/producer/ProducerImages.java | 109 ++++++ source/mircoders/producer/ProducerList.java | 160 ++++++++ source/mircoders/producer/ProducerNavigation.java | 69 ++++ source/mircoders/producer/ProducerOpenPosting.java | 52 +++ source/mircoders/producer/ProducerOverview.java | 177 +++++++++ source/mircoders/producer/ProducerStartPage.java | 131 +++++++ source/mircoders/producer/ProducerTopics.java | 117 ++++++ source/mircoders/producer/ProducerWap.java | 106 ++++++ .../mircoders/servlet/ServletModuleBreaking.java | 75 ++++ source/mircoders/servlet/ServletModuleComment.java | 126 +++++++ source/mircoders/servlet/ServletModuleContent.java | 416 +++++++++++++++++++++ source/mircoders/servlet/ServletModuleGroups.java | 48 +++ source/mircoders/servlet/ServletModuleImages.java | 328 ++++++++++++++++ .../servlet/ServletModuleMediafolder.java | 51 +++ source/mircoders/servlet/ServletModuleMessage.java | 80 ++++ .../mircoders/servlet/ServletModuleOpenIndy.java | 221 +++++++++++ .../mircoders/servlet/ServletModuleProducer.java | 70 ++++ .../servlet/ServletModuleSchwerpunkt.java | 47 +++ source/mircoders/servlet/ServletModuleTopics.java | 45 +++ source/mircoders/servlet/ServletModuleUsers.java | 82 ++++ source/mircoders/storage/DatabaseArticleType.java | 50 +++ source/mircoders/storage/DatabaseBreaking.java | 44 +++ source/mircoders/storage/DatabaseComment.java | 70 ++++ source/mircoders/storage/DatabaseContent.java | 107 ++++++ .../mircoders/storage/DatabaseContentToTopics.java | 217 +++++++++++ source/mircoders/storage/DatabaseFeature.java | 51 +++ source/mircoders/storage/DatabaseGroups.java | 46 +++ source/mircoders/storage/DatabaseImageColor.java | 46 +++ source/mircoders/storage/DatabaseImageFormat.java | 46 +++ source/mircoders/storage/DatabaseImageLayout.java | 46 +++ source/mircoders/storage/DatabaseImageType.java | 46 +++ source/mircoders/storage/DatabaseImages.java | 76 ++++ source/mircoders/storage/DatabaseLanguage.java | 50 +++ source/mircoders/storage/DatabaseMediafolder.java | 54 +++ source/mircoders/storage/DatabaseMessages.java | 49 +++ source/mircoders/storage/DatabaseRights.java | 46 +++ source/mircoders/storage/DatabaseTopics.java | 53 +++ source/mircoders/storage/DatabaseUsers.java | 48 +++ source/mircoders/storage/DatabaseVideos.java | 74 ++++ 76 files changed, 6269 insertions(+) create mode 100755 source/mircoders/entity/EntityArticleType.java create mode 100755 source/mircoders/entity/EntityBreaking.java create mode 100755 source/mircoders/entity/EntityComment.java create mode 100755 source/mircoders/entity/EntityContent.java create mode 100755 source/mircoders/entity/EntityFeature.java create mode 100755 source/mircoders/entity/EntityGruppen.java create mode 100755 source/mircoders/entity/EntityImage.java create mode 100755 source/mircoders/entity/EntityImageColor.java create mode 100755 source/mircoders/entity/EntityImageFormat.java create mode 100755 source/mircoders/entity/EntityImageLayout.java create mode 100755 source/mircoders/entity/EntityImageType.java create mode 100755 source/mircoders/entity/EntityLanguage.java create mode 100755 source/mircoders/entity/EntityMediafolder.java create mode 100755 source/mircoders/entity/EntityMessage.java create mode 100755 source/mircoders/entity/EntityRights.java create mode 100755 source/mircoders/entity/EntityTopics.java create mode 100755 source/mircoders/entity/EntityUsers.java create mode 100755 source/mircoders/entity/EntityVideo.java create mode 100755 source/mircoders/input/XmlFilenameFilter.java create mode 100755 source/mircoders/input/XmlHandler.java create mode 100755 source/mircoders/input/XmlInputParser.java create mode 100755 source/mircoders/module/ModuleBreaking.java create mode 100755 source/mircoders/module/ModuleComment.java create mode 100755 source/mircoders/module/ModuleContent.java create mode 100755 source/mircoders/module/ModuleFeature.java create mode 100755 source/mircoders/module/ModuleGruppen.java create mode 100755 source/mircoders/module/ModuleImages.java create mode 100755 source/mircoders/module/ModuleMediafolder.java create mode 100755 source/mircoders/module/ModuleMessage.java create mode 100755 source/mircoders/module/ModuleSchwerpunkt.java create mode 100755 source/mircoders/module/ModuleTopics.java create mode 100755 source/mircoders/module/ModuleUsers.java create mode 100755 source/mircoders/producer/DEADJOE create mode 100755 source/mircoders/producer/Producer.java create mode 100755 source/mircoders/producer/ProducerAll.java create mode 100755 source/mircoders/producer/ProducerContent.java create mode 100755 source/mircoders/producer/ProducerFeature.java create mode 100755 source/mircoders/producer/ProducerImages.java create mode 100755 source/mircoders/producer/ProducerList.java create mode 100755 source/mircoders/producer/ProducerNavigation.java create mode 100755 source/mircoders/producer/ProducerOpenPosting.java create mode 100755 source/mircoders/producer/ProducerOverview.java create mode 100755 source/mircoders/producer/ProducerStartPage.java create mode 100755 source/mircoders/producer/ProducerTopics.java create mode 100755 source/mircoders/producer/ProducerWap.java create mode 100755 source/mircoders/servlet/ServletModuleBreaking.java create mode 100755 source/mircoders/servlet/ServletModuleComment.java create mode 100755 source/mircoders/servlet/ServletModuleContent.java create mode 100755 source/mircoders/servlet/ServletModuleGroups.java create mode 100755 source/mircoders/servlet/ServletModuleImages.java create mode 100755 source/mircoders/servlet/ServletModuleMediafolder.java create mode 100755 source/mircoders/servlet/ServletModuleMessage.java create mode 100755 source/mircoders/servlet/ServletModuleOpenIndy.java create mode 100755 source/mircoders/servlet/ServletModuleProducer.java create mode 100755 source/mircoders/servlet/ServletModuleSchwerpunkt.java create mode 100755 source/mircoders/servlet/ServletModuleTopics.java create mode 100755 source/mircoders/servlet/ServletModuleUsers.java create mode 100755 source/mircoders/storage/DatabaseArticleType.java create mode 100755 source/mircoders/storage/DatabaseBreaking.java create mode 100755 source/mircoders/storage/DatabaseComment.java create mode 100755 source/mircoders/storage/DatabaseContent.java create mode 100755 source/mircoders/storage/DatabaseContentToTopics.java create mode 100755 source/mircoders/storage/DatabaseFeature.java create mode 100755 source/mircoders/storage/DatabaseGroups.java create mode 100755 source/mircoders/storage/DatabaseImageColor.java create mode 100755 source/mircoders/storage/DatabaseImageFormat.java create mode 100755 source/mircoders/storage/DatabaseImageLayout.java create mode 100755 source/mircoders/storage/DatabaseImageType.java create mode 100755 source/mircoders/storage/DatabaseImages.java create mode 100755 source/mircoders/storage/DatabaseLanguage.java create mode 100755 source/mircoders/storage/DatabaseMediafolder.java create mode 100755 source/mircoders/storage/DatabaseMessages.java create mode 100755 source/mircoders/storage/DatabaseRights.java create mode 100755 source/mircoders/storage/DatabaseTopics.java create mode 100755 source/mircoders/storage/DatabaseUsers.java create mode 100755 source/mircoders/storage/DatabaseVideos.java diff --git a/source/mircoders/entity/EntityArticleType.java b/source/mircoders/entity/EntityArticleType.java new file mode 100755 index 00000000..69ee99f5 --- /dev/null +++ b/source/mircoders/entity/EntityArticleType.java @@ -0,0 +1,32 @@ +package mircoders.entity; + +/** + * Title: EntityArticleType + * Description: Maps table "article_type" to Java Object + * Copyright: Copyright (c) 2001 + * Company: Indymedia.de + * @author /rk + * @version 1.0 + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +public class EntityArticleType extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityArticleType() { super(); instances++; } + public EntityArticleType(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityBreaking.java b/source/mircoders/entity/EntityBreaking.java new file mode 100755 index 00000000..bb8016f5 --- /dev/null +++ b/source/mircoders/entity/EntityBreaking.java @@ -0,0 +1,41 @@ +package mircoders.entity; + +/** + * Title: EntityBreaking + * Description: Maps table "breaking" to Java Object + * Copyright: Copyright (c) 2001 + * Company: Indymedia.de + * @author /rk + * @version 1.0 + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +public class EntityBreaking extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityBreaking() { super(); instances++; } + public EntityBreaking(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + + + public HashMap getValues() { + HashMap returnHash = super.getValues(); + String date=null; + + if ((date=(String)returnHash.get("webdb_create"))!=null) + returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date)); + return returnHash; + } +} diff --git a/source/mircoders/entity/EntityComment.java b/source/mircoders/entity/EntityComment.java new file mode 100755 index 00000000..462a636b --- /dev/null +++ b/source/mircoders/entity/EntityComment.java @@ -0,0 +1,69 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; + +/** + * This class maps one line of the comment-table to a java-object. + * + * @author RK + * @version 1.0 + */ + + +public class EntityComment extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityComment() + { + super(); + instances++; + } + + public EntityComment(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public HashMap getValues() { + HashMap returnHash = super.getValues(); + String create = (String)returnHash.get("webdb_create"); + returnHash.put("date",StringUtil.dateToReadableDate(create)); + + return returnHash; + } + +/** + * overridden method setValues to patch creator_main_url + */ + + public void setValues(HashMap theStringValues) + { + if (theStringValues != null) { + if (!theStringValues.containsKey("is_published")) + theStringValues.put("is_published","0"); + if (theStringValues.containsKey("main_url")) + if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) { + theStringValues.remove("main_url"); + } else if (!((String)theStringValues.get("main_url")).startsWith("http://")){ + theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url"))); + } + } + super.setValues(theStringValues); + } + + + public void finalize() { + instances--; + super.finalize(); + } +} diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java new file mode 100755 index 00000000..0345cea2 --- /dev/null +++ b/source/mircoders/entity/EntityContent.java @@ -0,0 +1,205 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import freemarker.template.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; + +/** + * this class implements mapping of one line of the database table content + * to a java object + * + * @author RK + * @version 2001 + */ + + +public class EntityContent extends AbstractEntity implements Entity +{ + + private static int instances; + + // constructors + + public EntityContent() + { + super(); + instances++; + //content_data is now filed-type "text" + //streamedInput = new ArrayList(); + //streamedInput.add("content_data"); + } + + public EntityContent(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public void finalize() { + instances--; + super.finalize(); + } + + // + // methods + + /** + * set is_produced flag for the article + */ + + public void setProduced(boolean yesno) + { + Connection con=null;Statement stmt=null; + String value = (yesno) ? "1":"0"; + String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'"; + try { + con = theStorageObject.getPooledCon(); + /** @todo should be preparedStatement: faster!! */ + stmt = con.createStatement(); + theStorageObject.executeUpdate(stmt,sql); + } catch (StorageObjectException e) { + theLog.printDebugInfo(e.toString() + "\n -- set produced failed"); + } catch (SQLException e) { + theLog.printDebugInfo(e.toString() + "\n -- set produced failed"); + } finally { + theStorageObject.freeConnection(con,stmt); + } + } + + + /** + * make openposting to newswire + */ + + public void newswire() + { + String sql = "update content set to_article_type='1', is_produced='0' where id='" + getId()+"'"; + try { + theStorageObject.executeUpdate(sql); + } catch (StorageObjectException e) { + theLog.printError(e.toString() + "newswire failed"); + } catch (SQLException e) { + theLog.printError(e.toString() + "newswire failed"); + } + } + + + /** + * dettach from media + */ + + public void dettach() + { + String sql = "update content set to_media=null, is_produced='0' where id='" + getId()+"'"; + try { + theStorageObject.executeUpdate(sql); + } catch (StorageObjectException e) { + theLog.printError(e.toString() + "dettach failed"); + } catch (SQLException e) { + theLog.printError(e.toString() + "dettach failed"); + } + } + + /** + * attach to media + */ + + public void attach(String mid) + { + if (mid!=null) { + String sql = "update content set to_media='" + mid + "', is_produced='0' where id='" + getId()+"'"; + try { + theStorageObject.executeUpdate(sql); + } catch (StorageObjectException e) { + theLog.printError(e.toString() + "attach failed"); + } catch (SQLException e) { + theLog.printError(e.toString() + "attach failed"); + } + } + else + theLog.printError("EntityContent: attach without mid"); + } + + /** + * overridden method getValues to include formatted date into every + * entityContent + */ + + public HashMap getValues() { + HashMap returnHash = super.getValues(); + String date=null; + + if ((date=(String)returnHash.get("date"))!=null) + returnHash.put("date_formatted", StringUtil.webdbDate2readableDate(date)); + if ((date=(String)returnHash.get("webdb_create"))!=null) + returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date)); + if ((date=(String)returnHash.get("webdb_lastchange"))!=null) + returnHash.put("webdb_lastchange_formatted", StringUtil.dateToReadableDate(date)); + return returnHash; + } + + /** + * overridden method setValues to patch creator_main_url + */ + public void setValues(HashMap theStringValues) { + if (theStringValues != null) { + if (theStringValues.containsKey("creator_main_url")){ + if (((String)theStringValues.get("creator_main_url")).equalsIgnoreCase("http://")){ + theStringValues.remove("creator_main_url"); + } else if (!((String)theStringValues.get("creator_main_url")).startsWith("http://")){ + theStringValues.put("creator_main_url","http://"+((String)theStringValues.get("creator_main_url"))); + } + } + } + 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) )); + } +*/ + + /** + * fetches all the comments belonging to an article + * + * @return freemarker.template.SimpleList + */ + public SimpleList getComments() { + return ((DatabaseContent)theStorageObject).getComments(this); + } + + +} diff --git a/source/mircoders/entity/EntityFeature.java b/source/mircoders/entity/EntityFeature.java new file mode 100755 index 00000000..5f85c9fd --- /dev/null +++ b/source/mircoders/entity/EntityFeature.java @@ -0,0 +1,47 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 29.6.1999 + */ + + +public class EntityFeature extends AbstractEntity implements Entity +{ + private static int instances; + + + public EntityFeature() + { + super(); + instances++; + } + + public EntityFeature(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public void update() throws StorageObjectException{ + super.update(); + DatabaseContent dbContent = DatabaseContent.getInstance(); + dbContent.setUnproduced("to_feature="+getId()); + } + + public void finalize() { + instances--; + super.finalize(); + } +} diff --git a/source/mircoders/entity/EntityGruppen.java b/source/mircoders/entity/EntityGruppen.java new file mode 100755 index 00000000..7c0a217c --- /dev/null +++ b/source/mircoders/entity/EntityGruppen.java @@ -0,0 +1,47 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 29.6.1999 + */ + + +public class EntityGruppen extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityGruppen() + { + super(); + instances++; + } + + public EntityGruppen(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public void update() throws StorageObjectException{ + super.update(); + DatabaseContent dbContent = DatabaseContent.getInstance(); + dbContent.setUnproduced("urheber_id="+getId()); + } + + public void finalize() { + instances--; + super.finalize(); + } +} diff --git a/source/mircoders/entity/EntityImage.java b/source/mircoders/entity/EntityImage.java new file mode 100755 index 00000000..6ab1a8f8 --- /dev/null +++ b/source/mircoders/entity/EntityImage.java @@ -0,0 +1,155 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 11.11.2000 + */ + + +public class EntityImage extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityImage() + { + super(); + instances++; + } + + public EntityImage(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + // + // methods + + + + public byte[] getImage() + { + theLog.printDebugInfo("--getimage started"); + Connection con=null;Statement stmt=null; + byte[] img_data=null; + + try { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + stmt = con.createStatement(); + ResultSet rs = theStorageObject.executeSql(stmt,"select image_data from images where id="+getId()); + if(rs!=null) { + if (rs.next()) { + img_data = rs.getBytes(1); + } + rs.close(); + } + } + catch (Exception e) {theLog.printDebugInfo("-- getImage gescheitert: "+e.toString());} + finally { + try {con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,stmt); } + + return img_data; + } + + public void setImage(byte[] uploadData, int imageType) + { + if (uploadData!=null) { + Connection con=null;PreparedStatement pstmt=null; + try { + + theLog.printDebugInfo("settimage :: making internal representation of image"); + WebdbImage webdbImage= new WebdbImage(uploadData,imageType); + theLog.printDebugInfo("settimage :: made internal representation of image"); + byte[] imageData = webdbImage.getImage(); + theLog.printDebugInfo("settimage :: getImage"); + byte[] iconData = webdbImage.getIcon(); + theLog.printDebugInfo("settimage :: getIcon"); + + if (iconData!=null && imageData!=null) { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + theLog.printDebugInfo("settimage :: trying to insert image"); + + // setting values + String sql = "update images set img_height='"+webdbImage.getImageHeight() + + "',img_width='" + webdbImage.getImageWidth() + + "',icon_height='" + webdbImage.getIconHeight() + + "',icon_width='" + webdbImage.getIconWidth() + "', image_data=?, icon_data=? where id="+getId(); + theLog.printDebugInfo("settimage :: updating sizes: "+ sql); + pstmt = con.prepareStatement(sql); + pstmt.setBytes(1, imageData); + pstmt.setBytes(2, iconData); + pstmt.executeUpdate(); + sql="update content set is_produced='0' where to_media="+getId(); + pstmt = con.prepareStatement(sql); + pstmt.executeUpdate(); + } + } + catch (Exception e) {theLog.printDebugInfo("settimage :: setImage gescheitert: "+e.toString());} + finally { + try {con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,pstmt); } + } + } + + public void update() throws StorageObjectException { + super.update(); + try { + theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId()); + } catch (SQLException e) { + theLog.printError("EntityImage :: update :: failed!! "+ e.toString()); + } + } + + public void setValues(HashMap theStringValues) + { + if (theStringValues != null) { + if (!theStringValues.containsKey("is_published")) + theStringValues.put("is_published","0"); + } + super.setValues(theStringValues); + } + + public byte[] getIcon() + { + Connection con=null;Statement stmt=null; + byte[] img_data=null; + + try { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + stmt = con.createStatement(); + ResultSet rs = theStorageObject.executeSql(stmt,"select icon_data from images where id="+getId()); + if(rs!=null) { + if (rs.next()) { + img_data = rs.getBytes(1); + } + rs.close(); + } + } + catch (Exception e) {theLog.printDebugInfo("-- getIcon gescheitert: "+e.toString());} + finally { + try {con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,stmt); } + + return img_data; + } + + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityImageColor.java b/source/mircoders/entity/EntityImageColor.java new file mode 100755 index 00000000..0f42e8c3 --- /dev/null +++ b/source/mircoders/entity/EntityImageColor.java @@ -0,0 +1,32 @@ +package mircoders.entity; + +/** + * Title: EntityImageColor + * Description: Maps table "img_color" to Java Object + * Copyright: Copyright (c) 2001 + * Company: Indymedia.de + * @author /rk + * @version 1.0 + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +public class EntityImageColor extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityImageColor() { super(); instances++; } + public EntityImageColor(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityImageFormat.java b/source/mircoders/entity/EntityImageFormat.java new file mode 100755 index 00000000..7e2b3bc7 --- /dev/null +++ b/source/mircoders/entity/EntityImageFormat.java @@ -0,0 +1,31 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 15.01.2001 + */ + + +public class EntityImageFormat extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityImageFormat() { super(); instances++; } + public EntityImageFormat(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityImageLayout.java b/source/mircoders/entity/EntityImageLayout.java new file mode 100755 index 00000000..f67591c1 --- /dev/null +++ b/source/mircoders/entity/EntityImageLayout.java @@ -0,0 +1,31 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 15.01.2001 + */ + + +public class EntityImageLayout extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityImageLayout() { super(); instances++; } + public EntityImageLayout(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityImageType.java b/source/mircoders/entity/EntityImageType.java new file mode 100755 index 00000000..d86e6548 --- /dev/null +++ b/source/mircoders/entity/EntityImageType.java @@ -0,0 +1,31 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 15.01.2001 + */ + + +public class EntityImageType extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityImageType() { super(); instances++; } + public EntityImageType(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityLanguage.java b/source/mircoders/entity/EntityLanguage.java new file mode 100755 index 00000000..a34ef2a6 --- /dev/null +++ b/source/mircoders/entity/EntityLanguage.java @@ -0,0 +1,32 @@ +package mircoders.entity; + +/** + * Title: EntityLanguage + * Description: Maps table "language" to Java Object + * Copyright: Copyright (c) 2001 + * Company: Indymedia.de + * @author /rk + * @version 1.0 + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +public class EntityLanguage extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityLanguage() { super(); instances++; } + public EntityLanguage(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityMediafolder.java b/source/mircoders/entity/EntityMediafolder.java new file mode 100755 index 00000000..53a747b8 --- /dev/null +++ b/source/mircoders/entity/EntityMediafolder.java @@ -0,0 +1,50 @@ +package mircoders.entity; + +/** + * Title: Mir + * Description: Ihre Beschreibung + * Copyright: Copyright (c) 1999 + * Company: + * @author + * @version + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 29.6.1999 + */ + + +public class EntityMediafolder extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityMediafolder() + { + super(); + instances++; + } + + public EntityMediafolder(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public void finalize() { + instances--; + super.finalize(); + } +} diff --git a/source/mircoders/entity/EntityMessage.java b/source/mircoders/entity/EntityMessage.java new file mode 100755 index 00000000..a2c96e53 --- /dev/null +++ b/source/mircoders/entity/EntityMessage.java @@ -0,0 +1,32 @@ +package mircoders.entity; + +/** + * Title: EntityMessages + * Description: Maps table "messages" to Java Object + * Copyright: Copyright (c) 2001 + * Company: Indymedia.de + * @author /rk + * @version 1.0 + */ + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +public class EntityMessage extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityMessage() { super(); instances++; } + public EntityMessage(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityRights.java b/source/mircoders/entity/EntityRights.java new file mode 100755 index 00000000..7cae200c --- /dev/null +++ b/source/mircoders/entity/EntityRights.java @@ -0,0 +1,31 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 15.01.2001 + */ + + +public class EntityRights extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityRights() { super(); instances++; } + public EntityRights(StorageObject theStorage) { this(); setStorage(theStorage); } + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/entity/EntityTopics.java b/source/mircoders/entity/EntityTopics.java new file mode 100755 index 00000000..0a736b3d --- /dev/null +++ b/source/mircoders/entity/EntityTopics.java @@ -0,0 +1,47 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.storage.*; +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 29.6.1999 + */ + + +public class EntityTopics extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityTopics(){ + super(); + instances++; + } + + public EntityTopics(StorageObject theStorage) + { + this(); + setStorage(theStorage); + } + + // Dependencies einhalten + public void update() throws StorageObjectException{ + super.update(); + DatabaseContent dbContent = DatabaseContent.getInstance(); + dbContent.setUnproduced("to_topic="+getId()); + } + + public void finalize() { + instances--; + super.finalize(); + } +} diff --git a/source/mircoders/entity/EntityUsers.java b/source/mircoders/entity/EntityUsers.java new file mode 100755 index 00000000..8e9459b9 --- /dev/null +++ b/source/mircoders/entity/EntityUsers.java @@ -0,0 +1,49 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * This class is objectmapping of database webdb_users + * + * @author RK + * @version 11.11.2000 + */ + + +public class EntityUsers extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityUsers() + { + super(); + instances++; + } + + public EntityUsers(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + public void finalize() { + instances--; + super.finalize(); + } + + // Methods + + public boolean isAdmin() + { + String admin=getValue("is_admin"); + //theLog.printDebugInfo("admin::::"+admin); + return (admin!=null&&admin.equals("1"))?true:false; + } + +} diff --git a/source/mircoders/entity/EntityVideo.java b/source/mircoders/entity/EntityVideo.java new file mode 100755 index 00000000..802fc8f9 --- /dev/null +++ b/source/mircoders/entity/EntityVideo.java @@ -0,0 +1,115 @@ +package mircoders.entity; + +import java.lang.*; +import java.io.*; +import java.util.*; +import java.sql.*; + +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +/** + * Diese Klasse enthält die Daten eines MetaObjekts + * + * @author RK + * @version 11.11.2000 + */ + + +public class EntityVideo extends AbstractEntity implements Entity +{ + private static int instances; + + public EntityVideo() + { + super(); + instances++; + } + + public EntityVideo(StorageObject theStorage) { + this(); + setStorage(theStorage); + } + + // + // methods + + public byte[] getVideoData() + { + + Connection con=null;Statement stmt=null; + byte[] video_data=null; + + try { + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + stmt = con.createStatement(); + ResultSet rs = theStorageObject.executeSql(stmt,"select video_data from video where id="+getId()); + if(rs!=null) { + if (rs.next()) { + video_data = rs.getBytes(1); + } + rs.close(); + } + } + catch (Exception e) {theLog.printDebugInfo("-- getImage gescheitert: "+e.toString());} + finally { + try {con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,stmt); } + + return video_data; + } + + public void setVideoData(byte[] uploadData) + { + if (uploadData!=null) { + Connection con=null;PreparedStatement pstmt=null; + try { + + con = theStorageObject.getPooledCon(); + con.setAutoCommit(false); + theLog.printDebugInfo("setvideo :: trying to insert video"); + + // setting values + String sql = "update videos set image_data=? where id="+getId(); + theLog.printDebugInfo("setvideo: "+ sql); + pstmt = con.prepareStatement(sql); + pstmt.setBytes(1, uploadData); + pstmt.executeUpdate(); + sql="update content set is_produced='0' where to_media="+getId(); + pstmt = con.prepareStatement(sql); + pstmt.executeUpdate(); + } + catch (Exception e) {theLog.printDebugInfo("setvideo :: setvideo gescheitert: "+e.toString());} + finally { + try {con.setAutoCommit(true); } catch (Exception e) {;} + theStorageObject.freeConnection(con,pstmt); } + } + } + + public void update() throws StorageObjectException { + super.update(); + try { + theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId()); + } catch (SQLException e) { + theLog.printError("video :: update :: failed!! "+ e.toString()); + } + } + + public void setValues(HashMap theStringValues) + { + if (theStringValues != null) { + if (!theStringValues.containsKey("is_published")) + theStringValues.put("is_published","0"); + } + super.setValues(theStringValues); + } + + + public void finalize() { + instances--; + super.finalize(); + } + +} diff --git a/source/mircoders/input/XmlFilenameFilter.java b/source/mircoders/input/XmlFilenameFilter.java new file mode 100755 index 00000000..9c0a9db5 --- /dev/null +++ b/source/mircoders/input/XmlFilenameFilter.java @@ -0,0 +1,38 @@ +package mircoders.input; + +import java.io.FilenameFilter; +import java.io.File; + + +/** + * Title: Indy-Prodsystem + * Description: + * Copyright: Copyright (c) 2001 + * Company: indymedia.de + * @author idfx + * @version 1.0 + */ +public class XmlFilenameFilter + implements FilenameFilter { + + /** + * put your documentation comment here + */ + public XmlFilenameFilter () { + } + + /** + * @param dir + * @param name + * @return + */ + public boolean accept (File dir, String name) { + if (name.endsWith(".xml")) { + return true; + } + return false; + } +} + + + diff --git a/source/mircoders/input/XmlHandler.java b/source/mircoders/input/XmlHandler.java new file mode 100755 index 00000000..8297e892 --- /dev/null +++ b/source/mircoders/input/XmlHandler.java @@ -0,0 +1,63 @@ +/** + * Title: Indy + * Description: + * Copyright: Copyright (c) 2001 + * Company: indymedia.de + * @author idfx + * @version 1.0 + * + * formatted with JxBeauty (c) johann.langhofer@nextra.at + */ + + +package mircoders.input; + +import org.xml.sax.helpers.DefaultHandler; +import org.xml.sax.Attributes; +import java.util.HashMap; + + +/** + * put your documentation comment here + */ +public class XmlHandler extends DefaultHandler { + static HashMap valueHash = new HashMap(); + + /** + * parses every starting XML-Element + * @param uri + * @param name + * @param qname + * @param atts + */ + public void startElement (String uri, String name, String qname, Attributes atts) { + HashMap values = new HashMap(); + if (name.equals("content")) { + //table content + valueHash.put("table", "Content"); + valueHash.put("values", values); + // content-articles should be published immediatly + ((HashMap)valueHash.get("values")).put("is_published", "1"); + } + else if (name.equals("breaking")) { + //table content + valueHash.put("table", "Breaking"); + valueHash.put("values", values); + } + else { + //System.out.println(name + ": " + atts.getValue("value")); + ((HashMap)valueHash.get("values")).put(name, atts.getValue("value")); + } + } + + /** + * Returns the HashMap filled with the Values of the parsed XML-File + * @return + */ + public static HashMap returnHash () { + return valueHash; + } +} + + + diff --git a/source/mircoders/input/XmlInputParser.java b/source/mircoders/input/XmlInputParser.java new file mode 100755 index 00000000..f27902d3 --- /dev/null +++ b/source/mircoders/input/XmlInputParser.java @@ -0,0 +1,189 @@ +/** + * Title: Indy + * Description: Parses Xml-Files into the Database + * Copyright: Copyright (c) 2001 + * Company: indymedia.de + * @author idfx + * @version 1.0 + * + * formatted with JxBeauty (c) johann.langhofer@nextra.at + */ + + +package mircoders.input; + +import java.io.*; +import java.util.*; +import java.lang.reflect.*; +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import mir.storage.*; +import mir.module.*; +import org.xml.sax.*; +import org.xml.sax.helpers.*; +import com.icl.saxon.aelfred.*; + + +/** + * put your documentation comment here + */ +public class XmlInputParser { + static Logfile logger; + + /** + * the main-method + * a DirectoryName should be given + */ + public static void main (String[] args) { + //logging + File logDir = new File(args[0] + "LOG"); + if (!logDir.exists()) { + logDir.mkdir(); + } + logger = Logfile.getInstance(args[0] + "LOG/xml.log"); + XmlInputParser xmlInputParser = new XmlInputParser(); + //get the config-file + Configuration.initConfig("config"); + //parse the xml-files in the given directory + xmlInputParser.parse(args[0]); + // stop freemarker templateCache (cracy) + HTMLTemplateProcessor.stopAutoUpdate(); + //stop it + System.exit(0); + } + + /** + * this method parses the xml-file an + * returns 0 if succesful + * returns -1 if failed + */ + private boolean loadXml (String fileName) { + try { + XMLReader reader = new SAXDriver(); + InputSource is = new InputSource(new FileInputStream(fileName)); + reader.setContentHandler(new XmlHandler()); + reader.parse(is); + } catch (IOException ex) { + logger.printError(ex.toString()); + return false; + } catch (SAXException ex) { + logger.printError(ex.toString()); + return false; + } + return true; + } + + /** + * Reads all XML-Files in the given Directory + * and returns a String[] with the filenames + * @param dir + * @return + */ + public String[] readDir (String dir) { + File file = new File(dir); + String[] fileNames = file.list(new XmlFilenameFilter()); + return fileNames; + } + + /** + * parses the XML-Files in the given Directory + * @param dir + */ + public void parse (String dir) { + File goodDir = new File(dir + "/GOOD"); + File badDir = new File(dir + "/BAD"); + boolean result = false; + //read the directory + String[] fileNames = readDir(dir); + for (int i = 0; i < fileNames.length; i++) { + //parse every file + result = loadXml(dir + "/" + fileNames[i]); + if (result == true) { //if succesfully parsed + HashMap hash = XmlHandler.returnHash(); + HashMap val = (HashMap)hash.get("values"); + //set the default user + val.put("to_publisher", "5"); + String table = (String)hash.get("table"); + AbstractModule moduleInstance = null; + try { + Class databaseClass = Class.forName("mir.storage.Database" + + table); + Method m = databaseClass.getMethod("getInstance", null); + Database databaseInstance = (Database)m.invoke(null, null); + moduleInstance = (AbstractModule)Class.forName("mir.module.Module" + + table).newInstance(); + //AbstractModule moduleInstance = new ModuleContent(databaseInstance); + moduleInstance.setStorage(databaseInstance); + } catch (Exception e) { + //logger.printError(e.toString()); + result = false; + } + result = insert(val, moduleInstance); + } + if (result == false) { //if error + File file = new File(dir + "/" + fileNames[i]); + if (!badDir.exists()) { //exits Bad-Dir? + badDir.mkdir(); + } + if (!file.renameTo(new File(dir + "/BAD/" + fileNames[i]))) { + logger.printError("Failed move to BAD: " + fileNames[i]); + } + } + else { //end if(result == false) + File file = new File(dir + "/" + fileNames[i]); + if (!goodDir.exists()) { //exists Good-Dir? + goodDir.mkdir(); + } + if (!file.renameTo(new File(dir + "/GOOD/" + fileNames[i]))) { + logger.printError("Failed move to GOOD: " + fileNames[i]); + } + logger.printInfo("Successfully parsed: " + fileNames[i]); + } //end else (result == true) + } //end for + } //end parse + + /** + * Holt die Felder aus der Metadatenfelderliste des StorageObjects, die + * im HttpRequest vorkommen und liefert sie als HashMap zurueck + * @return HashMap + */ + public HashMap getIntersectingValues (HashMap values, StorageObject theStorage) { + ArrayList theFieldList; + try { + theFieldList = theStorage.getFields(); + } catch (StorageObjectException e) { + logger.printError("Failed: " + e.toString()); + return null; + } + HashMap withValues = new HashMap(); + String aField, aValue; + for (int i = 0; i < theFieldList.size(); i++) { + aField = (String)theFieldList.get(i); + aValue = (String)values.get(aField); + if (aValue != null) + withValues.put(aField, aValue); + } + return withValues; + } + + /** + * Inserts a hash with values in a table + * @param values + * @param module + * @return + */ + public boolean insert (HashMap values, AbstractModule module) { + try { + HashMap withValues = getIntersectingValues(values, module.getStorageObject()); + module.add(withValues); + } catch (Exception e) { + logger.printError("Failed to insert: " + e.toString()); + return false; + } + return true; + } +} + + + diff --git a/source/mircoders/module/ModuleBreaking.java b/source/mircoders/module/ModuleBreaking.java new file mode 100755 index 00000000..231b885f --- /dev/null +++ b/source/mircoders/module/ModuleBreaking.java @@ -0,0 +1,47 @@ +package mircoders.module; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; + + +/* + * ContentObjekt - + * + * + * @author RK + */ + +public class ModuleBreaking extends AbstractModule +{ + static Logfile theLog; + + // Kontruktor + + public ModuleBreaking (StorageObject theStorage) + { + + if (theLog == null) theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Module.Breaking.Logfile")); + if (theStorage == null) theLog.printWarning("ModuleBreaking -- StorageObject was null!"); + + this.theStorage = theStorage; + + } + + // Methoden + +} diff --git a/source/mircoders/module/ModuleComment.java b/source/mircoders/module/ModuleComment.java new file mode 100755 index 00000000..e8173f79 --- /dev/null +++ b/source/mircoders/module/ModuleComment.java @@ -0,0 +1,44 @@ +package mircoders.module; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; + + +/* + * ModuleComment - methods and access for comments + * + * @author RK + */ + +public class ModuleComment extends AbstractModule +{ + static Logfile theLog; + + // Contructor + public ModuleComment(StorageObject theStorage) + { + if (theLog == null) theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Module.Comment.Logfile")); + if (theStorage == null) theLog.printWarning("StorageObject was null!"); + this.theStorage = theStorage; + } + + // Methoden + public SimpleList getCommentAsSimpleList() { + return ((DatabaseComment)theStorage).getPopupData(); + } +} diff --git a/source/mircoders/module/ModuleContent.java b/source/mircoders/module/ModuleContent.java new file mode 100755 index 00000000..b2b16477 --- /dev/null +++ b/source/mircoders/module/ModuleContent.java @@ -0,0 +1,178 @@ +package mircoders.module; + +import java.io.*; +import java.util.*; +import java.sql.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.entity.*; +import webdb.misc.*; +import webdb.storage.*; + +import mir.entity.*; + +/* + * ContentObjekt - + * + * + * @author RK + */ + +public class ModuleContent extends AbstractModule +{ + static Logfile theLog; + + public ModuleContent() { + super(); + if (theLog == null) theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Module.Content.Logfile")); + } + + public ModuleContent(StorageObject theStorage) { + this.theStorage = theStorage; + if (theLog == null) theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("Module.Content.Logfile")); + } + + // + // methoden, um an ContentEntities zu kommen + + + public EntityList getContent(HashMap searchValues, boolean concat, int offset, EntityUsers user) + throws ModuleException { + + try { + + String whereClause ="", aField, aValue; + boolean first = true; + + Set set = searchValues.keySet(); + Iterator it = set.iterator(); + for (int i=0;i" + filename + ""); + //theLog.printInfo("Produced: " + producerStorageRoot + filename); + //theLog.printDebugInfo("free mem:" + java.lang.Runtime.getRuntime().freeMemory()); + //theLog.printDebugInfo("total mem:" + java.lang.Runtime.getRuntime().totalMemory()); + return true; + + } catch(IOException exception){ + logHTML(htmlout, "Producer: File konnte nicht zum schreiben geoeffnet werden: " + filename); + return false; + } catch(HTMLParseException exception){ + logHTML(htmlout,"Producer: File konnte nicht hatemelisiert werden: " + filename); + return false; + } + } + + public boolean produceFile(String filename, byte[] in, PrintWriter htmlout, boolean icon) { + + boolean retVal = false; + + if (in!=null) { + try { + File f = null; + if(icon==false){ + f = new File(filename); + theLog.printDebugInfo("image: " + filename); + } else { + f = new File(producerStorageRoot + filename); + theLog.printDebugInfo("icon: " + filename); + } + File dir = new File(f.getParent()); + dir.mkdirs(); + + FileOutputStream outStream; + outStream = new FileOutputStream(f); + outStream.write(in); + outStream.close(); + retVal = true; + } catch(IOException exception) { + logHTML(htmlout, "Producer: File could not be written: " + filename); + } + } + return retVal; + } + + + + // + // filename routinen + + public String indexFileNameForPageCount(int pc) { + return fileNameForPageCount("/index", pc); + } + + public String fileNameForPageCount(String stub, int pc) { + String fileName = producerDocRoot + stub; + if (pc>1) { + fileName+=pc; + } + fileName += ".html"; + return fileName; + } + + /** + * logging + */ + public void logHTML(PrintWriter out, String s) { + _print(out, s, true); + } + + public void printHTML(PrintWriter out, String s) { + _print(out, s, false); + } + + private void _print(PrintWriter out, String s, boolean log) { + if (out != null) { out.println(s+"
");out.flush(); } + if (log == true) { + theLog.printInfo(s); + } + } + +} diff --git a/source/mircoders/producer/ProducerAll.java b/source/mircoders/producer/ProducerAll.java new file mode 100755 index 00000000..c12e7060 --- /dev/null +++ b/source/mircoders/producer/ProducerAll.java @@ -0,0 +1,105 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + +public class ProducerAll extends Producer{ + + private boolean rsync; + + public static void main(String argv[]) + { + try { new ProducerAll().handle(new PrintWriter(System.out), null, false,false); } + catch(Exception e) { System.err.println(e.toString()); } + } + + // handle all + public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync) + throws StorageObjectException, ModuleException { + printHTML(htmlout, "Producer.All: started"); + + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + new ProducerImages().handle(htmlout, user, force,sync); + new ProducerStartPage().handle(htmlout, user, force,sync); + new ProducerContent().handle(htmlout, user, force,sync); + new ProducerOpenPosting().handle(htmlout, user, force,sync); + new ProducerTopics().handle(htmlout, user, force,sync); + new ProducerNavigation().handle(htmlout, user, force,sync); + + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.All finished: " + sessionConnectTime + " ms."); + + // do we have to rsync the site + if (sync==true){ + sessionConnectTime = 0; + if (Helper.rsync()!=0){ + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Rsync failed: " + sessionConnectTime + " ms."); + } else { + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Rsync succeded: " + sessionConnectTime + " ms."); + } + } + } + + // handle all + public void handle2(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync) + throws StorageObjectException, ModuleException { + printHTML(htmlout, "Producer.All: started"); + + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + EntityContent currentContent; + HashMap currentContentValues; + + //get all new unproduced content-entities + String whereClause="is_produced='0' && to_article_type>0"; + String orderBy="date desc"; + EntityList entityList = contentModule.getContent(whereClause,orderBy,0,-1,null); + + //get their values + while (entityList != null) { + for(int i=0;i0){ + 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); + } + } + + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(currentContentValues); + + // get the images + currentMediaId = currentContent.getValue("to_media"); + if (currentMediaId!=null && !currentMediaId.equals("")) { + imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); + } + mergeData.put("images", imageHash); + + // get the comments for the article + mergeData.put("comments", currentContent.getComments()); + + // get the topics of this article + mergeData.put("topics",HTMLTemplateProcessor.makeSimpleList(DatabaseContentToTopics.getInstance().getTopics(currentContent))); + + boolean retVal = produce(contentTemplate, htmlFileName, mergeData, htmlout); + sessionConnectTime = new java.util.Date().getTime() - startTime; + if (retVal == true && !"1".equals(currentContent.getValue("is_produced"))) + currentContent.setProduced(true); + } + if (batchEntityList.hasNextBatch()){ + batchEntityList = contentModule.getContent(whereClause, orderBy, batchEntityList.getNextBatch(),contentBatchsize, userEntity); + //theLog.printDebugInfo("producing next batch"); + } else { + batchEntityList=null; + } + } + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Content finished: " + sessionConnectTime + " ms."); + + } + +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerFeature.java b/source/mircoders/producer/ProducerFeature.java new file mode 100755 index 00000000..3df75f93 --- /dev/null +++ b/source/mircoders/producer/ProducerFeature.java @@ -0,0 +1,60 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + + +public class ProducerFeature extends ProducerList { + + + public void setAdditional(String key, TemplateModel value) { + additional.put(key,value); + } + + public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync) + throws StorageObjectException, ModuleException { + orderBy="date desc"; + listTemplate = Configuration.getProperty("Producer.FeatureList.Template"); + EntityList featureEntityList = featureModule.getByWhereClause("","title", -1); + SimpleList featureList = HTMLTemplateProcessor.makeSimpleList(featureEntityList); + boolean first=true; + whereClause="is_published!=true AND to_article_type=0 AND id IN ("; + for(int i=0; i < featureEntityList.size(); i++){ + if(first==false) { + whereClause += ","; + } + + EntityTopics currentTopic = (EntityTopics)featureEntityList.elementAt(i); + EntityList contentEntityList = DatabaseContentToTopics.getInstance().getContent(currentTopic); + whereClause += currentTopic.getId(); + fileDesc = currentTopic.getValue("filename").trim(); + setAdditional("topic",HTMLTemplateProcessor.makeSimpleHash(currentTopic)); + + first = false; + } + whereClause += ")"; + handleIt(htmlout,user,force); + } + + public static void main(String argv[]){ + try { + new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false); + } catch(Exception e) { + System.err.println(e.toString()); + } + } +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerImages.java b/source/mircoders/producer/ProducerImages.java new file mode 100755 index 00000000..526ae37b --- /dev/null +++ b/source/mircoders/producer/ProducerImages.java @@ -0,0 +1,109 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + + +public class ProducerImages extends Producer { + + public static void main(String argv[]){ + try { + new ProducerContent().handle(new PrintWriter(System.out), null, false,false); + } catch(Exception e) { System.err.println(e.toString()); } + } + + public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync) + throws StorageObjectException, ModuleException { + handle(htmlout,user,force,sync,null); + } + + public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync, String id) + throws StorageObjectException, ModuleException + { + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + String whereClause; + String iconFilename; + String imageFilename; + String productionPath; + EntityImage currentImage; + EntityList batchEntityList; + + int contentBatchsize = Integer.parseInt(Configuration.getProperty("Producer.Content.Batchsize")); + String imageHost = Configuration.getProperty("Producer.Image.Host"); + String imagePath = Configuration.getProperty("Producer.Image.Path"); + String iconPath = Configuration.getProperty("Producer.Image.IconPath"); + + // get batch of non-produced images, that are to be published + whereClause="is_published='1'"; + if (id!= null) + whereClause += " and id="+id; + if (force==false) whereClause += " and icon_is_produced='0'"; + + batchEntityList = imageModule.getByWhereClause(whereClause, null, 0, contentBatchsize); + theLog.printDebugInfo("whereclause: " + whereClause); + + + while (batchEntityList != null) { + for(int i=0;i")); + // make image + boolean imageProduced = produceFile(productionPath, currentImage.getImage(), htmlout, false); + logHTML(htmlout,"image: " + productionPath + ((imageProduced==true)?" succeded":" ")); + + // update image-data + if (iconProduced && imageProduced) { + currentImage.setValueForProperty("icon_is_produced", "1"); + currentImage.update(); + } + + } + } + + // if next batch get it... + if (batchEntityList.hasNextBatch()){ + batchEntityList = imageModule.getByWhereClause(whereClause, null, batchEntityList.getNextBatch(),contentBatchsize); + } else { + batchEntityList=null; + } + } + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Images finished: " + sessionConnectTime + " ms."); + + } + +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerList.java b/source/mircoders/producer/ProducerList.java new file mode 100755 index 00000000..ff8aa708 --- /dev/null +++ b/source/mircoders/producer/ProducerList.java @@ -0,0 +1,160 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + + +abstract public class ProducerList extends Producer { + + public String listTemplate; + public String whereClause; + public String orderBy; + public String fileDesc; + protected HashMap additional = new HashMap(); + + public void handle(PrintWriter htmlout, EntityUsers user, boolean sync, boolean force) + throws StorageObjectException, ModuleException { + handleIt(htmlout,user,force); + } + + public void handleIt(PrintWriter htmlout, EntityUsers user, boolean force) + throws StorageObjectException, ModuleException { + + logHTML(htmlout, "Producer.List: started"); + int newsPerPage = Integer.parseInt(Configuration.getProperty("Producer.StartPage.Newswire")); + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + String htmlFileName = ""; + String currentMediaId; + EntityContent currentContent; + EntityList list; + EntityGruppen userEntity=null; + SimpleHash imageHash = new SimpleHash(); + int size = 0; + int listSize = 0; + + int maxItemsOnPage = Integer.parseInt(Configuration.getProperty("Lists.Max.Items")); + + try { + listSize = contentModule.getSize(whereClause); + } catch (Exception e) { + logHTML(htmlout,e.toString()); + } + + int modRest = listSize % maxItemsOnPage; + int numberOfPages = (listSize - modRest) / maxItemsOnPage; + boolean first=true; + for (int i = 0;i < numberOfPages+1;i ++) { + //break the loop, if only athe actuell pages should be produced + if (force == false && i==3) { + break; + } + //break, if only the first page has to be produced + if (force == false && modRest != 0 && first==false){ + break; + } + + + if (first==true) { + //get the data for the first page + size=maxItemsOnPage + modRest; + list = contentModule.getContent(whereClause, orderBy, 0, size, userEntity); + first=false; + } else { + //get the data for the other pages + list = contentModule.getContent(whereClause, orderBy, size, maxItemsOnPage, userEntity); + size = size + maxItemsOnPage; + } + + //now produce the pages + if (list!=null || force==true) { + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(list); + //first we try to get the images + SimpleList itemList = HTMLTemplateProcessor.makeSimpleList(list); + if(list!=null){ + for (int k=0; k < list.size();k++) { + currentContent = (EntityContent)list.elementAt(k); + //images to content + currentMediaId = currentContent.getValue("to_media"); + if (currentMediaId!=null && !currentMediaId.equals("")) { + imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); + } + //content to html + if(currentContent.getValue("is_html").equals("0")){ + String temp = (String)currentContent.getValue("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.createHTML(temp); + temp = StringUtil.decodeHTMLinTags(temp); + currentContent.setValueForProperty("description",temp); + } + } else { + String temp = (String)currentContent.getValue("description"); + if(temp!=null && temp.length()>0){ + temp = StringUtil.decodeHTMLinTags(temp); + currentContent.setValueForProperty("description",temp); + } + } + } + mergeData.put("images", imageHash); + } + + //process hashmap additional and add to mergedata + if (additional != null) { + Set set = additional.keySet(); + for (Iterator it = set.iterator();it.hasNext();) { + String key = (String)it.next(); + mergeData.put(key,(TemplateModel)additional.get(key)); + } + } + + if (i==0){ + htmlFileName = producerDocRoot + "/" + fileDesc + ".shtml"; + mergeData.put("filename",fileDesc + ".shtml"); + mergeData.put("previousPage",""); + if(numberOfPages<=1){ + mergeData.put("nextPage",""); + } else { + mergeData.put("nextPage",fileDesc + (numberOfPages-1) + ".shtml"); + } + } else { + if (i==1 && numberOfPages > 2){ + mergeData.put("previousPage",fileDesc + ".shtml"); + mergeData.put("nextPage",fileDesc + (numberOfPages-2) + ".shtml"); + } else { + if (i==(numberOfPages-1)){ + mergeData.put("previousPage",fileDesc + (numberOfPages-i+1) + ".shtml"); + mergeData.put("nextPage",""); + } else { + mergeData.put("previousPage",fileDesc + (numberOfPages-(i-1)) + ".shtml"); + mergeData.put("nextPage",fileDesc + (numberOfPages-(i+1)) + ".shtml"); + } + } + htmlFileName = producerDocRoot + "/" + fileDesc + (numberOfPages-i) + ".shtml"; + mergeData.put("filename",fileDesc + (numberOfPages-i) + ".shtml"); + } + + //producing the html-files + boolean retVal = produce(listTemplate, htmlFileName, mergeData, htmlout); + } //end if + }//end for + + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.List finished: " + sessionConnectTime + " ms."); + } //end handle + + abstract public void setAdditional(String key, TemplateModel value); +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerNavigation.java b/source/mircoders/producer/ProducerNavigation.java new file mode 100755 index 00000000..a26bbe78 --- /dev/null +++ b/source/mircoders/producer/ProducerNavigation.java @@ -0,0 +1,69 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.storage.*; +import mir.entity.*; + +/** + * Title: mir - another content management system + * Description: + * Copyright: Copyright (c) 2001 + * Company: indymedia + * @author idefix + * @version 1.0 + */ + +public class ProducerNavigation extends Producer { + + private static String naviPageTemplate = Configuration.getProperty("Producer.Navigation.Template"); + + public void handle(PrintWriter htmlout, EntityUsers user, boolean forced, boolean sync) + throws webdb.module.ModuleException, webdb.storage.StorageObjectException { + + printHTML(htmlout, "Producer.Navigation: started"); + + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + String nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar()); + String whereClause; + String orderBy; + FileWriter outputFile; + String htmlFileName; + EntityContent currentContent; + EntityList entityList; + SimpleHash naviPageModel; + + // get the topiclist + entityList = topicsModule.getByWhereClause("","title",-1); + SimpleList topicList = HTMLTemplateProcessor.makeSimpleList(entityList); + + // put the informations into the navipagemodel + naviPageModel = new SimpleHash(); + naviPageModel.put("topics", topicList); + + htmlFileName = producerDocRoot + "/navigation.inc"; + + produce(naviPageTemplate, htmlFileName, naviPageModel, new LineFilterWriter(htmlout)); + + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Navigation finished: " + sessionConnectTime + " ms."); + + if(sync==true){ + Helper.rsync(); + logHTML(htmlout, "Producer.Startseite: rsync done"); + } + } + +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerOpenPosting.java b/source/mircoders/producer/ProducerOpenPosting.java new file mode 100755 index 00000000..247d553f --- /dev/null +++ b/source/mircoders/producer/ProducerOpenPosting.java @@ -0,0 +1,52 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + + +public class ProducerOpenPosting extends ProducerList { + + public void setAdditional(String key, TemplateModel value) { + additional.put(key,value); + } + + public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync) + throws StorageObjectException, ModuleException { + + listTemplate = Configuration.getProperty("Producer.OpenPosting.Template"); + whereClause="is_published='1'"; + orderBy="date desc, webdb_create desc"; + fileDesc="open"; + + EntityList topicsEntityList = topicsModule.getByWhereClause("","title", -1); + SimpleList topicsList = HTMLTemplateProcessor.makeSimpleList(topicsEntityList); + SimpleScalar title = new SimpleScalar(); + title.setValue("Open-Posting"); + setAdditional("topicslist",topicsList); + setAdditional("title",title); + + handleIt(htmlout,user,force); + } + + public static void main(String argv[]){ + try { + new ProducerOpenPosting().handle(new PrintWriter(System.out), null,false, false); + } catch(Exception e) { + System.err.println(e.toString()); + } + } +} \ No newline at end of file diff --git a/source/mircoders/producer/ProducerOverview.java b/source/mircoders/producer/ProducerOverview.java new file mode 100755 index 00000000..45c1edec --- /dev/null +++ b/source/mircoders/producer/ProducerOverview.java @@ -0,0 +1,177 @@ +package mircoders.producer; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.sql.*; + +import freemarker.template.*; + +import webdb.misc.*; +import webdb.storage.*; +import webdb.module.*; +import webdb.entity.*; + +import mir.module.*; +import mir.entity.*; +import mir.storage.*; + + + +public class ProducerOverview extends Producer { + + static String monthTemplate; + static String yearTemplate; + static int numberOfTermine; + + static { + // Initialierung + monthTemplate = Configuration.getProperty("Producer.Overview.MonthTemplate"); + yearTemplate = Configuration.getProperty("Producer.Overview.YearTemplate"); + numberOfTermine = Integer.parseInt(Configuration.getProperty("Producer.Startseite.Termine")); + } + + public static void main(String argv[]){ + try { + new ProducerOverview().handle(new PrintWriter(System.out), null, false, false); + } + catch(Exception e) { + System.err.println(e.toString()); + } + } + + public void handle(PrintWriter htmlout, EntityUsers user, boolean force, boolean sync) + throws StorageObjectException, ModuleException + { + logHTML(htmlout, "Producer.Overview: started"); + + long sessionConnectTime = 0; + long startTime = (new java.util.Date()).getTime(); + String nowWebdbDate = StringUtil.date2webdbDate(new GregorianCalendar()); + String whereClause; + String orderBy="date"; + String fileName; + EntityContent currentContent; + EntityList monatsListe; + EntityList batchEntityList; + EntityGruppen userEntity=null; + + SimpleHash gruppenPopupData = gruppenModule.getHashData(); + SimpleHash themenPopupData = topicsModule.getHashData(); + SimpleHash schwerpunktPopupData = schwerpunktModule.getHashData(); + ArrayList yearArrayList = new ArrayList(); + HashMap yearHash = new HashMap(); + + // Datenstrukturen fuer Themen/Schwerpunkt aufbauen + batchEntityList = schwerpunktModule.getByWhereClause("is_published!=0", 0); + SimpleList schwerpunktList = HTMLTemplateProcessor.makeSimpleList(batchEntityList); + batchEntityList = contentModule.getContent("(date_from<="+ nowWebdbDate +" and date_to>=" + nowWebdbDate+ ")", "", 0, numberOfTermine, null); + SimpleList terminList = HTMLTemplateProcessor.makeSimpleList(batchEntityList); + batchEntityList = topicsModule.getByWhereClause("","title",-1); + SimpleList themenList = HTMLTemplateProcessor.makeSimpleList(batchEntityList); + + Connection con=null; + Statement stmt=null; + ResultSet rs=null; + DatabaseContent dbContent=DatabaseContent.getInstance(); + + String sql = "select distinct LEFT(date,6) as date from content order by date desc"; + try { + con = dbContent.getPooledCon(); + stmt = con.createStatement(); + rs = dbContent.executeSql(stmt,sql); + + //jetzt übersetzen wir month in text + SimpleHash monatslookup = new SimpleHash(); + monatslookup.put("01","Januar"); + monatslookup.put("02","Februar"); + monatslookup.put("03","März"); + monatslookup.put("04","April"); + monatslookup.put("05","Mai"); + monatslookup.put("06","Juni"); + monatslookup.put("07","Juli"); + monatslookup.put("08","August"); + monatslookup.put("09","September"); + monatslookup.put("10","Oktober"); + monatslookup.put("11","November"); + monatslookup.put("12","Dezember"); + + + // fuer alle yyyy/mm + while(rs.next()){ + // select * from content_objekt where datum like yyyymm% + String currentDate = rs.getString(1); + whereClause="date like '"+ currentDate + "%' and is_published!=0 and islink=0"; + monatsListe = contentModule.getContent(whereClause, orderBy, 0, -1, userEntity); + + // baue uebersichtsseite aus erbenis + if (monatsListe!=null) { + SimpleList items = new SimpleList(); + for(int i=0;i" + wmlFileName + ""); + } catch (FileNotFoundException e) { + System.err.println(e.toString()); + } catch (IOException e) { + System.err.println(e.toString()); + } catch (org.xml.sax.SAXException e) { + logHTML(htmlout,e.toString()); + System.err.println(e.toString()); + } + + // Finish + sessionConnectTime = new java.util.Date().getTime() - startTime; + logHTML(htmlout, "Producer.Startseite finished: " + sessionConnectTime + " ms."); + } +} + diff --git a/source/mircoders/servlet/ServletModuleBreaking.java b/source/mircoders/servlet/ServletModuleBreaking.java new file mode 100755 index 00000000..b31c7f0b --- /dev/null +++ b/source/mircoders/servlet/ServletModuleBreaking.java @@ -0,0 +1,75 @@ +package mircoders.servlet; + +import java.io.*; +import java.net.*; +import javax.servlet.http.*; +import javax.servlet.*; +import freemarker.template.*; +import webdb.servlet.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; +import webdb.module.*; +import mir.module.*; +import mir.storage.*; + +/* + * ServletModuleBreaking - + * Authentified Navigation for Breaking News + * + * + */ + +public class ServletModuleBreaking extends ServletModule +{ + + // Singelton / Kontruktor + + private static ServletModuleBreaking instance = new ServletModuleBreaking(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleBreaking() { + + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Breaking.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Breaking.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Breaking.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Breaking.ConfirmTemplate"); + try { + mainModule = new ModuleBreaking(DatabaseBreaking.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("ServletModuleBreaking konnte nicht initialisiert werden"); + } + } + + public void list(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + // fetch and deliver + try { + SimpleHash mergeData = new SimpleHash(); + String offset = req.getParameter("offset"); + if (offset==null || offset.equals("")) offset="0"; + mergeData.put("offset",offset); + EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue()); + mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList)); + if(theList.getOrder()!=null) { + mergeData.put("order", theList.getOrder()); + mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder())); + } + mergeData.put("count", (new Integer(theList.getCount())).toString()); + mergeData.put("from", (new Integer(theList.getFrom())).toString()); + mergeData.put("to", (new Integer(theList.getTo())).toString()); + if (theList.hasNextBatch()) + mergeData.put("next", (new Integer(theList.getNextBatch())).toString()); + if (theList.hasPrevBatch()) + mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString()); + + // raus damit + HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter()); + } + catch (ModuleException e) {throw new ServletModuleException(e.toString());} + catch (IOException e) {throw new ServletModuleException(e.toString());} + catch (Exception e) {throw new ServletModuleException(e.toString());} + } +} diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java new file mode 100755 index 00000000..3c1c6e4b --- /dev/null +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -0,0 +1,126 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import java.net.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleComment - controls navigation for Comments + * + * + * @author RK + */ + +public class ServletModuleComment extends ServletModule +{ + + private ModuleContent moduleContent; + + // Singelton / Kontruktor + private static ServletModuleComment instance = new ServletModuleComment(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleComment() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Comment.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Comment.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Comment.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Comment.ConfirmTemplate"); + try { + mainModule = new ModuleComment(DatabaseComment.getInstance()); + moduleContent = new ModuleContent(DatabaseContent.getInstance()); + } + catch (StorageObjectException e) { + theLog.printError("servletmodule: comment could not be initialized"); + } + } + + + public void list(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + // Parameter auswerten + SimpleHash mergeData = new SimpleHash(); + String query_text = req.getParameter("query_text"); + mergeData.put("query_text",query_text); + if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text)); + String query_field = req.getParameter("query_field"); + mergeData.put("query_field",query_field); + String query_is_published = req.getParameter("query_is_published"); + mergeData.put("query_is_published",query_is_published); + + String offset = req.getParameter("offset"); + if (offset==null || offset.equals("")) offset="0"; + mergeData.put("offset",offset); + + // patching order + String order = req.getParameter("order"); + if(order!=null) { + mergeData.put("order", order); + mergeData.put("order_encoded", URLEncoder.encode(order)); + if (order.equals("webdb_create")) order="webdb_create desc"; + } + + // sql basteln + String whereClause=""; boolean isFirst=true; + if (query_text!=null && !query_text.equalsIgnoreCase("")) { + whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;} + if (query_is_published != null && !query_is_published.equals("")) { + if (isFirst==false) whereClause+=" and "; + whereClause += "is_published='"+query_is_published+"'"; + isFirst=false; + } + + theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset); + + // fetch und ausliefern + try { + + if (query_text!=null || query_is_published!=null ) { + EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue()); + if (theList!=null) { + + //make articleHash for comment + StringBuffer buf= new StringBuffer("id in (");boolean first=true; + for(int i=0;i0){ + Entity topics = (EntityTopics)topicToContent.elementAt(0); + mergeData.put("to_topic",topics.getId()); + } + //obsolete, because of psqgl 7.1.x + //mergeData.put("content_data", entContent.getContentData()); + mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); + mergeData.put("gruppenPopupData", gruppenModule.getGruppenAsSimpleList()); + try { + mergeData.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData()); + } catch (Exception e) {theLog.printError("articletype could not be fetched.");} + + // get the images + String currentMediaId = entContent.getValue("to_media"); + SimpleHash imageHash = new SimpleHash(); + if (currentMediaId!=null && !currentMediaId.equals("")) { + imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); + mergeData.put("images", imageHash); + } + + + //mergeData.put("gruppenHashData", gruppenModule.getHashData()); + mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); + // hier code um zur liste zurueckzukommen + String offsetParam, whereParam, orderParam; + if ((offsetParam = req.getParameter("offset"))!=null) mergeData.put("offset", offsetParam); + if ((whereParam = req.getParameter("where"))!=null) mergeData.put("where", whereParam); + if ((orderParam = req.getParameter("order"))!=null) mergeData.put("order", orderParam); + mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(_getUser(req))); + deliver(req, res, mergeData, templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } + + + public void _list(EntityList theList, HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException { + + try { + // hier dann htmlcode rausschreiben + if (theList == null || theList.getCount() == 0 || theList.getCount()>1) { + SimpleHash modelRoot = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(theList); + modelRoot.put("themenHashData", themenModule.getHashData()); + modelRoot.put("schwerpunktHashData", schwerpunktModule.getHashData()); + modelRoot.put("gruppenHashData", gruppenModule.getHashData()); + modelRoot.put("articletypeHash", DatabaseArticleType.getInstance().getHashData()); + deliver(req, res, modelRoot, templateListString); + } else { // count = 1 + _showObject(theList.elementAt(0).getId(),req,res); + } + } catch (StorageObjectException e) { + throw new ServletModuleException(e.toString()); + } + } + + public void _listop(EntityList theList, HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException { + + try { + // hier dann htmlcode rausschreiben + if (theList == null || theList.getCount() == 0 || theList.getCount()>1) { + SimpleHash modelRoot = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(theList); + modelRoot.put("articletypeHash", DatabaseArticleType.getInstance().getHashData()); + modelRoot.put("gruppenHashData", gruppenModule.getHashData()); + deliver(req, res, modelRoot, templateListString); + } else { // count = 1 + _showObject(theList.elementAt(0).getId(), req, res); + } + } catch (StorageObjectException e) { + throw new ServletModuleException(e.toString()); + } + } + + private EntityUsers _getUser(HttpServletRequest req) + { + HttpSession session=req.getSession(false); + return (EntityUsers)session.getAttribute("login.uid"); + } + + +} + diff --git a/source/mircoders/servlet/ServletModuleGroups.java b/source/mircoders/servlet/ServletModuleGroups.java new file mode 100755 index 00000000..ab895cbe --- /dev/null +++ b/source/mircoders/servlet/ServletModuleGroups.java @@ -0,0 +1,48 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleGruppen - + * liefert HTML fuer Gruppen + * + * + * @author RK + */ + +public class ServletModuleGroups extends ServletModule +{ + + // Singelton / Kontruktor + + private static ServletModuleGroups instance = new ServletModuleGroups(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleGroups() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Gruppen.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Gruppen.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Gruppen.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Gruppen.ConfirmTemplate"); + try { + mainModule = new ModuleGruppen(DatabaseGroups.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("servletmodulegruppen konnte nicht initialisiert werden"); + } + } + +} diff --git a/source/mircoders/servlet/ServletModuleImages.java b/source/mircoders/servlet/ServletModuleImages.java new file mode 100755 index 00000000..8159cc4a --- /dev/null +++ b/source/mircoders/servlet/ServletModuleImages.java @@ -0,0 +1,328 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import java.net.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; +import com.oreilly.servlet.multipart.*; +import com.oreilly.servlet.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleBilder - + * liefert HTML fuer Bilder + * + * + * @author RK + */ + +public class ServletModuleImages extends webdb.servlet.ServletModule +{ + + private static ModuleMediafolder mediafolderModule; + private static DatabaseRights dbRights; + private static DatabaseImageFormat dbImageFormat; + private static DatabaseImageType dbImageType; + private static DatabaseImageColor dbImageColor; + private static DatabaseImageLayout dbImageLayout; + + // Singelton / Kontruktor + private static ServletModuleImages instance = new ServletModuleImages(); + public static ServletModule getInstance() { return instance; } + + + private ServletModuleImages() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Bilder.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Bilder.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Bilder.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Bilder.ConfirmTemplate"); + try { + mainModule = new ModuleImages(DatabaseImages.getInstance()); + mediafolderModule = new ModuleMediafolder(DatabaseMediafolder.getInstance()); + dbRights = DatabaseRights.getInstance(); + dbImageFormat = DatabaseImageFormat.getInstance(); + dbImageColor = DatabaseImageColor.getInstance(); + dbImageType = DatabaseImageType.getInstance(); + dbImageLayout = DatabaseImageLayout.getInstance(); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("servletmodulebilder konnte nicht initialisiert werden"); + } + } + + + public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + try { + WebdbMultipartRequest mp = new WebdbMultipartRequest(req); + HashMap parameters = mp.getParameters(); + byte[] imageData=mp.getMedia(); + String fileName=mp.getFilename(); + + EntityUsers user = _getUser(req); + parameters.put("date", StringUtil.date2webdbDate(new GregorianCalendar())); + parameters.put("to_publisher", user.getId()); + parameters.put("is_produced", "0"); + if (!parameters.containsKey("is_published")) + parameters.put("is_published","0"); + + String id = mainModule.add(parameters); + EntityImage entImage = (EntityImage)mainModule.getById(id); + + if (imageData!=null && fileName!=null) { + int fileType = -1; + if (fileName.toLowerCase().endsWith(".jpg")) fileType=0; + if (fileName.toLowerCase().endsWith(".gif")) fileType=1; + if (fileType>=0) + entImage.setImage(imageData, fileType); + else + theLog.printError("Wrong file uploaded!"); + } + _edit(id, req, res); + } + catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());} + catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());} + + } + + public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + + try { + WebdbMultipartRequest mp = new WebdbMultipartRequest(req); + HashMap parameters = mp.getParameters(); + byte[] imageData=mp.getMedia(); + String fileName=mp.getFilename(); + + EntityUsers user = _getUser(req); + parameters.put("to_publisher", user.getId()); + parameters.put("is_produced", "0"); + if (!parameters.containsKey("is_published")) + parameters.put("is_published","0"); + + String id = mainModule.set(parameters); + EntityImage entImage = (EntityImage)mainModule.getById(id); + + if (imageData!=null && fileName!=null) { + int fileType = -1; + if (fileName.toLowerCase().endsWith(".jpg")) fileType=0; + if (fileName.toLowerCase().endsWith(".gif")) fileType=1; + if (fileType>=0) + entImage.setImage(imageData, fileType); + else + theLog.printError("Wrong file uploaded!"); + } + _edit(id, req, res); + } + catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());} + catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());} + + } + + + public void showimg(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + String idParam = req.getParameter("id"); + if (idParam!=null && !idParam.equals("")) { + try { + EntityImage entImage =(EntityImage)mainModule.getById(idParam); + res.setContentType("image/jpeg"); // testweise + ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist + + byte[] outbytes = entImage.getImage(); + out.write(outbytes); + out.close(); + } + + catch (IOException e) {throw new ServletModuleException(e.toString());} + catch (ModuleException e) {throw new ServletModuleException(e.toString());} + catch (Exception e) {throw new ServletModuleException(e.toString());} + } + else theLog.printDebugInfo("id nicht angeben."); + // darf keine exception werfen + } + + public void showicon(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + String idParam = req.getParameter("id"); + if (idParam!=null && !idParam.equals("")) { + try { + EntityImage entImage =(EntityImage)mainModule.getById(idParam); + res.setContentType("image/jpeg"); // testweise + ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist + + byte[] outbytes = entImage.getIcon(); + out.write(outbytes); + out.close(); + } + + catch (IOException e) {throw new ServletModuleException(e.toString());} + catch (ModuleException e) {throw new ServletModuleException(e.toString());} + catch (Exception e) {throw new ServletModuleException(e.toString());} + } + else throw new ServletModuleException("id nicht angeben."); + } + + public void list(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + // Parameter auswerten + SimpleHash mergeData = new SimpleHash(); + String query_text = req.getParameter("query_text"); + mergeData.put("query_text",query_text); + if (query_text!=null) mergeData.put("query_text_encoded",URLEncoder.encode(query_text)); + String query_field = req.getParameter("query_field"); + mergeData.put("query_field",query_field); + String query_is_published = req.getParameter("query_is_published"); + mergeData.put("query_is_published",query_is_published); + String query_media_folder = req.getParameter("query_media_folder"); + mergeData.put("query_media_folder",query_media_folder); + String offset = req.getParameter("offset"); + if (offset==null || offset.equals("")) offset="0"; + mergeData.put("offset",offset); + + String order = req.getParameter("order"); + if (order==null) order="webdb_lastchange desc"; + + // if in connection mode to content + String cid = req.getParameter("cid"); + mergeData.put("cid",cid); + + + // sql basteln + String whereClause=""; boolean isFirst=true; + if (query_text!=null && !query_text.equalsIgnoreCase("")) { + whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;} + if (query_is_published != null && !query_is_published.equals("")) { + if (isFirst==false) whereClause+=" and "; + whereClause += "is_published='"+query_is_published+"'"; + isFirst=false; + } + if (query_media_folder != null && !query_media_folder.equals("")) { + if (isFirst==false) whereClause+=" and "; + whereClause += "to_media_folder='"+query_media_folder+"'"; + } + //theLog.printDebugInfo("sql-whereclause: " + whereClause + " order: " + order + " offset: " + offset); + + // fetch und ausliefern + try { + mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData()); + mergeData.put("mediafolderHashdata", mediafolderModule.getHashData()); + if (query_text!=null || query_is_published!=null || query_media_folder!=null) { + EntityList theList = mainModule.getByWhereClause(whereClause, order, (new Integer(offset)).intValue(),10); + if (theList != null) { + mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList)); + if(theList.getOrder()!=null) { + mergeData.put("order", theList.getOrder()); + mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder())); + } + mergeData.put("count", (new Integer(theList.getCount())).toString()); + mergeData.put("from", (new Integer(theList.getFrom())).toString()); + mergeData.put("to", (new Integer(theList.getTo())).toString()); + if (theList.hasNextBatch()) + mergeData.put("next", (new Integer(theList.getNextBatch())).toString()); + if (theList.hasPrevBatch()) + mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString()); + } + } + // raus damit + HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter()); + } + catch (ModuleException e) {throw new ServletModuleException(e.toString());} + catch (IOException e) {throw new ServletModuleException(e.toString());} + catch (Exception e) {throw new ServletModuleException(e.toString());} + } + + + public void add(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + SimpleHash mergeData = new SimpleHash(); + mergeData.put("new", "1"); + mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData()); + deliver(req, res, mergeData, templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } + + public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + String idParam = req.getParameter("id"); + _edit(idParam, req, res); + } + + private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleException { + if (idParam!=null && !idParam.equals("")) { + try { + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam)); + mergeData.put("mediafolderPopupData", mediafolderModule.getPopupData()); + mergeData.put("rightsHashdata", dbRights.getHashData()); + mergeData.put("imgformatHashdata", dbImageFormat.getHashData()); + mergeData.put("imgcolorHashdata", dbImageColor.getHashData()); + mergeData.put("imgtypeHashdata", dbImageType.getHashData()); + mergeData.put("imglayoutHashdata", dbImageLayout.getHashData()); + deliver(req, res, mergeData, templateObjektString); + } + catch (ModuleException e) { throw new ServletModuleException(e.toString());} + } + else throw new ServletModuleException("ServletmoduleImage :: _edit without id"); + } + + + /** @todo should be in ServletModule.java */ + private EntityUsers _getUser(HttpServletRequest req) + { + HttpSession session=req.getSession(false); + return (EntityUsers)session.getAttribute("login.uid"); + } + + + // deprecated + public void upload(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + //theLog.printDebugInfo("-- trying to upload"); + String idParam = req.getParameter("id"); + if (idParam!=null && !idParam.equals("")) { + try { + + WebdbMultipartRequest mp = new WebdbMultipartRequest(req); + HashMap withValues = mp.getParameters(); + byte[] imageData=mp.getMedia(); + String fileName=mp.getFilename(); + + int fileType = -1; + if (fileName.toLowerCase().endsWith(".jpg")) fileType=0; + if (fileName.toLowerCase().endsWith(".gif")) fileType=1; + if (fileType>=0) { + EntityImage entImage = (EntityImage)mainModule.getById(idParam); + entImage.setImage(imageData, fileType); + } + else + theLog.printError("Wrong file uploaded!"); + } + catch (IOException e) { throw new ServletModuleException("upload -- ioexception " + e.toString());} + catch (ModuleException e) { throw new ServletModuleException("upload -- moduleexception " + e.toString());} + } + else // keine id + throw new ServletModuleException("Keine id angegeben"); + edit(req,res); + } + + +} diff --git a/source/mircoders/servlet/ServletModuleMediafolder.java b/source/mircoders/servlet/ServletModuleMediafolder.java new file mode 100755 index 00000000..711ad3c1 --- /dev/null +++ b/source/mircoders/servlet/ServletModuleMediafolder.java @@ -0,0 +1,51 @@ +package mircoders.servlet; + +/** + * Title: Mir + * Description: liefert Webseiten zur Verwaltung von Mediafoldern aus. + * @author rk + * @version 02 + */ + +import java.util.*; +import javax.servlet.http.*; +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.misc.*; +import webdb.storage.*; +import mir.storage.*; +import mir.module.*; + + +public class ServletModuleMediafolder extends ServletModule +{ + + // Singelton / Kontruktor + public static ServletModule getInstance() { return instance; } + private static ServletModuleMediafolder instance = new ServletModuleMediafolder(); + + private ServletModuleMediafolder() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Mediafolder.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Mediafolder.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Mediafolder.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Mediafolder.ConfirmTemplate"); + try { + mainModule = new ModuleMediafolder(DatabaseMediafolder.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("ServletModuleMediafolder konnte nicht initialisiert werden"); + } + } + + public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + SimpleHash mergeData = new SimpleHash(); + mergeData.put("new", "1"); + String now = StringUtil.date2webdbDate(new GregorianCalendar()); + // date auf now + mergeData.put("date", new SimpleScalar(now)); + deliver(req, res, mergeData, templateObjektString); + } + +} \ No newline at end of file diff --git a/source/mircoders/servlet/ServletModuleMessage.java b/source/mircoders/servlet/ServletModuleMessage.java new file mode 100755 index 00000000..b065a91b --- /dev/null +++ b/source/mircoders/servlet/ServletModuleMessage.java @@ -0,0 +1,80 @@ +package mircoders.servlet; + +import java.io.*; +import java.net.*; +import javax.servlet.http.*; +import javax.servlet.*; +import freemarker.template.*; +import webdb.servlet.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; +import webdb.module.*; +import mir.module.*; +import mir.storage.*; + +/** + * Title: ServletModuleMessage + * Description: + * Copyright: Copyright (c) 2001 + * Company: Indymedia + * @author + * @version 1.0 + */ + + +public class ServletModuleMessage extends ServletModule +{ + + // Singelton / Kontruktor + + private static ServletModuleMessage instance = new ServletModuleMessage(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleMessage() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Messages.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Messages.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Messages.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Messages.ConfirmTemplate"); + try { + mainModule = new ModuleMessage(DatabaseMessages.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("ServletModuleMessage konnte nicht initialisiert werden"); + } + } + + public void list(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + // fetch and deliver + try { + SimpleHash mergeData = new SimpleHash(); + String offset = req.getParameter("offset"); + if (offset==null || offset.equals("")) offset="0"; + mergeData.put("offset",offset); + EntityList theList = mainModule.getByWhereClause(null, "webdb_create desc", (new Integer(offset)).intValue()); + mergeData.put("contentlist",HTMLTemplateProcessor.makeSimpleList(theList)); + if(theList.getOrder()!=null) { + mergeData.put("order", theList.getOrder()); + mergeData.put("order_encoded", URLEncoder.encode(theList.getOrder())); + } + mergeData.put("count", (new Integer(theList.getCount())).toString()); + mergeData.put("from", (new Integer(theList.getFrom())).toString()); + mergeData.put("to", (new Integer(theList.getTo())).toString()); + if (theList.hasNextBatch()) + mergeData.put("next", (new Integer(theList.getNextBatch())).toString()); + if (theList.hasPrevBatch()) + mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString()); + + // raus damit + HTMLTemplateProcessor.process(getLanguage(req)+"/"+templateListString, mergeData, res.getWriter()); + + } + catch (ModuleException e) {throw new ServletModuleException(e.toString());} + catch (IOException e) {throw new ServletModuleException(e.toString());} + catch (Exception e) {throw new ServletModuleException(e.toString());} + } + + +} diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java new file mode 100755 index 00000000..6452a7eb --- /dev/null +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -0,0 +1,221 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; +import com.oreilly.servlet.multipart.*; +import com.oreilly.servlet.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; +import mir.producer.*; + +/* + * ServletModuleOpenIndy - + * is the open-access-servlet, which is responsible for + * adding comments to articles & + * open-postings to the newswire + * + * @author RK + */ + +public class ServletModuleOpenIndy extends ServletModule +{ + + private String commentFormTemplate, commentFormDoneTemplate; + private String postingFormTemplate, postingFormDoneTemplate; + private ModuleContent contentModule; + private ModuleImages imageModule; + + // Singelton / Kontruktor + private static ServletModuleOpenIndy instance = new ServletModuleOpenIndy(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleOpenIndy() { + try { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.OpenIndy.Logfile")); + commentFormTemplate = Configuration.getProperty("ServletModule.OpenIndy.CommentTemplate"); + commentFormDoneTemplate = Configuration.getProperty("ServletModule.OpenIndy.CommentDoneTemplate"); + postingFormTemplate = Configuration.getProperty("ServletModule.OpenIndy.PostingTemplate"); + postingFormDoneTemplate = Configuration.getProperty("ServletModule.OpenIndy.PostingDoneTemplate"); + + mainModule = new ModuleComment(DatabaseComment.getInstance()); + contentModule = new ModuleContent(DatabaseContent.getInstance()); + imageModule = new ModuleImages(DatabaseImages.getInstance()); + defaultAction="addposting"; + } + catch (StorageObjectException e) { + theLog.printError("servletmoduleopenindy could not be initialized"); + } + } + + + /** + * Method for making a comment + */ + + public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + String aid = req.getParameter("aid"); // the article id the comment will belong to + if (aid!=null && !aid.equals("")) + { + SimpleHash mergeData = new SimpleHash(); + // ok, article + mergeData.put("aid", aid); + deliver(req, res, mergeData, commentFormTemplate); + } + else throw new ServletModuleException("aid not set!"); + } + + /** + * Method for inserting a comment into the Database and delivering + * the commentDone Page + */ + + public void inscomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + String aid = req.getParameter("to_media"); // the article id the comment will belong to + if (aid!=null && !aid.equals("")) + { + // ok, collecting data from form + try { + HashMap withValues = getIntersectingValues(req, DatabaseComment.getInstance()); + withValues.put("is_published","1"); + + // inserting into database + String id = mainModule.add(withValues); + + // producing new page + new ProducerContent().handle(null, null, true, false, aid); + + // sync the server + int exitValue = Helper.rsync(); + + // redirecting to url + // should implement back to article + SimpleHash mergeData = new SimpleHash(); + deliver(req, res, mergeData, commentFormDoneTemplate); + } + catch (StorageObjectException e) { throw new ServletModuleException(e.toString());} + catch (ModuleException e) { throw new ServletModuleException(e.toString());} + + } + else throw new ServletModuleException("aid not set!"); + + } + + /** + * Method for delivering the form-Page for open posting + */ + + public void addposting(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + SimpleHash mergeData = new SimpleHash(); + /** @todo popups missing */ + deliver(req, res, mergeData, postingFormTemplate); + } + + /** + * Method for inserting an open posting into the Database and delivering + * the postingDone Page + */ + + public void insposting(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + SimpleHash mergeData = new SimpleHash(); + + try { + + WebdbMultipartRequest mp = new WebdbMultipartRequest(req); + HashMap withValues = mp.getParameters(); + byte[] mediaData=mp.getMedia(); + String fileName=mp.getFilename(); + + // if op contains imagedata + String mediaId=null; + if (mediaData!=null && fileName!=null) { + HashMap mediaValues = new HashMap(); + mediaValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar())); + mediaValues.put("to_publisher", "1"); // op user + mediaValues.put("to_media_folder", "7"); // op media_folder + mediaValues.put("is_produced", "0"); + mediaValues.put("is_published","1"); + + String mediaTitle=(String)withValues.get("media_title"); + if (mediaTitle==null) + mediaTitle = (String)withValues.get("title"); + mediaValues.put("title",mediaTitle); + + if (fileName.toLowerCase().endsWith("rm")) { + // this is video !! + //theLog.printDebugInfo("--GOT VIDEO"); + EntityVideo entVideo = new EntityVideo(DatabaseVideos.getInstance()); + entVideo.setValues(mediaValues); + mediaId = entVideo.insert(); + entVideo.setVideoData(mediaData); + } + else if (fileName.toLowerCase().endsWith(".jpg") || fileName.toLowerCase().endsWith(".gif")) { + // this is image !! + mediaId = imageModule.add(mediaValues); + EntityImage entImage = (EntityImage)imageModule.getById(mediaId); + + int fileType = -1; + if (fileName.toLowerCase().endsWith(".jpg")) fileType=0; + if (fileName.toLowerCase().endsWith(".gif")) fileType=1; + if (fileType>=0) { + entImage.setImage(mediaData, fileType); + withValues.put("to_media",mediaId); + } + else + theLog.printDebugInfo("Wrong file uploaded!" + fileName); + } + } + + withValues.put("date", StringUtil.date2webdbDate(new GregorianCalendar())); + withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date"))); + withValues.put("is_produced", "0"); + // op-articles are immediatly published + withValues.put("is_published","1"); + // owner is openposting user + withValues.put("to_publisher","1"); + if (withValues.get("creator").toString().equals("")) + withValues.put("creator","Anonym"); + + // inserting content into database + String id = contentModule.add(withValues); + + + // producing new page + if(mediaId!=null){ + new ProducerImages().handle(null, null, false, false, mediaId); + } + // producing openpostinglist + new ProducerOpenPosting().handle(null,null,false,false); + // producing new page + new ProducerContent().handle(null, null, false, false,id); + + // sync the server + int exitValue = Helper.rsync(); + + } + catch (IOException e) { throw new ServletModuleException(e.toString());} + catch (StorageObjectException e) { throw new ServletModuleException(e.toString());} + catch (ModuleException e) { throw new ServletModuleException(e.toString());} + + deliver(req, res, mergeData, postingFormDoneTemplate); + } + +} + diff --git a/source/mircoders/servlet/ServletModuleProducer.java b/source/mircoders/servlet/ServletModuleProducer.java new file mode 100755 index 00000000..30957ed9 --- /dev/null +++ b/source/mircoders/servlet/ServletModuleProducer.java @@ -0,0 +1,70 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.misc.*; + +import mir.producer.*; +import mir.entity.*; + +/* Verteilerservlet, dass je nach Parameter task die Klasse Producer"TASK" + * ueber die Methode handle(); aufruft + * + * @author RK + */ + +public class ServletModuleProducer extends ServletModule +{ + + private static ServletModuleProducer instance = new ServletModuleProducer(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleProducer() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Producer.Logfile")); + defaultAction="produce"; + } + + + public void produce(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + PrintWriter out = res.getWriter(); + String taskParam = req.getParameter("task"); + String forcedParam = req.getParameter("forced"); + String syncParam = req.getParameter("sync"); + theLog.printInfo("Starting Task: " + taskParam); + if (taskParam == null) { + throw new ServletModuleException("Kein Task angegeben!"); + } else { + Class producerModule = Class.forName("mir.producer.Producer" + taskParam); + Producer producer = (Producer)producerModule.newInstance(); + HttpSession session=req.getSession(false); + EntityUsers user = (EntityUsers)session.getAttribute("login.uid"); + + if (forcedParam!=null && !forcedParam.equals("")) { + if (syncParam!=null && !syncParam.equals("")) { + producer.handle(out, user, true, true); + } else { + producer.handle(out, user, true,false); + } + } else { + producer.handle(out, user, false,false); + } + + } + } + catch (Exception e) { + throw new ServletModuleException(e.toString()); + } + } + + +} diff --git a/source/mircoders/servlet/ServletModuleSchwerpunkt.java b/source/mircoders/servlet/ServletModuleSchwerpunkt.java new file mode 100755 index 00000000..234be0a5 --- /dev/null +++ b/source/mircoders/servlet/ServletModuleSchwerpunkt.java @@ -0,0 +1,47 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleSchwerpunkt - + * liefert HTML fuer Schwerpunkt + * + * + * @author RK + */ + +public class ServletModuleSchwerpunkt extends ServletModule +{ + // Singelton / Kontruktor + private static ServletModuleSchwerpunkt instance = new ServletModuleSchwerpunkt(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleSchwerpunkt() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Schwerpunkt.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Schwerpunkt.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Schwerpunkt.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Schwerpunkt.ConfirmTemplate"); + try { + mainModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("servletmodulethemen konnte nicht initialisiert werden"); + } + } +} diff --git a/source/mircoders/servlet/ServletModuleTopics.java b/source/mircoders/servlet/ServletModuleTopics.java new file mode 100755 index 00000000..3df42f09 --- /dev/null +++ b/source/mircoders/servlet/ServletModuleTopics.java @@ -0,0 +1,45 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleThemen - + * liefert HTML fuer Themen + * + * + * @author RK + */ + +public class ServletModuleTopics extends ServletModule +{ + + // Singelton / Kontruktor + private static ServletModuleTopics instance = new ServletModuleTopics(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleTopics() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Themen.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Themen.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Themen.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Themen.ConfirmTemplate"); + try { + mainModule = new ModuleTopics(DatabaseTopics.getInstance()); + } catch (StorageObjectException e) { + theLog.printDebugInfo("servletmoduletopics konnte nicht initialisiert werden"); + } + } +} diff --git a/source/mircoders/servlet/ServletModuleUsers.java b/source/mircoders/servlet/ServletModuleUsers.java new file mode 100755 index 00000000..163f674f --- /dev/null +++ b/source/mircoders/servlet/ServletModuleUsers.java @@ -0,0 +1,82 @@ +package mircoders.servlet; + +import java.io.*; +import java.sql.*; +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import freemarker.template.*; + +import webdb.servlet.*; +import webdb.module.*; +import webdb.misc.*; +import webdb.entity.*; +import webdb.storage.*; + +import mir.entity.*; +import mir.storage.*; +import mir.module.*; + +/* + * ServletModuleUsers - + * liefert HTML fuer Users + * + * + * @author RK + */ + +public class ServletModuleUsers extends webdb.servlet.ServletModule +{ + // Singelton / Kontruktor + private static ServletModuleUsers instance = new ServletModuleUsers(); + public static ServletModule getInstance() { return instance; } + + private ServletModuleUsers() { + theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Users.Logfile")); + templateListString = Configuration.getProperty("ServletModule.Users.ListTemplate"); + templateObjektString = Configuration.getProperty("ServletModule.Users.ObjektTemplate"); + templateConfirmString = Configuration.getProperty("ServletModule.Users.ConfirmTemplate"); + try { + mainModule = new ModuleUsers(DatabaseUsers.getInstance()); + } + catch (StorageObjectException e) { + theLog.printDebugInfo("servletmoduleusers konnte nicht initialisiert werden"); + } + } + + public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + String idParam = req.getParameter("id"); + if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben"); + try { + //theLog.printInfo("Showing User with id: " + idParam); + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam)); + deliver(req, res, mergeData, templateObjektString); + } + catch (ModuleException e) { throw new ServletModuleException(e.toString());} + } + + public void add(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + SimpleHash mergeData = new SimpleHash(); + mergeData.put("new", "1"); + deliver(req, res, mergeData, templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } + + public void insert(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject()); + String id = mainModule.add(withValues); + SimpleHash mergeData = HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(id)); + deliver(req, res, mergeData, templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } +} diff --git a/source/mircoders/storage/DatabaseArticleType.java b/source/mircoders/storage/DatabaseArticleType.java new file mode 100755 index 00000000..e7119e7b --- /dev/null +++ b/source/mircoders/storage/DatabaseArticleType.java @@ -0,0 +1,50 @@ +package mircoders.storage; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: Indymedia + * @author + * @version 1.0 + */ + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + + +public class DatabaseArticleType extends Database implements StorageObject{ + + private static DatabaseArticleType instance; + private static SimpleList articletypePopupData; + + public static DatabaseArticleType getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseArticleType(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseArticleType() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="article_type"; + try { this.theEntityClass = Class.forName("mir.entity.EntityArticleType"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",false); } + + +} diff --git a/source/mircoders/storage/DatabaseBreaking.java b/source/mircoders/storage/DatabaseBreaking.java new file mode 100755 index 00000000..1a8790af --- /dev/null +++ b/source/mircoders/storage/DatabaseBreaking.java @@ -0,0 +1,44 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseBreaking extends Database implements StorageObject{ + + private static DatabaseBreaking instance; + + public static DatabaseBreaking getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseBreaking(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseBreaking() throws StorageObjectException + { + super(); + this.cache = new HashMap(); + this.theTable="breaking"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityBreaking"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + +} diff --git a/source/mircoders/storage/DatabaseComment.java b/source/mircoders/storage/DatabaseComment.java new file mode 100755 index 00000000..7787a58e --- /dev/null +++ b/source/mircoders/storage/DatabaseComment.java @@ -0,0 +1,70 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * This class implements the access to the comment-table for the + * media table. + * + * + */ + +public class DatabaseComment extends Database implements StorageObject{ + + private static DatabaseComment instance; + + public static DatabaseComment getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseComment(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseComment() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.cache = new HashMap(); + this.theTable="comment"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityComment"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("title",true); } + + public boolean deleteByContentId(String id) + throws StorageObjectException { + Statement stmt=null; + Connection con=null; + String sql; + int res = 0; + + /** @todo comments and topics should be deleted */ + sql = "delete from "+ theTable + " where to_media="+id; + //theLog.printInfo("DELETE "+ sql); + + try { + con=getPooledCon(); + stmt = con.createStatement(); + res = stmt.executeUpdate(sql); + } catch (SQLException sqe) { + new StorageObjectException(sqe.toString()); + return false; + } finally { + freeConnection(con,stmt); + } + return true; + } +} diff --git a/source/mircoders/storage/DatabaseContent.java b/source/mircoders/storage/DatabaseContent.java new file mode 100755 index 00000000..7725d970 --- /dev/null +++ b/source/mircoders/storage/DatabaseContent.java @@ -0,0 +1,107 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +import mir.entity.*; + +/** + * this class implements the access to the content-table + * + * + */ + +public class DatabaseContent extends Database implements StorageObject { + + private static DatabaseContent instance; + private static EntityRelation relationComments; + private static EntityRelation relationFeature; + + // Contructors / Singleton + + public static DatabaseContent getInstance() + throws StorageObjectException { + + if (instance == null ) { + instance = new DatabaseContent(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseContent() + throws StorageObjectException { + + super(); + this.theTable="content"; + this.theCoreTable="media"; + relationComments = new EntityRelation("id", "to_media", DatabaseComment.getInstance(), EntityRelation.TO_MANY); + relationFeature = new EntityRelation("id", "to_feature", DatabaseFeature.getInstance(), EntityRelation.TO_ONE); + try { this.theEntityClass = Class.forName("mir.entity.EntityContent"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + // methods + + /** + * sets the database flag is_produced to unproduced + */ + + public void setUnproduced(String where) + { + Connection con=null;Statement stmt=null; + String sql = "update content set is_produced=0 where " + where; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + executeSql(stmt,sql); + } + catch (Exception e) {theLog.printDebugInfo("-- set unproduced failed");} + finally { freeConnection(con,stmt);} + } + + /** + * returns the comments that belong to the article (via entityrelation) + */ + public SimpleList getComments(EntityContent entC) { + SimpleList comments=null; + try { + comments = relationComments.getManyAsSimpleList(entC,"webdb_create"); + } + catch (StorageObjectException e) { + theLog.printError("DatabaseComments :: failed to get comments"); + } + return comments; + } + + /** + * returns the features that belong to the article (via entityrelation) + */ + public SimpleList getFeature(EntityContent entC) { + SimpleList feature=null; + try { + feature = relationFeature.getManyAsSimpleList(entC); + } + catch (StorageObjectException e) { + theLog.printError("DatabaseComments :: failed to get features"); + } + return feature; + } + + public boolean delete(String id) + throws StorageObjectException { + DatabaseComment.getInstance().deleteByContentId(id); + super.delete(id); + return true; + } + +} diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java new file mode 100755 index 00000000..fadadf89 --- /dev/null +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -0,0 +1,217 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +import mir.entity.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseContentToTopics extends Database implements StorageObject{ + + private static DatabaseContentToTopics instance; + + public static DatabaseContentToTopics getInstance() + throws StorageObjectException { + if (instance == null) { + instance = new DatabaseContentToTopics(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseContentToTopics() + throws StorageObjectException { + + super(); + this.hasTimestamp = false; + this.theTable="content_x_topic"; + try { + // this.theEntityClass = Class.forName("mir.entity.EntityGruppen"); + } catch (Exception e) { + throw new StorageObjectException(e.toString()); + } + } + + + public EntityList getTopics(EntityContent content) { + EntityList returnList=null; + if (content != null) { + // get all to_topic from content_x_topic + String id = content.getId(); + String subselect = "id in (select topic_id from " + theTable + " where content_id=" + id+")"; + + try { + returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1); + } catch (Exception e) { + theLog.printDebugInfo("-- get topics failed " + e.toString()); + } + } + return returnList; + } + + + public void setTopics(EntityContent content, ArrayList topicId) { + if (content == null && topicId == null) { + return; + } + String contentId = content.getId(); + //first delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where content_id=" + contentId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } catch (Exception e) { + theLog.printDebugInfo("-- set topics failed -- delete"); + } finally { + freeConnection(con,stmt); + } + + //now insert + //first delete all row with content_id=contentId + + for (Iterator i = topicId.listIterator(); i.hasNext();) { + sql = "insert into "+ theTable +" (content_id,topic_id) values (" + + contentId + "," + i.next().toString() + ")"; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } catch (Exception e) { + theLog.printDebugInfo("-- set topics failed -- insert"); + } finally { + freeConnection(con,stmt); + } + } + } + + + public void setTopics(String contentId, String topicId) { + if (contentId == null && topicId == null) { + return; + } + //first delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where content_id=" + contentId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + int rs = executeUpdate(stmt,sql); + } catch (Exception e) { + theLog.printDebugInfo("-- set topics failed -- delete"); + } finally { + freeConnection(con,stmt); + } + + //now insert + //first delete all row with content_id=contentId + + sql = "insert into "+ theTable +" (content_id,topic_id) values (" + + contentId + "," + topicId + ")"; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + int rs = executeUpdate(stmt,sql); + } catch (Exception e) { + theLog.printDebugInfo("-- set topics failed -- insert"); + } finally { + freeConnection(con,stmt); + } + } + + public void deleteByContentId(String contentId) { + if (contentId == null) { + //theLog.printDebugInfo("-- delete topics failed -- no content id"); + return; + } + //delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where content_id=" + contentId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } catch (Exception e) { + //theLog.printDebugInfo("-- delete topics failed "); + } finally { + freeConnection(con,stmt); + } + } + + public void deleteByTopicId(String topicId) { + if (topicId == null) { + //theLog.printDebugInfo("-- delete topics failed -- no topic id"); + return; + } + //delete all row with content_id=contentId + String sql = "delete from "+ theTable +" where topic_id=" + topicId; + + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,sql); + } catch (Exception e) { + theLog.printDebugInfo("-- delete topics failed "); + } finally { + freeConnection(con,stmt); + } + } + + + public EntityList getContent(EntityTopics topic) { + EntityList returnList=null; + if (topic != null) { + String id = topic.getId(); + String select = "select content_id from " + theTable + " where topic_id=" + id; + + // execute select statement + Connection con=null;Statement stmt=null; + try { + con = getPooledCon(); + // should be a preparedStatement because is faster + stmt = con.createStatement(); + ResultSet rs = executeSql(stmt,select); + if (rs!=null) { + String topicSelect= "id IN ("; + boolean first=true; + while (rs.next()) { + if (first==false) topicSelect+=","; + topicSelect += rs.getString(1); + first=false; + } + topicSelect+=")"; + if (first==false) + returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1); + } + } + catch (Exception e) {theLog.printDebugInfo("-- get contetn failed");} + finally { freeConnection(con,stmt);} + } + return returnList; + } + +} diff --git a/source/mircoders/storage/DatabaseFeature.java b/source/mircoders/storage/DatabaseFeature.java new file mode 100755 index 00000000..e51bbf76 --- /dev/null +++ b/source/mircoders/storage/DatabaseFeature.java @@ -0,0 +1,51 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseFeature extends Database implements StorageObject{ + + private static DatabaseFeature instance; + + public static DatabaseFeature getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseFeature(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseFeature() throws StorageObjectException + { + super(); + this.cache = new HashMap(); + this.hasTimestamp = false; + this.theTable="feature"; + + try { + this.theEntityClass = Class.forName("mir.entity.EntityFeature"); + } + catch (Exception e) { + throw new StorageObjectException(e.toString()); + } + } + + public SimpleList getPopupData() { + return getPopupData("title",true); + } + +} diff --git a/source/mircoders/storage/DatabaseGroups.java b/source/mircoders/storage/DatabaseGroups.java new file mode 100755 index 00000000..666fcd2d --- /dev/null +++ b/source/mircoders/storage/DatabaseGroups.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseGroups extends Database implements StorageObject{ + + private static DatabaseGroups instance; + + public static DatabaseGroups getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseGroups(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseGroups() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.cache = new HashMap(); + this.theTable="creator"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityGruppen"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + +} diff --git a/source/mircoders/storage/DatabaseImageColor.java b/source/mircoders/storage/DatabaseImageColor.java new file mode 100755 index 00000000..15200f86 --- /dev/null +++ b/source/mircoders/storage/DatabaseImageColor.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseImageColor extends Database implements StorageObject{ + + private static DatabaseImageColor instance; + private static SimpleList publisherPopupData; + + public static DatabaseImageColor getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseImageColor(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseImageColor() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="img_color"; + try { this.theEntityClass = Class.forName("mir.entity.EntityImageColor"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + + +} diff --git a/source/mircoders/storage/DatabaseImageFormat.java b/source/mircoders/storage/DatabaseImageFormat.java new file mode 100755 index 00000000..0616549d --- /dev/null +++ b/source/mircoders/storage/DatabaseImageFormat.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseImageFormat extends Database implements StorageObject{ + + private static DatabaseImageFormat instance; + private static SimpleList publisherPopupData; + + public static DatabaseImageFormat getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseImageFormat(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseImageFormat() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="img_format"; + try { this.theEntityClass = Class.forName("mir.entity.EntityImageFormat"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + + +} diff --git a/source/mircoders/storage/DatabaseImageLayout.java b/source/mircoders/storage/DatabaseImageLayout.java new file mode 100755 index 00000000..3151bcc6 --- /dev/null +++ b/source/mircoders/storage/DatabaseImageLayout.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseImageLayout extends Database implements StorageObject{ + + private static DatabaseImageLayout instance; + private static SimpleList publisherPopupData; + + public static DatabaseImageLayout getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseImageLayout(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseImageLayout() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="img_layout"; + try { this.theEntityClass = Class.forName("mir.entity.EntityImageLayout"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + + +} diff --git a/source/mircoders/storage/DatabaseImageType.java b/source/mircoders/storage/DatabaseImageType.java new file mode 100755 index 00000000..b74df246 --- /dev/null +++ b/source/mircoders/storage/DatabaseImageType.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseImageType extends Database implements StorageObject{ + + private static DatabaseImageType instance; + private static SimpleList publisherPopupData; + + public static DatabaseImageType getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseImageType(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseImageType() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="img_type"; + try { this.theEntityClass = Class.forName("mir.entity.EntityImageType"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + + +} diff --git a/source/mircoders/storage/DatabaseImages.java b/source/mircoders/storage/DatabaseImages.java new file mode 100755 index 00000000..8890c0d7 --- /dev/null +++ b/source/mircoders/storage/DatabaseImages.java @@ -0,0 +1,76 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseImages extends Database implements StorageObject{ + + private static DatabaseImages instance; + private static SimpleList publisherPopupData; + + public static DatabaseImages getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseImages(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseImages() throws StorageObjectException + { + super(); + this.hasTimestamp = true; + this.theTable="images"; + this.theCoreTable="media"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityImage"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { + return getPopupData("title",true); + } + + public void update(Entity theEntity) throws StorageObjectException + { + theEntity.setValueForProperty("to_media_type","1"); + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + + super.update(theEntity); + } + + + public String insert(Entity theEntity) throws StorageObjectException + { + theEntity.setValueForProperty("to_media_type","1"); + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + return super.insert(theEntity); + } + + // initialisierungen aus den statischen Tabellen + +} diff --git a/source/mircoders/storage/DatabaseLanguage.java b/source/mircoders/storage/DatabaseLanguage.java new file mode 100755 index 00000000..221ffffc --- /dev/null +++ b/source/mircoders/storage/DatabaseLanguage.java @@ -0,0 +1,50 @@ +package mircoders.storage; + +/** + * Title: DatabaseLanguage + * Description: + * Copyright: Copyright (c) 2001 + * Company: Indymedia + * @author + * @version 1.0 + */ + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + + +public class DatabaseLanguage extends Database implements StorageObject{ + + private static DatabaseLanguage instance; + private static SimpleList languagePopupData; + + public static DatabaseLanguage getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseLanguage(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseLanguage() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="language"; + try { this.theEntityClass = Class.forName("mir.entity.EntityLanguage"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",false); } + + +} diff --git a/source/mircoders/storage/DatabaseMediafolder.java b/source/mircoders/storage/DatabaseMediafolder.java new file mode 100755 index 00000000..e6377ea5 --- /dev/null +++ b/source/mircoders/storage/DatabaseMediafolder.java @@ -0,0 +1,54 @@ +package mircoders.storage; + +/** + * Title: Mir + * Description: Ihre Beschreibung + * Copyright: Copyright (c) 1999 + * Company: + * @author + * @version + */ + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + + + +public class DatabaseMediafolder extends Database implements StorageObject{ + + private static DatabaseMediafolder instance; + + public static DatabaseMediafolder getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseMediafolder(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseMediafolder() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.cache = new HashMap(); + this.theTable="media_folder"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityMediafolder"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); + } + } + + public SimpleList getPopupData() { + return getPopupData("name",true); + } + +} diff --git a/source/mircoders/storage/DatabaseMessages.java b/source/mircoders/storage/DatabaseMessages.java new file mode 100755 index 00000000..0950f90b --- /dev/null +++ b/source/mircoders/storage/DatabaseMessages.java @@ -0,0 +1,49 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: Indymedia + * @author + * @version 1.0 + */ + + +public class DatabaseMessages extends Database implements StorageObject{ + + private static DatabaseMessages instance; + + public static DatabaseMessages getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseMessages(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseMessages() throws StorageObjectException + { + super(); + this.cache = new HashMap(); + this.theTable="messages"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityMessage"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + +} diff --git a/source/mircoders/storage/DatabaseRights.java b/source/mircoders/storage/DatabaseRights.java new file mode 100755 index 00000000..39906fcc --- /dev/null +++ b/source/mircoders/storage/DatabaseRights.java @@ -0,0 +1,46 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseRights extends Database implements StorageObject{ + + private static DatabaseRights instance; + private static SimpleList publisherPopupData; + + public static DatabaseRights getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseRights(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseRights() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="rights"; + try { this.theEntityClass = Class.forName("mir.entity.EntityRights"); } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { return getPopupData("name",true); } + + +} diff --git a/source/mircoders/storage/DatabaseTopics.java b/source/mircoders/storage/DatabaseTopics.java new file mode 100755 index 00000000..55731a5f --- /dev/null +++ b/source/mircoders/storage/DatabaseTopics.java @@ -0,0 +1,53 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseTopics extends Database implements StorageObject{ + + private static DatabaseTopics instance; + + public static DatabaseTopics getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseTopics(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseTopics() throws StorageObjectException + { + super(); + this.cache = new HashMap(); + this.hasTimestamp = false; + this.theTable="topic"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityTopics"); + } + catch (Exception e) { + throw new StorageObjectException(e.toString()); + } + + } + + public SimpleList getPopupData() { + return getPopupData("title",true); + } + + + +} diff --git a/source/mircoders/storage/DatabaseUsers.java b/source/mircoders/storage/DatabaseUsers.java new file mode 100755 index 00000000..03e38d77 --- /dev/null +++ b/source/mircoders/storage/DatabaseUsers.java @@ -0,0 +1,48 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseUsers extends Database implements StorageObject{ + + private static DatabaseUsers instance; + + public static DatabaseUsers getInstance() throws StorageObjectException { + if (instance == null) { + instance = new DatabaseUsers(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseUsers() throws StorageObjectException + { + super(); + this.hasTimestamp = false; + this.theTable="webdb_users"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityUsers"); + } + catch (Exception e) { + throw new StorageObjectException(e.toString()); + } + } + + public SimpleList getPopupData() { + return getPopupData("login",true); + } +} diff --git a/source/mircoders/storage/DatabaseVideos.java b/source/mircoders/storage/DatabaseVideos.java new file mode 100755 index 00000000..2cfa8e55 --- /dev/null +++ b/source/mircoders/storage/DatabaseVideos.java @@ -0,0 +1,74 @@ +package mircoders.storage; + +import java.lang.*; +import java.sql.*; +import java.io.*; +import java.util.*; + +import freemarker.template.*; + +import webdb.storage.*; +import webdb.entity.*; +import webdb.misc.*; + +/** + * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle + * + * + */ + +public class DatabaseVideos extends Database implements StorageObject{ + + private static DatabaseVideos instance; + private static SimpleList publisherPopupData; + + public static DatabaseVideos getInstance() throws StorageObjectException + { + if (instance == null) { + instance = new DatabaseVideos(); + instance.myselfDatabase = instance; + } + return instance; + } + + private DatabaseVideos() throws StorageObjectException + { + super(); + this.hasTimestamp = true; + this.theTable="videos"; + this.theCoreTable="media"; + try { + this.theEntityClass = Class.forName("mir.entity.EntityVideo"); + } + catch (Exception e) { throw new StorageObjectException(e.toString()); } + } + + public SimpleList getPopupData() { + return getPopupData("title",true); + } + + public void update(Entity theEntity) throws StorageObjectException + { + theEntity.setValueForProperty("to_media_type","3"); + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + + super.update(theEntity); + } + + + public String insert(Entity theEntity) throws StorageObjectException + { + theEntity.setValueForProperty("to_media_type","3"); + String date = theEntity.getValue("date"); + if (date==null){ + date = StringUtil.date2webdbDate(new GregorianCalendar()); + theEntity.setValueForProperty("date",date); + } + return super.insert(theEntity); + } + +} -- 2.11.0