From d1fe8297d584e69a5d2bed84cc979d8bdd13cb31 Mon Sep 17 00:00:00 2001 From: zapata Date: Sun, 18 Jan 2004 17:30:55 +0000 Subject: [PATCH] fixed / clean ups --- bundles/admin_en.properties | 4 +- source/Mir.java | 4 +- source/mir/entity/AbstractEntity.java | 174 ++++++++++++++ source/mir/entity/Entity.java | 205 ++--------------- source/mir/entity/EntityBrowser.java | 17 +- source/mir/entity/EntityList.java | 5 +- source/mir/entity/GenericEntity.java | 16 +- source/mir/entity/StorableObjectEntity.java | 26 +-- source/mir/entity/adapter/EntityAdapter.java | 13 +- .../entity/adapter/EntityAdapterDefinition.java | 4 +- .../mir/entity/adapter/EntityIteratorAdapter.java | 16 +- source/mir/module/AbstractModule.java | 103 ++------- .../mir/producer/EntityModifyingProducerNode.java | 6 +- source/mir/rss/RSSReader.java | 2 +- source/mir/storage/Database.java | 253 ++++++++------------- source/mir/storage/StorageObject.java | 197 +++------------- source/mir/storage/store/StoreContainerType.java | 14 +- source/mir/storage/store/StoreIdentifier.java | 14 +- source/mir/storage/store/StoreUtil.java | 17 +- source/mir/util/EntityUtility.java | 62 +++++ source/mir/util/InternetFunctions.java | 1 - source/mircoders/accesscontrol/AccessControl.java | 14 +- source/mircoders/entity/EntityComment.java | 27 +-- source/mircoders/entity/EntityContent.java | 45 ++-- source/mircoders/entity/EntityImages.java | 61 +++-- source/mircoders/entity/EntityUploadedMedia.java | 18 +- source/mircoders/entity/EntityUsers.java | 20 +- source/mircoders/entity/EntityVideo.java | 14 +- source/mircoders/global/Abuse.java | 33 ++- source/mircoders/global/MirGlobal.java | 2 +- .../basic/MirBasicAdminInterfaceLocalizer.java | 25 +- .../basic/MirBasicAntiAbuseFilterTypes.java | 4 +- .../basic/MirBasicArticlePostingHandler.java | 14 +- .../basic/MirBasicChildArticlePostingHandler.java | 2 +- .../basic/MirBasicCommentPostingHandler.java | 10 +- .../basic/MirBasicDataModelLocalizer.java | 8 +- source/mircoders/media/MediaHandlerGeneric.java | 20 +- source/mircoders/media/MediaHandlerImages.java | 14 +- .../mircoders/media/MediaHandlerImagesExtern.java | 18 +- source/mircoders/media/MediaHandlerMp3.java | 14 +- source/mircoders/media/MediaHandlerOgg.java | 12 +- source/mircoders/media/MediaHandlerRealAudio.java | 10 +- source/mircoders/media/MediaHandlerRealVideo.java | 10 +- source/mircoders/media/MediaHelper.java | 2 +- source/mircoders/media/MediaUploadProcessor.java | 2 +- source/mircoders/media/URLMediaHandler.java | 2 +- source/mircoders/module/ModuleArticleType.java | 4 +- source/mircoders/module/ModuleBreaking.java | 27 +-- source/mircoders/module/ModuleComment.java | 10 +- source/mircoders/module/ModuleCommentStatus.java | 4 +- source/mircoders/module/ModuleContent.java | 8 +- source/mircoders/module/ModuleImages.java | 2 +- source/mircoders/module/ModuleLanguage.java | 4 +- source/mircoders/module/ModuleMediaType.java | 2 +- source/mircoders/module/ModuleMediafolder.java | 4 +- source/mircoders/module/ModuleMessage.java | 16 +- source/mircoders/module/ModuleTopics.java | 24 +- source/mircoders/module/ModuleUploadedMedia.java | 16 +- source/mircoders/module/ModuleUsers.java | 11 +- source/mircoders/pdf/PDFGenerator.java | 26 +-- .../producer/ContentMarkingProducerNode.java | 14 +- .../producer/ContentModifyingProducerNode.java | 4 +- .../mircoders/producer/IndexingProducerNode.java | 28 +-- .../producer/MediaGeneratingProducerNode.java | 12 +- .../producer/PDFPreFormattingProducerNode.java | 10 +- .../mircoders/producer/UnIndexingProducerNode.java | 2 +- source/mircoders/search/ContentSearchTerm.java | 2 +- source/mircoders/search/ImagesSearchTerm.java | 2 +- source/mircoders/search/KeywordSearchTerm.java | 16 +- source/mircoders/search/TextSearchTerm.java | 2 +- source/mircoders/search/TopicMatrixSearchTerm.java | 2 +- source/mircoders/search/TopicSearchTerm.java | 2 +- source/mircoders/search/UnIndexedSearchTerm.java | 2 +- source/mircoders/search/UnStoredSearchTerm.java | 2 +- source/mircoders/servlet/ServletHelper.java | 2 +- source/mircoders/servlet/ServletModuleAbuse.java | 27 ++- source/mircoders/servlet/ServletModuleContent.java | 6 +- .../servlet/ServletModuleUploadedMedia.java | 2 +- source/mircoders/servlet/ServletModuleUsers.java | 2 +- source/mircoders/storage/DatabaseArticleType.java | 3 +- source/mircoders/storage/DatabaseAudio.java | 12 +- source/mircoders/storage/DatabaseBreaking.java | 2 +- source/mircoders/storage/DatabaseComment.java | 4 +- .../mircoders/storage/DatabaseCommentStatus.java | 2 +- .../mircoders/storage/DatabaseCommentToMedia.java | 50 ++-- source/mircoders/storage/DatabaseContent.java | 4 +- .../mircoders/storage/DatabaseContentToMedia.java | 54 ++--- .../mircoders/storage/DatabaseContentToTopics.java | 28 +-- source/mircoders/storage/DatabaseImageColor.java | 2 +- source/mircoders/storage/DatabaseImageFormat.java | 2 +- source/mircoders/storage/DatabaseImageLayout.java | 2 +- source/mircoders/storage/DatabaseImageType.java | 2 +- source/mircoders/storage/DatabaseImages.java | 12 +- source/mircoders/storage/DatabaseLanguage.java | 4 +- source/mircoders/storage/DatabaseMediaType.java | 2 +- source/mircoders/storage/DatabaseMediafolder.java | 2 +- source/mircoders/storage/DatabaseMessages.java | 2 +- source/mircoders/storage/DatabaseOther.java | 12 +- source/mircoders/storage/DatabaseRights.java | 2 +- source/mircoders/storage/DatabaseTopics.java | 4 +- .../mircoders/storage/DatabaseUploadedMedia.java | 6 +- source/mircoders/storage/DatabaseUsers.java | 2 +- source/mircoders/storage/DatabaseVideo.java | 12 +- templates/admin/abuse.filters.template | 10 +- 104 files changed, 943 insertions(+), 1145 deletions(-) create mode 100755 source/mir/entity/AbstractEntity.java create mode 100755 source/mir/util/EntityUtility.java diff --git a/bundles/admin_en.properties b/bundles/admin_en.properties index 1e0ef2b6..a5c7253d 100755 --- a/bundles/admin_en.properties +++ b/bundles/admin_en.properties @@ -1,6 +1,6 @@ ########## admin ########## # language: english -# $Id: admin_en.properties,v 1.48.2.21 2004/01/11 20:35:50 zapata Exp $ +# $Id: admin_en.properties,v 1.48.2.22 2004/01/18 17:30:55 zapata Exp $ languagename=English @@ -483,6 +483,8 @@ abuse.log.filterexpression=Expression abuse.filters = Filters abuse.filters.movedown = down abuse.filters.moveup = up +abuse.filters.movebottom = bottom +abuse.filters.movetop = top abuse.filter.type = Type abuse.filter.expression = Expression diff --git a/source/Mir.java b/source/Mir.java index a2e8b152..d3673423 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -70,7 +70,7 @@ import org.apache.struts.util.MessageResources; * Mir.java - main servlet, that dispatches to servletmodules * * @author $Author: zapata $ - * @version $Id: Mir.java,v 1.49.2.10 2004/01/11 20:35:51 zapata Exp $ + * @version $Id: Mir.java,v 1.49.2.11 2004/01/18 17:30:56 zapata Exp $ * */ public class Mir extends AbstractServlet { @@ -225,7 +225,7 @@ public class Mir extends AbstractServlet { } } else if (moduleName.equals("logout")) { - logger.info(userEntity.getValue("login") + " has logged out"); + logger.info(userEntity.getFieldValue("login") + " has logged out"); session.invalidate(); _sendLoginPage(aResponse, aRequest); return; diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java new file mode 100755 index 00000000..925ff8d1 --- /dev/null +++ b/source/mir/entity/AbstractEntity.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. + */ +package mir.entity; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; +import mir.log.LoggerWrapper; +import mir.storage.StorageObject; +import mir.storage.StorageObjectExc; +import mir.storage.StorageObjectFailure; + +/** + * Base class the entities are derived from. Provides base functionality of + * an entity. + * + * @version $Id: AbstractEntity.java,v 1.8.2.1 2004/01/18 17:30:56 zapata Exp $ + */ + +public class AbstractEntity implements Entity { + protected static MirPropertiesConfiguration configuration; + + protected Map values; + protected StorageObject storageObject; + protected LoggerWrapper logger; + + static { + try { + configuration = MirPropertiesConfiguration.instance(); + } + catch (PropertiesConfigExc e) { + throw new RuntimeException(e.getMessage()); + } + } + + public AbstractEntity() { + logger = new LoggerWrapper("Entity"); + + values = new HashMap(); + } + + /** + * Constructor + * @param StorageObject The StorageObject of the Entity. + */ + + public AbstractEntity(StorageObject StorageObject) { + this(); + + setStorage(StorageObject); + } + + public void setStorage(StorageObject storage) { + this.storageObject = storage; + } + + /** {@inheritDoc} */ + public void setValues(Map aMap) { + if (aMap!=null) { + Iterator i = aMap.entrySet().iterator(); + synchronized(this) { + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + + setFieldValue( (String) entry.getKey(), (String) entry.getValue()); + } + } + } + } + + /** {@inheritDoc} */ + public String getId() { + return getFieldValue(storageObject.getIdName()); + } + + /** {@inheritDoc} */ + public void setId(String id) { + setFieldValue(storageObject.getIdName(), id); + } + + /** {@inheritDoc} */ + public String insert() throws StorageObjectExc { + logger.debug("Entity: trying to insert ..."); + + if (storageObject != null) { + return storageObject.insert(this); + } + else + throw new StorageObjectExc("storageObject == null!"); + } + + /** {@inheritDoc} */ + public void update() throws StorageObjectFailure { + storageObject.update(this); + } + + /** {@inheritDoc} */ + public String getFieldValue(String aFieldName) { + String returnValue = null; + + if (aFieldName != null) { + returnValue = (String) values.get(aFieldName); + } + return returnValue; + } + + /** {@inheritDoc} */ + public boolean hasFieldValue(String aFieldName) { + return values.containsKey(aFieldName); + } + + /** + * Sets the value for a field. Issues a log message if the field name + * supplied was not found in the Entity. + * @param theProp The field name whose value has to be set + * @param theValue The new value of the field + * @exception StorageObjectFailure + */ + public void setFieldValue(String theProp, String theValue) throws StorageObjectFailure { + if (hasField(theProp)) + values.put(theProp, theValue); + else { + logger.warn("Entity.setFieldValue: Property not found: " + theProp + " (" + theValue + ")"); + } + } + + /** + * Returns the field names of the Entity + */ + public List getFieldNames() throws StorageObjectFailure { + return storageObject.getFields(); + } + + /** Returns whether fieldName is a valid field name of this Entity. + * @param fieldName + * @return true in case fieldName is a field name, else false. + * @exception StorageObjectFailure + */ + public boolean hasField(String fieldName) throws StorageObjectFailure { + return getFieldNames().contains(fieldName); + } +} + diff --git a/source/mir/entity/Entity.java b/source/mir/entity/Entity.java index e2e19c47..adfe2d0b 100755 --- a/source/mir/entity/Entity.java +++ b/source/mir/entity/Entity.java @@ -40,61 +40,17 @@ import mir.log.LoggerWrapper; import mir.storage.StorageObject; import mir.storage.StorageObjectExc; import mir.storage.StorageObjectFailure; -import mir.util.*; /** - * Base class the entities are derived from. Provides base functionality of - * an entity. Entities are used to represent rows of a database table.

- * - * @version $Id: Entity.java,v 1.21.2.6 2003/12/21 13:32:03 zapata Exp $ - * @author rk + * An Entity represents a persistent data object, typically + * stored in a database.

* + * @version $Id: Entity.java,v 1.21.2.7 2004/01/18 17:30:56 zapata Exp $ */ -public class Entity +public interface Entity { - protected static MirPropertiesConfiguration configuration; - -// protected Map theValuesHash; // tablekey / value - protected Map values; - protected StorageObject theStorageObject; - protected List streamedInput = null; - protected LoggerWrapper logger; - - static { - try { - configuration = MirPropertiesConfiguration.instance(); - } - catch (PropertiesConfigExc e) { - throw new RuntimeException(e.getMessage()); - } - } - - public Entity() { - logger = new LoggerWrapper("Entity"); - - values = new HashMap(); - } - - /** - * Constructor - * @param StorageObject The StorageObject of the Entity. - */ - - public Entity(StorageObject StorageObject) { - this(); - - setStorage(StorageObject); - } - - /** - * - * @param storage - */ - - public void setStorage(StorageObject storage) { - this.theStorageObject = storage; - } + public void setStorage(StorageObject storage); /** * Sets the values of the Entity. (Only to be called by the Storage Object) @@ -102,175 +58,58 @@ public class Entity * @param aMap Map containing the new values of the Entity */ - public void setValues(Map aMap) { - if (aMap!=null) { - Iterator i = aMap.entrySet().iterator(); - synchronized(this) { - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - - setValueForProperty( (String) entry.getKey(), (String) entry.getValue()); - } - } - } - } + public void setValues(Map aMap); /** * Returns the primary key of the Entity. * @return String Id */ - public String getId() { - return (String) getValue(theStorageObject.getIdName()); - } + public String getId(); /** * Defines the primary key of the Entity (only to be set by the StorageObject) * @param id */ - public void setId(String id) { - setValueForProperty(theStorageObject.getIdName(), id); - } - - /** - * Returns the value of a field by field name. - * @param field The name of the field - * @return value of the field - */ - public String getValue(String field) { - String returnValue = null; - - if (field != null) { - returnValue = (String) values.get(field); - } - return returnValue; - } - - public boolean hasValueForField(String field) { - return values.containsKey(field); - } + public void setId(String id); /** * Insers Entity into the database via StorageObject * @return Primary Key of the Entity - * @exception StorageObjectException + * @exception StorageObjectExc */ - public String insert() throws StorageObjectExc { - logger.debug("Entity: trying to insert ..."); - - if (theStorageObject != null) { - return theStorageObject.insert(this); - } - else - throw new StorageObjectExc("theStorageObject == null!"); - } + public String insert() throws StorageObjectExc; /** * Saves changes of this Entity to the database - * @exception StorageObjectException + * @exception StorageObjectFailure */ - public void update() throws StorageObjectFailure { - theStorageObject.update(this); - } + public void update() throws StorageObjectFailure; /** * Sets the value for a field. Issues a log message if the field name * supplied was not found in the Entity. * @param theProp The field name whose value has to be set * @param theValue The new value of the field - * @exception StorageObjectException + * @exception StorageObjectFailure */ - public void setValueForProperty(String theProp, String theValue) throws StorageObjectFailure { - try { - if (isField(theProp)) - values.put(theProp, theValue); - else { - logger.warn("Entity.setValueForProperty: Property not found: " + theProp + " (" + theValue + ")"); - } - } - catch (Throwable t) { - logger.error("Entity.setValueForProperty: " + t.toString()); - t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); - - throw new StorageObjectFailure(t); - } - } + public void setFieldValue(String theProp, String theValue); /** - * Returns the field names of the Entity as ArrayListe. - * @return ArrayList with field names - * @exception StorageObjectException is throuwn if database access was impossible + * Returns the field names of the Entity */ - public List getFields() throws StorageObjectFailure { - return theStorageObject.getFields(); - } - - /** - * Returns an int[] with the types of the fields - * @return int[] that contains the types of the fields - * @exception StorageObjectException - */ - public int[] getTypes() throws StorageObjectFailure { - return theStorageObject.getTypes(); - } - - /** - * Returns an ArrayList with field names - * @return List with field names - * @exception StorageObjectException - */ - public List getLabels() throws StorageObjectFailure { - return theStorageObject.getLabels(); - } - + public List getFieldNames() throws StorageObjectFailure; /** - * Returns an ArrayList with all database fields that can - * be evaluated as streamedInput. - * Could be automated by the types (blob, etc.) - * Until now to be created manually in the inheriting class - * - * Liefert einen ArrayList mit allen Datenbankfeldern, die - * als streamedInput ausgelesen werden muessen. - * Waere automatisierbar ueber die types (blob, etc.) - * Bisher manuell anzulegen in der erbenden Klasse + * Returns the value of a field by field name. + * @param field The name of the field + * @return value of the field */ + public String getFieldValue(String field); - public List streamedInput() { - return streamedInput; - } + public boolean hasFieldValue(String field); /** Returns whether fieldName is a valid field name of this Entity. - * @param fieldName - * @return true in case fieldName is a field name, else false. - * @exception StorageObjectException - */ - public boolean isField(String fieldName) throws StorageObjectFailure { - return theStorageObject.getFields().contains(fieldName); - } - - protected void throwStorageObjectFailure(Throwable e, String wo) throws StorageObjectFailure { - logger.error(e.toString() + " function: " + wo); - e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); - - throw new StorageObjectFailure("Storage Object Exception in entity", e); - } - - /** - * Helper method to append a line to a field */ - public void appendLineToField(String aFieldName, String aLine) { - StringBuffer fieldContent = new StringBuffer(); - try { - fieldContent.append(StringRoutines.interpretAsString(getValue(aFieldName))); - } - catch (Throwable t) { - } - if (fieldContent.length() > 0 && fieldContent.charAt(fieldContent.length() - 1) != '\n') { - fieldContent.append('\n'); - } - - fieldContent.append(aLine); - setValueForProperty(aFieldName, fieldContent.toString()); - } + public boolean hasField(String aFieldName) throws StorageObjectFailure; } diff --git a/source/mir/entity/EntityBrowser.java b/source/mir/entity/EntityBrowser.java index e3ab6eec..77bc5593 100755 --- a/source/mir/entity/EntityBrowser.java +++ b/source/mir/entity/EntityBrowser.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -44,7 +44,6 @@ public class EntityBrowser implements RewindableIterator { private String whereClause; private String orderByClause; private int batchSize; - private int toFetch; private EntityList currentBatch; private int skip; @@ -65,7 +64,7 @@ public class EntityBrowser implements RewindableIterator { batchSize=aBatchSize; skip=aSkip; limit=aLimit; - + rewind(); } diff --git a/source/mir/entity/EntityList.java b/source/mir/entity/EntityList.java index 0de6bba9..fad20bfa 100755 --- a/source/mir/entity/EntityList.java +++ b/source/mir/entity/EntityList.java @@ -98,7 +98,6 @@ public class EntityList implements StorableObject { return whereClause; } - /** * Sets the sorting criterium of this EntityList * @param oc @@ -243,8 +242,8 @@ public class EntityList implements StorableObject { */ public Entity elementAt(int i) { - /** @todo check if i is in list.size() */ - return (Entity)theEntityArrayList.get(i); + /** todo check if i is in list.size() */ + return (Entity) theEntityArrayList.get(i); } diff --git a/source/mir/entity/GenericEntity.java b/source/mir/entity/GenericEntity.java index d5632e1c..2a9f7b38 100755 --- a/source/mir/entity/GenericEntity.java +++ b/source/mir/entity/GenericEntity.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.entity; @@ -38,7 +38,7 @@ package mir.entity; * @author /rk * @version 1.2 */ -public class GenericEntity extends Entity {} +public class GenericEntity extends AbstractEntity {} diff --git a/source/mir/entity/StorableObjectEntity.java b/source/mir/entity/StorableObjectEntity.java index 796d560e..b955d681 100755 --- a/source/mir/entity/StorableObjectEntity.java +++ b/source/mir/entity/StorableObjectEntity.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.entity; @@ -47,7 +47,7 @@ import mir.storage.store.StorableObject; import mir.storage.store.StoreIdentifier; -public class StorableObjectEntity extends Entity +public class StorableObjectEntity extends AbstractEntity implements StorableObject { /** @@ -59,8 +59,8 @@ public class StorableObjectEntity extends Entity */ public StoreIdentifier getStoreIdentifier() { String id = getId(); - if ( id!=null && theStorageObject!= null ) - return new StoreIdentifier(this, id+"@"+theStorageObject.getTableName()); + if ( id!=null && storageObject!= null ) + return new StoreIdentifier(this, id+"@"+storageObject.getTableName()); return null; } @@ -72,10 +72,10 @@ public class StorableObjectEntity extends Entity return new StoreIdentifier(theEntityClass, id + "@" + theTable); } } - + public static final StoreIdentifier getStoreIdentifier(Database theStorage, Class theEntityClass, ResultSet rs) throws SQLException { - + String idcol = theStorage.getIdName(); String idval = rs.getObject(idcol).toString(); @@ -83,7 +83,7 @@ public class StorableObjectEntity extends Entity return getStoreIdentifier(theEntityClass, theStorage.getTableName(), idval); } - + return null; } diff --git a/source/mir/entity/adapter/EntityAdapter.java b/source/mir/entity/adapter/EntityAdapter.java index 1b21f3e9..e2239816 100755 --- a/source/mir/entity/adapter/EntityAdapter.java +++ b/source/mir/entity/adapter/EntityAdapter.java @@ -55,9 +55,8 @@ public class EntityAdapter implements Map { public boolean containsKey(Object aKey) { try { if (aKey instanceof String) - return entity.hasValueForField((String) aKey) - || definition.hasCalculatedField((String) aKey) - || entity.getFields().contains(aKey); + return entity.hasField((String) aKey) + || definition.hasCalculatedField((String) aKey); } catch (Throwable t) { } @@ -95,7 +94,7 @@ public class EntityAdapter implements Map { return result; } else if (aKey instanceof String) { - return entity.getValue((String) aKey); + return entity.getFieldValue((String) aKey); } else { return null; @@ -146,10 +145,10 @@ public class EntityAdapter implements Map { String aWhereClause, String anOrderByClause, String aDefinition) { try { return - new CachingRewindableIterator( - new EntityIteratorAdapter(aMainTablePrefix, someExtraTables, + new CachingRewindableIterator( + new EntityIteratorAdapter(aMainTablePrefix, someExtraTables, aWhereClause, anOrderByClause, - -1, getModel(), aDefinition, -1, 0) + -1, getModel(), aDefinition, -1, 0) ); } catch (Throwable t) { diff --git a/source/mir/entity/adapter/EntityAdapterDefinition.java b/source/mir/entity/adapter/EntityAdapterDefinition.java index 80cb4233..571df52e 100755 --- a/source/mir/entity/adapter/EntityAdapterDefinition.java +++ b/source/mir/entity/adapter/EntityAdapterDefinition.java @@ -137,7 +137,7 @@ public class EntityAdapterDefinition { public Object getValue(EntityAdapter anEntityAdapter) { Object result = null; - String textValue = anEntityAdapter.getEntity().getValue(fieldName); + String textValue = anEntityAdapter.getEntity().getFieldValue(fieldName); Calendar calendar = GregorianCalendar.getInstance(); int year; int month; @@ -176,7 +176,7 @@ public class EntityAdapterDefinition { public Object getValue(EntityAdapter anEntityAdapter) { Object result = null; - String text = anEntityAdapter.getEntity().getValue(fieldName); + String text = anEntityAdapter.getEntity().getFieldValue(fieldName); if (text!=null) { try { diff --git a/source/mir/entity/adapter/EntityIteratorAdapter.java b/source/mir/entity/adapter/EntityIteratorAdapter.java index 49df936d..dfa9ae7d 100755 --- a/source/mir/entity/adapter/EntityIteratorAdapter.java +++ b/source/mir/entity/adapter/EntityIteratorAdapter.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.entity.adapter; @@ -59,7 +59,7 @@ public class EntityIteratorAdapter implements RewindableIterator { this(new EntityBrowser(aModel.getMappingForName(aDefinitionName).getStorage(), aWhereClause, anOrderByClause, aBatchSize, aLimit, aSkip), aModel, aDefinitionName); } - public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables, + public EntityIteratorAdapter(String aMainTablePrefix, List someExtraTables, String aWhereClause, String anOrderByClause, int aBatchSize, EntityAdapterModel aModel, String aDefinitionName, int aLimit, int aSkip) throws StorageObjectFailure, EntityAdapterExc { diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java index aa9b6318..f1bba191 100755 --- a/source/mir/module/AbstractModule.java +++ b/source/mir/module/AbstractModule.java @@ -30,6 +30,7 @@ package mir.module; import java.util.Map; +import java.sql.SQLException; import mir.entity.Entity; import mir.entity.EntityList; @@ -49,10 +50,10 @@ import mir.storage.StorageObject; */ public class AbstractModule { - protected StorageObject theStorage; + protected StorageObject storage; public void setStorage(StorageObject storage) { - this.theStorage = storage; + this.storage = storage; } /** @@ -60,19 +61,14 @@ public class AbstractModule { * @return Standard-StorageObject */ public StorageObject getStorageObject () { - return theStorage; + return storage; } - /** - * Holt eine Entity anhand der Id via StorageObject - * @param String der Entity - * @return Entity - */ public Entity getById (String id) throws ModuleExc, ModuleFailure { try { - if (theStorage == null) + if (storage == null) throw new ModuleExc("AbstractModule.getById: No StorageObject set!"); - Entity entity = (Entity)theStorage.selectById(id); + Entity entity = storage.selectById(id); if (entity == null) throw new ModuleExc("AbstractModule.getById: No object for id = " + id); @@ -84,59 +80,12 @@ public class AbstractModule { } } - /** - * Holt eine EntityListe anhand des WhereClause via StorageObject - * @param String whereclause - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure { try { - if (theStorage == null) + if (storage == null) throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!"); - return theStorage.selectByWhereClause(whereClause, offset); - } - catch (Throwable e) { - throw new ModuleFailure(e); - } - } - - /** - * Holt eine EntityListe anhand des WhereClause aus dem StorageObject - * @param String where WhereClause - * @param String order Sortierreihenfolge - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ - public EntityList getByWhereClause (String where, String order, int offset) throws ModuleExc, ModuleFailure { - try { - if (theStorage==null) - throw new ModuleExc("AbstractModule.getByWhereClause: No StorageObject set!"); - - return theStorage.selectByWhereClause(where, order, offset); - } - catch (Throwable e) { - throw new ModuleFailure(e); - } - } - /** - * Executes a where clause on the StorageObject with order criteria - * fetching from offset the number of limit objects - * - * @param String where - * @param String order - * @param int offset - * @param int limit - * @return EntityList - */ - - public EntityList getByWhereClause(String where, String order, int offset, int limit) throws ModuleExc, ModuleFailure { - try { - if (theStorage==null) - throw new ModuleExc("AbstractModule.getByWhereClause: StorageObject not set!"); - - return theStorage.selectByWhereClause(where, order, offset, limit); + return storage.selectByWhereClause(whereClause, offset); } catch (Throwable e) { throw new ModuleFailure(e); @@ -144,19 +93,6 @@ public class AbstractModule { } /** - * Holt eine EntityListe anhand des Wertes aValue von Feld aField aus dem StorageObject - * @param String aField - Feldname im StorageObject - * @param String aValue - Wert in Feld im StorageObject - * @param offset - ab welchem Datensatz die gematchten Entities zurueckgeliefert werden - * @return EntityList Liste der gematchten Datens?tze - */ - public EntityList getByFieldValue (String aField, String aValue, int offset) throws ModuleExc, ModuleFailure { - String whereClause; - whereClause = aField + " like '%" + aValue + "%'"; - return getByWhereClause(whereClause, offset); - } - - /** * * Standardfunktion, um einen Datensatz via StorageObject einzuf?gen * @param theValues Hash mit Spalte/Wert-Paaren * @return Id des eingef?gten Objekts @@ -165,8 +101,8 @@ public class AbstractModule { */ public String add (Map theValues) throws ModuleExc, ModuleFailure { try { - Entity theEntity = (Entity)theStorage.getEntityClass().newInstance(); - theEntity.setStorage(theStorage); + Entity theEntity = (Entity)storage.getEntityClass().newInstance(); + theEntity.setStorage(storage); theEntity.setValues(theValues); return theEntity.insert(); } @@ -177,16 +113,11 @@ public class AbstractModule { /** * This function creates an Entity without yet storing it in the database - * - * @param theValues - * @return - * @throws ModuleExc - * @throws ModuleFailure */ public Entity createNew() throws ModuleExc, ModuleFailure { try { - Entity result = (Entity)theStorage.getEntityClass().newInstance(); - result.setStorage(theStorage); + Entity result = (Entity)storage.getEntityClass().newInstance(); + result.setStorage(storage); return result; } @@ -204,7 +135,7 @@ public class AbstractModule { */ public String set (Map theValues) throws ModuleExc, ModuleFailure { try { - Entity theEntity = theStorage.selectById((String)theValues.get("id")); + Entity theEntity = storage.selectById((String)theValues.get("id")); if (theEntity == null) throw new ModuleExc("No object found with id " + theValues.get("id")); theEntity.setValues(theValues); @@ -224,7 +155,7 @@ public class AbstractModule { */ public void deleteById (String idParam) throws ModuleExc, ModuleFailure { try { - theStorage.delete(idParam); + storage.delete(idParam); } catch (Throwable e) { throw new ModuleFailure(e); @@ -236,10 +167,10 @@ public class AbstractModule { */ public int getSize(String where) throws ModuleExc, ModuleFailure { try { - return theStorage.getSize(where); + return storage.getSize(where); } - catch (Throwable e) { - throw new ModuleFailure(e); + catch (SQLException e) { + throw new ModuleFailure("Can't retrieve number of entities: " + e.toString(), e); } } diff --git a/source/mir/producer/EntityModifyingProducerNode.java b/source/mir/producer/EntityModifyingProducerNode.java index d0c9c4dd..ec3e0c73 100755 --- a/source/mir/producer/EntityModifyingProducerNode.java +++ b/source/mir/producer/EntityModifyingProducerNode.java @@ -86,11 +86,11 @@ public class EntityModifyingProducerNode implements ProducerNode { Object value = ParameterExpander.evaluateExpression(aValueMap, valueExpression); if (value instanceof String) - entity.setValueForProperty(entityField, (String) value); + entity.setFieldValue(entityField, (String) value); else if (value instanceof EntityAdapter) - entity.setValueForProperty(entityField, ((EntityAdapter) value).getEntity().getId()); + entity.setFieldValue(entityField, ((EntityAdapter) value).getEntity().getId()); else if (value instanceof Date) { - entity.setValueForProperty(entityField, JDBCStringRoutines.formatDate((Date) value)); + entity.setFieldValue(entityField, JDBCStringRoutines.formatDate((Date) value)); } else aLogger.warn("Can't set value " + value + " for field " + entityField); diff --git a/source/mir/rss/RSSReader.java b/source/mir/rss/RSSReader.java index 4b6f120a..1d7bf402 100755 --- a/source/mir/rss/RSSReader.java +++ b/source/mir/rss/RSSReader.java @@ -279,7 +279,7 @@ public class RSSReader { public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof PropertyValueSectionHandler) { usePropertyValueSectionHandler(resource, (PropertyValueSectionHandler) aHandler, currentTag); -// resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getValue()); +// resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getFieldValue()); } }; diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java index 599af40b..38e7583f 100755 --- a/source/mir/storage/Database.java +++ b/source/mir/storage/Database.java @@ -75,56 +75,33 @@ import com.codestudio.util.SQLManager; * Treiber, Host, User und Passwort, ueber den der Zugriff auf die * Datenbank erfolgt. * - * @version $Id: Database.java,v 1.44.2.20 2003/11/28 17:21:50 rk Exp $ + * @version $Id: Database.java,v 1.44.2.21 2004/01/18 17:30:57 zapata Exp $ * @author rk * */ public class Database implements StorageObject { private static Class GENERIC_ENTITY_CLASS = mir.entity.StorableObjectEntity.class; - private static Class STORABLE_OBJECT_ENTITY_CLASS = mir.entity.StorableObjectEntity.class; - - - private static Map POPUP_EMPTYLINE = new HashMap(); protected static final ObjectStore o_store = ObjectStore.getInstance(); private static final int _millisPerHour = 60 * 60 * 1000; - private static final int _millisPerMinute = 60 * 1000; - - static { - // always same object saves a little space - POPUP_EMPTYLINE.put("key", ""); - POPUP_EMPTYLINE.put("value", "--"); - } protected LoggerWrapper logger; protected MirPropertiesConfiguration configuration; - protected String theTable; - protected String theCoreTable = null; - protected String thePKeyName = "id"; - protected int thePKeyType; - protected int thePKeyIndex; + protected String mainTable; + protected String primaryKeySequence = null; + protected String primaryKeyField = "id"; + protected boolean evaluatedMetaData = false; protected ArrayList metadataFields; protected ArrayList metadataLabels; protected ArrayList metadataNotNullFields; protected int[] metadataTypes; protected Class theEntityClass; - protected List popupCache = null; - protected boolean hasPopupCache = false; - protected Map hashCache = null; protected boolean hasTimestamp = true; - private String database_driver; - private String database_url; private int defaultLimit; TimeZone timezone; SimpleDateFormat internalDateFormat; SimpleDateFormat userInputDateFormat; -/* - private SimpleDateFormat _dateFormatterOut; - private SimpleDateFormat _dateFormatterIn; - _dateFormatterOut = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - _dateFormatterIn = new SimpleDateFormat("yyyy-MM-dd HH:mm"); -*/ /** * Kontruktor bekommt den Filenamen des Konfigurationsfiles ?bergeben. @@ -133,8 +110,6 @@ public class Database implements StorageObject { * Database.Host und Database.Adaptor * ausgelesen und ein Broker f?r die Verbindugen zur Datenbank * erzeugt. - * - * @param String confFilename Dateiname der Konfigurationsdatei */ public Database() throws StorageObjectFailure { try { @@ -151,7 +126,6 @@ public class Database implements StorageObject { userInputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); userInputDateFormat.setTimeZone(timezone); - String theAdaptorName = configuration.getString("Database.Adaptor"); defaultLimit = Integer.parseInt(configuration.getString("Database.Limit")); @@ -191,7 +165,7 @@ public class Database implements StorageObject { * @return Name des Primary-Keys */ public String getIdName() { - return thePKeyName; + return primaryKeyField; } /** @@ -200,29 +174,27 @@ public class Database implements StorageObject { * @return Name der Tabelle */ public String getTableName() { - return theTable; + return mainTable; } - /* - * Dient dazu vererbte Tabellen bei objectrelationalen DBMS - * zu speichern, wenn die id einer Tabelle in der parenttabelle verwaltet - * wird. - * @return liefert theCoreTabel als String zurueck, wenn gesetzt, sonst - * the Table + /** + * Returns the id that was most recently added to the database */ - public String getCoreTable() { - if (theCoreTable != null) { - return theCoreTable; - } - else { - return theTable; - } + private String getLatestInsertedId(Connection aConnection) throws SQLException { + if (primaryKeySequence==null) + primaryKeySequence = mainTable+"_id_seq"; + + PreparedStatement statement = aConnection.prepareStatement("select currval('" + primaryKeySequence + "')"); + + ResultSet rs = statement.executeQuery(); + rs.next(); + return rs.getString(1); } /** * Liefert Feldtypen der Felder der Tabelle zurueck (s.a. java.sql.Types) * @return int-Array mit den Typen der Felder - * @exception StorageObjectException + * @exception StorageObjectFailure */ public int[] getTypes() throws StorageObjectFailure { if (metadataTypes == null) { @@ -234,8 +206,6 @@ public class Database implements StorageObject { /** * Liefert eine Liste der Labels der Tabellenfelder - * @return ArrayListe mit Labeln - * @exception StorageObjectException */ public List getLabels() throws StorageObjectFailure { if (metadataLabels == null) { @@ -248,7 +218,6 @@ public class Database implements StorageObject { /** * Liefert eine Liste der Felder der Tabelle * @return ArrayList mit Feldern - * @exception StorageObjectException */ public List getFields() throws StorageObjectFailure { if (metadataFields == null) { @@ -262,7 +231,7 @@ public class Database implements StorageObject { * Gets value out of ResultSet according to type and converts to String * @param rs ResultSet. * @param aType a type from java.sql.Types.* - * @param index index in ResultSet + * @param valueIndex index in ResultSet * @return returns the value as String. If no conversion is possible * /unsupported value/ is returned */ @@ -293,7 +262,7 @@ public class Database implements StorageObject { case java.sql.Types.NUMERIC: - /** @todo Numeric can be float or double depending upon + /** todo Numeric can be float or double depending upon * metadata.getScale() / especially with oracle */ long outl = rs.getLong(valueIndex); @@ -405,7 +374,7 @@ public class Database implements StorageObject { String uniqueId = id; if (theEntityClass.equals(StorableObjectEntity.class)) { - uniqueId += ("@" + theTable); + uniqueId += ("@" + mainTable); } StoreIdentifier search_sid = new StoreIdentifier(theEntityClass, uniqueId); @@ -425,9 +394,9 @@ public class Database implements StorageObject { try { ResultSet rs; - /** @todo better prepared statement */ + /** todo better prepared statement */ String selectSql = - "select * from " + theTable + " where " + thePKeyName + "=" + id; + "select * from " + mainTable + " where " + primaryKeyField + "=" + id; stmt = con.createStatement(); rs = executeSql(stmt, selectSql); @@ -440,13 +409,13 @@ public class Database implements StorageObject { returnEntity = makeEntityFromResultSet(rs); } else { - logger.warn("No data for id: " + id + " in table " + theTable); + logger.warn("No data for id: " + id + " in table " + mainTable); } rs.close(); } else { - logger.warn("No Data for Id " + id + " in Table " + theTable); + logger.warn("No Data for Id " + id + " in Table " + mainTable); } } catch (SQLException sqe) { @@ -465,7 +434,7 @@ public class Database implements StorageObject { /** * This method makes it possible to make selects across multiple tables - * + * * @param mainTablePrefix prefix for the mainTable * @param extraTables a vector of tables for relational select * @param aWhereClause whereClause @@ -473,7 +442,7 @@ public class Database implements StorageObject { * @throws StorageObjectFailure */ - public EntityList selectByWhereClauseWithExtraTables(String mainTablePrefix, + public EntityList selectByWhereClauseWithExtraTables(String mainTablePrefix, List extraTables, String aWhereClause ) throws StorageObjectFailure { return selectByWhereClause( mainTablePrefix, extraTables, aWhereClause, "", 0, defaultLimit); @@ -481,8 +450,8 @@ public class Database implements StorageObject { /** * select-Operator um Datensaetze zu bekommen, die key = value erfuellen. - * @param key Datenbankfeld der Bedingung. - * @param value Wert die der key anehmen muss. + * @param aField Datenbankfeld der Bedingung. + * @param aValue Wert die der key anehmen muss. * @return EntityList mit den gematchten Entities */ public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure { @@ -491,8 +460,8 @@ public class Database implements StorageObject { /** * select-Operator um Datensaetze zu bekommen, die key = value erfuellen. - * @param key Datenbankfeld der Bedingung. - * @param value Wert die der key anehmen muss. + * @param aField Datenbankfeld der Bedingung. + * @param aValue Wert die der key anehmen muss. * @param offset Gibt an ab welchem Datensatz angezeigt werden soll. * @return EntityList mit den gematchten Entities */ @@ -504,9 +473,9 @@ public class Database implements StorageObject { * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck. * Also offset wird der erste Datensatz genommen. * - * @param wc where-Clause + * @param where where-Clause * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String where) throws StorageObjectFailure { return selectByWhereClause(where, 0); @@ -516,10 +485,10 @@ public class Database implements StorageObject { * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck. * Als maximale Anzahl wird das Limit auf der Konfiguration genommen. * - * @param wc where-Clause + * @param whereClause where-Clause * @param offset ab welchem Datensatz. * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure { return selectByWhereClause(whereClause, null, offset); @@ -530,10 +499,10 @@ public class Database implements StorageObject { * Also offset wird der erste Datensatz genommen. * Als maximale Anzahl wird das Limit auf der Konfiguration genommen. * - * @param wc where-Clause - * @param ob orderBy-Clause + * @param where where-Clause + * @param order orderBy-Clause * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String where, String order) throws StorageObjectFailure { return selectByWhereClause(where, order, 0); @@ -547,11 +516,11 @@ public class Database implements StorageObject { * select-Operator liefert eine EntityListe mit den gematchten Datens?tzen zur?ck. * Als maximale Anzahl wird das Limit auf der Konfiguration genommen. * - * @param wc where-Clause - * @param ob orderBy-Clause + * @param whereClause where-Clause + * @param orderBy orderBy-Clause * @param offset ab welchem Datensatz * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure { return selectByWhereClause(whereClause, orderBy, offset, defaultLimit); @@ -564,11 +533,11 @@ public class Database implements StorageObject { * @param offset ab welchem Datensatz * @param limit wieviele Datens?tze * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String aWhereClause, String anOrderByClause, int offset, int limit) throws StorageObjectFailure { - return selectByWhereClause("", null, aWhereClause, anOrderByClause, offset, limit); + return selectByWhereClause("", null, aWhereClause, anOrderByClause, offset, limit); } @@ -579,35 +548,35 @@ public class Database implements StorageObject { * @param offset ab welchem Datensatz * @param limit wieviele Datens?tze * @return EntityList mit den gematchten Entities - * @exception StorageObjectException + * @exception StorageObjectFailure */ public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, String aWhereClause, String anOrderByClause, int offset, int limit) throws StorageObjectFailure { - + // TODO get rid of emtpy Strings in extraTables // make extraTables null, if single empty String in it - // cause StringUtil.splitString puts in emptyString + // cause StringUtil.splitString puts in emptyString if (extraTables != null && ((String)extraTables.get(0)).trim().equals("")) { logger.debug("+++ made extraTables to null!"); extraTables=null; } - - String useTable = theTable; + + String useTable = mainTable; String selectStar = "*"; if (mainTablePrefix!=null && mainTablePrefix.trim().length()>0) { useTable+=" "+mainTablePrefix; selectStar=mainTablePrefix.trim() + ".*"; } - + // check o_store for entitylist // only if no relational select if (extraTables==null) { if (StoreUtil.extendsStorableEntity(theEntityClass)) { StoreIdentifier searchSid = new StoreIdentifier(theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST, - StoreUtil.getEntityListUniqueIdentifierFor(theTable, + StoreUtil.getEntityListUniqueIdentifierFor(mainTable, aWhereClause, anOrderByClause, offset, limit)); EntityList hit = (EntityList) o_store.use(searchSid); @@ -635,17 +604,17 @@ public class Database implements StorageObject { new StringBuffer("select count(*) from ").append(useTable); StringBuffer selectSql = new StringBuffer("select "+selectStar+" from ").append(useTable); - + // append extratables, if necessary if (extraTables!=null) { for (int i=0;i < extraTables.size();i++) { - if (!extraTables.get(i).equals("")) { + if (!extraTables.get(i).equals("")) { countSql.append( ", " + extraTables.get(i)); selectSql.append( ", " + extraTables.get(i)); } } } - + if (aWhereClause != null) { selectSql.append(" where ").append(aWhereClause); countSql.append(" where ").append(aWhereClause); @@ -757,7 +726,6 @@ public class Database implements StorageObject { Entity returnEntity = null; try { - // ask object store for object @ thePKeyIndex if (StoreUtil.extendsStorableEntity(theEntityClass)) { StoreIdentifier searchSid = StorableObjectEntity.getStoreIdentifier(this, theEntityClass, rs); @@ -805,7 +773,7 @@ public class Database implements StorageObject { returnEntity.setValues(theResultHash); if (returnEntity instanceof StorableObject) { - logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + theTable); + logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + mainTable); o_store.add(((StorableObject) returnEntity).getStoreIdentifier()); } } else { @@ -853,7 +821,6 @@ public class Database implements StorageObject { PreparedStatement pstmt = null; try { - List streamedInput = theEntity.streamedInput(); StringBuffer f = new StringBuffer(); StringBuffer v = new StringBuffer(); String aField; @@ -864,26 +831,21 @@ public class Database implements StorageObject { for (int i = 0; i < getFields().size(); i++) { aField = (String) getFields().get(i); - if (!aField.equals(thePKeyName)) { + if (!aField.equals(primaryKeyField)) { aValue = null; // exceptions - if (!theEntity.hasValueForField(aField) && ( + if (!theEntity.hasFieldValue(aField) && ( aField.equals("webdb_create") || aField.equals("webdb_lastchange"))) { aValue = "NOW()"; } else { - if ((streamedInput != null) && streamedInput.contains(aField)) { - aValue = "?"; - } - else { - if (theEntity.hasValueForField(aField)) { + if (theEntity.hasFieldValue(aField)) { aValue = "'" + - JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField)) + "'"; + JDBCStringRoutines.escapeStringLiteral(theEntity.getFieldValue(aField)) + "'"; } - } } // wenn Wert gegeben, dann einbauen @@ -905,7 +867,7 @@ public class Database implements StorageObject { // insert into db StringBuffer sqlBuf = - new StringBuffer("insert into ").append(theTable).append("(").append(f) + new StringBuffer("insert into ").append(mainTable).append("(").append(f) .append(") values (").append(v).append(")"); String sql = sqlBuf.toString(); @@ -914,14 +876,6 @@ public class Database implements StorageObject { con.setAutoCommit(false); pstmt = con.prepareStatement(sql); - if (streamedInput != null) { - for (int i = 0; i < streamedInput.size(); i++) { - String inputString = - (String) theEntity.getValue((String) streamedInput.get(i)); - pstmt.setBytes(i + 1, inputString.getBytes()); - } - } - int ret = pstmt.executeUpdate(); if (ret == 0) { @@ -929,11 +883,9 @@ public class Database implements StorageObject { return null; } - pstmt = con.prepareStatement("select currval('" + getCoreTable() + "_id_seq')"); +// pstmt = con.prepareStatement("select currval('" + + "_id_seq')"); - ResultSet rs = pstmt.executeQuery(); - rs.next(); - returnId = rs.getString(1); + returnId = getLatestInsertedId(con); theEntity.setId(returnId); } catch (SQLException sqe) { @@ -949,7 +901,7 @@ public class Database implements StorageObject { freeConnection(con, pstmt); } - /** @todo store entity in o_store */ + /** todo store entity in o_store */ return returnId; } @@ -962,13 +914,13 @@ public class Database implements StorageObject { Connection con = null; PreparedStatement pstmt = null; - /** @todo this is stupid: why do we prepare statement, when we + /** todo this is stupid: why do we prepare statement, when we * throw it away afterwards. should be regular statement * update/insert could better be one routine called save() * that chooses to either insert or update depending if we * have a primary key in the entity. i don't know if we * still need the streamed input fields. // rk */ - /** @todo extension: check if Entity did change, otherwise we don't need + /** todo extension: check if Entity did change, otherwise we don't need * the roundtrip to the database */ /** invalidating corresponding entitylists in o_store*/ if (StoreUtil.extendsStorableEntity(theEntityClass)) { @@ -978,7 +930,6 @@ public class Database implements StorageObject { o_store.invalidate(stoc_type); } - List streamedInput = theEntity.streamedInput(); String id = theEntity.getId(); String aField; StringBuffer fv = new StringBuffer(); @@ -992,11 +943,11 @@ public class Database implements StorageObject { aField = (String) metadataFields.get(i); // only normal cases - if ( !(aField.equals(thePKeyName) || + // todo if entity.hasFieldValue returns false, then the value should be stored as null + if (!(aField.equals(primaryKeyField) || aField.equals("webdb_create") || - aField.equals("webdb_lastchange") || - ((streamedInput != null) && streamedInput.contains(aField)))) { - if (theEntity.hasValueForField(aField)) { + aField.equals("webdb_lastchange"))) { + if (theEntity.hasFieldValue(aField)) { if (firstField == false) { fv.append(", "); } @@ -1004,15 +955,15 @@ public class Database implements StorageObject { firstField = false; } - fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral((String) theEntity.getValue(aField))).append("'"); + fv.append(aField).append("='").append(JDBCStringRoutines.escapeStringLiteral(theEntity.getFieldValue(aField))).append("'"); - // fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getValue(aField))).append("'"); + // fv.append(aField).append("='").append(StringUtil.quote((String)theEntity.getFieldValue(aField))).append("'"); } } } StringBuffer sql = - new StringBuffer("update ").append(theTable).append(" set ").append(fv); + new StringBuffer("update ").append(mainTable).append(" set ").append(fv); // exceptions if (metadataFields.contains("webdb_lastchange")) { @@ -1022,10 +973,10 @@ public class Database implements StorageObject { // special case: the webdb_create requires the field in yyyy-mm-dd HH:mm // format so anything extra will be ignored. -mh if (metadataFields.contains("webdb_create") && - theEntity.hasValueForField("webdb_create")) { + theEntity.hasFieldValue("webdb_create")) { // minimum of 10 (yyyy-mm-dd)... - if (theEntity.getValue("webdb_create").length() >= 10) { - String dateString = theEntity.getValue("webdb_create"); + if (theEntity.getFieldValue("webdb_create").length() >= 10) { + String dateString = theEntity.getFieldValue("webdb_create"); // if only 10, then add 00:00 so it doesn't throw a ParseException if (dateString.length() == 10) { @@ -1044,12 +995,6 @@ public class Database implements StorageObject { } } - if (streamedInput != null) { - for (int i = 0; i < streamedInput.size(); i++) { - sql.append(",").append(streamedInput.get(i)).append("=?"); - } - } - sql.append(" where id=").append(id); logger.info("UPDATE: " + sql); @@ -1058,14 +1003,6 @@ public class Database implements StorageObject { con.setAutoCommit(false); pstmt = con.prepareStatement(sql.toString()); - if (streamedInput != null) { - for (int i = 0; i < streamedInput.size(); i++) { - String inputString = - theEntity.getValue((String) streamedInput.get(i)); - pstmt.setBytes(i + 1, inputString.getBytes()); - } - } - pstmt.executeUpdate(); } catch (SQLException sqe) { @@ -1096,7 +1033,7 @@ public class Database implements StorageObject { String uniqueId = id; if (theEntityClass.equals(StorableObjectEntity.class)) { - uniqueId += ("@" + theTable); + uniqueId += ("@" + mainTable); } logger.debug("CACHE: (del) " + id); @@ -1107,12 +1044,12 @@ public class Database implements StorageObject { o_store.invalidate(search_sid); } - /** @todo could be prepared Statement */ + /** todo could be prepared Statement */ Statement stmt = null; Connection con = null; int res = 0; String sql = - "delete from " + theTable + " where " + thePKeyName + "='" + id + "'"; + "delete from " + mainTable + " where " + primaryKeyField + "='" + id + "'"; //theLog.printInfo("DELETE " + sql); try { @@ -1146,7 +1083,7 @@ public class Database implements StorageObject { Connection con = null; int res = 0; String sql = - "delete from " + theTable + " where " + aWhereClause; + "delete from " + mainTable + " where " + aWhereClause; //theLog.printInfo("DELETE " + sql); try { @@ -1173,20 +1110,14 @@ public class Database implements StorageObject { return false; } - /* invalidates the popupCache - */ protected void invalidatePopupCache() { - /** @todo invalidates toooo much */ - popupCache = null; - hashCache = null; + /** todo invalidates toooo much */ } /** * Diese Methode fuehrt den Sqlstring sql aus und timed im Logfile. * @param stmt Statemnt * @param sql Sql-String - * @return ResultSet - * @exception StorageObjectException */ public ResultSet executeSql(Statement stmt, String sql) throws StorageObjectFailure, SQLException { @@ -1206,7 +1137,7 @@ public class Database implements StorageObject { return rs; } - private Map processRow(ResultSet aResultSet) throws StorageObjectFailure, StorageObjectExc { + private Map processRow(ResultSet aResultSet) throws StorageObjectFailure { try { Map result = new HashMap(); ResultSetMetaData metaData = aResultSet.getMetaData(); @@ -1288,10 +1219,10 @@ public class Database implements StorageObject { * returns the number of rows in the table */ public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure { - + long startTime = System.currentTimeMillis(); - - String useTable = theTable; + + String useTable = mainTable; if (mainTablePrefix!=null && mainTablePrefix.trim().length()>0) { useTable+=" "+mainTablePrefix; } @@ -1300,7 +1231,7 @@ public class Database implements StorageObject { // append extratables, if necessary if (extraTables!=null) { for (int i=0;i < extraTables.size();i++) { - if (!extraTables.get(i).equals("")) { + if (!extraTables.get(i).equals("")) { countSql.append( ", " + extraTables.get(i)); } } @@ -1380,7 +1311,6 @@ public class Database implements StorageObject { /** * Wertet ResultSetMetaData aus und setzt interne Daten entsprechend * @param md ResultSetMetaData - * @exception StorageObjectException */ private void evalMetaData(ResultSetMetaData md) throws StorageObjectFailure { this.evaluatedMetaData = true; @@ -1402,9 +1332,7 @@ public class Database implements StorageObject { aType = md.getColumnType(i); metadataTypes[i - 1] = aType; - if (aField.equals(thePKeyName)) { - thePKeyType = aType; - thePKeyIndex = i; + if (aField.equals(primaryKeyField)) { } if (md.isNullable(i) == ResultSetMetaData.columnNullable) { @@ -1424,7 +1352,7 @@ public class Database implements StorageObject { private void get_meta_data() throws StorageObjectFailure { Connection con = null; PreparedStatement pstmt = null; - String sql = "select * from " + theTable + " where 0=1"; + String sql = "select * from " + mainTable + " where 0=1"; try { con = getPooledCon(); @@ -1467,8 +1395,7 @@ public class Database implements StorageObject { /** * Wertet SQLException aus und wirft dannach eine StorageObjectException * @param sqe SQLException - * @param wo Funktonsname, in der die SQLException geworfen wurde - * @exception StorageObjectException + * @param aFunction Funktonsname, in der die SQLException geworfen wurde */ protected void throwSQLException(SQLException sqe, String aFunction) throws StorageObjectFailure { String state = ""; @@ -1505,8 +1432,8 @@ public class Database implements StorageObject { /** * Loggt Fehlermeldung mit dem Parameter Message und wirft dannach * eine StorageObjectException - * @param message Nachricht mit dem Fehler - * @exception StorageObjectException + * @param aMessage Nachricht mit dem Fehler + * @exception StorageObjectFailure */ void throwStorageObjectException(String aMessage) throws StorageObjectFailure { logger.error(aMessage); diff --git a/source/mir/storage/StorageObject.java b/source/mir/storage/StorageObject.java index 78a97124..62617e24 100755 --- a/source/mir/storage/StorageObject.java +++ b/source/mir/storage/StorageObject.java @@ -39,211 +39,78 @@ import java.util.Map; import mir.entity.Entity; import mir.entity.EntityList; - /** - * Implementiert Interface f?r die Speicherschicht. - * Bislang gibt es in der Bibliothek nur die M?glichkeit - * in einer Datenbank zu speichern. - * @author RK - * @version 29.6.1999 + * Interface for low-level database actions. */ + public interface StorageObject { - /** - * Dokumentation siehe Database.java - * @param id - * @return Entity - * @exception StorageObjectException - */ - abstract public Entity selectById(String id) throws StorageObjectExc; + public Entity selectById(String id) throws StorageObjectExc; - /** - * Dokumentation siehe Database.java - * @param aField - * @param aValue - * @return EntityList - * @exception StorageObjectException - */ - abstract public EntityList selectByFieldValue(String aField, String aValue) - throws StorageObjectFailure; + public EntityList selectByFieldValue(String aField, String aValue) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param whereClause - * @return EntityList - * @exception StorageObjectException - */ - abstract public EntityList selectByWhereClause(String whereClause) - throws StorageObjectFailure; + public EntityList selectByWhereClause(String whereClause) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param whereClause - * @param offset - * @return EntityList - * @exception StorageObjectException - */ - abstract public EntityList selectByWhereClause(String whereClause, int offset) - throws StorageObjectFailure; + public EntityList selectByWhereClause(String whereClause, int offset) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param whereClause - * @param orderBy - * @param offset - * @return EntityList - * @exception StorageObjectException - */ - abstract public EntityList selectByWhereClause(String whereClause, - String orderBy, int offset) throws StorageObjectFailure; + public EntityList selectByWhereClause(String whereClause, String orderBy, int offset) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param whereClause - * @param orderBy - * @param offset - * @param limit - * @return EntityList - * @exception StorageObjectException - */ - abstract public EntityList selectByWhereClause(String whereClause, - String orderBy, int offset, int limit) throws StorageObjectFailure; - - abstract public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, - String aWhereClause, String anOrderByClause, - int offset, int limit) throws StorageObjectFailure; + public EntityList selectByWhereClause(String whereClause, String orderBy, int offset, int limit) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param id - * @return boolen - * @exception StorageObjectException - */ - abstract public boolean delete(String id) throws StorageObjectFailure; + public EntityList selectByWhereClause(String mainTablePrefix, List extraTables, String aWhereClause, String anOrderByClause, int offset, int limit) throws StorageObjectFailure; + + public boolean delete(String id) throws StorageObjectFailure; /** * Deletes entities based on a where clause - * - * @param aWhereClause - * @return - * @throws StorageObjectFailure */ public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @return ArrayList - * @exception StorageObjectException - */ - abstract public List getFields() throws StorageObjectFailure; + public List getFields() throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @return int[] - * @exception StorageObjectException - */ - abstract public int[] getTypes() throws StorageObjectFailure; + public int[] getTypes() throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @return ArrayList - * @exception StorageObjectException - */ - abstract public List getLabels() throws StorageObjectFailure; + public List getLabels() throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param a - * @exception StorageObjectException - */ - abstract public void update(Entity a) throws StorageObjectFailure; - + public void update(Entity a) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @param a - * @return String id - * @exception StorageObjectException - */ - abstract public String insert(Entity a) throws StorageObjectFailure; + public String insert(Entity a) throws StorageObjectFailure; - /** - * Dokumentation siehe Database.java - * @return Class Klasse der Entity - */ - abstract public Class getEntityClass(); + public Class getEntityClass(); - /** - * put your documentation comment here - * @return - */ - abstract public String getIdName(); + public String getIdName(); - /** - * Dokumentation siehe Database.java - * @return String - */ - abstract public String getTableName(); + public String getTableName(); - /** - * Dokumentation siehe Database.java - * @return Connection - * @exception StorageObjectException - */ - abstract public Connection getPooledCon() throws StorageObjectFailure; + public Connection getPooledCon() throws StorageObjectFailure; - /** - * - * @param a - * @param sql - * @return - * @throws StorageObjectFailure - * @throws SQLException - */ - abstract public ResultSet executeSql(Statement a, String sql) throws StorageObjectFailure, SQLException; + public ResultSet executeSql(Statement a, String sql) throws StorageObjectFailure, SQLException; /** - * Executes 1 sql statement and returns the results as a List of Maps - * - * @param sql - * @return - * @throws StorageObjectFailure - * @throws StorageObjectExc + * Executes 1 sql statement and returns the results as a List of + * Maps */ - abstract public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc; + public List executeFreeSql(String sql, int aLimit) throws StorageObjectFailure, StorageObjectExc; /** * Executes 1 sql statement and returns the first result row as a <Maps * (null if there wasn't any row) - * - * @param sql - * @return - * @throws StorageObjectFailure - * @throws StorageObjectExc */ - abstract public Map executeFreeSingleRowSql(String sql) throws StorageObjectFailure, StorageObjectExc ; + public Map executeFreeSingleRowSql(String sql) throws StorageObjectFailure, StorageObjectExc ; /** * Executes 1 sql statement and returns the first column of the first result row as a <Strings * (null if there wasn't any row) - * - * @param sql - * @return - * @throws StorageObjectFailure - * @throws StorageObjectExc */ - abstract public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ; + public String executeFreeSingleValueSql(String sql) throws StorageObjectFailure, StorageObjectExc ; - /** - * @param con - * @param stmt - */ - abstract public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure; + public void freeConnection(Connection con, Statement stmt) throws StorageObjectFailure; + + public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException; - abstract public int executeUpdate(Statement a, String sql) throws StorageObjectFailure, SQLException; + public int executeUpdate(String sql) throws StorageObjectFailure, SQLException; - abstract public int executeUpdate(String sql) throws StorageObjectFailure, SQLException; + public int getSize(String where) throws SQLException, StorageObjectFailure; - abstract public int getSize(String where) throws SQLException, StorageObjectFailure; - abstract public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure; + public int getSize(String mainTablePrefix, List extraTables, String where) throws SQLException, StorageObjectFailure; } diff --git a/source/mir/storage/store/StoreContainerType.java b/source/mir/storage/store/StoreContainerType.java index 4f913c3e..8e8bbcb3 100755 --- a/source/mir/storage/store/StoreContainerType.java +++ b/source/mir/storage/store/StoreContainerType.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.storage.store; diff --git a/source/mir/storage/store/StoreIdentifier.java b/source/mir/storage/store/StoreIdentifier.java index 26f8af10..358a5c5b 100755 --- a/source/mir/storage/store/StoreIdentifier.java +++ b/source/mir/storage/store/StoreIdentifier.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.storage.store; diff --git a/source/mir/storage/store/StoreUtil.java b/source/mir/storage/store/StoreUtil.java index 378d3d7d..917ceb92 100755 --- a/source/mir/storage/store/StoreUtil.java +++ b/source/mir/storage/store/StoreUtil.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.storage.store; @@ -85,7 +85,8 @@ public final class StoreUtil { if (superclass != null) { if (superclass == StorableObjectEntity.class) { return true; - } else { + } + else { return extendsStorableEntity(superclass); } } diff --git a/source/mir/util/EntityUtility.java b/source/mir/util/EntityUtility.java new file mode 100755 index 00000000..aca1e66a --- /dev/null +++ b/source/mir/util/EntityUtility.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. + * If you do not wish to do so, delete this exception statement from your version. + */ +package mir.util; + +import mir.entity.Entity; + +/** + * Utility methods for entity manipulation + */ +public class EntityUtility { + /** + * This class should never get instances + */ + private EntityUtility() { + + } + + /** + * Helper method to append a line to a field + */ + public static void appendLineToField(Entity anEntity, String aFieldName, String aLine) { + StringBuffer fieldContent = new StringBuffer(); + try { + fieldContent.append(StringRoutines.interpretAsString(anEntity.getFieldValue(aFieldName))); + } + catch (Throwable t) { + } + if (fieldContent.length() > 0 && fieldContent.charAt(fieldContent.length() - 1) != '\n') { + fieldContent.append('\n'); + } + + fieldContent.append(aLine); + anEntity.setFieldValue(aFieldName, fieldContent.toString()); + } +} diff --git a/source/mir/util/InternetFunctions.java b/source/mir/util/InternetFunctions.java index 171e8f89..2dd057b1 100755 --- a/source/mir/util/InternetFunctions.java +++ b/source/mir/util/InternetFunctions.java @@ -54,7 +54,6 @@ public class InternetFunctions { public static long parseIPAddress(String anIpAddress) throws Exception { int[] parts = {0,0,0,0}; int i; - long result; List stringParts = StringRoutines.splitString(anIpAddress, "."); if (stringParts.size()!=4) diff --git a/source/mircoders/accesscontrol/AccessControl.java b/source/mircoders/accesscontrol/AccessControl.java index 9f0dc3b0..42cece2f 100755 --- a/source/mircoders/accesscontrol/AccessControl.java +++ b/source/mircoders/accesscontrol/AccessControl.java @@ -122,11 +122,11 @@ public class AccessControl { } public boolean mayAddUsers(EntityUsers aSubject) { - return superusers.contains(aSubject.getValue("login")); + return superusers.contains(aSubject.getFieldValue("login")); } protected boolean isSuperUser(EntityUsers aUser) { - return superusers.contains(aUser.getValue("login")); + return superusers.contains(aUser.getFieldValue("login")); } public void assertMayEditUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure { @@ -141,11 +141,11 @@ public class AccessControl { } public boolean mayEditUser(EntityUsers aSubject, EntityUsers anObject) { - return superusers.contains(aSubject.getValue("login")); + return superusers.contains(aSubject.getFieldValue("login")); } public boolean mayEditUsers(EntityUsers aSubject) { - return superusers.contains(aSubject.getValue("login")); + return superusers.contains(aSubject.getFieldValue("login")); } public void assertMayDeleteUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure { @@ -159,15 +159,15 @@ public class AccessControl { } public boolean mayDeleteUser(EntityUsers aSubject, EntityUsers anObject) { - return superusers.contains(aSubject.getValue("login")); + return superusers.contains(aSubject.getFieldValue("login")); } public boolean mayDeleteUsers(EntityUsers aSubject) { - return superusers.contains(aSubject.getValue("login")); + return superusers.contains(aSubject.getFieldValue("login")); } public boolean mayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) { - return aSubject.getId().equals(anObject.getId()) || superusers.contains(aSubject.getValue("login")); + return aSubject.getId().equals(anObject.getId()) || superusers.contains(aSubject.getFieldValue("login")); } public void assertMayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure { diff --git a/source/mircoders/entity/EntityComment.java b/source/mircoders/entity/EntityComment.java index 9e7046fa..b8baf809 100755 --- a/source/mircoders/entity/EntityComment.java +++ b/source/mircoders/entity/EntityComment.java @@ -32,7 +32,7 @@ package mircoders.entity; import java.util.Map; -import mir.entity.Entity; +import mir.entity.AbstractEntity; import mir.storage.StorageObject; import mir.storage.StorageObjectFailure; import mircoders.storage.DatabaseCommentToMedia; @@ -42,12 +42,11 @@ import mircoders.storage.DatabaseContent; * This class maps one line of the comment-table to a java-object. * * @author $Author: zapata $ - * @version $Revision: 1.16.2.1 $ $Date: 2003/07/29 22:01:59 $ + * @version $Revision: 1.16.2.2 $ $Date: 2004/01/18 17:30:58 $ */ -public class EntityComment extends Entity -{ +public class EntityComment extends AbstractEntity { public EntityComment() { @@ -90,14 +89,8 @@ public class EntityComment extends Entity public void dettach(String aCommentId,String aMediaId) throws StorageObjectFailure { if (aMediaId!=null){ - try{ - DatabaseCommentToMedia.getInstance().delete(aCommentId, aMediaId); - } - catch (Exception e){ - throwStorageObjectFailure(e, "dettach: failed to get instance"); - } - - DatabaseContent.getInstance().setUnproduced("id="+getValue("to_media")); + DatabaseCommentToMedia.getInstance().delete(aCommentId, aMediaId); + DatabaseContent.getInstance().setUnproduced("id="+getFieldValue("to_media")); } } @@ -110,14 +103,8 @@ public class EntityComment extends Entity public void attach(String aMediaId) throws StorageObjectFailure { if (aMediaId!=null) { - try{ - DatabaseCommentToMedia.getInstance().addMedia(getId(), aMediaId); - } - catch(StorageObjectFailure e){ - throwStorageObjectFailure(e, "attach: could not get the instance"); - } - - DatabaseContent.getInstance().setUnproduced("id="+getValue("to_media")); + DatabaseCommentToMedia.getInstance().addMedia(getId(), aMediaId); + DatabaseContent.getInstance().setUnproduced("id="+getFieldValue("to_media")); } else { logger.error("EntityContent: attach without mid"); diff --git a/source/mircoders/entity/EntityContent.java b/source/mircoders/entity/EntityContent.java index 59ed4784..f9c5fdf2 100755 --- a/source/mircoders/entity/EntityContent.java +++ b/source/mircoders/entity/EntityContent.java @@ -35,25 +35,23 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Map; -import mir.entity.Entity; +import mir.entity.AbstractEntity; import mir.log.LoggerWrapper; import mir.storage.StorageObject; import mir.storage.StorageObjectFailure; -import mir.util.StringRoutines; import mircoders.storage.DatabaseContentToMedia; /** * this class implements mapping of one line of the database table content * to a java object * - * @version $Id: EntityContent.java,v 1.19.2.4 2003/12/21 13:32:04 zapata Exp $ + * @version $Id: EntityContent.java,v 1.19.2.5 2004/01/18 17:30:58 zapata Exp $ * @author mir-coders group * */ -public class EntityContent extends Entity -{ +public class EntityContent extends AbstractEntity { // constructors public EntityContent() @@ -69,34 +67,30 @@ public class EntityContent extends Entity setStorage(theStorage); } - // - // methods - /** * set is_produced flag for the article */ - public void setProduced(boolean yesno) throws StorageObjectFailure { String value = (yesno) ? "1":"0"; - if (value.equals( getValue("is_produced") )) return; + if (value.equals( getFieldValue("is_produced") )) return; Connection con=null;Statement stmt=null; String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'"; try { - con = theStorageObject.getPooledCon(); - /** @todo should be preparedStatement: faster!! */ + con = storageObject.getPooledCon(); + /** todo should be preparedStatement: faster!! */ stmt = con.createStatement(); - theStorageObject.executeUpdate(stmt,sql); + storageObject.executeUpdate(stmt,sql); } catch (StorageObjectFailure e) { - throwStorageObjectFailure(e, "\n -- set produced failed"); + throw e; } catch (SQLException e) { - throwStorageObjectFailure(e, "\n -- set produced failed"); + throw new StorageObjectFailure(e); } finally { - theStorageObject.freeConnection(con,stmt); + storageObject.freeConnection(con,stmt); } } @@ -110,33 +104,20 @@ public class EntityContent extends Entity public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure { if (aMediaId!=null){ - try{ - DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId); - } - catch (Exception e){ - throwStorageObjectFailure(e, "\n -- failed to get instance"); - } + DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId); setProduced(false); } } /** - * Attaches media to an article - * - * @param mid - * @throws StorageObjectFailure + * Attaches media to the article */ public void attach(String aMediaId) throws StorageObjectFailure { if (aMediaId!=null) { - try{ - DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId); - } - catch(StorageObjectFailure e){ - throwStorageObjectFailure(e, "attach: could not get the instance"); - } + DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId); setProduced(false); } else { diff --git a/source/mircoders/entity/EntityImages.java b/source/mircoders/entity/EntityImages.java index f821483d..82be8d5e 100755 --- a/source/mircoders/entity/EntityImages.java +++ b/source/mircoders/entity/EntityImages.java @@ -53,7 +53,7 @@ import org.postgresql.largeobject.LargeObjectManager; /** * * @author RK, mh, mir-coders - * @version $Id: EntityImages.java,v 1.21.2.3 2003/12/14 16:37:07 zapata Exp $ + * @version $Id: EntityImages.java,v 1.21.2.4 2004/01/18 17:30:58 zapata Exp $ */ @@ -87,13 +87,14 @@ public class EntityImages extends EntityUploadedMedia Statement stmt=null; BlobInputStream in; InputStream img_in = null; + try { - con = theStorageObject.getPooledCon(); + con = storageObject.getPooledCon(); con.setAutoCommit(false); LargeObjectManager lom; java.sql.Connection jCon; stmt = con.createStatement(); - ResultSet rs = theStorageObject.executeSql(stmt, + ResultSet rs = storageObject.executeSql(stmt, "select image_data from images where id="+getId()); jCon = ((com.codestudio.sql.PoolManConnectionHandle)con) .getNativeConnection(); @@ -120,19 +121,21 @@ public class EntityImages extends EntityUploadedMedia } try { - theStorageObject.freeConnection(con, stmt); + storageObject.freeConnection(con, stmt); } catch (Throwable e) { logger.error("EntityImages.getImage freeing connection failed: " +e.toString()); } - throwStorageObjectFailure(t, "EntityImages -- getImage failed: "); + throw new StorageObjectFailure(t); } + return img_in; } public void setImage(InputStream in, String type) throws StorageObjectFailure { - + // todo: failures should be treated in a better way: exception -> rollback instead + // of commit if (in != null) { Connection con = null; @@ -146,7 +149,7 @@ public class EntityImages extends EntityUploadedMedia FileUtil.write(f, in); ImageProcessor processor = new ImageProcessor(f); - con = theStorageObject.getPooledCon(); + con = storageObject.getPooledCon(); con.setAutoCommit(false); LargeObjectManager lom; java.sql.Connection connection; @@ -159,8 +162,8 @@ public class EntityImages extends EntityUploadedMedia processor.descaleImage(maxImageSize, minDescaleRatio, minDescaleReduction); processor.writeScaledData(lobImage.getOutputStream(), type); lobImage.close(); - setValueForProperty("img_height", new Integer(processor.getScaledHeight()).toString()); - setValueForProperty("img_width", new Integer(processor.getScaledWidth()).toString()); + setFieldValue("img_height", new Integer(processor.getScaledHeight()).toString()); + setFieldValue("img_width", new Integer(processor.getScaledWidth()).toString()); int oidIcon = lom.create(); LargeObject lobIcon = lom.open(oidIcon); @@ -168,27 +171,39 @@ public class EntityImages extends EntityUploadedMedia processor.writeScaledData(lobIcon.getOutputStream(), type); lobIcon.close(); - setValueForProperty("icon_height", new Integer(processor.getScaledHeight()).toString()); - setValueForProperty("icon_width", new Integer(processor.getScaledWidth()).toString()); + setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString()); + setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString()); - setValueForProperty("image_data", new Integer(oidImage).toString()); - setValueForProperty("icon_data", new Integer(oidIcon).toString()); + setFieldValue("image_data", new Integer(oidImage).toString()); + setFieldValue("icon_data", new Integer(oidIcon).toString()); update(); } catch (Exception e) { - throwStorageObjectFailure(e, "settimage :: setImage failed: "); + throw new StorageObjectFailure(e); } finally { try { if (con!=null) con.setAutoCommit(true); // get rid of the temp. file + } + catch (Throwable e) { + logger.error("EntityImages.setImage: unable to reset the connection to auto-commit:" + e.toString()); + } + try { f.delete(); - } catch (SQLException e) { - throwStorageObjectFailure(e,"Resetting transaction-mode failed"); } - if (con!=null) - theStorageObject.freeConnection(con,pstmt); + catch (Throwable t) { + logger.error("EntityImages.setImage: unable to delete the temporary file:" + t.toString()); + } + + try { + if (con!=null) + storageObject.freeConnection(con,pstmt); + } + catch (Throwable t) { + logger.error("EntityImages.setImage: unable to free the connection:" + t.toString()); + } } } } @@ -206,12 +221,12 @@ public class EntityImages extends EntityUploadedMedia ImageInputStream img_in=null; try { - con = theStorageObject.getPooledCon(); + con = storageObject.getPooledCon(); con.setAutoCommit(false); LargeObjectManager lom; java.sql.Connection jCon; stmt = con.createStatement(); - ResultSet rs = theStorageObject.executeSql(stmt, "select icon_data from images where id="+getId()); + ResultSet rs = storageObject.executeSql(stmt, "select icon_data from images where id="+getId()); jCon = ((com.codestudio.sql.PoolManConnectionHandle)con) .getNativeConnection(); lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI(); @@ -237,13 +252,13 @@ public class EntityImages extends EntityUploadedMedia e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); } try { - theStorageObject.freeConnection(con, stmt); + storageObject.freeConnection(con, stmt); } catch (Throwable e) { logger.error("EntityImages -- freeing connection failed: " + e.getMessage()); } - throwStorageObjectFailure(t, "EntityImages -- getIcon failed:"); + throw new StorageObjectFailure(t); } return img_in; @@ -270,7 +285,7 @@ public class EntityImages extends EntityUploadedMedia _in.close(); try { _con.setAutoCommit(true); - theStorageObject.freeConnection(_con,_stmt); + storageObject.freeConnection(_con,_stmt); } catch (Exception e) { throw new IOException("close(): "+e.toString()); diff --git a/source/mircoders/entity/EntityUploadedMedia.java b/source/mircoders/entity/EntityUploadedMedia.java index 8c38e50f..436cdb05 100755 --- a/source/mircoders/entity/EntityUploadedMedia.java +++ b/source/mircoders/entity/EntityUploadedMedia.java @@ -30,14 +30,11 @@ package mircoders.entity; import java.sql.SQLException; -import java.util.List; import java.util.Map; +import mir.entity.AbstractEntity; import mir.entity.Entity; import mir.log.LoggerWrapper; -import mircoders.media.MediaHelper; -import mir.media.MediaHandler; -import mir.misc.NumberUtils; import mir.storage.StorageObject; import mir.storage.StorageObjectFailure; import mircoders.storage.DatabaseUploadedMedia; @@ -45,11 +42,10 @@ import mircoders.storage.DatabaseUploadedMedia; /** * * @author mh, mir-coders group - * @version $Id: EntityUploadedMedia.java,v 1.26.2.5 2003/12/21 13:32:04 zapata Exp $ + * @version $Id: EntityUploadedMedia.java,v 1.26.2.6 2004/01/18 17:30:58 zapata Exp $ */ - -public class EntityUploadedMedia extends Entity { +public class EntityUploadedMedia extends AbstractEntity { public EntityUploadedMedia() { super(); @@ -66,11 +62,11 @@ public class EntityUploadedMedia extends Entity { super.update(); try { - theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")"); - theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")"); + storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")"); + storageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")"); } catch (SQLException e) { - throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! "); + throw new StorageObjectFailure(e); } } @@ -94,7 +90,7 @@ public class EntityUploadedMedia extends Entity { ent = DatabaseUploadedMedia.getInstance().getMediaType(this); } catch (StorageObjectFailure e) { - throwStorageObjectFailure(e, "get MediaType failed -- "); + throw new StorageObjectFailure(e); } return ent; } diff --git a/source/mircoders/entity/EntityUsers.java b/source/mircoders/entity/EntityUsers.java index 8cf339db..ceedeeec 100755 --- a/source/mircoders/entity/EntityUsers.java +++ b/source/mircoders/entity/EntityUsers.java @@ -18,18 +18,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.entity; import mir.entity.Entity; +import mir.entity.AbstractEntity; import mir.storage.StorageObject; /** @@ -40,8 +41,7 @@ import mir.storage.StorageObject; */ -public class EntityUsers extends Entity -{ +public class EntityUsers extends AbstractEntity { public EntityUsers() { @@ -57,7 +57,7 @@ public class EntityUsers extends Entity public boolean isAdmin() { - String admin=getValue("is_admin"); + String admin=getFieldValue("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 index a0e299e3..879fc2c0 100755 --- a/source/mircoders/entity/EntityVideo.java +++ b/source/mircoders/entity/EntityVideo.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.entity; diff --git a/source/mircoders/global/Abuse.java b/source/mircoders/global/Abuse.java index 14eb5034..19859a35 100755 --- a/source/mircoders/global/Abuse.java +++ b/source/mircoders/global/Abuse.java @@ -54,6 +54,7 @@ import mir.session.Request; import mir.util.DateTimeFunctions; import mir.util.GeneratorFormatAdapters; import mir.util.StringRoutines; +import mir.util.EntityUtility; import mircoders.entity.EntityComment; import mircoders.entity.EntityContent; import mircoders.localizer.MirAdminInterfaceLocalizer; @@ -185,7 +186,7 @@ public class Abuse { line.append(" "); line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")"); - aComment.appendLineToField("comment", line.toString()); + EntityUtility.appendLineToField(aComment, "comment", line.toString()); MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction()); setCookie(aResponse); @@ -225,7 +226,7 @@ public class Abuse { line.append(" "); line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")"); - anArticle.appendLineToField("comment", line.toString()); + EntityUtility.appendLineToField(anArticle, "comment", line.toString()); MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction()); setCookie(aResponse); @@ -531,6 +532,14 @@ public class Abuse { moveFilter(filterRules, anIdentifier, 1); } + public void moveFilterToTop(String anIdentifier) { + setFilterPosition(filterRules, anIdentifier, 0); + } + + public void moveFilterToBottom(String anIdentifier) { + setFilterPosition(filterRules, anIdentifier, Integer.MAX_VALUE); + } + private String addFilter(List aFilters, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aLastHit) { MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType); @@ -598,6 +607,26 @@ public class Abuse { return null; } + private void setFilterPosition(List aFilters, String anIdentifier, int aPosition) { + synchronized (aFilters) { + if (aPosition<0) + aPosition=0; + + for (int i = 0; i < aFilters.size(); i++) { + FilterRule rule = (FilterRule) aFilters.get(i); + + if (rule.getId().equals(anIdentifier)) { + aFilters.remove(rule); + + if (aPosition - * @version $Id: MediaHandlerGeneric.java,v 1.20.2.5 2003/12/14 16:37:07 zapata Exp $ + * @version $Id: MediaHandlerGeneric.java,v 1.20.2.6 2004/01/18 17:30:58 zapata Exp $ */ public class MediaHandlerGeneric implements MediaHandler @@ -91,15 +91,15 @@ public class MediaHandlerGeneric implements MediaHandler } public void store (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure { - String ext = mediaTypeEnt.getValue("name"); + String ext = mediaTypeEnt.getFieldValue("name"); String mediaFname = ent.getId() + "." + ext; - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); try { long size = FileUtil.write(getStoragePath() + File.separator + datePath + File.separator + mediaFname, in); - ent.setValueForProperty("publish_path", datePath + mediaFname); - ent.setValueForProperty("size", new Long(size).toString()); + ent.setFieldValue("publish_path", datePath + mediaFname); + ent.setFieldValue("size", new Long(size).toString()); ent.update(); } catch (Throwable e) { @@ -112,16 +112,16 @@ public class MediaHandlerGeneric implements MediaHandler //check first if the media file exist since produced //location is also the storage location - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); - String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name"); + String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getFieldValue("name"); String fname = getStoragePath()+relPath; if(! new File(fname).exists()) throw new MediaExc("error in MirMediaHandler.produce(): " + relPath + " does not exist!"); } public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { - String publishPath = ent.getValue("publish_path"); + String publishPath = ent.getFieldValue("publish_path"); String fname = getStoragePath()+publishPath; File f = new File(fname); if(! f.exists()) @@ -144,7 +144,7 @@ public class MediaHandlerGeneric implements MediaHandler public String getThumbnailMimeType (Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure { ServletContext servletContext = MirPropertiesConfiguration.getContext(); - String fileName = aMediaEntity.getId()+"."+aMediaType.getValue("name"); + String fileName = aMediaEntity.getId()+"."+aMediaType.getFieldValue("name"); return servletContext.getMimeType(fileName); }; @@ -188,7 +188,7 @@ public class MediaHandlerGeneric implements MediaHandler public String getDescr( Entity mediaType) { - return mediaType.getValue("mime_type"); + return mediaType.getFieldValue("mime_type"); } } diff --git a/source/mircoders/media/MediaHandlerImages.java b/source/mircoders/media/MediaHandlerImages.java index 38da566f..1e4f9fa9 100755 --- a/source/mircoders/media/MediaHandlerImages.java +++ b/source/mircoders/media/MediaHandlerImages.java @@ -59,7 +59,7 @@ import mircoders.entity.EntityImages; * * @see mir.media.MirMediaHandler * @author mh - * @version $Id: MediaHandlerImages.java,v 1.23.2.3 2003/12/14 16:37:07 zapata Exp $ + * @version $Id: MediaHandlerImages.java,v 1.23.2.4 2004/01/18 17:30:58 zapata Exp $ */ @@ -115,25 +115,25 @@ public abstract class MediaHandlerImages implements MediaHandler } public void produce(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure { - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); - String ext = "."+mediaTypeEnt.getValue("name"); + String ext = "."+mediaTypeEnt.getFieldValue("name"); String filepath = datePath+ent.getId()+ext; String iconFilePath = configuration.getString("Producer.StorageRoot") +getIconStoragePath() + filepath; String productionFilePath = getStoragePath() + File.separator + filepath; - if (ent.getValue("icon_data")!= null && - ent.getValue("image_data")!= null) { + if (ent.getFieldValue("icon_data")!= null && + ent.getFieldValue("image_data")!= null) { // make icon try { InputStream in = ((EntityImages)ent).getIcon(); FileUtil.write(iconFilePath, in); in = ((EntityImages)ent).getImage(); FileUtil.write(productionFilePath, in); - ent.setValueForProperty("icon_path",getIconStoragePath()+filepath); - ent.setValueForProperty("publish_path",filepath); + ent.setFieldValue("icon_path",getIconStoragePath()+filepath); + ent.setFieldValue("publish_path",filepath); ent.update(); } catch (Throwable e) { diff --git a/source/mircoders/media/MediaHandlerImagesExtern.java b/source/mircoders/media/MediaHandlerImagesExtern.java index 5df1112c..7d90b7ff 100755 --- a/source/mircoders/media/MediaHandlerImagesExtern.java +++ b/source/mircoders/media/MediaHandlerImagesExtern.java @@ -75,9 +75,9 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MediaExc, MediaFailure { try { - String date = anImageEntity.getValue("date"); + String date = anImageEntity.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); - String ext = "." + mediaTypeEnt.getValue("name"); + String ext = "." + mediaTypeEnt.getFieldValue("name"); String fileBasePath = datePath + anImageEntity.getId(); String filePath = fileBasePath + ext; String iconPath = getIconStoragePath() + fileBasePath + ".jpg"; @@ -100,14 +100,14 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric } processor.writeScaledData(iconFile, "JPEG"); - anImageEntity.setValueForProperty("img_height", new Integer(processor.getHeight()).toString()); - anImageEntity.setValueForProperty("img_width", new Integer(processor.getWidth()).toString()); + anImageEntity.setFieldValue("img_height", new Integer(processor.getHeight()).toString()); + anImageEntity.setFieldValue("img_width", new Integer(processor.getWidth()).toString()); - anImageEntity.setValueForProperty("icon_height", new Integer(processor.getScaledHeight()).toString()); - anImageEntity.setValueForProperty("icon_width", new Integer(processor.getScaledWidth()).toString()); + anImageEntity.setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString()); + anImageEntity.setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString()); - anImageEntity.setValueForProperty("icon_path", iconPath); - anImageEntity.setValueForProperty("publish_path", filePath); + anImageEntity.setFieldValue("icon_path", iconPath); + anImageEntity.setFieldValue("publish_path", filePath); anImageEntity.update(); @@ -125,7 +125,7 @@ public class MediaHandlerImagesExtern extends MediaHandlerGeneric public InputStream getIcon(Entity anImageEntity) throws MediaExc, MediaFailure { try { String filePath = - configuration.getString("Producer.StorageRoot") + anImageEntity.getValue("icon_path"); + configuration.getString("Producer.StorageRoot") + anImageEntity.getFieldValue("icon_path"); logger.info(filePath); diff --git a/source/mircoders/media/MediaHandlerMp3.java b/source/mircoders/media/MediaHandlerMp3.java index f1dbe8d5..ed968875 100755 --- a/source/mircoders/media/MediaHandlerMp3.java +++ b/source/mircoders/media/MediaHandlerMp3.java @@ -67,7 +67,7 @@ import mir.misc.StringUtil; * * @see mir.media.MediaHandler * @author mh - * @version $Id: MediaHandlerMp3.java,v 1.15.2.3 2003/12/14 16:37:08 zapata Exp $ + * @version $Id: MediaHandlerMp3.java,v 1.15.2.4 2004/01/18 17:30:59 zapata Exp $ */ public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler @@ -83,9 +83,9 @@ public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler super.produce(ent, mediaTypeEnt); String baseName = ent.getId(); - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); - String mp3Pointer = getPublishHost() + ent.getValue("publish_path"); + String mp3Pointer = getPublishHost() + ent.getFieldValue("publish_path"); String mpegURLFile = baseName + ".m3u"; String playlistFile = baseName + ".pls"; @@ -108,24 +108,24 @@ public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler public List getURL(Entity ent, Entity mediaTypeEnt) { List theList = new Vector(); - //String stringSize = ent.getValue("size"); + //String stringSize = ent.getFieldValue("size"); //int size = Integer.parseInt(stringSize, 10)/1024; theList.add(ent); - String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"), + String basePath = StringUtil.regexpReplace(ent.getFieldValue("publish_path"), ".mp3$", ""); // @todo the texts ("title") below urgently need to be sanely localizaeble // somehow Map m3uHash = new HashMap(); m3uHash.put("publish_path", basePath + ".m3u"); - m3uHash.put("publish_server", ent.getValue("publish_server")); + m3uHash.put("publish_server", ent.getFieldValue("publish_server")); m3uHash.put("title", "stream URL"); theList.add(m3uHash); Map plsHash = new HashMap(); plsHash.put("publish_path", basePath + ".pls"); - plsHash.put("publish_server", ent.getValue("publish_server")); + plsHash.put("publish_server", ent.getFieldValue("publish_server")); plsHash.put("title", "playlist URL"); theList.add(plsHash); diff --git a/source/mircoders/media/MediaHandlerOgg.java b/source/mircoders/media/MediaHandlerOgg.java index f3c537f7..d518f8b9 100755 --- a/source/mircoders/media/MediaHandlerOgg.java +++ b/source/mircoders/media/MediaHandlerOgg.java @@ -83,9 +83,9 @@ public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler super.produce(ent, mediaTypeEnt); String baseName = ent.getId(); - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); - String oggPointer = getPublishHost() + ent.getValue("publish_path"); + String oggPointer = getPublishHost() + ent.getFieldValue("publish_path"); //String mpegURLFile = baseName + ".m3u"; String playlistFile = baseName + ".pls"; @@ -109,11 +109,11 @@ public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler public List getURL(Entity ent, Entity mediaTypeEnt) { List theList = new Vector(); - //String stringSize = ent.getValue("size"); + //String stringSize = ent.getFieldValue("size"); //int size = Integer.parseInt(stringSize, 10)/1024; theList.add(ent); - String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"), + String basePath = StringUtil.regexpReplace(ent.getFieldValue("publish_path"), ".ogg$", ""); // @todo the texts ("title") below urgently need to be sanely localizaeble @@ -121,13 +121,13 @@ public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler //no .m3u! //Map m3uHash = new HashMap(); //m3uHash.put("publish_path", basePath + ".m3u"); - //m3uHash.put("publish_server", ent.getValue("publish_server")); + //m3uHash.put("publish_server", ent.getFieldValue("publish_server")); //m3uHash.put("title", "stream URL"); //theList.add(m3uHash); Map plsHash = new HashMap(); plsHash.put("publish_path", basePath + ".pls"); - plsHash.put("publish_server", ent.getValue("publish_server")); + plsHash.put("publish_server", ent.getFieldValue("publish_server")); plsHash.put("title", "playlist URL"); theList.add(plsHash); diff --git a/source/mircoders/media/MediaHandlerRealAudio.java b/source/mircoders/media/MediaHandlerRealAudio.java index dca1bf15..7e0ce648 100755 --- a/source/mircoders/media/MediaHandlerRealAudio.java +++ b/source/mircoders/media/MediaHandlerRealAudio.java @@ -53,7 +53,7 @@ import mir.misc.StringUtil; * @see mir.media.MediaHandlerGeneric * @see mir.media.MediaHandler * @author john , mh - * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.3 2003/12/21 13:32:05 zapata Exp $ + * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.4 2004/01/18 17:30:59 zapata Exp $ */ @@ -69,12 +69,12 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHan super.produce(ent, mediaTypeEnt); String baseName = ent.getId(); - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); String rtspDir = configuration.getString("Producer.RealMedia.Path"); String rtspMediaHost = configuration.getString("Producer.RealMedia.Host"); - String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path"); + String RealMediaPointer = rtspMediaHost+ent.getFieldValue("publish_path"); String RealMediaFile = datePath+ent.getId()+".ram"; try { //write an rm (ram?. -mh) file @@ -91,11 +91,11 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHan { List theList = new Vector(); - //String stringSize = ent.getValue("size"); + //String stringSize = ent.getFieldValue("size"); //int size = Integer.parseInt(stringSize, 10)/1024; theList.add(ent); - String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"), + String basePath=StringUtil.regexpReplace(ent.getFieldValue("publish_path"), ".ra$",""); // @todo the texts ("title") below urgently need to be sanely localizaeble diff --git a/source/mircoders/media/MediaHandlerRealVideo.java b/source/mircoders/media/MediaHandlerRealVideo.java index 1d1b5ef7..849461c8 100755 --- a/source/mircoders/media/MediaHandlerRealVideo.java +++ b/source/mircoders/media/MediaHandlerRealVideo.java @@ -54,7 +54,7 @@ import mir.misc.StringUtil; * @see mir.media.MediaHandlerGeneric * @see mir.media.MediaHandler * @author john , mh - * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.3 2003/12/14 16:37:08 zapata Exp $ + * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.4 2004/01/18 17:30:59 zapata Exp $ */ @@ -70,12 +70,12 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MediaHan super.produce(ent, mediaTypeEnt); String baseName = ent.getId(); - String date = ent.getValue("date"); + String date = ent.getFieldValue("date"); String datePath = StringUtil.webdbDate2path(date); String rtspDir = configuration.getString("Producer.RealMedia.Path"); String rtspMediaHost = configuration.getString("Producer.RealMedia.Host"); - String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path"); + String RealMediaPointer = rtspMediaHost+ent.getFieldValue("publish_path"); String RealMediaFile = datePath+ent.getId()+".ram"; try { //write an rm (ram?. -mh) file @@ -92,11 +92,11 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MediaHan public List getURL(Entity ent, Entity mediaTypeEnt) { List theList = new Vector(); - //String stringSize = ent.getValue("size"); + //String stringSize = ent.getFieldValue("size"); //int size = Integer.parseInt(stringSize, 10)/1024; theList.add(ent); - String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"), + String basePath=StringUtil.regexpReplace(ent.getFieldValue("publish_path"), ".rm$",""); // @todo the texts ("title") below urgently need to be sanely localizaeble diff --git a/source/mircoders/media/MediaHelper.java b/source/mircoders/media/MediaHelper.java index 71bdd496..bad3d164 100755 --- a/source/mircoders/media/MediaHelper.java +++ b/source/mircoders/media/MediaHelper.java @@ -57,7 +57,7 @@ public final class MediaHelper { } public static MediaHandler getHandler(Entity aMediaType) throws MediaExc, MediaFailure { - String handlerName = aMediaType.getValue("classname"); + String handlerName = aMediaType.getFieldValue("classname"); try { return MirGlobal.localizer().media().getHandler(handlerName); diff --git a/source/mircoders/media/MediaUploadProcessor.java b/source/mircoders/media/MediaUploadProcessor.java index cd2220ca..e7d2eb7f 100755 --- a/source/mircoders/media/MediaUploadProcessor.java +++ b/source/mircoders/media/MediaUploadProcessor.java @@ -73,7 +73,7 @@ public class MediaUploadProcessor { try { mediaHandler = MediaHelper.getHandler(mediaType); - mediaStorage = MediaHelper.getStorage(mediaType, mediaType.getValue("tablename")); + mediaStorage = MediaHelper.getStorage(mediaType, mediaType.getFieldValue("tablename")); } catch (Throwable e) { throw new MediaFailure(e); diff --git a/source/mircoders/media/URLMediaHandler.java b/source/mircoders/media/URLMediaHandler.java index 55b86022..6603d1c9 100755 --- a/source/mircoders/media/URLMediaHandler.java +++ b/source/mircoders/media/URLMediaHandler.java @@ -46,7 +46,7 @@ public class URLMediaHandler implements MediaHandler { public List getURL(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure { List result = new ArrayList(); - result.add(aMediaTypeEntity.getValue("publish_server")+aMediaTypeEntity.getValue("publish_path")); + result.add(aMediaTypeEntity.getFieldValue("publish_server")+aMediaTypeEntity.getFieldValue("publish_path")); return result; } diff --git a/source/mircoders/module/ModuleArticleType.java b/source/mircoders/module/ModuleArticleType.java index 85b1a1aa..8a127675 100755 --- a/source/mircoders/module/ModuleArticleType.java +++ b/source/mircoders/module/ModuleArticleType.java @@ -44,12 +44,12 @@ public class ModuleArticleType extends AbstractModule { if (theStorage == null) logger.warn("ModuleArticleType -- StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } public String articleTypeIdForName(String aName) throws ModuleExc, ModuleFailure { try { - return theStorage.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); + return storage.executeFreeSingleValueSql("select id from article_type where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); } catch (Throwable t) { throw new ModuleFailure(t); diff --git a/source/mircoders/module/ModuleBreaking.java b/source/mircoders/module/ModuleBreaking.java index ff7bcdeb..16dba4c2 100755 --- a/source/mircoders/module/ModuleBreaking.java +++ b/source/mircoders/module/ModuleBreaking.java @@ -18,18 +18,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.module; -import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.module.AbstractModule; import mir.storage.StorageObject; @@ -50,18 +49,8 @@ public class ModuleBreaking extends AbstractModule public ModuleBreaking (StorageObject theStorage) { if (theStorage == null) logger.warn("ModuleBreaking -- StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } // Methoden - public EntityList getBreakingNews() { - EntityList returnList = null; - try { - returnList = getByWhereClause(null,"webdb_create desc",0,5); - } - catch (Exception ex) { - logger.error("--getBreakingNews(): could not fetch Breaking News" + ex.toString()); - } - return returnList; - } } diff --git a/source/mircoders/module/ModuleComment.java b/source/mircoders/module/ModuleComment.java index 7e52745d..efef4ccc 100755 --- a/source/mircoders/module/ModuleComment.java +++ b/source/mircoders/module/ModuleComment.java @@ -53,14 +53,14 @@ public class ModuleComment extends AbstractModule public ModuleComment(StorageObject theStorage) { if (theStorage == null) logger.warn("StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } public void deleteById (String anId) throws ModuleExc, ModuleFailure { try { - Entity theEntity = theStorage.selectById((String)anId); + Entity theEntity = storage.selectById((String)anId); if (theEntity != null) - DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media")); + DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media")); super.deleteById(anId); } @@ -79,10 +79,10 @@ public class ModuleComment extends AbstractModule public String set(Map theValues) throws ModuleExc, ModuleFailure { try { - Entity theEntity = theStorage.selectById((String)theValues.get("id")); + Entity theEntity = storage.selectById((String)theValues.get("id")); if (theEntity == null) throw new ModuleExc("No Object in the database with id " + theValues.get("id")); - DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media")); + DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media")); theEntity.setValues(theValues); theEntity.update(); return theEntity.getId(); diff --git a/source/mircoders/module/ModuleCommentStatus.java b/source/mircoders/module/ModuleCommentStatus.java index 43b1c099..f0d9a987 100755 --- a/source/mircoders/module/ModuleCommentStatus.java +++ b/source/mircoders/module/ModuleCommentStatus.java @@ -43,12 +43,12 @@ public class ModuleCommentStatus extends AbstractModule { if (theStorage == null) logger.warn("ModuleCommentStatus -- StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } public String commentStatusIdForName(String aName) throws ModuleExc, ModuleFailure { try { - return theStorage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); + return storage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); } catch (Throwable t) { throw new ModuleFailure(t); diff --git a/source/mircoders/module/ModuleContent.java b/source/mircoders/module/ModuleContent.java index ae16645c..7ba90822 100755 --- a/source/mircoders/module/ModuleContent.java +++ b/source/mircoders/module/ModuleContent.java @@ -55,7 +55,7 @@ public class ModuleContent extends AbstractModule } public ModuleContent(StorageObject aStorage) { - theStorage = aStorage; + storage = aStorage; } public void expireArticleLock(String anId, String aUserId) { @@ -82,7 +82,7 @@ public class ModuleContent extends AbstractModule if (!aForce) query = query + " and to_locking_user is null"; - return theStorage.executeUpdate(query) > 0; + return storage.executeUpdate(query) > 0; } catch (Throwable t) { return false; @@ -107,7 +107,7 @@ public class ModuleContent extends AbstractModule if (!aForce) query = query + " and to_locking_user = "+JDBCStringRoutines.escapeStringLiteral(aUserId); - return theStorage.executeUpdate(query) > 0; + return storage.executeUpdate(query) > 0; } catch (Throwable t) { return false; @@ -122,7 +122,7 @@ public class ModuleContent extends AbstractModule */ public String queryArticleLock(String anId) { try { - String result = theStorage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId)); + String result = storage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId)); if (result!=null && !MirGlobal.isUserLoggedIn(result)) { expireArticleLock(anId, result); diff --git a/source/mircoders/module/ModuleImages.java b/source/mircoders/module/ModuleImages.java index b20d9896..eaef33fd 100755 --- a/source/mircoders/module/ModuleImages.java +++ b/source/mircoders/module/ModuleImages.java @@ -39,6 +39,6 @@ public class ModuleImages extends AbstractModule { public ModuleImages(StorageObject theStorage) { if (theStorage == null) logger.warn("ModuleImages: StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } } diff --git a/source/mircoders/module/ModuleLanguage.java b/source/mircoders/module/ModuleLanguage.java index b78444b2..e33de75f 100755 --- a/source/mircoders/module/ModuleLanguage.java +++ b/source/mircoders/module/ModuleLanguage.java @@ -52,12 +52,12 @@ public class ModuleLanguage extends AbstractModule { if (theStorage == null) logger.warn("ModuleLanguage -- StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } public String languageIdForCode(String aCode) throws ModuleExc, ModuleFailure { try { - return theStorage.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'"); + return storage.executeFreeSingleValueSql("select id from language where code = '" + JDBCStringRoutines.escapeStringLiteral(aCode) + "'"); } catch (Throwable t) { throw new ModuleFailure(t); diff --git a/source/mircoders/module/ModuleMediaType.java b/source/mircoders/module/ModuleMediaType.java index b6d5dadb..8a75c378 100755 --- a/source/mircoders/module/ModuleMediaType.java +++ b/source/mircoders/module/ModuleMediaType.java @@ -51,7 +51,7 @@ public class ModuleMediaType extends AbstractModule { } public ModuleMediaType(StorageObject aStorage) { - this.theStorage = aStorage; + this.storage = aStorage; } public Entity findMediaTypeForMimeType(String aMimeType) throws ModuleExc, ModuleFailure { diff --git a/source/mircoders/module/ModuleMediafolder.java b/source/mircoders/module/ModuleMediafolder.java index 287338ce..fe97a7e3 100755 --- a/source/mircoders/module/ModuleMediafolder.java +++ b/source/mircoders/module/ModuleMediafolder.java @@ -55,11 +55,11 @@ public class ModuleMediafolder extends AbstractModule if (aStorage == null) logger.warn("ModuleMediafolder: StorageObject was null!"); - theStorage = aStorage; + storage = aStorage; } public String mediaFolderIdForName(String aName) throws ModuleExc, ModuleFailure { try { - return theStorage.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); + return storage.executeFreeSingleValueSql("select id from media_folder where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'"); } catch (Throwable t) { throw new ModuleFailure(t); diff --git a/source/mircoders/module/ModuleMessage.java b/source/mircoders/module/ModuleMessage.java index bd04bd25..79def2bb 100755 --- a/source/mircoders/module/ModuleMessage.java +++ b/source/mircoders/module/ModuleMessage.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.module; @@ -51,6 +51,6 @@ public class ModuleMessage extends AbstractModule { if (theStorage == null) logger.warn("ModuleMessage -- StorageObject was null!"); - this.theStorage = theStorage; + this.storage = theStorage; } } \ No newline at end of file diff --git a/source/mircoders/module/ModuleTopics.java b/source/mircoders/module/ModuleTopics.java index e52a7c6c..85d9990f 100755 --- a/source/mircoders/module/ModuleTopics.java +++ b/source/mircoders/module/ModuleTopics.java @@ -32,7 +32,6 @@ package mircoders.module; import java.util.Map; import mir.entity.Entity; -import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.module.AbstractModule; import mir.module.ModuleExc; @@ -44,36 +43,19 @@ public class ModuleTopics extends AbstractModule { static LoggerWrapper logger = new LoggerWrapper("Module.Topics"); public ModuleTopics(StorageObject theStorage) { - this.theStorage = theStorage; - } - - /** - * Method getTopicList - * - * @return SimpleList of all Topics sorted by title - * - */ - public EntityList getTopicsList() throws ModuleExc, ModuleFailure { - try { - return getByWhereClause("", "title", -1); - } - catch (Throwable e) { - logger.error("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage()); - - throw new ModuleFailure("ModuleTopics.getTopicsList: topics could not be fetched: " + e.getMessage(), e); - } + this.storage = theStorage; } /** * Overrides the AbstractModule.set(), * All dependent ContentEntities are set unproduced. + * * @param theValues Hash mit Spalte/Wert-Paaren * @return Id des eingef?gten Objekts - * @exception ModuleException */ public String set(Map theValues) throws ModuleExc, ModuleFailure { try { - Entity theEntity = theStorage.selectById((String) theValues.get("id")); + Entity theEntity = storage.selectById((String) theValues.get("id")); if (theEntity == null) { throw new ModuleExc("No topic with id " + theValues.get("id") + " found"); } diff --git a/source/mircoders/module/ModuleUploadedMedia.java b/source/mircoders/module/ModuleUploadedMedia.java index 95a3fee0..8eaf59f3 100755 --- a/source/mircoders/module/ModuleUploadedMedia.java +++ b/source/mircoders/module/ModuleUploadedMedia.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -49,6 +49,6 @@ public class ModuleUploadedMedia extends AbstractModule static LoggerWrapper logger = new LoggerWrapper("Module.UploadedMedia"); public ModuleUploadedMedia(StorageObject aStorage) { - theStorage = aStorage; + storage = aStorage; } } \ No newline at end of file diff --git a/source/mircoders/module/ModuleUsers.java b/source/mircoders/module/ModuleUsers.java index c99bd9e2..eaf4ff08 100755 --- a/source/mircoders/module/ModuleUsers.java +++ b/source/mircoders/module/ModuleUsers.java @@ -60,7 +60,7 @@ public class ModuleUsers extends AbstractModule if (aStorage == null) logger.warn("ModuleUsers(): StorageObject was null!"); - theStorage = aStorage; + storage = aStorage; } /** @@ -87,10 +87,9 @@ public class ModuleUsers extends AbstractModule if (userList != null && userList.getCount() == 1) { EntityUsers result = (EntityUsers) userList.elementAt(0); - if (result.getValue("is_disabled") == null || - result.getValue("is_disabled").equals("0")) + if (result.getFieldValue("is_disabled") == null || + result.getFieldValue("is_disabled").equals("0")) return result; - } return null; @@ -102,7 +101,7 @@ public class ModuleUsers extends AbstractModule public boolean checkUserPassword(EntityUsers aUser, String aPassword) throws ModuleExc, ModuleFailure { try { - return aUser.getValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword)); + return aUser.getFieldValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword)); } catch (Throwable t) { throw new ModuleFailure(t); @@ -165,7 +164,7 @@ public class ModuleUsers extends AbstractModule try { String sql = "update webdb_users set lastlogin=now() where id = " + aUser.getId(); - theStorage.executeUpdate(sql); + storage.executeUpdate(sql); } catch (Throwable t) { // no propagation of this error for now, to allow mir to still function diff --git a/source/mircoders/pdf/PDFGenerator.java b/source/mircoders/pdf/PDFGenerator.java index 0d5d6b36..3676ddb4 100755 --- a/source/mircoders/pdf/PDFGenerator.java +++ b/source/mircoders/pdf/PDFGenerator.java @@ -260,8 +260,8 @@ public class PDFGenerator{ try { ColumnText ict = new ColumnText(cb); - String theTitle = entityContent.getValue("title"); - String theCreator = entityContent.getValue("creator"); + String theTitle = entityContent.getFieldValue("title"); + String theCreator = entityContent.getFieldValue("creator"); Phrase titleP=new Phrase(" - " + theTitle,new Font(indexFontFamily,indexFontSize,Font.BOLD)); Phrase creatorP=new Phrase( " :: " + theCreator,new Font(indexFontFamily,indexFontSize)); float toYPosition = currentYPosition - indexLineHeight; @@ -440,8 +440,8 @@ public class PDFGenerator{ while (images.hasNext()){ EntityImages currentImage=(EntityImages) images.next(); - float img_width=(new Float(currentImage.getValue("img_width"))).floatValue(); - float img_height=(new Float(currentImage.getValue("img_height"))).floatValue(); + float img_width=(new Float(currentImage.getFieldValue("img_width"))).floatValue(); + float img_height=(new Float(currentImage.getFieldValue("img_height"))).floatValue(); if (img_height>maxImageHeight){ img_width=(new Float((new Float(img_width*(maxImageHeight/img_height))).intValue())).floatValue(); img_height=maxImageHeight; @@ -451,8 +451,8 @@ public class PDFGenerator{ img_width=maxImageWidth; } - String img_title=currentImage.getValue("title"); - String img_path=currentImage.getValue("publish_path"); + String img_title=currentImage.getFieldValue("title"); + String img_path=currentImage.getFieldValue("publish_path"); if ((status & ColumnText.NO_MORE_TEXT) == 0){ // there is still text, so add an image which will have text wrapped around it, then add the text which @@ -645,18 +645,18 @@ public class PDFGenerator{ "cxm.content_id="+entityContent.getId()+"and cxm.media_id=i.id", "i.id desc", 30, -1, 0); - String isHTML = entityContent.getValue("is_html"); - String theTitle = entityContent.getValue("title"); - String theCreator = entityContent.getValue("creator"); + String isHTML = entityContent.getFieldValue("is_html"); + String theTitle = entityContent.getFieldValue("title"); + String theCreator = entityContent.getFieldValue("creator"); String theDate = DateTimeFunctions.advancedDateFormat( configuration.getString("RDF.Meta.DateFormat"), - StringUtil.convertMirInternalDateToDate(entityContent.getValue("webdb_create")), + StringUtil.convertMirInternalDateToDate(entityContent.getFieldValue("webdb_create")), configuration.getString("Mir.DefaultTimezone")); - String theDescriptionRaw = entityContent.getValue("description"); - String theContentRaw = entityContent.getValue("content_data"); - String theSource = configuration.getString("Producer.PublicationHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getValue("publish_path") + entityContent.getValue("id") + ".shtml"; + String theDescriptionRaw = entityContent.getFieldValue("description"); + String theContentRaw = entityContent.getFieldValue("content_data"); + String theSource = configuration.getString("Producer.PublicationHost") + "/" + configuration.getString("StandardLanguage") + entityContent.getFieldValue("publish_path") + entityContent.getFieldValue("id") + ".shtml"; diff --git a/source/mircoders/producer/ContentMarkingProducerNode.java b/source/mircoders/producer/ContentMarkingProducerNode.java index cb100d85..94a2a2b1 100755 --- a/source/mircoders/producer/ContentMarkingProducerNode.java +++ b/source/mircoders/producer/ContentMarkingProducerNode.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.producer; diff --git a/source/mircoders/producer/ContentModifyingProducerNode.java b/source/mircoders/producer/ContentModifyingProducerNode.java index 3f788836..787923e1 100755 --- a/source/mircoders/producer/ContentModifyingProducerNode.java +++ b/source/mircoders/producer/ContentModifyingProducerNode.java @@ -76,8 +76,8 @@ public class ContentModifyingProducerNode implements ProducerNode { value = ParameterExpander.expandExpression(aValueMap, valueExpression); fieldName = ParameterExpander.expandExpression(aValueMap, fieldNameExpression); - entity.setValueForProperty("is_produced", "0"); - entity.setValueForProperty(fieldName, value); + entity.setFieldValue("is_produced", "0"); + entity.setFieldValue(fieldName, value); entity.update(); aLogger.info(" Modified content " + entity.getId() + ": " + fieldName + " = " + value ); diff --git a/source/mircoders/producer/IndexingProducerNode.java b/source/mircoders/producer/IndexingProducerNode.java index 22b3a196..685a2c15 100755 --- a/source/mircoders/producer/IndexingProducerNode.java +++ b/source/mircoders/producer/IndexingProducerNode.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.producer; @@ -98,7 +98,7 @@ public class IndexingProducerNode implements ProducerNode { entity.getClass().getName() + " adapter", null); } - aLogger.info("Indexing " + (String) entity.getValue("id") + " into " + + aLogger.info("Indexing " + (String) entity.getFieldValue("id") + " into " + index); // create an index here if one did not already exist @@ -124,7 +124,7 @@ public class IndexingProducerNode implements ProducerNode { //this initialization should go somewhere global like an xml file.... (new KeywordSearchTerm("id", "", "id", "", "id")).index(theDoc, entity); - String textValue = entity.getValue("webdb_create"); + String textValue = entity.getFieldValue("webdb_create"); Calendar calendar = GregorianCalendar.getInstance(); int year; int month; @@ -155,11 +155,11 @@ public class IndexingProducerNode implements ProducerNode { (new KeywordSearchTerm("webdb_create_formatted", "search_date", "webdb_create_formatted", "webdb_create_formatted", "webdb_create_formatted")).indexValue(theDoc,formattedDate); - + (new UnIndexedSearchTerm("", "", "", "where", "where")).indexValue(theDoc, - StringUtil.webdbDate2path(entity.getValue("date")) + - entity.getValue("id") + ".shtml"); + StringUtil.webdbDate2path(entity.getFieldValue("date")) + + entity.getFieldValue("id") + ".shtml"); (new TextSearchTerm("creator", "search_creator", "creator", "creator", "creator")).index(theDoc, entity); @@ -171,8 +171,8 @@ public class IndexingProducerNode implements ProducerNode { "creationDate", "creationDate", "creationDate")).index(theDoc, entity); (new ContentSearchTerm("content_data", "search_content", "content", "", "")).indexValue(theDoc, - entity.getValue("content_data") + " " + entity.getValue("description") + - " " + entity.getValue("title")); + entity.getFieldValue("content_data") + " " + entity.getFieldValue("description") + + " " + entity.getFieldValue("title")); (new TopicSearchTerm()).index(theDoc, entity); diff --git a/source/mircoders/producer/MediaGeneratingProducerNode.java b/source/mircoders/producer/MediaGeneratingProducerNode.java index 1c0b5311..501e8933 100755 --- a/source/mircoders/producer/MediaGeneratingProducerNode.java +++ b/source/mircoders/producer/MediaGeneratingProducerNode.java @@ -75,20 +75,20 @@ public class MediaGeneratingProducerNode implements ProducerNode { currentMediaHandler = MediaHelper.getHandler( mediaType ); currentMediaHandler.produce(entity, mediaType); - entity.setValueForProperty("publish_server", currentMediaHandler.getPublishHost()); - entity.setValueForProperty("icon_is_produced", "1"); - entity.setValueForProperty("is_produced", "1"); + entity.setFieldValue("publish_server", currentMediaHandler.getPublishHost()); + entity.setFieldValue("icon_is_produced", "1"); + entity.setFieldValue("is_produced", "1"); entity.update(); - aLogger.info("media with id "+uploadedMediaEntity.getValue("id") + ", mediaType " + mediaType.getValue("name") + " successfully produced"); + aLogger.info("media with id "+uploadedMediaEntity.getFieldValue("id") + ", mediaType " + mediaType.getFieldValue("name") + " successfully produced"); } catch (Throwable t) { String message = "Error while generating media"; try { if (uploadedMediaEntity!=null) - message = message + " with id "+uploadedMediaEntity.getValue("id"); + message = message + " with id "+uploadedMediaEntity.getFieldValue("id"); if (mediaType!=null) { - message = message + ", mediaType " + mediaType.getValue("name"); + message = message + ", mediaType " + mediaType.getFieldValue("name"); } } catch (Throwable s) { diff --git a/source/mircoders/producer/PDFPreFormattingProducerNode.java b/source/mircoders/producer/PDFPreFormattingProducerNode.java index 50e69bf2..e7c80343 100755 --- a/source/mircoders/producer/PDFPreFormattingProducerNode.java +++ b/source/mircoders/producer/PDFPreFormattingProducerNode.java @@ -112,7 +112,7 @@ public class PDFPreFormattingProducerNode implements ProducerNode { "cxm.content_id="+entity.getId()+"and cxm.media_id=i.id", "i.id desc", 30, -1, 0); - String theContent = ((EntityContent) entity).getValue("content_data"); + String theContent = ((EntityContent) entity).getFieldValue("content_data"); //remove pesky characters theContent = HTMLRoutines.encodeXML(theContent); //put in the
tags so we can turn them to empty blocks @@ -144,8 +144,8 @@ public class PDFPreFormattingProducerNode implements ProducerNode { Map row1 = new HashMap(); Map row2 = new HashMap(); EntityImages currentImage=(EntityImages) images.next(); - float img_width=(new Float(currentImage.getValue("img_width"))).floatValue(); - float img_height=(new Float(currentImage.getValue("img_height"))).floatValue(); + float img_width=(new Float(currentImage.getFieldValue("img_width"))).floatValue(); + float img_height=(new Float(currentImage.getFieldValue("img_height"))).floatValue(); //oversize images must be shrunk if (img_width>250){ @@ -162,7 +162,7 @@ public class PDFPreFormattingProducerNode implements ProducerNode { row1.put("text_widthCM",Float.toString(text_widthCM)); - row1.put("img_title",currentImage.getValue("title")); + row1.put("img_title",currentImage.getFieldValue("title")); row1.put("img_width",Float.toString(img_width)); row1.put("img_height",Float.toString(img_height)); @@ -170,7 +170,7 @@ public class PDFPreFormattingProducerNode implements ProducerNode { aLogger.debug("img_width " +Float.toString(img_width)); aLogger.debug("img_height "+Float.toString(img_height)); - row1.put("img_src",currentImage.getValue("publish_path")); + row1.put("img_src",currentImage.getFieldValue("publish_path")); row1.put("hasImage","1"); if (! outOfText){ try { diff --git a/source/mircoders/producer/UnIndexingProducerNode.java b/source/mircoders/producer/UnIndexingProducerNode.java index 77a25d51..8589f75f 100755 --- a/source/mircoders/producer/UnIndexingProducerNode.java +++ b/source/mircoders/producer/UnIndexingProducerNode.java @@ -71,7 +71,7 @@ public class UnIndexingProducerNode implements ProducerNode { if (! (entity instanceof EntityContent)) { throw new ProducerFailure("UnIndexingProducerNode: value of '"+contentKey+"' is not a content EntityAdapter, but a " + entity.getClass().getName() + " adapter", null); } - aLogger.info("UnIndexing " + (String) entity.getValue("id") + " out of " + index); + aLogger.info("UnIndexing " + (String) entity.getFieldValue("id") + " out of " + index); IndexUtil.unindexEntity((EntityContent) entity, index); } diff --git a/source/mircoders/search/ContentSearchTerm.java b/source/mircoders/search/ContentSearchTerm.java index 636d1eca..8ea3d6f3 100755 --- a/source/mircoders/search/ContentSearchTerm.java +++ b/source/mircoders/search/ContentSearchTerm.java @@ -54,7 +54,7 @@ public class ContentSearchTerm extends SearchTerm{ } public void index(Document doc, Entity entity){ - doc.add(Field.UnStored(matchField,entity.getValue(partOfEntity))); + doc.add(Field.UnStored(matchField,entity.getFieldValue(partOfEntity))); } public void indexValue(Document doc, String value){ diff --git a/source/mircoders/search/ImagesSearchTerm.java b/source/mircoders/search/ImagesSearchTerm.java index 4039373d..b1fa9aef 100755 --- a/source/mircoders/search/ImagesSearchTerm.java +++ b/source/mircoders/search/ImagesSearchTerm.java @@ -59,7 +59,7 @@ public class ImagesSearchTerm extends SearchTerm{ if (k != 0){ imageURLString = imageURLString + ":"; } - imageURLString = imageURLString + (images.elementAt(k)).getValue("icon_path"); + imageURLString = imageURLString + (images.elementAt(k)).getFieldValue("icon_path"); } doc.add(Field.UnIndexed("images",imageURLString)); } diff --git a/source/mircoders/search/KeywordSearchTerm.java b/source/mircoders/search/KeywordSearchTerm.java index 0cd904d6..dfee6884 100755 --- a/source/mircoders/search/KeywordSearchTerm.java +++ b/source/mircoders/search/KeywordSearchTerm.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ @@ -54,7 +54,7 @@ public class KeywordSearchTerm extends SearchTerm{ public void index(Document doc, Entity entity){ - doc.add(Field.Keyword(matchField,entity.getValue(partOfEntity))); + doc.add(Field.Keyword(matchField,entity.getFieldValue(partOfEntity))); } public void indexValue(Document doc, String value){ diff --git a/source/mircoders/search/TextSearchTerm.java b/source/mircoders/search/TextSearchTerm.java index 9f4e4332..334a4243 100755 --- a/source/mircoders/search/TextSearchTerm.java +++ b/source/mircoders/search/TextSearchTerm.java @@ -50,7 +50,7 @@ public class TextSearchTerm extends SearchTerm{ } public void index(Document doc, Entity entity){ - String value =entity.getValue(partOfEntity); + String value =entity.getFieldValue(partOfEntity); if (value==null) value=""; diff --git a/source/mircoders/search/TopicMatrixSearchTerm.java b/source/mircoders/search/TopicMatrixSearchTerm.java index f02d9e4f..e6be2a19 100755 --- a/source/mircoders/search/TopicMatrixSearchTerm.java +++ b/source/mircoders/search/TopicMatrixSearchTerm.java @@ -52,7 +52,7 @@ public class TopicMatrixSearchTerm extends SearchTerm{ EntityList topics = DatabaseContentToTopics.getInstance().getTopics((EntityContent) entity); if (topics != null && topics.size()>0){ for(int k=0;k0){ for(int k=0;kimplements abstract DB connection to the comment_x_media SQL table * * @author RK, mir-coders group - * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.5 2003/11/26 19:23:16 rk Exp $ + * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.6 2004/01/18 17:31:01 zapata Exp $ * */ @@ -67,7 +67,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ super(); logger = new LoggerWrapper("Database.CommentToMedia"); hasTimestamp = false; - theTable = "comment_x_media"; + mainTable = "comment_x_media"; theEntityClass = mir.entity.GenericEntity.class; } @@ -92,19 +92,19 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ private EntityList getMultiMediaForComment(StorageObject store, EntityComment comment) throws StorageObjectFailure { - + EntityList returnList = null; if (comment != null) { String id = comment.getId(); - try { + try { Vector extraTable = new Vector(); - extraTable.add(theTable+" cxm"); + extraTable.add(mainTable+" cxm"); // media should stay in uploaded order. this is especially important // for photo stories which require a specific chronologic order. - // this is why we have the the second parameter "id" - store.selectByWhereClause("m", extraTable, + // this is why we have the the second parameter "id" + store.selectByWhereClause("m", extraTable, "m.id=cxm.media_id and cxm.comment_id="+id, "id", -1, -1); - + } catch (Exception e) { logger.error("DatabaseCommenttToMedia.getMultiMediaForComment: " + e.toString()); throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForComment: " + @@ -159,7 +159,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ return; } //first delete all row with comment_id=commentId - String sql = "delete from " + theTable + " where comment_id=" + commentId; + String sql = "delete from " + mainTable + " where comment_id=" + commentId; Connection con = null; Statement stmt = null; @@ -180,7 +180,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ //now insert //first delete all row with comment_id=commentId for (int i = 0; i < mediaId.length; i++) { - sql = "insert into " + theTable + " (comment_id,media_id) values (" + sql = "insert into " + mainTable + " (comment_id,media_id) values (" + commentId + "," + mediaId[i] + ")"; try { con = getPooledCon(); @@ -208,7 +208,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ Statement stmt = null; //now insert - String sql = "insert into " + theTable + " (comment_id,media_id) values (" + String sql = "insert into " + mainTable + " (comment_id,media_id) values (" + commentId + "," + mediaId + ")"; try { con = getPooledCon(); @@ -231,7 +231,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ return; } //first delete all row with comment_id=commentId - String sql = "delete from " + theTable + " where comment_id=" + commentId; + String sql = "delete from " + mainTable + " where comment_id=" + commentId; Connection con = null; Statement stmt = null; @@ -252,7 +252,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ //now insert //first delete all row with comment_id=commentId - sql = "insert into " + theTable + " (comment_id,media_id) values (" + sql = "insert into " + mainTable + " (comment_id,media_id) values (" + commentId + "," + mediaId + ")"; try { con = getPooledCon(); @@ -275,7 +275,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ return; } //delete all row with comment_id=commentId - String sql = "delete from " + theTable + " where comment_id=" + commentId; + String sql = "delete from " + mainTable + " where comment_id=" + commentId; Connection con = null; Statement stmt = null; @@ -301,7 +301,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ return; } //delete all row with comment_id=commentId - String sql = "delete from " + theTable + " where media_id=" + mediaId; + String sql = "delete from " + mainTable + " where media_id=" + mediaId; Connection con = null; Statement stmt = null; @@ -328,7 +328,7 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ return; } //delete all row with comment_id=commentId and media_id=mediaId - String sql = "delete from " + theTable + " where media_id=" + mediaId + + String sql = "delete from " + mainTable + " where media_id=" + mediaId + " and comment_id= " + commentId; Connection con = null; @@ -351,19 +351,19 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ public EntityList getComment(EntityUploadedMedia media) throws StorageObjectFailure { - + EntityList returnList = null; if (media != null) { String id = media.getId(); Vector extraTables = new Vector(); - extraTables.add(theTable + " cxm"); - + extraTables.add(mainTable + " cxm"); + String mediaSelect = "cxm.comment_id=c.id and cxm.media_id="+id; try { returnList = DatabaseComment.getInstance().selectByWhereClause("c", extraTables, mediaSelect, "c.id" ); - + } catch (Exception e) { logger.error("-- get comment failed"); @@ -374,21 +374,21 @@ public class DatabaseCommentToMedia extends Database implements StorageObject{ } /** - * Returns a EntityList with all comment-objects having + * Returns a EntityList with all comment-objects having * a relation to a media */ public EntityList getComment() throws StorageObjectFailure { EntityList returnList = null; - + Vector extraTables = new Vector(); - extraTables.add(theTable + " cxm"); - + extraTables.add(mainTable + " cxm"); + String mediaSelect = "cxm.comment_id=c.id"; try { returnList = DatabaseComment.getInstance().selectByWhereClause("c", extraTables, mediaSelect, "c.webdb_lastchange desc" ); - + } catch (Exception e) { logger.error("-- get comment failed"); diff --git a/source/mircoders/storage/DatabaseContent.java b/source/mircoders/storage/DatabaseContent.java index 6d172732..8d5e8095 100755 --- a/source/mircoders/storage/DatabaseContent.java +++ b/source/mircoders/storage/DatabaseContent.java @@ -64,8 +64,8 @@ public class DatabaseContent extends Database implements StorageObject { private DatabaseContent() throws StorageObjectFailure { super(); - theTable="content"; - theCoreTable="media"; + mainTable="content"; + primaryKeySequence="media_id_seq"; logger = new LoggerWrapper("Database.Content"); theEntityClass = mircoders.entity.EntityContent.class; diff --git a/source/mircoders/storage/DatabaseContentToMedia.java b/source/mircoders/storage/DatabaseContentToMedia.java index 425e13a1..c99bf762 100755 --- a/source/mircoders/storage/DatabaseContentToMedia.java +++ b/source/mircoders/storage/DatabaseContentToMedia.java @@ -48,7 +48,7 @@ import mircoders.entity.EntityUploadedMedia; * implements abstract DB connection to the content_x_media SQL table * * @author RK, mir-coders group - * @version $Id: DatabaseContentToMedia.java,v 1.19.2.4 2003/11/26 19:21:06 rk Exp $ + * @version $Id: DatabaseContentToMedia.java,v 1.19.2.5 2004/01/18 17:31:01 zapata Exp $ * */ @@ -68,14 +68,14 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ logger = new LoggerWrapper("Database.ContentToMedia"); hasTimestamp = false; - theTable = "content_x_media"; + mainTable = "content_x_media"; theEntityClass = mir.entity.GenericEntity.class; } public boolean hasMedia(EntityContent content) throws StorageObjectFailure, StorageObjectExc { if (content != null) { - try { + try { return (getSize("content_id=" + content.getId()) == 0) ? false:true; } catch (Exception e) { @@ -93,19 +93,19 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ private EntityList getMultiMediaForContent(StorageObject store, EntityContent content) throws StorageObjectFailure { - + EntityList returnList = null; if (content != null) { String id = content.getId(); - try { + try { Vector extraTable = new Vector(); - extraTable.add(theTable+" cxm"); + extraTable.add(mainTable+" cxm"); // media should stay in uploaded order. this is especially important // for photo stories which require a specific chronologic order. - // this is why we have the the second parameter "id" - store.selectByWhereClause("m", extraTable, + // this is why we have the the second parameter "id" + store.selectByWhereClause("m", extraTable, "m.id=cxm.media_id and cxm.content_id="+id, "id", -1, -1); - + } catch (Exception e) { logger.error("DatabaseContentToMedia.getMultiMediaForContent: " + e.toString()); throw new StorageObjectFailure("DatabaseContentToMedia.etMultiMediaForContent: " + @@ -114,7 +114,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } return returnList; } - + /** * get all the audio belonging to a content entity */ @@ -156,7 +156,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ return; } //first delete all row with content_id=contentId - String sql = "delete from " + theTable + " where content_id=" + contentId; + String sql = "delete from " + mainTable + " where content_id=" + contentId; Connection con = null; Statement stmt = null; @@ -177,7 +177,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ //now insert //first delete all row with content_id=contentId for (int i = 0; i < mediaId.length; i++) { - sql = "insert into " + theTable + " (content_id,media_id) values (" + sql = "insert into " + mainTable + " (content_id,media_id) values (" + contentId + "," + mediaId[i] + ")"; try { con = getPooledCon(); @@ -205,7 +205,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ Statement stmt = null; //now insert - String sql = "insert into " + theTable + " (content_id,media_id) values (" + String sql = "insert into " + mainTable + " (content_id,media_id) values (" + contentId + "," + mediaId + ")"; try { con = getPooledCon(); @@ -228,7 +228,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ return; } //first delete all row with content_id=contentId - String sql = "delete from " + theTable + " where content_id=" + contentId; + String sql = "delete from " + mainTable + " where content_id=" + contentId; Connection con = null; Statement stmt = null; @@ -249,7 +249,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ //now insert //first delete all row with content_id=contentId - sql = "insert into " + theTable + " (content_id,media_id) values (" + sql = "insert into " + mainTable + " (content_id,media_id) values (" + contentId + "," + mediaId + ")"; try { con = getPooledCon(); @@ -272,7 +272,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ return; } //delete all row with content_id=contentId - String sql = "delete from " + theTable + " where content_id=" + contentId; + String sql = "delete from " + mainTable + " where content_id=" + contentId; Connection con = null; Statement stmt = null; @@ -293,13 +293,13 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ } public void deleteByMediaId(String mediaId) throws StorageObjectFailure { - + if (mediaId == null) { //theLog.printDebugInfo("-- delete topics failed -- no topic id"); return; } //delete all row with content_id=contentId - String sql = "delete from " + theTable + " where media_id=" + mediaId; + String sql = "delete from " + mainTable + " where media_id=" + mediaId; Connection con = null; Statement stmt = null; @@ -326,7 +326,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ return; } //delete all row with content_id=contentId and media_id=mediaId - String sql = "delete from " + theTable + " where media_id=" + mediaId + + String sql = "delete from " + mainTable + " where media_id=" + mediaId + " and content_id= " + contentId; Connection con = null; @@ -349,19 +349,19 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ public EntityList getContent(EntityUploadedMedia media) throws StorageObjectFailure { - + EntityList returnList = null; if (media != null) { String id = media.getId(); Vector extraTables = new Vector(); - extraTables.add(theTable + " cxm"); - + extraTables.add(mainTable + " cxm"); + String mediaSelect = "cxm.content_id=c.id and cxm.media_id="+id; try { returnList = DatabaseContent.getInstance().selectByWhereClause("c", extraTables, mediaSelect, "c.id" ); - + } catch (Exception e) { logger.error("-- get content failed"); @@ -378,15 +378,15 @@ public class DatabaseContentToMedia extends Database implements StorageObject{ public EntityList getContent() throws StorageObjectFailure { EntityList returnList = null; - + Vector extraTables = new Vector(); - extraTables.add(theTable + " cxm"); - + extraTables.add(mainTable + " cxm"); + String mediaSelect = "cxm.content_id=c.id"; try { returnList = DatabaseContent.getInstance().selectByWhereClause("c", extraTables, mediaSelect, "c.webdb_lastchange desc" ); - + } catch (Exception e) { logger.error("-- get content failed"); diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index eca6c293..2ad9fb2b 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -70,7 +70,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ logger = new LoggerWrapper("Database.ContentToTopics"); hasTimestamp = false; - theTable="content_x_topic"; + mainTable="content_x_topic"; theEntityClass = mir.entity.GenericEntity.class; } @@ -86,10 +86,10 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ String id = content.getId(); try { Vector extraTables = new Vector(); - extraTables.add(theTable+" cxt"); + extraTables.add(mainTable+" cxt"); returnList = DatabaseTopics.getInstance() - .selectByWhereClauseWithExtraTables("t",extraTables, - "t.id=cxt.topic_id and cxt.content_id="+id ); + .selectByWhereClauseWithExtraTables("t",extraTables, + "t.id=cxt.topic_id and cxt.content_id="+id ); } catch (Exception e) { logger.error("-- get topics failed " + e.toString()); @@ -107,7 +107,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ ArrayList returnList = new ArrayList(); if (contentId != null) { - String sql = "select topic_id from " + theTable + " where content_id=" + contentId; + String sql = "select topic_id from " + mainTable + " where content_id=" + contentId; Connection con=null;Statement stmt=null; try { con = getPooledCon(); @@ -171,9 +171,9 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ logger.debug("to add = " + topicsToAdd.toString()); - if (!topicsToDelete.isEmpty()) { + if (!topicsToDelete.isEmpty()) { String sql = - "delete from " + theTable + " " + + "delete from " + mainTable + " " + "where content_id=" + anArticleId + " and topic_id in (" + getIdListExpression(topicsToDelete) + ")"; @@ -200,7 +200,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ while (i.hasNext()) { Integer topicId = (Integer) i.next(); String sql = - "insert into " + theTable + " (content_id, topic_id) "+ + "insert into " + mainTable + " (content_id, topic_id) "+ "values (" + anArticleId + "," + topicId + ")"; Connection connection=null; Statement statement=null; @@ -230,7 +230,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ return; } //delete all row with content_id=contentId - String sql = "delete from "+ theTable +" where content_id=" + contentId; + String sql = "delete from "+ mainTable +" where content_id=" + contentId; Connection con=null;Statement stmt=null; try { @@ -252,7 +252,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ return; } //delete all row with content_id=contentId - String sql = "delete from "+ theTable +" where topic_id=" + topicId; + String sql = "delete from "+ mainTable +" where topic_id=" + topicId; Connection con=null;Statement stmt=null; try { @@ -268,7 +268,7 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ freeConnection(con,stmt); } } - + /** * Returns list of Content for a specific topic * @param topic @@ -282,10 +282,10 @@ public class DatabaseContentToTopics extends Database implements StorageObject{ String id = topic.getId(); try { Vector extraTables = new Vector(); - extraTables.add(theTable+" cxt"); + extraTables.add(mainTable+" cxt"); returnList = DatabaseContent.getInstance() - .selectByWhereClauseWithExtraTables("c",extraTables, - "c.id=cxt.content_id and cxt.topic_id="+id ); + .selectByWhereClauseWithExtraTables("c",extraTables, + "c.id=cxt.content_id and cxt.topic_id="+id ); } catch (Exception e) { logger.error("-- get content failed"); diff --git a/source/mircoders/storage/DatabaseImageColor.java b/source/mircoders/storage/DatabaseImageColor.java index cb364bf5..6881eba5 100755 --- a/source/mircoders/storage/DatabaseImageColor.java +++ b/source/mircoders/storage/DatabaseImageColor.java @@ -58,7 +58,7 @@ public class DatabaseImageColor extends Database implements StorageObject{ super(); logger = new LoggerWrapper("Database.ImageColor"); hasTimestamp = false; - theTable = "img_color"; + mainTable = "img_color"; } } diff --git a/source/mircoders/storage/DatabaseImageFormat.java b/source/mircoders/storage/DatabaseImageFormat.java index 76a3f290..210dfb21 100755 --- a/source/mircoders/storage/DatabaseImageFormat.java +++ b/source/mircoders/storage/DatabaseImageFormat.java @@ -58,6 +58,6 @@ public class DatabaseImageFormat extends Database implements StorageObject{ super(); logger = new LoggerWrapper("Database.ImageFormat"); hasTimestamp = false; - theTable = "img_format"; + mainTable = "img_format"; } } diff --git a/source/mircoders/storage/DatabaseImageLayout.java b/source/mircoders/storage/DatabaseImageLayout.java index 2e517d51..8e48eb30 100755 --- a/source/mircoders/storage/DatabaseImageLayout.java +++ b/source/mircoders/storage/DatabaseImageLayout.java @@ -59,6 +59,6 @@ public class DatabaseImageLayout extends Database implements StorageObject{ logger = new LoggerWrapper("Database.ImageLayout"); hasTimestamp = false; - theTable = "img_layout"; + mainTable = "img_layout"; } } diff --git a/source/mircoders/storage/DatabaseImageType.java b/source/mircoders/storage/DatabaseImageType.java index 87e30008..8bf91f4e 100755 --- a/source/mircoders/storage/DatabaseImageType.java +++ b/source/mircoders/storage/DatabaseImageType.java @@ -58,6 +58,6 @@ public class DatabaseImageType extends Database implements StorageObject{ logger = new LoggerWrapper("Database.ImageType"); hasTimestamp = false; - theTable = "img_type"; + mainTable = "img_type"; } } diff --git a/source/mircoders/storage/DatabaseImages.java b/source/mircoders/storage/DatabaseImages.java index 606963bb..33a07699 100755 --- a/source/mircoders/storage/DatabaseImages.java +++ b/source/mircoders/storage/DatabaseImages.java @@ -62,27 +62,27 @@ public class DatabaseImages extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Images"); hasTimestamp = true; - theTable = "images"; - theCoreTable = "media"; + mainTable = "images"; + primaryKeySequence = "media_id_seq"; theEntityClass = mircoders.entity.EntityImages.class; } public void update(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } super.update(theEntity); } public String insert(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } return super.insert(theEntity); diff --git a/source/mircoders/storage/DatabaseLanguage.java b/source/mircoders/storage/DatabaseLanguage.java index 7595fd03..61f9958a 100755 --- a/source/mircoders/storage/DatabaseLanguage.java +++ b/source/mircoders/storage/DatabaseLanguage.java @@ -72,7 +72,7 @@ public class DatabaseLanguage extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Language"); this.hasTimestamp = false; - this.theTable = "language"; + this.mainTable = "language"; } public List getPopupData() throws StorageObjectFailure { @@ -83,7 +83,7 @@ public class DatabaseLanguage extends Database implements StorageObject{ Entity e = (Entity) i.next(); Map entry = new HashMap(); entry.put("key", e.getId()); - entry.put("value", e.getValue("name")); + entry.put("value", e.getFieldValue("name")); result.add(entry); } diff --git a/source/mircoders/storage/DatabaseMediaType.java b/source/mircoders/storage/DatabaseMediaType.java index cd2cf1a1..fd900f95 100755 --- a/source/mircoders/storage/DatabaseMediaType.java +++ b/source/mircoders/storage/DatabaseMediaType.java @@ -58,7 +58,7 @@ public class DatabaseMediaType extends Database implements StorageObject{ logger = new LoggerWrapper("Database.MediaType"); hasTimestamp = false; - theTable="media_type"; + mainTable="media_type"; theEntityClass = mir.entity.GenericEntity.class; } diff --git a/source/mircoders/storage/DatabaseMediafolder.java b/source/mircoders/storage/DatabaseMediafolder.java index 3e967084..a9d3dd4b 100755 --- a/source/mircoders/storage/DatabaseMediafolder.java +++ b/source/mircoders/storage/DatabaseMediafolder.java @@ -54,6 +54,6 @@ public class DatabaseMediafolder extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Mediafolder"); hasTimestamp = false; - theTable="media_folder"; + mainTable="media_folder"; } } diff --git a/source/mircoders/storage/DatabaseMessages.java b/source/mircoders/storage/DatabaseMessages.java index 81ad6968..efac2e7f 100755 --- a/source/mircoders/storage/DatabaseMessages.java +++ b/source/mircoders/storage/DatabaseMessages.java @@ -61,7 +61,7 @@ public class DatabaseMessages extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Messages"); - this.theTable="messages"; + this.mainTable="messages"; } diff --git a/source/mircoders/storage/DatabaseOther.java b/source/mircoders/storage/DatabaseOther.java index 167ba857..c4c422be 100755 --- a/source/mircoders/storage/DatabaseOther.java +++ b/source/mircoders/storage/DatabaseOther.java @@ -68,26 +68,26 @@ public class DatabaseOther extends Database implements StorageObject{ logger = new LoggerWrapper("Database.OtherMedia"); hasTimestamp = true; - theTable = "other_media"; - theCoreTable = "media"; + mainTable = "other_media"; + primaryKeySequence = "media_id_seq"; theEntityClass = mircoders.entity.EntityOther.class; } public void update(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } super.update(theEntity); } public String insert(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } return super.insert(theEntity); } diff --git a/source/mircoders/storage/DatabaseRights.java b/source/mircoders/storage/DatabaseRights.java index 5bdbd087..d2a5c632 100755 --- a/source/mircoders/storage/DatabaseRights.java +++ b/source/mircoders/storage/DatabaseRights.java @@ -61,6 +61,6 @@ public class DatabaseRights extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Rights"); hasTimestamp = false; - theTable = "rights"; + mainTable = "rights"; } } diff --git a/source/mircoders/storage/DatabaseTopics.java b/source/mircoders/storage/DatabaseTopics.java index e18e92eb..252ae0b3 100755 --- a/source/mircoders/storage/DatabaseTopics.java +++ b/source/mircoders/storage/DatabaseTopics.java @@ -69,7 +69,7 @@ public class DatabaseTopics extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Topics"); hasTimestamp = false; - theTable = "topic"; + mainTable = "topic"; theEntityClass = mircoders.entity.EntityTopics.class; } @@ -81,7 +81,7 @@ public class DatabaseTopics extends Database implements StorageObject{ Entity e = (Entity) i.next(); Map entry = new HashMap(); entry.put("key", e.getId()); - entry.put("value", e.getValue("title")); + entry.put("value", e.getFieldValue("title")); result.add(entry); } diff --git a/source/mircoders/storage/DatabaseUploadedMedia.java b/source/mircoders/storage/DatabaseUploadedMedia.java index 8c4e0bc0..ce42e110 100755 --- a/source/mircoders/storage/DatabaseUploadedMedia.java +++ b/source/mircoders/storage/DatabaseUploadedMedia.java @@ -55,8 +55,8 @@ public class DatabaseUploadedMedia extends Database implements StorageObject { logger = new LoggerWrapper("Database.UploadedMedia"); - theTable="uploaded_media"; - theCoreTable="media"; + mainTable="uploaded_media"; + primaryKeySequence="media_id_seq"; theEntityClass = mircoders.entity.EntityUploadedMedia.class; } @@ -68,7 +68,7 @@ public class DatabaseUploadedMedia extends Database implements StorageObject { public Entity getMediaType(Entity ent) throws StorageObjectFailure { Entity type=null; try { - Iterator i = new EntityBrowser(DatabaseMediaType.getInstance(), ent.getValue("to_media_type") + " = id" , "id", 1); + Iterator i = new EntityBrowser(DatabaseMediaType.getInstance(), ent.getFieldValue("to_media_type") + " = id" , "id", 1); if (i.hasNext()) type = (Entity) i.next(); } diff --git a/source/mircoders/storage/DatabaseUsers.java b/source/mircoders/storage/DatabaseUsers.java index 29dddacc..3e2c4b32 100755 --- a/source/mircoders/storage/DatabaseUsers.java +++ b/source/mircoders/storage/DatabaseUsers.java @@ -65,7 +65,7 @@ public class DatabaseUsers extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Users"); hasTimestamp = false; - theTable = "webdb_users"; + mainTable = "webdb_users"; theEntityClass = mircoders.entity.EntityUsers.class; } } diff --git a/source/mircoders/storage/DatabaseVideo.java b/source/mircoders/storage/DatabaseVideo.java index d5609eaf..4595bef9 100755 --- a/source/mircoders/storage/DatabaseVideo.java +++ b/source/mircoders/storage/DatabaseVideo.java @@ -69,26 +69,26 @@ public class DatabaseVideo extends Database implements StorageObject{ logger = new LoggerWrapper("Database.Video"); hasTimestamp = true; - theTable = "video"; - theCoreTable = "media"; + mainTable = "video"; + primaryKeySequence = "media_id_seq"; theEntityClass = mircoders.entity.EntityVideo.class; } public void update(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } super.update(theEntity); } public String insert(Entity theEntity) throws StorageObjectFailure { - String date = theEntity.getValue("date"); + String date = theEntity.getFieldValue("date"); if (date == null) { date = StringUtil.date2webdbDate(new GregorianCalendar()); - theEntity.setValueForProperty("date", date); + theEntity.setFieldValue("date", date); } return super.insert(theEntity); } diff --git a/templates/admin/abuse.filters.template b/templates/admin/abuse.filters.template index 50503c16..5c9db62b 100755 --- a/templates/admin/abuse.filters.template +++ b/templates/admin/abuse.filters.template @@ -41,8 +41,9 @@ f.lastHit.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"]) ], "module=Abuse&id="+f.id, - ["&do=moveup", "&do=movedown"], - [lang("abuse.filters.moveup"), lang("abuse.filters.movedown")]) + ["&do=moveup", "&do=movedown", "&do=movetop", "&do=movebottom"], + [lang("abuse.filters.moveup"), lang("abuse.filters.movedown"), + lang("abuse.filters.movetop"), lang("abuse.filters.movebottom")]) > -- 2.11.0