From e44404fac09c8da04b5ef7874160cb91f8fc98a9 Mon Sep 17 00:00:00 2001 From: rhindes Date: Thu, 10 Feb 2005 16:22:20 +0000 Subject: [PATCH] some code cleanup. removed unnecessary semikolons, unused vars, etc. --- source/Mir.java | 47 +- source/mir/bundle/CascadingBundleFactory.java | 2 +- source/mir/bundle/PropertiesBundle.java | 7 +- source/mir/bundle/PropertiesFileBundleLoader.java | 2 +- source/mir/config/MirPropertiesConfiguration.java | 6 +- source/mir/entity/AbstractEntity.java | 7 +- source/mir/entity/Entity.java | 8 +- source/mir/entity/EntityBrowser.java | 9 +- source/mir/entity/EntityList.java | 14 +- source/mir/entity/StorableObjectEntity.java | 3 +- source/mir/entity/adapter/EntityAdapter.java | 6 +- .../entity/adapter/EntityAdapterDefinition.java | 2 +- source/mir/entity/adapter/EntityAdapterModel.java | 6 +- .../mir/entity/adapter/EntityIteratorAdapter.java | 2 +- .../mir/generator/CompositeGeneratorLibrary.java | 11 +- source/mir/generator/FreemarkerGenerator.java | 28 +- source/mir/generator/GeneratorHelper.java | 6 +- source/mir/generator/TALGenerator.java | 6 +- source/mir/generator/VelocityGenerator.java | 37 +- .../tal/SimpleTemplateNodeLibraryRegistry.java | 4 +- source/mir/generator/tal/TALTemplateEngine.java | 18 +- source/mir/generator/tal/TALTemplateParser.java | 8 +- source/mir/generator/tal/TALTest.java | 6 +- .../tal/template/CoreTemplateNodeLibrary.java | 765 ++++----- .../tal/template/MacroTemplateNodeLibrary.java | 8 +- .../tal/template/TemplateNodeLibrary.java | 98 +- source/mir/log/LoggerToWriterAdapter.java | 2 +- source/mir/log/LoggerWrapper.java | 14 +- source/mir/log/log4j/LoggerImpl.java | 1 + source/mir/misc/FileUtil.java | 9 +- source/mir/misc/StringUtil.java | 29 +- source/mir/module/AbstractModule.java | 5 +- source/mir/producer/AssignmentProducerNode.java | 3 +- source/mir/producer/BundleProducerNode.java | 2 +- .../mir/producer/EntityBatchingProducerNode.java | 4 +- .../mir/producer/EntityDeletingProducerNode.java | 2 +- .../producer/EntityEnumeratingProducerNode.java | 2 +- .../producer/EvaluatedAssignmentProducerNode.java | 3 +- .../mir/producer/ExecuteProgramProducerNode.java | 256 +-- .../producer/ExpandedAssignmentProducerNode.java | 3 +- source/mir/producer/ExternalDbProducerNode.java | 9 +- source/mir/producer/FreeQueryProducerNode.java | 2 +- .../mir/producer/ListEnumeratingProducerNode.java | 2 +- source/mir/producer/LoopProducerNode.java | 2 +- source/mir/producer/NodedProducer.java | 2 +- source/mir/producer/ProducerFactory.java | 2 +- source/mir/producer/ProducerFailure.java | 3 +- source/mir/producer/RDFAggregatorProducerNode.java | 2 +- source/mir/producer/RSSProducerNode.java | 2 +- source/mir/producer/ValuesMapProducerNode.java | 2 +- .../reader/DefaultProducerNodeBuilders.java | 114 +- .../mir/producer/reader/ProducerConfigReader.java | 18 +- .../reader/ProducerNodeBuilderLibrary.java | 3 +- .../producer/reader/ScriptedProducerFactory.java | 2 +- source/mir/rss/RSS091Reader.java | 70 +- source/mir/rss/RSSData.java | 2 +- source/mir/rss/RSSReader.java | 86 +- source/mir/servlet/ServletModule.java | 10 +- source/mir/session/CommonsUploadedFileAdapter.java | 8 +- source/mir/session/HTTPAdapters.java | 32 +- source/mir/session/ValidationHelper.java | 3 +- source/mir/storage/Database.java | 55 +- source/mir/storage/StorageObjectFailure.java | 4 +- source/mir/storage/store/ObjectStore.java | 1 + source/mir/storage/store/StoreContainer.java | 4 +- source/mir/storage/store/test/EntityC1.java | 2 +- source/mir/util/CachingRewindableIterator.java | 2 +- source/mir/util/DateTimeFunctions.java | 19 +- source/mir/util/FileFunctions.java | 26 +- source/mir/util/GeneratorDateTimeFunctions.java | 2 +- source/mir/util/GeneratorFormatAdapters.java | 4 +- source/mir/util/HTTPParsedRequest.java | 16 +- source/mir/util/HTTPRequestParser.java | 3 +- source/mir/util/InternetFunctions.java | 2 +- source/mir/util/ParameterExpander.java | 49 +- source/mir/util/PropertiesManipulator.java | 6 +- source/mir/util/ReflectionRoutines.java | 120 +- source/mir/util/StreamCopier.java | 2 +- source/mir/util/StringParseRoutines.java | 4 +- source/mir/util/StringRoutines.java | 5 +- source/mir/util/StructuredContentParser.java | 2 +- source/mir/util/SubsetIterator.java | 7 +- .../util/generator/BundleGeneratorFunction.java | 6 +- source/mir/util/xml/AbstractSectionHandler.java | 78 +- source/mir/util/xml/XMLName.java | 174 +- source/mir/util/xml/XMLParserEngine.java | 7 +- source/mir/util/xml/XMLParserFailure.java | 45 +- source/mir/util/xml/XMLReaderTool.java | 3 +- source/mir/util/xml/XMLSAXParserProvider.java | 321 ++-- source/mir/util/xml/html/HTMLParser.java | 8 +- source/mir/util/xml/html/HTMLScanner.java | 7 +- .../mir/util/xml/html/HTMLSchemaInformation.java | 5 +- .../mir/util/xml/html/XMLHTMLParserProvider.java | 192 +-- source/mircoders/abuse/FilterEngine.java | 913 +++++------ source/mircoders/abuse/IPFilterType.java | 160 +- .../abuse/RegularExpressionFilterType.java | 5 +- source/mircoders/abuse/ThrottleFilter.java | 300 ++-- source/mircoders/accesscontrol/AccessControl.java | 6 +- source/mircoders/entity/EntityComment.java | 8 +- source/mircoders/entity/EntityContent.java | 12 +- source/mircoders/entity/EntityImages.java | 10 +- source/mircoders/entity/EntityUploadedMedia.java | 8 +- source/mircoders/entity/EntityVideo.java | 4 +- source/mircoders/global/Abuse.java | 27 +- source/mircoders/global/CacheKey.java | 3 +- source/mircoders/global/DatabaseEngine.java | 1 + source/mircoders/global/JobQueue.java | 13 +- source/mircoders/global/MirGlobal.java | 708 ++++---- source/mircoders/global/ProducerEngine.java | 17 +- .../localizer/MirAdminInterfaceLocalizer.java | 6 +- .../localizer/MirCachingLocalizerDecorator.java | 12 +- .../basic/MirBasicAdminInterfaceLocalizer.java | 39 +- .../basic/MirBasicArticlePostingHandler.java | 17 +- .../basic/MirBasicChildArticlePostingHandler.java | 2 +- .../basic/MirBasicCommentPostingHandler.java | 5 +- .../basic/MirBasicDataModelLocalizer.java | 1710 ++++++++++---------- .../basic/MirBasicEmailArticleHandler.java | 13 +- .../basic/MirBasicGeneratorLocalizer.java | 10 +- .../localizer/basic/MirBasicLocalizer.java | 4 +- .../localizer/basic/MirBasicMediaLocalizer.java | 14 +- .../basic/MirBasicOpenPostingLocalizer.java | 11 +- .../basic/MirBasicPostingSessionHandler.java | 26 +- .../basic/MirBasicProducerAssistantLocalizer.java | 36 +- .../localizer/basic/MirBasicProducerLocalizer.java | 8 +- .../basic/MirBasicTranslationPostingHandler.java | 2 +- .../localizer/basic/MirBasicUtilityFunctions.java | 323 ++-- .../localizer/basic/MirBasicWriterEngine.java | 4 +- .../basic/actions/ArticleTopicAction.java | 2 +- source/mircoders/media/AbstractMediaHandler.java | 118 +- source/mircoders/media/MediaHandlerGeneric.java | 17 +- source/mircoders/media/MediaHandlerMp3.java | 6 +- source/mircoders/media/MediaHandlerOgg.java | 3 +- source/mircoders/media/MediaHandlerRealAudio.java | 4 +- source/mircoders/media/MediaHandlerRealVideo.java | 10 +- source/mircoders/media/MediaHelper.java | 19 +- source/mircoders/media/MediaUploadProcessor.java | 8 +- source/mircoders/media/URLMediaHandler.java | 6 +- source/mircoders/module/ModuleComment.java | 6 +- source/mircoders/module/ModuleLanguage.java | 8 +- source/mircoders/module/ModuleMediaType.java | 10 +- source/mircoders/module/ModuleUsers.java | 6 +- source/mircoders/pdf/PDFGenerator.java | 37 +- .../mircoders/producer/IndexingProducerNode.java | 4 +- .../producer/MediaGeneratingProducerNode.java | 2 +- .../producer/PDFPreFormattingProducerNode.java | 6 +- .../producer/RadicalendarProducerNode.java | 8 +- .../mircoders/producer/UnIndexingProducerNode.java | 4 +- .../reader/SupplementalProducerNodeBuilders.java | 34 +- source/mircoders/search/AudioSearchTerm.java | 9 +- source/mircoders/search/ContentSearchTerm.java | 4 +- source/mircoders/search/ImagesSearchTerm.java | 5 +- source/mircoders/search/IndexUtil.java | 5 +- source/mircoders/search/KeywordSearchTerm.java | 4 +- source/mircoders/search/MediaSearchTerm.java | 4 +- source/mircoders/search/SearchTerm.java | 3 + source/mircoders/search/TextSearchTerm.java | 4 +- source/mircoders/search/TopicMatrixSearchTerm.java | 4 +- source/mircoders/search/TopicSearchTerm.java | 4 +- source/mircoders/search/UnStoredSearchTerm.java | 4 +- source/mircoders/search/VideoSearchTerm.java | 8 +- source/mircoders/servlet/ServletHelper.java | 343 ++-- source/mircoders/servlet/ServletModuleAbuse.java | 9 +- source/mircoders/servlet/ServletModuleAdmin.java | 1 + source/mircoders/servlet/ServletModuleComment.java | 19 +- source/mircoders/servlet/ServletModuleContent.java | 22 +- .../mircoders/servlet/ServletModuleFileEdit.java | 13 +- source/mircoders/servlet/ServletModuleHidden.java | 13 +- .../mircoders/servlet/ServletModuleLocalizer.java | 12 +- .../mircoders/servlet/ServletModuleMediaType.java | 1 - .../mircoders/servlet/ServletModuleOpenIndy.java | 3 +- .../mircoders/servlet/ServletModuleProducer.java | 18 +- source/mircoders/servlet/ServletModuleUsers.java | 16 +- source/mircoders/storage/DatabaseArticleType.java | 1 - source/mircoders/storage/DatabaseAudio.java | 4 +- source/mircoders/storage/DatabaseBreaking.java | 1 - source/mircoders/storage/DatabaseComment.java | 1 - .../mircoders/storage/DatabaseCommentStatus.java | 1 - .../mircoders/storage/DatabaseCommentToMedia.java | 6 +- source/mircoders/storage/DatabaseContent.java | 1 - .../mircoders/storage/DatabaseContentToMedia.java | 6 +- .../mircoders/storage/DatabaseContentToTopics.java | 15 +- source/mircoders/storage/DatabaseFilter.java | 115 +- source/mircoders/storage/DatabaseFilterGroup.java | 113 +- source/mircoders/storage/DatabaseImageColor.java | 1 - source/mircoders/storage/DatabaseImageFormat.java | 1 - source/mircoders/storage/DatabaseImageLayout.java | 1 - source/mircoders/storage/DatabaseImageType.java | 1 - source/mircoders/storage/DatabaseImages.java | 1 - source/mircoders/storage/DatabaseLanguage.java | 7 +- source/mircoders/storage/DatabaseMediaType.java | 1 - source/mircoders/storage/DatabaseMediafolder.java | 1 - source/mircoders/storage/DatabaseMessages.java | 1 - source/mircoders/storage/DatabaseOther.java | 1 - source/mircoders/storage/DatabaseRights.java | 1 - source/mircoders/storage/DatabaseTopics.java | 7 +- .../mircoders/storage/DatabaseUploadedMedia.java | 1 - source/mircoders/storage/DatabaseUsers.java | 1 - source/mircoders/storage/DatabaseVideo.java | 1 - source/tool/BundleTool.java | 1 - source/tool/ImageTool.java | 1 - 200 files changed, 4358 insertions(+), 4226 deletions(-) diff --git a/source/Mir.java b/source/Mir.java index 515d1ee1..8d291125 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -28,28 +28,43 @@ * If you do not wish to do so, delete this exception statement from your version. */ +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionBindingEvent; +import javax.servlet.http.HttpSessionBindingListener; + import mir.bundle.Bundle; import mir.config.MirPropertiesConfiguration; -import mir.servlet.*; +import mir.log.LoggerWrapper; +import mir.servlet.AbstractServlet; +import mir.servlet.ServletModule; +import mir.servlet.ServletModuleDispatch; +import mir.servlet.ServletModuleExc; +import mir.servlet.ServletModuleUserExc; import mir.util.ExceptionFunctions; import mir.util.StringRoutines; -import mir.log.LoggerWrapper; import mircoders.entity.EntityUsers; import mircoders.global.MirGlobal; import mircoders.module.ModuleUsers; import mircoders.servlet.ServletHelper; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.UnavailableException; -import javax.servlet.http.*; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.PrintStream; -import java.io.StringWriter; -import java.lang.reflect.Method; -import java.util.*; - import multex.Failure; /** @@ -279,9 +294,7 @@ public class Mir extends AbstractServlet { throw new ServletModuleExc("*** error resolving classname for " + moduleName + " -- " + e.getMessage()); } } - else { - return (ServletModule) servletModuleInstanceHash.get(moduleName); - } + return (ServletModule) servletModuleInstanceHash.get(moduleName); } private void handleUserError(HttpServletRequest aRequest, HttpServletResponse aResponse, ServletModuleUserExc anException) { diff --git a/source/mir/bundle/CascadingBundleFactory.java b/source/mir/bundle/CascadingBundleFactory.java index b3a9920e..b50ae089 100755 --- a/source/mir/bundle/CascadingBundleFactory.java +++ b/source/mir/bundle/CascadingBundleFactory.java @@ -34,7 +34,7 @@ import java.util.Arrays; import java.util.List; public class CascadingBundleFactory implements BundleFactory { - private BundleFactory masterFactory; + BundleFactory masterFactory; /** {@inheritDoc} */ public CascadingBundleFactory(BundleFactory aMasterFactory) { diff --git a/source/mir/bundle/PropertiesBundle.java b/source/mir/bundle/PropertiesBundle.java index a7952852..0409df80 100755 --- a/source/mir/bundle/PropertiesBundle.java +++ b/source/mir/bundle/PropertiesBundle.java @@ -29,9 +29,9 @@ */ package mir.bundle; -import java.util.Properties; -import java.util.List; import java.util.Iterator; +import java.util.List; +import java.util.Properties; import mir.util.StringParseRoutines; @@ -78,7 +78,6 @@ public class PropertiesBundle implements Bundle { if (result==null || result.trim().length()==0) return null; - else - return formatValue(result, anArguments); + return formatValue(result, anArguments); } } diff --git a/source/mir/bundle/PropertiesFileBundleLoader.java b/source/mir/bundle/PropertiesFileBundleLoader.java index 5e889765..39801244 100755 --- a/source/mir/bundle/PropertiesFileBundleLoader.java +++ b/source/mir/bundle/PropertiesFileBundleLoader.java @@ -30,8 +30,8 @@ package mir.bundle; import java.io.File; -import java.io.IOException; import java.io.FileInputStream; +import java.io.IOException; import java.util.Properties; /** diff --git a/source/mir/config/MirPropertiesConfiguration.java b/source/mir/config/MirPropertiesConfiguration.java index 80ece216..198ff3ab 100755 --- a/source/mir/config/MirPropertiesConfiguration.java +++ b/source/mir/config/MirPropertiesConfiguration.java @@ -34,10 +34,12 @@ import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; + import javax.servlet.ServletContext; import multex.Exc; import multex.Failure; + import org.apache.commons.collections.ExtendedProperties; /** @@ -149,9 +151,7 @@ public class MirPropertiesConfiguration extends ExtendedProperties { if (result.isAbsolute()) { return result; } - else { - return new File(home, path); - } + return new File(home, path); } /** diff --git a/source/mir/entity/AbstractEntity.java b/source/mir/entity/AbstractEntity.java index 72e98ec3..ee350740 100755 --- a/source/mir/entity/AbstractEntity.java +++ b/source/mir/entity/AbstractEntity.java @@ -36,15 +36,15 @@ import java.util.Map; import mir.config.MirPropertiesConfiguration; import mir.log.LoggerWrapper; +import mir.storage.Database; import mir.storage.StorageObjectExc; import mir.storage.StorageObjectFailure; -import mir.storage.Database; /** * Base class the entities are derived from. Provides base functionality of * an entity. * - * @version $Id: AbstractEntity.java,v 1.8.2.5 2005/01/23 15:36:02 zapata Exp $ + * @version $Id: AbstractEntity.java,v 1.8.2.6 2005/02/10 16:22:30 rhindes Exp $ */ public class AbstractEntity implements Entity { @@ -95,8 +95,7 @@ public class AbstractEntity implements Entity { if (database != null) { return database.insert(this); } - else - throw new StorageObjectExc("database == null!"); + throw new StorageObjectExc("database == null!"); } /** {@inheritDoc} */ diff --git a/source/mir/entity/Entity.java b/source/mir/entity/Entity.java index cac1e44a..df2cb9a4 100755 --- a/source/mir/entity/Entity.java +++ b/source/mir/entity/Entity.java @@ -29,17 +29,17 @@ */ package mir.entity; -import mir.storage.StorageObjectExc; -import mir.storage.StorageObjectFailure; - import java.util.List; import java.util.Map; +import mir.storage.StorageObjectExc; +import mir.storage.StorageObjectFailure; + /** * An Entity represents a persistent data object, typically * stored in a database.

* - * @version $Id: Entity.java,v 1.21.2.10 2005/01/23 15:36:02 zapata Exp $ + * @version $Id: Entity.java,v 1.21.2.11 2005/02/10 16:22:30 rhindes Exp $ */ public interface Entity { diff --git a/source/mir/entity/EntityBrowser.java b/source/mir/entity/EntityBrowser.java index c51d9c94..7d42057f 100755 --- a/source/mir/entity/EntityBrowser.java +++ b/source/mir/entity/EntityBrowser.java @@ -30,12 +30,11 @@ package mir.entity; +import java.util.List; + import mir.storage.Database; import mir.storage.StorageObjectFailure; import mir.util.RewindableIterator; - -import java.util.List; - import multex.Failure; public class EntityBrowser implements RewindableIterator { @@ -121,9 +120,7 @@ public class EntityBrowser implements RewindableIterator { return result; } - else { - return null; - } + return null; } catch (Throwable t) { throw new RuntimeException(t.getMessage()); diff --git a/source/mir/entity/EntityList.java b/source/mir/entity/EntityList.java index 7e3cc85f..700d85d8 100755 --- a/source/mir/entity/EntityList.java +++ b/source/mir/entity/EntityList.java @@ -29,6 +29,9 @@ */ package mir.entity; +import java.util.ArrayList; +import java.util.Set; + import mir.config.MirPropertiesConfiguration; import mir.log.LoggerWrapper; import mir.storage.Database; @@ -37,9 +40,6 @@ import mir.storage.store.StoreContainerType; import mir.storage.store.StoreIdentifier; import mir.storage.store.StoreUtil; -import java.util.ArrayList; -import java.util.Set; - /** * * Container class for lists of Entities. @@ -205,11 +205,9 @@ public class EntityList implements StorableObject { StoreUtil.getEntityListUniqueIdentifierFor( storage.getTableName(), whereClause, orderClause, offset, limit )); } - else { - logger.warn("EntityList could not return StoreIdentifier"); - - return null; - } + logger.warn("EntityList could not return StoreIdentifier"); + + return null; } } diff --git a/source/mir/entity/StorableObjectEntity.java b/source/mir/entity/StorableObjectEntity.java index 8749bc2d..3f2d6270 100755 --- a/source/mir/entity/StorableObjectEntity.java +++ b/source/mir/entity/StorableObjectEntity.java @@ -68,9 +68,8 @@ public class StorableObjectEntity extends AbstractEntity Class theEntityClass, String theTable, String id) { if (id == null) { return null; - } else { - return new StoreIdentifier(theEntityClass, id + "@" + theTable); } + return new StoreIdentifier(theEntityClass, id + "@" + theTable); } public static final StoreIdentifier getStoreIdentifier(Database theStorage, diff --git a/source/mir/entity/adapter/EntityAdapter.java b/source/mir/entity/adapter/EntityAdapter.java index ee997e27..0006328d 100755 --- a/source/mir/entity/adapter/EntityAdapter.java +++ b/source/mir/entity/adapter/EntityAdapter.java @@ -175,8 +175,7 @@ public class EntityAdapter implements Map { if (i.hasNext()) return (EntityAdapter) i.next(); - else - return null; + return null; } catch (Throwable t) { throw new RuntimeException(t.getMessage()); @@ -191,8 +190,7 @@ public class EntityAdapter implements Map { if (i.hasNext()) return (EntityAdapter) i.next(); - else - return null; + return null; } catch (Throwable t) { throw new RuntimeException(t.getMessage()); diff --git a/source/mir/entity/adapter/EntityAdapterDefinition.java b/source/mir/entity/adapter/EntityAdapterDefinition.java index 571df52e..9c95ab37 100755 --- a/source/mir/entity/adapter/EntityAdapterDefinition.java +++ b/source/mir/entity/adapter/EntityAdapterDefinition.java @@ -75,7 +75,7 @@ public class EntityAdapterDefinition { /** * * @param aFieldName - * @return + * @return boolean true if aFieldName is a calculated Field */ public boolean hasCalculatedField(String aFieldName) { return calculatedFields.containsKey(aFieldName); diff --git a/source/mir/entity/adapter/EntityAdapterModel.java b/source/mir/entity/adapter/EntityAdapterModel.java index 0c0a0940..b840bc66 100755 --- a/source/mir/entity/adapter/EntityAdapterModel.java +++ b/source/mir/entity/adapter/EntityAdapterModel.java @@ -29,12 +29,12 @@ */ package mir.entity.adapter; -import mir.entity.Entity; -import mir.storage.Database; - import java.util.HashMap; import java.util.Map; +import mir.entity.Entity; +import mir.storage.Database; + public class EntityAdapterModel { private Map entityAdapterMappings; diff --git a/source/mir/entity/adapter/EntityIteratorAdapter.java b/source/mir/entity/adapter/EntityIteratorAdapter.java index fbc6a01b..967809bb 100755 --- a/source/mir/entity/adapter/EntityIteratorAdapter.java +++ b/source/mir/entity/adapter/EntityIteratorAdapter.java @@ -81,5 +81,5 @@ public class EntityIteratorAdapter implements RewindableIterator { public void rewind() { iterator.rewind(); - }; + } } diff --git a/source/mir/generator/CompositeGeneratorLibrary.java b/source/mir/generator/CompositeGeneratorLibrary.java index 324363fc..1f4ce63a 100755 --- a/source/mir/generator/CompositeGeneratorLibrary.java +++ b/source/mir/generator/CompositeGeneratorLibrary.java @@ -66,11 +66,8 @@ public class CompositeGeneratorLibrary implements Generator.Library { return library.makeGenerator(qualifier); } - else { - if (defaultLibrary!=null) - return defaultLibrary.makeGenerator(anIdentifier); - else - throw new GeneratorExc("CompositeGeneratorLibrary: no default library speficied"); - } - }; + if (defaultLibrary!=null) + return defaultLibrary.makeGenerator(anIdentifier); + throw new GeneratorExc("CompositeGeneratorLibrary: no default library speficied"); + } } \ No newline at end of file diff --git a/source/mir/generator/FreemarkerGenerator.java b/source/mir/generator/FreemarkerGenerator.java index b774a1d8..576442a3 100755 --- a/source/mir/generator/FreemarkerGenerator.java +++ b/source/mir/generator/FreemarkerGenerator.java @@ -29,8 +29,8 @@ */ package mir.generator; -import java.io.PrintWriter; import java.io.File; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -38,6 +38,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import mir.log.LoggerWrapper; +import mir.util.GeneratorFormatAdapters; +import mir.util.RewindableIterator; + +import org.apache.commons.beanutils.MethodUtils; +import org.apache.commons.beanutils.PropertyUtils; + import freemarker.template.FileTemplateCache; import freemarker.template.SimpleScalar; import freemarker.template.Template; @@ -48,11 +55,6 @@ import freemarker.template.TemplateModel; import freemarker.template.TemplateModelException; import freemarker.template.TemplateModelRoot; import freemarker.template.TemplateScalarModel; -import mir.log.LoggerWrapper; -import mir.util.GeneratorFormatAdapters; -import mir.util.RewindableIterator; -import org.apache.commons.beanutils.MethodUtils; -import org.apache.commons.beanutils.PropertyUtils; public class FreemarkerGenerator implements Generator { @@ -198,7 +200,7 @@ public class FreemarkerGenerator implements Generator { { valuesCache.add(makeAdapter(iterator.next())); } - }; + } public TemplateModel get(int anIndex) throws TemplateModelException { TemplateModel result; @@ -211,8 +213,7 @@ public class FreemarkerGenerator implements Generator { return result; } - else - throw new TemplateModelException( "Iterator out of bounds" ); + throw new TemplateModelException( "Iterator out of bounds" ); } public boolean hasNext() { @@ -266,8 +267,8 @@ public class FreemarkerGenerator implements Generator { if (i>>ERROR POSITION<<< "); - } - catch (Throwable s) { - throw new TemplateProcessingException(s); - } - } - finally { - aDestination.append(destination); - } - } - else { - outerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); - } - } - - public String getPlainText() { - return body.getPlainText(); - } - - public void outerProcess(TALExpressionParser aParser, Object aContext, - StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, - TemplateLibrary aLibrary) throws TemplateProcessingException { - - Object oldAttributes = aParser.evaluatePseudoVariable(aContext, "tagattributes"); - aParser.processPseudoAssignment(aContext, "tagattributes", Collections.unmodifiableMap(fixedAttributes)); - - Object oldContent = aParser.evaluatePseudoVariable(aContext, "tagcontent"); - aParser.processPseudoAssignment(aContext, "tagcontent", body.getPlainText()); - - try { - Iterator i; - - i = definitions.iterator(); - while (i.hasNext()) { - Definition d = (Definition) i.next(); - aParser.processAssignment(aContext, d.getVariable(), d.getExpression()); - } - - if (condition == null || aParser.evaluateBooleanExpression(aContext, condition)) { - if (repeatExpression != null) { - i = aParser.evaluateListExpression(aContext, repeatExpression); - - while (i.hasNext()) { - aParser.processDirectAssignment(aContext, repeatVariable, i.next()); - innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); - } - } - else { - innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); - } - } - } - finally { - try { - aParser.processPseudoAssignment(aContext, "tagattributes", oldAttributes); - aParser.processPseudoAssignment(aContext, "tagcontent", oldContent); - } - catch (Throwable t) { - } - } - }; - - private void innerProcess(TALExpressionParser aParser, Object aContext, - StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, TemplateLibrary aLibrary) - throws TemplateProcessingException { - - boolean omitTag = false; - StringBuffer content = aDestination; - - if (omitTagExpression != null) - omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression); - - if (!omitTag) { - content = new StringBuffer(); - Map generatedAttributes = new HashMap(fixedAttributes); - - Iterator i = attributeModifiers.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - - generatedAttributes.put(entry.getKey(), aParser.evaluateStringExpression(aContext, entry.getValue())); - } - - aDestination.append("<"); - aDestination.append(tag); - - i = generatedAttributes.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - aDestination.append(" "); - aDestination.append(entry.getKey()); - aDestination.append("="); - aDestination.append("\""); - aDestination.append(HTMLRoutines.encodeHTML( (String) entry.getValue())); - aDestination.append("\""); - } - } - - try{ - if (contentExpression != null) { - content.append(aParser.evaluateStringExpression(aContext, contentExpression)); - } - else { - if (body != null) { - body.process(aParser, aContext, content, aLogger, aTemplateContext, aLibrary); - } - } - if (!omitTag) { - if (content.length()==0) { - aDestination.append(" />"); - } - else { - aDestination.append(">"); - aDestination.append(content); - aDestination.append(""); - } - } - } - catch (Throwable t) { - if (!omitTag) { - aDestination.append(content); - } - - if (t instanceof TemplateProcessingException) { - throw (TemplateProcessingException) t; - } - else if (t instanceof RuntimeException) { - throw (RuntimeException) t; - } - else throw new TemplateProcessingException(t.toString()); - } - } - } -} +/* + * 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.generator.tal.template; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import mir.generator.tal.interfaces.TALExpressionParser; +import mir.generator.tal.interfaces.TALLogger; +import mir.util.HTMLRoutines; +import mir.util.StringRoutines; +import mir.util.xml.XMLName; +import mir.util.xml.XMLParserExc; +import mir.util.xml.XMLReaderTool; + +public class CoreTemplateNodeLibrary implements TemplateNodeLibrary { + private String prefix; + private String uri; + + private boolean isOurTag(XMLName aName) { + return prefix.equals(aName.getPrefix()) || uri.equals(aName.getNamespaceURI()); + } + + public CoreTemplateNodeLibrary(String aPrefix, String aUri) { + prefix = aPrefix; + uri = aUri; + } + + private static final String CONDITION_ATTRIBUTE = "condition"; + private static final String REPEAT_ATTRIBUTE = "repeat"; + private static final String CONTENT_ATTRIBUTE = "content"; + private static final String ERROR_ATTRIBUTE = "on-error"; + private static final String REPLACE_ATTRIBUTE = "replace"; + private static final String DEFINITION_ATTRIBUTE = "define"; + private static final String OMITTAG_ATTRIBUTE = "omit-tag"; + private static final String ATTRIBUTE_ATTRIBUTE = "attributes"; + + public TemplateNode constructTemplateNode(TALExpressionParser aParser, XMLName aTag, Map anAttributes, + TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc { + TALBasicTemplateNode result = new TALBasicTemplateNode(XMLReaderTool.normalizeXMLName(aTag)); + result.setBody(aChildTemplateNode); + + if (isOurTag(aTag)) + result.setOmitTag(aParser.preparseTRUE()); + + Iterator i = anAttributes.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + XMLName name = (XMLName) entry.getKey(); + + if (!isOurTag(name)) { + result.addFixedAttribute(XMLReaderTool.normalizeXMLName(name), (String) entry.getValue()); + } + else { + if (name.getLocalName().equalsIgnoreCase(DEFINITION_ATTRIBUTE)) { + List definitions = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\'); + + Iterator j = definitions.iterator(); + while (j.hasNext()) + { + List parts = StringRoutines.separateString((String) j.next(), " "); + + if (parts.size()==2) { + result.addDefinition(aParser.preparseReferenceExpression((String) parts.get(0)), aParser.preparseExpression((String) parts.get(1))); + } + } + } + else if (name.getLocalName().equalsIgnoreCase(CONDITION_ATTRIBUTE)) { + result.setCondition(aParser.preparseBooleanExpression((String) entry.getValue())); + } + else if (name.getLocalName().equalsIgnoreCase(CONTENT_ATTRIBUTE)) { + result.setContent(aParser.preparseStringExpression((String) entry.getValue())); + } + else if (name.getLocalName().equalsIgnoreCase(ERROR_ATTRIBUTE)) { + result.setError(aParser.preparseStringExpression((String) entry.getValue())); + } + else if (name.getLocalName().equalsIgnoreCase(OMITTAG_ATTRIBUTE)) { + if (((String) entry.getValue()).trim().length()==0) + result.setOmitTag(aParser.preparseTRUE()); + else + result.setOmitTag(aParser.preparseBooleanExpression((String) entry.getValue())); + } + else if (name.getLocalName().equalsIgnoreCase(REPLACE_ATTRIBUTE)) { + result.setOmitTag(aParser.preparseTRUE()); + result.setContent(aParser.preparseStringExpression((String) entry.getValue())); + } + else if (name.getLocalName().equalsIgnoreCase(REPEAT_ATTRIBUTE)) { + List parts = StringRoutines.separateString((String) entry.getValue(), " "); + + if (parts.size()==2) { + result.setRepeat(aParser.preparseReferenceExpression((String) parts.get(0)), aParser.preparseExpression((String) parts.get(1))); + } + } + else if (name.getLocalName().equalsIgnoreCase(ATTRIBUTE_ATTRIBUTE)) { + List attributes = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\'); + + Iterator j = attributes.iterator(); + while (j.hasNext()) { + String value = (String) j.next(); + List parts = StringRoutines.separateString(value.trim(), " "); + + if (parts.size()==2) { + result.addModifiedAttribute((String) parts.get(0), aParser.preparseExpression((String) parts.get(1))); + } + else { + throw new XMLParserExc(ATTRIBUTE_ATTRIBUTE + " tag should have exactly 2 parts ("+value+")"); + } + } + } + } + } + + return result; + } + + public static class TALBasicTemplateNode implements TemplateNode { + private String tag; + private Map fixedAttributes; + private Map attributeModifiers; + + private List definitions; + private Object condition; + + private Object repeatVariable; + private Object repeatExpression; + private Object contentExpression; + private Object omitTagExpression; + private Object errorExpression; + + private TemplateNode body; + + public TALBasicTemplateNode(String aTag) { + tag = aTag; + + fixedAttributes = new HashMap(); + attributeModifiers = new HashMap(); + + definitions = new ArrayList(); + condition = null; + + repeatVariable = null; + repeatExpression = null; + contentExpression = null; + omitTagExpression = null; + + body = null; + } + + public void setBody(TemplateNode aBody) { + body = aBody; + } + + public void addFixedAttribute(String aKey, String aValue) { + fixedAttributes.put(aKey, aValue); + } + + public void addModifiedAttribute(String aKey, Object aValue) { + attributeModifiers.put(aKey, aValue); + } + + public void addDefinition(Object aKey, Object aValue) { + definitions.add(new Definition(aKey, aValue)); + } + + public void setCondition(Object aCondition) { + condition = aCondition; + } + + public void setRepeat(Object aRepeatVariable, Object aRepeatExpression) { + repeatVariable = aRepeatVariable; + repeatExpression = aRepeatExpression; + } + + public void setContent(Object aContentExpression) { + contentExpression = aContentExpression; + } + + public void setOmitTag(Object anOmitTagExpression) { + omitTagExpression = anOmitTagExpression; + } + + public void setError(Object anErrorExpression) { + errorExpression = anErrorExpression; + } + + public static class Definition { + private Object variable; + private Object expression; + + public Definition(Object aVariable, Object anExpression) { + variable = aVariable; + expression = anExpression; + } + + public Object getVariable() { + return variable; + } + + public Object getExpression() { + return expression; + } + } + + public void process(TALExpressionParser aParser, Object aContext, + StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, + TemplateLibrary aLibrary) throws TemplateProcessingException { + if (errorExpression != null) { + StringBuffer destination = new StringBuffer(); + + try { + outerProcess(aParser, aContext, destination, aLogger, aTemplateContext, aLibrary); + } + catch (Throwable t) { + try { +// destination.delete(0, destination.length()); + aParser.processPseudoAssignment(aContext, "exception", t); + destination.insert(0, aParser.evaluateStringExpression(aContext, errorExpression)); + destination.append(" >>>ERROR POSITION<<< "); + } + catch (Throwable s) { + throw new TemplateProcessingException(s); + } + } + finally { + aDestination.append(destination); + } + } + else { + outerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); + } + } + + public String getPlainText() { + return body.getPlainText(); + } + + public void outerProcess(TALExpressionParser aParser, Object aContext, + StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, + TemplateLibrary aLibrary) throws TemplateProcessingException { + + Object oldAttributes = aParser.evaluatePseudoVariable(aContext, "tagattributes"); + aParser.processPseudoAssignment(aContext, "tagattributes", Collections.unmodifiableMap(fixedAttributes)); + + Object oldContent = aParser.evaluatePseudoVariable(aContext, "tagcontent"); + aParser.processPseudoAssignment(aContext, "tagcontent", body.getPlainText()); + + try { + Iterator i; + + i = definitions.iterator(); + while (i.hasNext()) { + Definition d = (Definition) i.next(); + aParser.processAssignment(aContext, d.getVariable(), d.getExpression()); + } + + if (condition == null || aParser.evaluateBooleanExpression(aContext, condition)) { + if (repeatExpression != null) { + i = aParser.evaluateListExpression(aContext, repeatExpression); + + while (i.hasNext()) { + aParser.processDirectAssignment(aContext, repeatVariable, i.next()); + innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); + } + } + else { + innerProcess(aParser, aContext, aDestination, aLogger, aTemplateContext, aLibrary); + } + } + } + finally { + try { + aParser.processPseudoAssignment(aContext, "tagattributes", oldAttributes); + aParser.processPseudoAssignment(aContext, "tagcontent", oldContent); + } + catch (Throwable t) { + } + } + } + + private void innerProcess(TALExpressionParser aParser, Object aContext, + StringBuffer aDestination, TALLogger aLogger, Map aTemplateContext, TemplateLibrary aLibrary) + throws TemplateProcessingException { + + boolean omitTag = false; + StringBuffer content = aDestination; + + if (omitTagExpression != null) + omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression); + + if (!omitTag) { + content = new StringBuffer(); + Map generatedAttributes = new HashMap(fixedAttributes); + + Iterator i = attributeModifiers.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + + generatedAttributes.put(entry.getKey(), aParser.evaluateStringExpression(aContext, entry.getValue())); + } + + aDestination.append("<"); + aDestination.append(tag); + + i = generatedAttributes.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + aDestination.append(" "); + aDestination.append(entry.getKey()); + aDestination.append("="); + aDestination.append("\""); + aDestination.append(HTMLRoutines.encodeHTML( (String) entry.getValue())); + aDestination.append("\""); + } + } + + try{ + if (contentExpression != null) { + content.append(aParser.evaluateStringExpression(aContext, contentExpression)); + } + else { + if (body != null) { + body.process(aParser, aContext, content, aLogger, aTemplateContext, aLibrary); + } + } + if (!omitTag) { + if (content.length()==0) { + aDestination.append(" />"); + } + else { + aDestination.append(">"); + aDestination.append(content); + aDestination.append(""); + } + } + } + catch (Throwable t) { + if (!omitTag) { + aDestination.append(content); + } + + if (t instanceof TemplateProcessingException) { + throw (TemplateProcessingException) t; + } + else if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + else throw new TemplateProcessingException(t.toString()); + } + } + } +} diff --git a/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java b/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java index 1310c7ba..fce8d8eb 100755 --- a/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java +++ b/source/mir/generator/tal/template/MacroTemplateNodeLibrary.java @@ -29,18 +29,18 @@ */ package mir.generator.tal.template; -import java.util.Map; +import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.HashMap; +import java.util.Map; import mir.generator.tal.interfaces.TALExpressionParser; import mir.generator.tal.interfaces.TALLogger; +import mir.util.HTMLRoutines; +import mir.util.StringRoutines; import mir.util.xml.XMLName; import mir.util.xml.XMLParserExc; import mir.util.xml.XMLReaderTool; -import mir.util.StringRoutines; -import mir.util.HTMLRoutines; public class MacroTemplateNodeLibrary implements TemplateNodeLibrary { /** {@inheritDoc} */ diff --git a/source/mir/generator/tal/template/TemplateNodeLibrary.java b/source/mir/generator/tal/template/TemplateNodeLibrary.java index bdb85459..de57d158 100755 --- a/source/mir/generator/tal/template/TemplateNodeLibrary.java +++ b/source/mir/generator/tal/template/TemplateNodeLibrary.java @@ -1,49 +1,49 @@ -/* - * 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.generator.tal.template; - -import java.util.Map; - -import mir.util.xml.XMLName; -import mir.util.xml.XMLParserExc; -import mir.generator.tal.interfaces.TALExpressionParser; - -public interface TemplateNodeLibrary { - /** - * Construct a {@link TemplateNode} based on the tag and attributes given. - * - * @param anExpressionParser - * @param aTag - * @param anAttributes - * @param aChildTemplateNode - */ - public TemplateNode constructTemplateNode(TALExpressionParser anExpressionParser, - XMLName aTag, Map anAttributes, TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc; -} +/* + * 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.generator.tal.template; + +import java.util.Map; + +import mir.generator.tal.interfaces.TALExpressionParser; +import mir.util.xml.XMLName; +import mir.util.xml.XMLParserExc; + +public interface TemplateNodeLibrary { + /** + * Construct a {@link TemplateNode} based on the tag and attributes given. + * + * @param anExpressionParser + * @param aTag + * @param anAttributes + * @param aChildTemplateNode + */ + public TemplateNode constructTemplateNode(TALExpressionParser anExpressionParser, + XMLName aTag, Map anAttributes, TemplateNode aChildTemplateNode, Map aTemplateContext) throws XMLParserExc; +} diff --git a/source/mir/log/LoggerToWriterAdapter.java b/source/mir/log/LoggerToWriterAdapter.java index 018547d5..f7eab509 100755 --- a/source/mir/log/LoggerToWriterAdapter.java +++ b/source/mir/log/LoggerToWriterAdapter.java @@ -73,7 +73,7 @@ public class LoggerToWriterAdapter extends Writer { } lineBuffer.delete(0, from); - }; + } public void write(char[] aBuffer, int anOffset, int aLength) { lineBuffer.append(aBuffer, anOffset, aLength); diff --git a/source/mir/log/LoggerWrapper.java b/source/mir/log/LoggerWrapper.java index 749d9d23..436ed960 100755 --- a/source/mir/log/LoggerWrapper.java +++ b/source/mir/log/LoggerWrapper.java @@ -46,31 +46,31 @@ public class LoggerWrapper { public void debug( String aMessage ) { LoggerEngine.debug(object, aMessage); - }; + } public void info( String aMessage ) { LoggerEngine.info(object, aMessage); - }; + } public void warn( String aMessage ) { LoggerEngine.warn(object, aMessage); - }; + } public void warn(String aMessage, Throwable anException) { LoggerEngine.warn(object, aMessage, anException); - }; + } public void error( String aMessage ) { LoggerEngine.error(object, aMessage); - }; + } public void error(String aMessage, Throwable anException) { LoggerEngine.error(object, aMessage, anException); - }; + } public void fatal( String aMessage ) { LoggerEngine.fatal(object, aMessage); - }; + } public void message( int aType, String aMessage) { switch(aType) { diff --git a/source/mir/log/log4j/LoggerImpl.java b/source/mir/log/log4j/LoggerImpl.java index 99414998..582854d0 100755 --- a/source/mir/log/log4j/LoggerImpl.java +++ b/source/mir/log/log4j/LoggerImpl.java @@ -35,6 +35,7 @@ import java.util.Map; import mir.config.MirPropertiesConfiguration; import mir.log.LoggerExc; import mir.log.LoggerFailure; + import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; diff --git a/source/mir/misc/FileUtil.java b/source/mir/misc/FileUtil.java index 688d9514..9226914b 100755 --- a/source/mir/misc/FileUtil.java +++ b/source/mir/misc/FileUtil.java @@ -160,14 +160,7 @@ public final class FileUtil { public static long getSize(String filename) { File f = null; f = new File(filename); - long l = 0; - - if (f.exists()) { - return f.length(); - } - else { - return -1; - } + return f.exists() ? f.length():-1; } } diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java index f9c996a7..b05c748f 100755 --- a/source/mir/misc/StringUtil.java +++ b/source/mir/misc/StringUtil.java @@ -41,7 +41,7 @@ import java.util.TimeZone; /** * Statische Hilfsmethoden zur Stringbehandlung * - * @version $Id: StringUtil.java,v 1.33.2.5 2003/10/23 14:55:28 rk Exp $ + * @version $Id: StringUtil.java,v 1.33.2.6 2005/02/10 16:22:30 rhindes Exp $ * @author mir-coders group * */ @@ -195,11 +195,11 @@ public final class StringUtil { } /** - * Ersetzt in String s das Regexp pattern durch substitute - * @param s + * Replaces in haystack matching pattern by substitute + * @param haystack * @param pattern * @param substitute - * @return String mit den Ersetzungen + * @return String with replacements. */ public static String regexpReplace(String haystack, String pattern, String substitute) { try { @@ -305,28 +305,27 @@ public final class StringUtil { /** * this routine takes text in url format and makes * a clickaeble "" link removing any "illegal" html tags - * @param haystack, the url - * @param title, the href link text - * @param imagRoot, the place to find icons - * @param extImage, the url of the icon to show next to the link + * @param haystack the url + * @param title the href link text + * @param imageRoot the place to find icons + * @param extImage the url of the icon to show next to the link * @return a String containing the url */ public static String createURLLinks(String haystack, String title, String imageRoot,String extImage) { if (title == null) { return re_url.substituteAll(haystack," $0"); - } else { - title = removeHTMLTags(title); - return re_url.substituteAll(haystack," "+title+""); } + title = removeHTMLTags(title); + return re_url.substituteAll(haystack," "+title+""); } /** * this routine takes text in url format and makes * a clickaeble "" link removing any "illegal" html tags - * @param haystack, the url - * @param imageRoot, the place to find icons - * @param extImage, the url of the icon to show next to the link - * @param intImage, unused + * @param haystack the url + * @param imageRoot the place to find icons + * @param extImage the url of the icon to show next to the link + * @param intImage unused * @return a String containing the url */ public static String createURLLinks(String haystack, String title, String imageRoot,String extImage,String intImage) { diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java index 490a50d5..4b38727b 100755 --- a/source/mir/module/AbstractModule.java +++ b/source/mir/module/AbstractModule.java @@ -29,8 +29,8 @@ */ package mir.module; -import java.util.Map; import java.sql.SQLException; +import java.util.Map; import mir.entity.Entity; import mir.entity.EntityList; @@ -71,8 +71,7 @@ public class AbstractModule { if (entity == null) throw new ModuleExc("AbstractModule.getById: No object for id = " + id); - else - return entity; + return entity; } catch (Throwable e) { throw new ModuleFailure(e); diff --git a/source/mir/producer/AssignmentProducerNode.java b/source/mir/producer/AssignmentProducerNode.java index 32dcc175..13c47934 100755 --- a/source/mir/producer/AssignmentProducerNode.java +++ b/source/mir/producer/AssignmentProducerNode.java @@ -36,7 +36,6 @@ import mir.util.ParameterExpander; public class AssignmentProducerNode extends ProducerNodeDecorator { private String key; - private String bundleIdentifier; private Object value; public AssignmentProducerNode(String aKey, Object aValue, ProducerNode aSubNode) { @@ -55,5 +54,5 @@ public class AssignmentProducerNode extends ProducerNodeDecorator { catch (Throwable t) { throw new ProducerFailure(t.getMessage(), t); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/BundleProducerNode.java b/source/mir/producer/BundleProducerNode.java index f7f8cdb8..c86cdafb 100755 --- a/source/mir/producer/BundleProducerNode.java +++ b/source/mir/producer/BundleProducerNode.java @@ -78,6 +78,6 @@ public class BundleProducerNode implements ProducerNode { aLogger.error("Failed to load bundle " + bundleExpression + " for language " + languageExpression + " into key " + key + ": " + t.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/EntityBatchingProducerNode.java b/source/mir/producer/EntityBatchingProducerNode.java index cbf1e9a9..abdacc65 100755 --- a/source/mir/producer/EntityBatchingProducerNode.java +++ b/source/mir/producer/EntityBatchingProducerNode.java @@ -29,11 +29,11 @@ */ package mir.producer; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.ArrayList; import mir.entity.adapter.EntityAdapterModel; import mir.entity.adapter.EntityIteratorAdapter; @@ -213,7 +213,7 @@ public class EntityBatchingProducerNode implements ProducerNode { catch (Throwable t) { aLogger.error("EntityBatchingProducerNode caused an exception: " + t.getMessage()); } - }; + } private class BatchLocation { int nrEntities; diff --git a/source/mir/producer/EntityDeletingProducerNode.java b/source/mir/producer/EntityDeletingProducerNode.java index 630c70bc..b82cfe90 100755 --- a/source/mir/producer/EntityDeletingProducerNode.java +++ b/source/mir/producer/EntityDeletingProducerNode.java @@ -56,6 +56,6 @@ public class EntityDeletingProducerNode implements ProducerNode { catch (Throwable t) { aLogger.error("Error while deleting entities: " + t.toString()); } - }; + } } diff --git a/source/mir/producer/EntityEnumeratingProducerNode.java b/source/mir/producer/EntityEnumeratingProducerNode.java index ca4fef8e..0ff765ac 100755 --- a/source/mir/producer/EntityEnumeratingProducerNode.java +++ b/source/mir/producer/EntityEnumeratingProducerNode.java @@ -93,5 +93,5 @@ public class EntityEnumeratingProducerNode extends ProducerNodeDecorator { catch (Throwable t) { aLogger.error("Exception occurred inside an EntityEnumeratingProducerNode: " + t.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/EvaluatedAssignmentProducerNode.java b/source/mir/producer/EvaluatedAssignmentProducerNode.java index 8583b987..424c41db 100755 --- a/source/mir/producer/EvaluatedAssignmentProducerNode.java +++ b/source/mir/producer/EvaluatedAssignmentProducerNode.java @@ -37,7 +37,6 @@ import mir.util.ParameterExpander; public class EvaluatedAssignmentProducerNode implements ProducerNode { private String key; - private String bundleIdentifier; private String value; public EvaluatedAssignmentProducerNode(String aKey, String aValue) { @@ -56,5 +55,5 @@ public class EvaluatedAssignmentProducerNode implements ProducerNode { catch (Throwable t) { aLogger.error("key " + key + " could not be set to " + value + ": " + t.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/ExecuteProgramProducerNode.java b/source/mir/producer/ExecuteProgramProducerNode.java index 0c57a150..0b7ee74a 100755 --- a/source/mir/producer/ExecuteProgramProducerNode.java +++ b/source/mir/producer/ExecuteProgramProducerNode.java @@ -1,128 +1,128 @@ -/* - * 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.producer; - -import java.util.Map; - -import mir.log.LoggerWrapper; -import mir.util.ParameterExpander; - -public class ExecuteProgramProducerNode implements ProducerNode { - private String scriptExpression; - private String maxDurationExpression; - private String outputVariableExpression; - private String returnValueVariableExpression; - - public ExecuteProgramProducerNode(String aScriptExpression, String aMaxDurationExpression, String anOutputVariableExpression, - String aReturnValueVariableExpression) { - scriptExpression = aScriptExpression; - maxDurationExpression = aMaxDurationExpression; - outputVariableExpression = anOutputVariableExpression; - returnValueVariableExpression = aReturnValueVariableExpression; - } - - public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { - String script; - long maxDuration; - - try { - script = ParameterExpander.expandExpression(aValueMap, scriptExpression); - maxDuration = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, maxDurationExpression, 0); - - ProcessRunner runner = new ProcessRunner(aLogger, script); - runner.start(); - - synchronized (runner) { - runner.wait(maxDuration); - } - runner.interrupt(); - - if (runner.getFinished()) { - aLogger.info(script + " terminated successfully, return value = " + runner.getReturnValue() + "."); - - if (returnValueVariableExpression != null) { - ParameterExpander.setValueForKey(aValueMap, - ParameterExpander.expandExpression(aValueMap, returnValueVariableExpression), - new Integer(runner.getReturnValue())); - } - - } - else { - aLogger.info(script + " interrupted prematurely after " + maxDuration + "ms."); - } - } - catch (Throwable e) { - aLogger.error("Error while executing " + scriptExpression + " : " + e.toString()); - } - } - - private static class ProcessRunner extends Thread { - private String script; - private boolean finished = false; - private int returnValue = 0; - private LoggerWrapper logger; - - public ProcessRunner(LoggerWrapper aLogger, String aScript) { - script = aScript; - logger = aLogger; - } - - public boolean getFinished() { - return finished; - } - - public int getReturnValue() { - return returnValue; - } - - public void run() { - Process process = null; - try { - process = Runtime.getRuntime().exec(script); - returnValue = process.waitFor(); - - finished = true; - - synchronized (this) { - this.notify(); - } - } - catch (InterruptedException e) { - if (process!=null) { - process.destroy(); - } - } - catch (Exception e) { - logger.error(script + " failed to execute: " + e.getMessage()); - } - } - } - -} +/* + * 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.producer; + +import java.util.Map; + +import mir.log.LoggerWrapper; +import mir.util.ParameterExpander; + +public class ExecuteProgramProducerNode implements ProducerNode { + private String scriptExpression; + private String maxDurationExpression; + private String outputVariableExpression; + private String returnValueVariableExpression; + + public ExecuteProgramProducerNode(String aScriptExpression, String aMaxDurationExpression, String anOutputVariableExpression, + String aReturnValueVariableExpression) { + scriptExpression = aScriptExpression; + maxDurationExpression = aMaxDurationExpression; + outputVariableExpression = anOutputVariableExpression; + returnValueVariableExpression = aReturnValueVariableExpression; + } + + public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { + String script; + long maxDuration; + + try { + script = ParameterExpander.expandExpression(aValueMap, scriptExpression); + maxDuration = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, maxDurationExpression, 0); + + ProcessRunner runner = new ProcessRunner(aLogger, script); + runner.start(); + + synchronized (runner) { + runner.wait(maxDuration); + } + runner.interrupt(); + + if (runner.getFinished()) { + aLogger.info(script + " terminated successfully, return value = " + runner.getReturnValue() + "."); + + if (returnValueVariableExpression != null) { + ParameterExpander.setValueForKey(aValueMap, + ParameterExpander.expandExpression(aValueMap, returnValueVariableExpression), + new Integer(runner.getReturnValue())); + } + + } + else { + aLogger.info(script + " interrupted prematurely after " + maxDuration + "ms."); + } + } + catch (Throwable e) { + aLogger.error("Error while executing " + scriptExpression + " : " + e.toString()); + } + } + + private static class ProcessRunner extends Thread { + private String script; + private boolean finished = false; + private int returnValue = 0; + private LoggerWrapper logger; + + public ProcessRunner(LoggerWrapper aLogger, String aScript) { + script = aScript; + logger = aLogger; + } + + public boolean getFinished() { + return finished; + } + + public int getReturnValue() { + return returnValue; + } + + public void run() { + Process process = null; + try { + process = Runtime.getRuntime().exec(script); + returnValue = process.waitFor(); + + finished = true; + + synchronized (this) { + this.notify(); + } + } + catch (InterruptedException e) { + if (process!=null) { + process.destroy(); + } + } + catch (Exception e) { + logger.error(script + " failed to execute: " + e.getMessage()); + } + } + } + +} diff --git a/source/mir/producer/ExpandedAssignmentProducerNode.java b/source/mir/producer/ExpandedAssignmentProducerNode.java index 7d497a80..0fb8481e 100755 --- a/source/mir/producer/ExpandedAssignmentProducerNode.java +++ b/source/mir/producer/ExpandedAssignmentProducerNode.java @@ -36,7 +36,6 @@ import mir.util.ParameterExpander; public class ExpandedAssignmentProducerNode implements ProducerNode { private String key; - private String bundleIdentifier; private String value; public ExpandedAssignmentProducerNode(String aKey, String aValue) { @@ -55,5 +54,5 @@ public class ExpandedAssignmentProducerNode implements ProducerNode { catch (Throwable t) { aLogger.error("key " + key + " could not be set to " + value + ": " + t.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/ExternalDbProducerNode.java b/source/mir/producer/ExternalDbProducerNode.java index cfc1e51c..5c621d89 100755 --- a/source/mir/producer/ExternalDbProducerNode.java +++ b/source/mir/producer/ExternalDbProducerNode.java @@ -29,12 +29,15 @@ */ package mir.producer; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.sql.*; - import mir.log.LoggerWrapper; import mir.util.ExceptionFunctions; @@ -116,5 +119,5 @@ public class ExternalDbProducerNode extends ProducerNodeDecorator { Throwable s = ExceptionFunctions.traceCauseException(t); aLogger.error("Error while accessing external database: " + s.getClass().getName()+","+ s.getMessage()); } - }; + } } diff --git a/source/mir/producer/FreeQueryProducerNode.java b/source/mir/producer/FreeQueryProducerNode.java index 94e6f420..08b70ebf 100755 --- a/source/mir/producer/FreeQueryProducerNode.java +++ b/source/mir/producer/FreeQueryProducerNode.java @@ -95,6 +95,6 @@ public class FreeQueryProducerNode implements ProducerNode { catch (Throwable t) { aLogger.error("Error while setting key " + key + ": " + t.toString()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/ListEnumeratingProducerNode.java b/source/mir/producer/ListEnumeratingProducerNode.java index e9a68fc6..0a594166 100755 --- a/source/mir/producer/ListEnumeratingProducerNode.java +++ b/source/mir/producer/ListEnumeratingProducerNode.java @@ -75,5 +75,5 @@ public class ListEnumeratingProducerNode extends ProducerNodeDecorator { catch (Throwable t) { aLogger.error("Exception occurred inside an ListEnumeratingProducerNode: " + t.getMessage()); } - }; + } } diff --git a/source/mir/producer/LoopProducerNode.java b/source/mir/producer/LoopProducerNode.java index 43dcbffb..5b56b046 100755 --- a/source/mir/producer/LoopProducerNode.java +++ b/source/mir/producer/LoopProducerNode.java @@ -67,5 +67,5 @@ public class LoopProducerNode extends ProducerNodeDecorator { catch (Throwable t) { aLogger.error("LoopProducerNode raised an exception: " + t.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/NodedProducer.java b/source/mir/producer/NodedProducer.java index e4f3da1e..28a31f6a 100755 --- a/source/mir/producer/NodedProducer.java +++ b/source/mir/producer/NodedProducer.java @@ -62,7 +62,7 @@ public class NodedProducer implements Producer { isFinished=true; return !isAborted; } - }; + } public void abort() { synchronized(this) { diff --git a/source/mir/producer/ProducerFactory.java b/source/mir/producer/ProducerFactory.java index d3ca0188..dc8d7712 100755 --- a/source/mir/producer/ProducerFactory.java +++ b/source/mir/producer/ProducerFactory.java @@ -29,8 +29,8 @@ */ package mir.producer; -import java.util.Map; import java.util.List; +import java.util.Map; public interface ProducerFactory { public interface ProducerVerb { diff --git a/source/mir/producer/ProducerFailure.java b/source/mir/producer/ProducerFailure.java index 79a20c75..48728130 100755 --- a/source/mir/producer/ProducerFailure.java +++ b/source/mir/producer/ProducerFailure.java @@ -33,7 +33,8 @@ import multex.Failure; public class ProducerFailure extends Failure { - public ProducerFailure(String msg,Throwable cause) { + + public ProducerFailure(String msg,Throwable cause) { super(msg,cause); } diff --git a/source/mir/producer/RDFAggregatorProducerNode.java b/source/mir/producer/RDFAggregatorProducerNode.java index fe99ff66..02ce1596 100755 --- a/source/mir/producer/RDFAggregatorProducerNode.java +++ b/source/mir/producer/RDFAggregatorProducerNode.java @@ -83,5 +83,5 @@ public class RDFAggregatorProducerNode implements ProducerNode { Throwable s = ExceptionFunctions.traceCauseException(t); aLogger.error("Error while aggregating RDF data: " + s.getClass().getName()+","+ s.getMessage()); } - }; + } } diff --git a/source/mir/producer/RSSProducerNode.java b/source/mir/producer/RSSProducerNode.java index 9d62022a..fa2bef15 100755 --- a/source/mir/producer/RSSProducerNode.java +++ b/source/mir/producer/RSSProducerNode.java @@ -92,5 +92,5 @@ public class RSSProducerNode implements ProducerNode { Throwable s = ExceptionFunctions.traceCauseException(t); aLogger.error("Error while processing RSS data: " + s.getClass().getName()+","+ s.getMessage()); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/ValuesMapProducerNode.java b/source/mir/producer/ValuesMapProducerNode.java index d0dac9ee..e0a4ffcf 100755 --- a/source/mir/producer/ValuesMapProducerNode.java +++ b/source/mir/producer/ValuesMapProducerNode.java @@ -51,5 +51,5 @@ public class ValuesMapProducerNode extends ProducerNodeDecorator { catch (Throwable t) { throw new ProducerFailure(t.getMessage(), t); } - }; + } } \ No newline at end of file diff --git a/source/mir/producer/reader/DefaultProducerNodeBuilders.java b/source/mir/producer/reader/DefaultProducerNodeBuilders.java index c2f9a018..e0c80249 100755 --- a/source/mir/producer/reader/DefaultProducerNodeBuilders.java +++ b/source/mir/producer/reader/DefaultProducerNodeBuilders.java @@ -29,6 +29,7 @@ */ package mir.producer.reader; +import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -36,12 +37,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.io.File; import mir.entity.adapter.EntityAdapterModel; import mir.generator.Generator; import mir.generator.WriterEngine; import mir.log.LoggerWrapper; +import mir.producer.BundleProducerNode; import mir.producer.ConditionalProducerNode; import mir.producer.DirCopyingProducerNode; import mir.producer.EntityBatchingProducerNode; @@ -50,6 +51,7 @@ import mir.producer.EntityEnumeratingProducerNode; import mir.producer.EntityListProducerNode; import mir.producer.EntityModifyingProducerNode; import mir.producer.EvaluatedAssignmentProducerNode; +import mir.producer.ExecuteProgramProducerNode; import mir.producer.ExpandedAssignmentProducerNode; import mir.producer.ExternalDbProducerNode; import mir.producer.FileDateSettingProducerNode; @@ -62,8 +64,6 @@ import mir.producer.LoopProducerNode; import mir.producer.ProducerNode; import mir.producer.RDFAggregatorProducerNode; import mir.producer.RSSProducerNode; -import mir.producer.BundleProducerNode; -import mir.producer.ExecuteProgramProducerNode; import mir.util.StringRoutines; import mir.util.xml.XMLParserExc; import mir.util.xml.XMLReaderTool; @@ -119,11 +119,11 @@ public class DefaultProducerNodeBuilders { public void setSubNode(String aName, ProducerNode aNode) { subNodes.put(aName, aNode); - }; + } public Set getAvailableSubNodes() { return availableSubnodes; - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -162,11 +162,11 @@ public class DefaultProducerNodeBuilders { key = (String) anAttributes.get(ASSIGNMENT_KEY_ATTRIBUTE); value = (String) anAttributes.get(ASSIGNMENT_VALUE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new ExpandedAssignmentProducerNode(key, value); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -185,11 +185,11 @@ public class DefaultProducerNodeBuilders { key = (String) anAttributes.get(ASSIGNMENT_KEY_ATTRIBUTE); value = (String) anAttributes.get(ASSIGNMENT_VALUE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new EvaluatedAssignmentProducerNode(key, value); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -254,14 +254,13 @@ public class DefaultProducerNodeBuilders { if (parts.size() > 1) mainTablePrefix = (String) parts.get(1); } - }; + } public ProducerNode constructNode() { if (definition!=null) return new EntityEnumeratingProducerNode(key, model, mainTablePrefix, extraTables, definition, selection, order, limit, skip, getSubNode(ENUMERATION_DEFAULT_SUBNODE )); - else - return new ListEnumeratingProducerNode(key, list, getSubNode(ENUMERATION_DEFAULT_SUBNODE )); - }; + return new ListEnumeratingProducerNode(key, list, getSubNode(ENUMERATION_DEFAULT_SUBNODE )); + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -306,11 +305,10 @@ public class DefaultProducerNodeBuilders { fieldValues.putAll(anAttributes); fieldValues.remove(UPDATE_KEY_ATTRIBUTE); fieldValues.remove(UPDATE_DEFINITION_ATTRIBUTE); - }; - + } public ProducerNode constructNode() { return new EntityModifyingProducerNode(model, false, definition, key, fieldValues); - }; + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -357,11 +355,11 @@ public class DefaultProducerNodeBuilders { fieldValues.putAll(anAttributes); fieldValues.remove(CREATEENTITY_KEY_ATTRIBUTE); fieldValues.remove(CREATEENTITY_DEFINITION_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new EntityModifyingProducerNode(model, true, definition, key, fieldValues); - }; + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -398,11 +396,11 @@ public class DefaultProducerNodeBuilders { condition = (String) anAttributes.get(LOOP_CONDITION_ATTRIBUTE); limit = XMLReaderTool.getStringAttributeWithDefault(anAttributes, LOOP_LIMIT_ATTRIBUTE, ""); - }; + } public ProducerNode constructNode() { return new LoopProducerNode(condition, limit, getSubNode( LOOP_DEFAULT_SUBNODE )); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -449,11 +447,11 @@ public class DefaultProducerNodeBuilders { if (parts.size()>0) definition=(String)parts.get(0); if (parts.size()>1) mainTablePrefix=(String)parts.get(1); - }; + } public ProducerNode constructNode() { return new EntityListProducerNode(key, model, mainTablePrefix, extraTables, definition, selection, order, limit, skip, null ); - }; + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -493,11 +491,11 @@ public class DefaultProducerNodeBuilders { definition = (String) anAttributes.get(DELETEENTITY_DEFINITION_ATTRIBUTE); selection = XMLReaderTool.getStringAttributeWithDefault(anAttributes, DELETEENTITY_SELECTION_ATTRIBUTE, ""); - }; + } public ProducerNode constructNode() { return new EntityDeletingProducerNode(model, definition, selection); - }; + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -552,11 +550,11 @@ public class DefaultProducerNodeBuilders { } else type = LoggerWrapper.INFO_MESSAGE; - }; + } public ProducerNode constructNode() { return new LoggingProducerNode(message, type); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -604,11 +602,11 @@ public class DefaultProducerNodeBuilders { } else type = FreeQueryProducerNode.QUERY_TYPE_SET; - }; + } public ProducerNode constructNode() { return new FreeQueryProducerNode(key, query, limit, type); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -651,11 +649,11 @@ public class DefaultProducerNodeBuilders { username = (String) anAttributes.get(EXTDB_USERNAME_ATTRIBUTE); password = (String) anAttributes.get(EXTDB_PASSWORD_ATTRIBUTE); query = (String) anAttributes.get(EXTDB_QUERY_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new ExternalDbProducerNode(key, driver, host, port, database, username, password, query, getSubNode(EXTDB_DEFAULT_SUBNODE)); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -682,11 +680,11 @@ public class DefaultProducerNodeBuilders { key = (String) anAttributes.get(RESOURCEBUNDLE_KEY_ATTRIBUTE); bundle = (String) anAttributes.get(RESOURCEBUNDLE_BUNDLE_ATTRIBUTE); language = (String) anAttributes.get(RESOURCEBUNDLE_LANGUAGE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new BundleProducerNode(key, bundle, language); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -710,11 +708,11 @@ public class DefaultProducerNodeBuilders { fileNameKey = (String) anAttributes.get(FILEDATESETTING_FILE_ATTRIBUTE); dateKey = (String) anAttributes.get(FILEDATESETTING_DATE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new FileDateSettingProducerNode(fileNameKey, dateKey); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -735,11 +733,11 @@ public class DefaultProducerNodeBuilders { XMLReaderTool.checkAttributes(anAttributes, FILEDELETING_REQUIRED_ATTRIBUTES, FILEDELETING_OPTIONAL_ATTRIBUTES); fileNameKey = (String) anAttributes.get(FILEDELETING_FILE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new FileDeletingProducerNode(fileNameKey); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -769,12 +767,12 @@ public class DefaultProducerNodeBuilders { time = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_MAXTIME_ATTRIBUTE, null); resultvar = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_RESULTVAR_ATTRIBUTE, null); returnValueVar = XMLReaderTool.getStringAttributeWithDefault(anAttributes, EXECUTEPROGRAM_RETURNVALUE_ATTRIBUTE, null); - }; + } public ProducerNode constructNode() { return new ExecuteProgramProducerNode(command, time, resultvar, returnValueVar); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -803,11 +801,11 @@ public class DefaultProducerNodeBuilders { source = (String) anAttributes.get(DIRCOPY_SOURCE_ATTRIBUTE); destination = (String) anAttributes.get(DIRCOPY_DESTINATION_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new DirCopyingProducerNode(sourceBasePath, destinationBasePath, source, destination); - }; + } public static class factory implements ProducerNodeBuilderFactory { private File sourceBasePath; @@ -853,11 +851,11 @@ public class DefaultProducerNodeBuilders { generator = (String) anAttributes.get(GENERATION_GENERATOR_ATTRIBUTE); destination = (String) anAttributes.get(GENERATION_DESTINATION_ATTRIBUTE); parameters = XMLReaderTool.getStringAttributeWithDefault(anAttributes, GENERATION_PARAMETERS_ATTRIBUTE, "" ); - }; + } public ProducerNode constructNode() { return new GeneratingProducerNode(generatorLibrary, writerEngine, generator, destination, parameters); - }; + } public static class factory implements ProducerNodeBuilderFactory { private Generator.Library generatorLibrary; @@ -935,7 +933,7 @@ public class DefaultProducerNodeBuilders { List parts = StringRoutines.splitString(definition.trim(), " "); if (parts.size()>0) definition = (String) parts.get(0); if (parts.size()>1) mainTablePrefix = (String) parts.get(1); - }; + } public ProducerNode constructNode() { return new EntityBatchingProducerNode( @@ -954,7 +952,7 @@ public class DefaultProducerNodeBuilders { getSubNode( BATCHER_BATCH_SUBNODE ), getSubNode( BATCHER_BATCHLIST_SUBNODE ) ); - }; + } public static class factory implements ProducerNodeBuilderFactory { private EntityAdapterModel model; @@ -990,7 +988,7 @@ public class DefaultProducerNodeBuilders { XMLReaderTool.checkAttributes(anAttributes, IF_REQUIRED_ATTRIBUTES, IF_OPTIONAL_ATTRIBUTES); condition = (String) anAttributes.get( IF_CONDITION_ATTRIBUTE ); - }; + } public ProducerNode constructNode() { return new ConditionalProducerNode( @@ -998,7 +996,7 @@ public class DefaultProducerNodeBuilders { getSubNode( IF_TRUE_SUBNODE ), getSubNode( IF_FALSE_SUBNODE ) ); - }; + } } @@ -1030,11 +1028,11 @@ public class DefaultProducerNodeBuilders { url = (String) anAttributes.get( RSS_URL_ATTRIBUTE ); version = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RSS_VERSION_ATTRIBUTE, "1.0"); encoding = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RSS_ENCODING_ATTRIBUTE, null); - }; + } public ProducerNode constructNode() { return new RSSProducerNode(key, url, version, encoding); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -1065,11 +1063,11 @@ public class DefaultProducerNodeBuilders { source = (String) anAttributes.get( RDF_AGGREGATOR_SOURCE_ATTRIBUTE ); order = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_SOURCE_ATTRIBUTE, ""); filter = XMLReaderTool.getStringAttributeWithDefault(anAttributes, RDF_AGGREGATOR_FILTER_ATTRIBUTE, ""); - }; + } public ProducerNode constructNode() { return new RDFAggregatorProducerNode(key, source, order, filter); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -1084,20 +1082,20 @@ public class DefaultProducerNodeBuilders { } public void setSubNode(String aName, ProducerNode aNode) { - }; + } public Set getAvailableSubNodes() { return new HashSet(); - }; + } public void setAttributes(Map anAttributes) throws ProducerConfigExc { if (!anAttributes.isEmpty()) throw new ProducerConfigExc("No parameters allowed here"); - }; + } public ProducerNode constructNode() { return new ScriptedProducerNodeDefinition.NodeParameterProducerNode(scriptedNodeName, parameterName); - }; + } } //////////////////////////////////////////////////////////////////////////////// @@ -1122,11 +1120,11 @@ public class DefaultProducerNodeBuilders { public void setSubNode(String aName, ProducerNode aNode) { nodeParameterValues.put(aName, aNode); - }; + } public Set getAvailableSubNodes() { return definition.getNodeParameters(); - }; + } public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLParserExc { XMLReaderTool.checkAttributeSet(anAttributes.keySet(), definition.getRequiredAttributes(), definition.getOptionalAttributes()); @@ -1140,11 +1138,11 @@ public class DefaultProducerNodeBuilders { else stringParameterValues.put(entry.getKey(), entry.getValue()); } - }; + } public ProducerNode constructNode() { return new ScriptedProducerNode(definition, stringParameterValues, integerParameterValues, nodeParameterValues); - }; + } public static class factory implements ProducerNodeBuilderFactory { private ScriptedProducerNodeDefinition definition; diff --git a/source/mir/producer/reader/ProducerConfigReader.java b/source/mir/producer/reader/ProducerConfigReader.java index 631573f9..d39fbee0 100755 --- a/source/mir/producer/reader/ProducerConfigReader.java +++ b/source/mir/producer/reader/ProducerConfigReader.java @@ -54,7 +54,7 @@ public class ProducerConfigReader { public ProducerConfigReader() { super(); - }; + } public void parse(Reader aReader, ProducerNodeBuilderLibrary aBuilderLibrary, List aProducerFactories) throws ProducerConfigFailure { try { @@ -104,8 +104,7 @@ public class ProducerConfigReader { if (aTag.equals("producers")) { return new ProducersSectionHandler(producers); } - else - throw new XMLParserExc("Tag 'producers' expected, tag '"+aTag+"' found"); + throw new XMLParserExc("Tag 'producers' expected, tag '"+aTag+"' found"); } public void endElement(mir.util.xml.SectionHandler aHandler) { @@ -201,14 +200,12 @@ public class ProducerConfigReader { throw new XMLParserExc("Verbs already processed"); if (body!=null) throw new XMLParserExc("Verbs should come before body"); - else - return new ProducerVerbsSectionHandler(); + return new ProducerVerbsSectionHandler(); } else if (aTag.equals("body")) { if (body==null) return new ProducerNodeSectionHandler(); - else - throw new XMLParserExc("Body already processed"); + throw new XMLParserExc("Body already processed"); } throw new XMLParserExc("Unexpected tag: '"+aTag+"'"); } @@ -288,8 +285,7 @@ public class ProducerConfigReader { return new ProducerNodeSectionHandler(); } - else - throw new XMLParserExc("Only 'verb' tags allowed here, '" + aTag + "' encountered."); + throw new XMLParserExc("Only 'verb' tags allowed here, '" + aTag + "' encountered."); } public void endElement(mir.util.xml.SectionHandler aHandler) { @@ -472,9 +468,7 @@ public class ProducerConfigReader { if (producerNode.getNrSubNodes()==1) { return producerNode.getSubNode(0); } - else { - return producerNode; - } + return producerNode; } public void finishSection() { diff --git a/source/mir/producer/reader/ProducerNodeBuilderLibrary.java b/source/mir/producer/reader/ProducerNodeBuilderLibrary.java index bc9f2878..90d1a4f7 100755 --- a/source/mir/producer/reader/ProducerNodeBuilderLibrary.java +++ b/source/mir/producer/reader/ProducerNodeBuilderLibrary.java @@ -59,7 +59,6 @@ public class ProducerNodeBuilderLibrary { public ProducerNodeBuilder constructBuilder(String aName) throws ProducerConfigExc { if (hasBuilderForName(aName)) return ((ProducerNodeBuilder.ProducerNodeBuilderFactory) nodeBuilders.get(aName)).makeBuilder(); - else - throw new ProducerConfigExc("ProducerNodeBuilder: no builder with name '" + aName + "' found."); + throw new ProducerConfigExc("ProducerNodeBuilder: no builder with name '" + aName + "' found."); } } diff --git a/source/mir/producer/reader/ScriptedProducerFactory.java b/source/mir/producer/reader/ScriptedProducerFactory.java index 5825ae96..e870733c 100755 --- a/source/mir/producer/reader/ScriptedProducerFactory.java +++ b/source/mir/producer/reader/ScriptedProducerFactory.java @@ -84,7 +84,7 @@ public class ScriptedProducerFactory implements ProducerFactory { rootNode.addSubNode(body); return new NodedProducer(rootNode, aVerb, aStartingValues); - }; + } public List verbs() { return verbs; diff --git a/source/mir/rss/RSS091Reader.java b/source/mir/rss/RSS091Reader.java index 3a01811c..2b9a4d01 100755 --- a/source/mir/rss/RSS091Reader.java +++ b/source/mir/rss/RSS091Reader.java @@ -29,14 +29,18 @@ */ package mir.rss; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import mir.util.HTTPClientHelper; import mir.util.xml.XMLParserEngine; import mir.util.xml.XMLParserExc; import mir.util.xml.XMLParserFailure; -import java.io.InputStream; -import java.util.*; - /** * *

Title:

@@ -151,20 +155,19 @@ public class RSS091Reader { if (aTag.getLocalName().equals("rss")) { return new RSS091SectionHandler(data); } - else - throw new XMLParserFailure(new RSSExc("'rss' tag expected")); - }; + throw new XMLParserFailure(new RSSExc("'rss' tag expected")); + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } } private class RSS091SectionHandler extends mir.util.xml.AbstractSectionHandler { @@ -180,15 +183,15 @@ public class RSS091Reader { return new RSS091ChannelSectionHandler(data); else throw new XMLParserExc("channel tag expected, " + aTag.getLocalName() + " found"); - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } } private class RSS091ChannelSectionHandler extends mir.util.xml.AbstractSectionHandler { @@ -217,7 +220,7 @@ public class RSS091Reader { } else return new DiscardingSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof PCDATASectionHandler) { @@ -226,12 +229,12 @@ public class RSS091Reader { else if (aHandler instanceof RSS091ItemSectionHandler) { items.add((((RSS091ItemSectionHandler) aHandler).getItem())); } - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { Iterator i = items.iterator(); @@ -239,7 +242,7 @@ public class RSS091Reader { while (i.hasNext()) { data.addResource((RDFResource) i.next()); } - }; + } } private class RSS091ItemSectionHandler extends mir.util.xml.AbstractSectionHandler { @@ -259,20 +262,19 @@ public class RSS091Reader { currentTag=(String) mappedItemProperties.get(tag); return new PCDATASectionHandler(); } - else - return new DiscardingSectionHandler(); - }; + return new DiscardingSectionHandler(); + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof PCDATASectionHandler) { attributes.put(currentTag, (((PCDATASectionHandler) aHandler).getData())); } - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { item = new RDFResource("rss:item", (String) attributes.get("rss:link")); @@ -283,7 +285,7 @@ public class RSS091Reader { item.set((String) entry.getKey(), entry.getValue()); } - }; + } public RDFResource getItem() { return item; @@ -300,17 +302,17 @@ public class RSS091Reader { public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc { throw new XMLParserFailure(new RSSExc("No subtags allowed here")); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { data.append(aCharacters); - }; + } public void finishSection() throws XMLParserExc { - }; + } public String getData() { return data.toString(); @@ -334,16 +336,16 @@ public class RSS091Reader { } return new DiscardingSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { - }; + } public void finishSection() throws XMLParserExc { - }; + } public List getItems() { return items; @@ -353,15 +355,15 @@ public class RSS091Reader { private class DiscardingSectionHandler extends mir.util.xml.AbstractSectionHandler { public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc { return this; - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { - }; + } public void finishSection() throws XMLParserExc { - }; + } } } diff --git a/source/mir/rss/RSSData.java b/source/mir/rss/RSSData.java index d858aed0..e1aa6a98 100755 --- a/source/mir/rss/RSSData.java +++ b/source/mir/rss/RSSData.java @@ -29,10 +29,10 @@ */ package mir.rss; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.ArrayList; public class RSSData { private List resources; diff --git a/source/mir/rss/RSSReader.java b/source/mir/rss/RSSReader.java index ad2958a8..faff1ea8 100755 --- a/source/mir/rss/RSSReader.java +++ b/source/mir/rss/RSSReader.java @@ -172,20 +172,19 @@ public class RSSReader { if (aTag.getLocalName().equals("RDF")) { return new RDFSectionHandler(data); } - else - throw new XMLParserFailure(new RSSExc("'RDF' tag expected")); - }; + throw new XMLParserFailure(new RSSExc("'RDF' tag expected")); + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } } private class RDFSectionHandler extends mir.util.xml.AbstractSectionHandler { @@ -201,21 +200,21 @@ public class RSSReader { String rdfClass = makeQualifiedName(aTag); return new RDFResourceSectionHandler(rdfClass, identifier); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof RDFResourceSectionHandler) { data.addResource(((RDFResourceSectionHandler) aHandler).getResource()); } - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } } private mir.util.xml.SectionHandler makePropertyValueSectionHandler(mir.util.xml.XMLName aTag, Map anAttributes) { @@ -294,22 +293,22 @@ public class RSSReader { currentTag = aTag; return makePropertyValueSectionHandler(aTag, anAttributes); - }; + } 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).getFieldValue()); } - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } public RDFResource getResource() { if ((resource.getIdentifier()==null || resource.getIdentifier().length()==0) && resource.get("rss:link")!=null) { @@ -338,20 +337,20 @@ public class RSSReader { return new RDFSequenceSectionHandler(); else return new DiscardingSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof RDFSequenceSectionHandler) { structuredData= ((RDFSequenceSectionHandler) aHandler).getItems(); } - }; + } public void characters(String aCharacters) throws XMLParserExc { stringData.append(aCharacters); - }; + } public void finishSection() throws XMLParserExc { - }; + } public String getData() { return stringData.toString(); @@ -360,8 +359,7 @@ public class RSSReader { public Object getValue() { if (structuredData==null) return stringData.toString(); - else - return structuredData; + return structuredData; } } @@ -377,21 +375,21 @@ public class RSSReader { return new RDFSequenceSectionHandler(); else return new DiscardingSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { if (aHandler instanceof RDFSequenceSectionHandler) { items.addAll(((RDFSequenceSectionHandler) aHandler).getItems()); } - }; + } public void characters(String aCharacters) throws XMLParserExc { if (aCharacters.trim().length()>0) throw new XMLParserExc("No character data allowed here"); - }; + } public void finishSection() throws XMLParserExc { - }; + } public List getItems() { return items; @@ -411,17 +409,17 @@ public class RSSReader { public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc { throw new XMLParserFailure(new RSSExc("No subtags allowed here")); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { data.append(aCharacters); - }; + } public void finishSection() throws XMLParserExc { - }; + } public String getData() { return data.toString(); @@ -441,17 +439,17 @@ public class RSSReader { public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc { throw new XMLParserFailure(new RSSExc("No subtags allowed here")); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { data.append(aCharacters); - }; + } public void finishSection() throws XMLParserExc { - }; + } public Object getValue() { try { @@ -483,16 +481,16 @@ public class RSSReader { } return new DiscardingSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { - }; + } public void finishSection() throws XMLParserExc { - }; + } public List getItems() { return items; @@ -516,19 +514,19 @@ public class RSSReader { data.append("<"+tag+">"); return new RDFLiteralSectionHandler(); - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { data.append(((RDFLiteralSectionHandler) aHandler).getData()); data.append(""); - }; + } public void characters(String aCharacters) throws XMLParserExc { data.append(aCharacters); - }; + } public void finishSection() throws XMLParserExc { - }; + } public Object getValue() { return data.toString(); @@ -538,15 +536,15 @@ public class RSSReader { private class DiscardingSectionHandler extends mir.util.xml.AbstractSectionHandler { public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc { return this; - }; + } public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc { - }; + } public void characters(String aCharacters) throws XMLParserExc { - }; + } public void finishSection() throws XMLParserExc { - }; + } } } diff --git a/source/mir/servlet/ServletModule.java b/source/mir/servlet/ServletModule.java index b3a2d6c7..13553f3b 100755 --- a/source/mir/servlet/ServletModule.java +++ b/source/mir/servlet/ServletModule.java @@ -29,7 +29,13 @@ */ package mir.servlet; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -376,7 +382,7 @@ public abstract class ServletModule { catch (ModuleExc t) { throw new ServletModuleFailure(t); } - }; + } /** * Generic delete confirmation servlet method diff --git a/source/mir/session/CommonsUploadedFileAdapter.java b/source/mir/session/CommonsUploadedFileAdapter.java index 968c0042..8fcaf883 100755 --- a/source/mir/session/CommonsUploadedFileAdapter.java +++ b/source/mir/session/CommonsUploadedFileAdapter.java @@ -29,11 +29,11 @@ */ package mir.session; -import org.apache.commons.fileupload.FileItem; - import java.io.File; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.fileupload.FileItem; public class CommonsUploadedFileAdapter implements UploadedFile { private FileItem fileItem; @@ -72,5 +72,5 @@ public class CommonsUploadedFileAdapter implements UploadedFile { public String getContentType() { return fileItem.getContentType(); - }; + } } \ No newline at end of file diff --git a/source/mir/session/HTTPAdapters.java b/source/mir/session/HTTPAdapters.java index 78cd3620..cc16c218 100755 --- a/source/mir/session/HTTPAdapters.java +++ b/source/mir/session/HTTPAdapters.java @@ -29,13 +29,20 @@ */ package mir.session; -import java.util.*; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import mir.util.HTTPParsedRequest; + import org.apache.commons.fileupload.FileItem; public class HTTPAdapters { @@ -68,11 +75,11 @@ public class HTTPAdapters { } return request.getHeader(aHeaderName); - }; + } public String getParameter(String aName) { return request.getParameter(aName); - }; + } public List getPrefixedParameterNames(String aPrefix) { List result = new ArrayList(); @@ -86,15 +93,15 @@ public class HTTPAdapters { } return result; - }; + } public List getUploadedFiles() { return Collections.EMPTY_LIST; - }; + } public List getParameters(String aName) { return Arrays.asList(request.getParameterValues(aName)); - }; + } public HttpServletRequest getRequest() { return request; @@ -117,9 +124,7 @@ public class HTTPAdapters { if (headers.hasMoreElements()) { return (String) headers.nextElement(); } - else { - return request.getRequest().getRemoteAddr(); - } + return request.getRequest().getRemoteAddr(); } if (aHeaderName.equals("hostname")) { @@ -140,11 +145,11 @@ public class HTTPAdapters { public String getParameter(String aName) { return request.getParameter(aName); - }; + } public List getParameters(String aName) { return request.getParameterList(aName); - }; + } public List getPrefixedParameterNames(String aPrefix) { List result = new ArrayList(); @@ -157,9 +162,8 @@ public class HTTPAdapters { result.add(name); } } - return result; - }; + } public List getUploadedFiles() { List result = new ArrayList(); @@ -170,7 +174,7 @@ public class HTTPAdapters { } return result; - }; + } public HttpServletRequest getRequest() { return request.getRequest(); diff --git a/source/mir/session/ValidationHelper.java b/source/mir/session/ValidationHelper.java index 9ac7e085..83a31bce 100755 --- a/source/mir/session/ValidationHelper.java +++ b/source/mir/session/ValidationHelper.java @@ -50,8 +50,7 @@ public class ValidationHelper { aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource)); return false; } - else - return true; + return true; } /** diff --git a/source/mir/storage/Database.java b/source/mir/storage/Database.java index ea6d9876..0f886dbb 100755 --- a/source/mir/storage/Database.java +++ b/source/mir/storage/Database.java @@ -29,32 +29,52 @@ */ package mir.storage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; + import mir.config.MirPropertiesConfiguration; +import mir.entity.AbstractEntity; import mir.entity.Entity; import mir.entity.EntityList; import mir.entity.StorableObjectEntity; -import mir.entity.AbstractEntity; import mir.log.LoggerWrapper; import mir.misc.StringUtil; -import mir.storage.store.*; +import mir.storage.store.ObjectStore; +import mir.storage.store.StorableObject; +import mir.storage.store.StoreContainerType; +import mir.storage.store.StoreIdentifier; +import mir.storage.store.StoreUtil; import mir.util.JDBCStringRoutines; import mircoders.global.MirGlobal; -import java.io.*; -import java.sql.*; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - import org.apache.commons.dbcp.DelegatingConnection; import org.postgresql.PGConnection; -import org.postgresql.largeobject.LargeObjectManager; import org.postgresql.largeobject.LargeObject; +import org.postgresql.largeobject.LargeObjectManager; /** * Implements database access. * - * @version $Id: Database.java,v 1.44.2.26 2005/01/23 15:36:03 zapata Exp $ + * @version $Id: Database.java,v 1.44.2.27 2005/02/10 16:22:33 rhindes Exp $ * @author rk * */ @@ -882,7 +902,8 @@ public class Database { con.setAutoCommit(true); } catch (Exception e) { - ; + + } freeConnection(con, pstmt); @@ -1041,7 +1062,7 @@ public class Database { freeConnection(connection, statement); } } - }; + } /** * Executes 1 sql statement and returns the first result row as a Maps @@ -1053,8 +1074,7 @@ public class Database { try { if (resultList.size()>0) return (Map) resultList.get(0); - else - return null; + return null; } finally { } @@ -1062,7 +1082,7 @@ public class Database { catch (Throwable t) { throw new StorageObjectFailure(t); } - }; + } /** * Executes 1 sql statement and returns the first column of the first result row as a Strings @@ -1077,9 +1097,8 @@ public class Database { Iterator i = row.values().iterator(); if (i.hasNext()) return (String) i.next(); - else - return null; - }; + return null; + } public int getSize(String where) throws SQLException, StorageObjectFailure { return getSize("", null, where); diff --git a/source/mir/storage/StorageObjectFailure.java b/source/mir/storage/StorageObjectFailure.java index c1b7aca1..3b946b9e 100755 --- a/source/mir/storage/StorageObjectFailure.java +++ b/source/mir/storage/StorageObjectFailure.java @@ -53,8 +53,8 @@ public class StorageObjectFailure extends Failure { } /** - * Construktor with message - * @param String msg + * Constructor with message + * @param msg */ public StorageObjectFailure(String msg, Throwable e) { super(msg, e); diff --git a/source/mir/storage/store/ObjectStore.java b/source/mir/storage/store/ObjectStore.java index 0c65b1c9..8c3a7f4a 100755 --- a/source/mir/storage/store/ObjectStore.java +++ b/source/mir/storage/store/ObjectStore.java @@ -63,6 +63,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.MissingResourceException; + import javax.servlet.http.HttpServletRequest; import mir.config.MirPropertiesConfiguration; diff --git a/source/mir/storage/store/StoreContainer.java b/source/mir/storage/store/StoreContainer.java index dafe1419..e1a455fa 100755 --- a/source/mir/storage/store/StoreContainer.java +++ b/source/mir/storage/store/StoreContainer.java @@ -67,7 +67,7 @@ public class StoreContainer { protected LoggerWrapper logger = new LoggerWrapper("Database.ObjectStore"); // avoid construction without parameters - private StoreContainer() {}; + private StoreContainer() {} public StoreContainer(StoreContainerType stoc_type) { @@ -183,7 +183,7 @@ public class StoreContainer { /** * Method: toString() * Description: gives out statistical Information, viewable via - * @see ServletStoreInfo. + * @see ServletStoreInfo * * @return String */ diff --git a/source/mir/storage/store/test/EntityC1.java b/source/mir/storage/store/test/EntityC1.java index 96273dec..837fb528 100755 --- a/source/mir/storage/store/test/EntityC1.java +++ b/source/mir/storage/store/test/EntityC1.java @@ -65,6 +65,6 @@ public class EntityC1 implements StorableObject { // simulates a relation to EntityC2 with uniqueIdentifier "1" notifiees.add(new StoreIdentifier(EntityC2.class,"1")); notifiees.add(new StoreIdentifier(EntityC2.class,"18")); - return (Set)notifiees; + return notifiees; } } \ No newline at end of file diff --git a/source/mir/util/CachingRewindableIterator.java b/source/mir/util/CachingRewindableIterator.java index 1bbfc0a8..0678e746 100755 --- a/source/mir/util/CachingRewindableIterator.java +++ b/source/mir/util/CachingRewindableIterator.java @@ -67,5 +67,5 @@ public class CachingRewindableIterator implements RewindableIterator { public void rewind() { iterationPosition=0; - }; + } } \ No newline at end of file diff --git a/source/mir/util/DateTimeFunctions.java b/source/mir/util/DateTimeFunctions.java index f89ef89d..4eff7486 100755 --- a/source/mir/util/DateTimeFunctions.java +++ b/source/mir/util/DateTimeFunctions.java @@ -45,6 +45,15 @@ public class DateTimeFunctions { private DateTimeFunctions() { } + + private final static String SPACE = "[\t\n\r ]*"; + private final static String NUMBER = "[0-9]*"; + private final static String TWODIGITNUMBER = "[0-9][0-9]"; + private final static String FOURDIGITNUMBER = "[0-9][0-9][0-9][0-9]"; + private final static String FRACTION = "(\\.[0-9]*)|)"; + private final static String SIGN = "[-+]"; + private final static String TZD = "(Z|(+|-)([0-9][0-9]:[0-9][0-9]|[0-9][0-9][0-9][0-9]))"; + /** * Function to parse a W3CDTF formatted string. * @@ -52,16 +61,8 @@ public class DateTimeFunctions { * YYYY[-MM[-DD[Thh:mm[:ss[.s*]]TZD]]] * * @param aString - * @return + * @return Date */ - private final static String SPACE = "[\t\n\r ]*"; - private final static String NUMBER = "[0-9]*"; - private final static String TWODIGITNUMBER = "[0-9][0-9]"; - private final static String FOURDIGITNUMBER = "[0-9][0-9][0-9][0-9]"; - private final static String FRACTION = "(\\.[0-9]*)|)"; - private final static String SIGN = "[-+]"; - private final static String TZD = "(Z|(+|-)([0-9][0-9]:[0-9][0-9]|[0-9][0-9][0-9][0-9]))"; - public static Date parseW3CDTFString(String aString) throws UtilExc, UtilFailure { try { int year = 1; diff --git a/source/mir/util/FileFunctions.java b/source/mir/util/FileFunctions.java index c9e6a109..476451c8 100755 --- a/source/mir/util/FileFunctions.java +++ b/source/mir/util/FileFunctions.java @@ -29,13 +29,20 @@ */ package mir.util; -import java.io.*; +import gnu.regexp.RE; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import java.util.Collections; import java.util.List; -import gnu.regexp.RE; - public class FileFunctions { protected static final int FILE_COPY_BUFFER_SIZE = 65536; @@ -146,7 +153,7 @@ public class FileFunctions { inputStream.close(); } aSource.delete(); - }; + } } public static class RegExpFileFilter implements FilenameFilter { @@ -179,8 +186,7 @@ public class FileFunctions { Object[] contents = aDirectory.list(aFilter); if (contents==null) return Collections.EMPTY_LIST; - else - return Arrays.asList(contents); + return Arrays.asList(contents); } public static String getExtension(String aPath) { @@ -188,9 +194,7 @@ public class FileFunctions { if (position>=0) { return aPath.substring(position+1); } - else { - return ""; - } + return ""; } public static boolean isAbsolutePath(String aPath) { @@ -201,8 +205,6 @@ public class FileFunctions { if (isAbsolutePath(aPath)) { return new File(aPath); } - else { - return new File(aParentIfRelative, aPath); - } + return new File(aParentIfRelative, aPath); } } \ No newline at end of file diff --git a/source/mir/util/GeneratorDateTimeFunctions.java b/source/mir/util/GeneratorDateTimeFunctions.java index d7d88beb..36a8d11a 100755 --- a/source/mir/util/GeneratorDateTimeFunctions.java +++ b/source/mir/util/GeneratorDateTimeFunctions.java @@ -90,7 +90,7 @@ public class GeneratorDateTimeFunctions { catch (Throwable t) { throw new GeneratorFailure("encodeURIGeneratorFunction: " + t.getMessage(), t); } - }; + } } diff --git a/source/mir/util/GeneratorFormatAdapters.java b/source/mir/util/GeneratorFormatAdapters.java index becea34c..7c7f5a39 100755 --- a/source/mir/util/GeneratorFormatAdapters.java +++ b/source/mir/util/GeneratorFormatAdapters.java @@ -72,7 +72,7 @@ public class GeneratorFormatAdapters { catch (Throwable t) { throw new GeneratorFailure("NumberFormattingFunction: " + t.getMessage(), t); } - }; + } } } @@ -149,7 +149,7 @@ public class GeneratorFormatAdapters { catch (Throwable t) { throw new GeneratorFailure("DateFormattingFunction: " + t.getMessage(), t); } - }; + } } /** diff --git a/source/mir/util/HTTPParsedRequest.java b/source/mir/util/HTTPParsedRequest.java index 3d9d96ff..881db9c3 100755 --- a/source/mir/util/HTTPParsedRequest.java +++ b/source/mir/util/HTTPParsedRequest.java @@ -29,13 +29,23 @@ */ package mir.util; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + import mir.log.LoggerWrapper; + import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; -import javax.servlet.http.HttpServletRequest; -import java.util.*; - public class HTTPParsedRequest { static final String MULTIPART_FORMDATA_CONTENTTYPE = "multipart/form-data"; diff --git a/source/mir/util/HTTPRequestParser.java b/source/mir/util/HTTPRequestParser.java index 46954688..a24c468d 100755 --- a/source/mir/util/HTTPRequestParser.java +++ b/source/mir/util/HTTPRequestParser.java @@ -31,9 +31,10 @@ package mir.util; import java.util.ArrayList; -import java.util.List; import java.util.Collections; +import java.util.List; import java.util.Map; + import javax.servlet.http.HttpServletRequest; public class HTTPRequestParser { diff --git a/source/mir/util/InternetFunctions.java b/source/mir/util/InternetFunctions.java index 2260d4db..a510aa30 100755 --- a/source/mir/util/InternetFunctions.java +++ b/source/mir/util/InternetFunctions.java @@ -31,8 +31,8 @@ package mir.util; -import java.util.List; import java.net.InetAddress; +import java.util.List; public class InternetFunctions { private InternetFunctions() { diff --git a/source/mir/util/ParameterExpander.java b/source/mir/util/ParameterExpander.java index e397f6f3..3077611a 100755 --- a/source/mir/util/ParameterExpander.java +++ b/source/mir/util/ParameterExpander.java @@ -29,14 +29,19 @@ */ package mir.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import mir.generator.Generator; import mir.generator.GeneratorExc; import multex.Exc; + import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.beanutils.PropertyUtils; -import java.util.*; - /** * Class to work with expressions. Will be gradually phased out and replaced * with {@link mir.util.expressions.ExpressionParser} @@ -263,25 +268,25 @@ public class ParameterExpander { private static abstract class Token { } - public static abstract class PunctuationToken extends Token { public PunctuationToken() { }; } - private static class LeftSquareBraceToken extends PunctuationToken {}; - private static class RightSquareBraceToken extends PunctuationToken {}; - private static class EqualsToken extends PunctuationToken {}; - private static class EqualsNotToken extends PunctuationToken {}; - private static class NOTToken extends PunctuationToken {}; - private static class LeftParenthesisToken extends PunctuationToken {}; - private static class RightParenthesisToken extends PunctuationToken {}; - private static class CommaToken extends PunctuationToken {}; - private static class PeriodToken extends PunctuationToken {}; - private static class PlusToken extends PunctuationToken {}; - private static class TimesToken extends PunctuationToken {}; - private static class DivideToken extends PunctuationToken {}; - private static class MinusToken extends PunctuationToken {}; - private static class ConcatenateToken extends PunctuationToken {}; - private static class LessThanOrEqualsToken extends PunctuationToken {}; - private static class GreaterThanOrEqualsToken extends PunctuationToken {}; - private static class LessThanToken extends PunctuationToken {}; - private static class GreaterThanToken extends PunctuationToken {}; + public static abstract class PunctuationToken extends Token { public PunctuationToken() { } } + private static class LeftSquareBraceToken extends PunctuationToken {} + private static class RightSquareBraceToken extends PunctuationToken {} + private static class EqualsToken extends PunctuationToken {} + private static class EqualsNotToken extends PunctuationToken {} + private static class NOTToken extends PunctuationToken {} + private static class LeftParenthesisToken extends PunctuationToken {} + private static class RightParenthesisToken extends PunctuationToken {} + private static class CommaToken extends PunctuationToken {} + private static class PeriodToken extends PunctuationToken {} + private static class PlusToken extends PunctuationToken {} + private static class TimesToken extends PunctuationToken {} + private static class DivideToken extends PunctuationToken {} + private static class MinusToken extends PunctuationToken {} + private static class ConcatenateToken extends PunctuationToken {} + private static class LessThanOrEqualsToken extends PunctuationToken {} + private static class GreaterThanOrEqualsToken extends PunctuationToken {} + private static class LessThanToken extends PunctuationToken {} + private static class GreaterThanToken extends PunctuationToken {} private static class IdentifierToken extends Token { @@ -443,7 +448,7 @@ public class ParameterExpander { public void skipWhitespace() { while (reader.hasNext() && Character.isWhitespace(reader.peek().charValue())) reader.getNext(); - }; + } private boolean isIdentifierStart(char c) { return Character.isLetter(c) || (c == '_'); diff --git a/source/mir/util/PropertiesManipulator.java b/source/mir/util/PropertiesManipulator.java index 0044577e..a820f57b 100755 --- a/source/mir/util/PropertiesManipulator.java +++ b/source/mir/util/PropertiesManipulator.java @@ -35,7 +35,11 @@ import java.io.LineNumberReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import multex.Exc; import multex.Failure; diff --git a/source/mir/util/ReflectionRoutines.java b/source/mir/util/ReflectionRoutines.java index b15014f9..df34672b 100755 --- a/source/mir/util/ReflectionRoutines.java +++ b/source/mir/util/ReflectionRoutines.java @@ -1,60 +1,60 @@ -/* - * 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 org.apache.commons.beanutils.MethodUtils; - -import java.lang.reflect.InvocationTargetException; - -public class ReflectionRoutines { - private ReflectionRoutines() { - } - - /** - * Method to overcome a shortcoming in {@link org.apache.commons.beanutils}'s - * {@link MethodUtils#invokeMethod(Object, String, Object[])} involving - * parameters that are null - */ - public static Object invokeMethod(Object aTarget, String aMethodName, Object[] aParameters) - throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class parameterTypes[] = new Class[aParameters.length]; - - for (int i=0; inull + */ + public static Object invokeMethod(Object aTarget, String aMethodName, Object[] aParameters) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class parameterTypes[] = new Class[aParameters.length]; + + for (int i=0; iTitle:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @author not attributable - * @version 1.0 - */ - -public abstract class AbstractSectionHandler implements SectionHandler { - public void extra(String anExtraData) throws XMLParserExc, XMLParserFailure { - } - - public SectionHandler startElement(XMLName aTag, java.util.Map anAttributes) throws XMLParserExc{ - return startElement(aTag.getLocalName(), XMLReaderTool.convertXMLAttributeMap(anAttributes)); - }; - - public SectionHandler startElement(String aLocalName, java.util.Map anAttributes) throws XMLParserExc{ - return new AbstractSectionHandler() {}; - }; - - public void endElement(SectionHandler aHandler) throws XMLParserExc{ - }; - - public void startSection() throws XMLParserExc{ - } - - public void finishSection() throws XMLParserExc{ - } - - public void characters(String aCharacters) throws XMLParserExc{ - if ( aCharacters.trim().length() > 0) { - throw new XMLParserExc("Text not allowed"); - } - } -} +package mir.util.xml; + +/** + * + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @author not attributable + * @version 1.0 + */ + +public abstract class AbstractSectionHandler implements SectionHandler { + public void extra(String anExtraData) throws XMLParserExc, XMLParserFailure { + } + + public SectionHandler startElement(XMLName aTag, java.util.Map anAttributes) throws XMLParserExc{ + return startElement(aTag.getLocalName(), XMLReaderTool.convertXMLAttributeMap(anAttributes)); + } + + public SectionHandler startElement(String aLocalName, java.util.Map anAttributes) throws XMLParserExc{ + return new AbstractSectionHandler() {}; + } + + public void endElement(SectionHandler aHandler) throws XMLParserExc{ + } + + public void startSection() throws XMLParserExc{ + } + + public void finishSection() throws XMLParserExc{ + } + + public void characters(String aCharacters) throws XMLParserExc{ + if ( aCharacters.trim().length() > 0) { + throw new XMLParserExc("Text not allowed"); + } + } +} diff --git a/source/mir/util/xml/XMLName.java b/source/mir/util/xml/XMLName.java index a9f60582..173bc016 100755 --- a/source/mir/util/xml/XMLName.java +++ b/source/mir/util/xml/XMLName.java @@ -1,88 +1,86 @@ -package mir.util.xml; - -/** - * Class to encapsulate an XML-style name (either for tagnames, - * or attribute names). - * - *

- * Usage requirements: - *

    - *
  • Namespace aware parsers must supply a local name - * and a namespace URI - *
  • Non-namespace aware parsers should supply a local name, - * and, if present and applicable, also a prefix - *
- */ - -public class XMLName { - private String namespaceURI; - private String localName; - private String prefix; - - public XMLName(String aLocalName) { - this(null, null, aLocalName); - } - - public XMLName(String aNamespaceURI, String aPrefix, String aLocalName) { - localName=""; - prefix=""; - namespaceURI=""; - - if (aLocalName!=null) - localName = aLocalName; - if (aPrefix!=null) - prefix = aPrefix; - if (aNamespaceURI!=null) - namespaceURI = aNamespaceURI; - } - - public XMLName(String aNamespaceURI, String aLocalName) { - this (aNamespaceURI, null, aLocalName); - } - - /** - * Returns the namespace URI if available - */ - public String getNamespaceURI() { - return namespaceURI; - } - - /** - * Returns the name of the tag, stripped from prefix - */ - public String getLocalName() { - return localName; - } - - /** - * Returns the prefix of the tag, if present - */ - public String getPrefix() { - return prefix; - } - - public int hashCode() { - if (namespaceURI == null) - return localName.hashCode() + 3*prefix.hashCode(); - else - return localName.hashCode() + 3*namespaceURI.hashCode(); - } - - public String toString() { - return ((namespaceURI.length()>0)? "["+namespaceURI+"]":"")+((prefix.length()>0)?prefix+":":"")+localName; - } - - public boolean equals(Object anObject) { - if (anObject instanceof mir.util.xml.XMLName) { - if (namespaceURI==null) - return (((mir.util.xml.XMLName) anObject).namespaceURI == null) && - prefix.equals(((mir.util.xml.XMLName) anObject).prefix) && - localName.equals(((mir.util.xml.XMLName) anObject).localName); - else - return namespaceURI.equals(((mir.util.xml.XMLName) anObject).namespaceURI) && - localName.equals(((mir.util.xml.XMLName) anObject).localName); - } - else - return false; - } -} +package mir.util.xml; + +/** + * Class to encapsulate an XML-style name (either for tagnames, + * or attribute names). + * + *

+ * Usage requirements: + *

    + *
  • Namespace aware parsers must supply a local name + * and a namespace URI + *
  • Non-namespace aware parsers should supply a local name, + * and, if present and applicable, also a prefix + *
+ */ + +public class XMLName { + private String namespaceURI; + private String localName; + private String prefix; + + public XMLName(String aLocalName) { + this(null, null, aLocalName); + } + + public XMLName(String aNamespaceURI, String aPrefix, String aLocalName) { + localName=""; + prefix=""; + namespaceURI=""; + + if (aLocalName!=null) + localName = aLocalName; + if (aPrefix!=null) + prefix = aPrefix; + if (aNamespaceURI!=null) + namespaceURI = aNamespaceURI; + } + + public XMLName(String aNamespaceURI, String aLocalName) { + this (aNamespaceURI, null, aLocalName); + } + + /** + * Returns the namespace URI if available + */ + public String getNamespaceURI() { + return namespaceURI; + } + + /** + * Returns the name of the tag, stripped from prefix + */ + public String getLocalName() { + return localName; + } + + /** + * Returns the prefix of the tag, if present + */ + public String getPrefix() { + return prefix; + } + + public int hashCode() { + if (namespaceURI == null) + return localName.hashCode() + 3*prefix.hashCode(); + return localName.hashCode() + 3*namespaceURI.hashCode(); + } + + public String toString() { + return ((namespaceURI.length()>0)? "["+namespaceURI+"]":"")+((prefix.length()>0)?prefix+":":"")+localName; + } + + public boolean equals(Object anObject) { + if (anObject instanceof mir.util.xml.XMLName) { + if (namespaceURI==null) + return (((mir.util.xml.XMLName) anObject).namespaceURI == null) && + prefix.equals(((mir.util.xml.XMLName) anObject).prefix) && + localName.equals(((mir.util.xml.XMLName) anObject).localName); + else + return namespaceURI.equals(((mir.util.xml.XMLName) anObject).namespaceURI) && + localName.equals(((mir.util.xml.XMLName) anObject).localName); + } + return false; + } +} diff --git a/source/mir/util/xml/XMLParserEngine.java b/source/mir/util/xml/XMLParserEngine.java index ee70a134..9b4d9286 100755 --- a/source/mir/util/xml/XMLParserEngine.java +++ b/source/mir/util/xml/XMLParserEngine.java @@ -31,16 +31,15 @@ package mir.util.xml; import java.io.BufferedInputStream; +import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import java.io.StringReader; -import java.io.File; -import java.io.Reader; import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; - import java.util.Stack; import mir.util.ExceptionFunctions; diff --git a/source/mir/util/xml/XMLParserFailure.java b/source/mir/util/xml/XMLParserFailure.java index b96d4511..e6c0b66d 100755 --- a/source/mir/util/xml/XMLParserFailure.java +++ b/source/mir/util/xml/XMLParserFailure.java @@ -1,20 +1,25 @@ -package mir.util.xml; - -/** - * - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @author not attributable - * @version 1.0 - */ -public class XMLParserFailure extends multex.Failure { - public XMLParserFailure(String aMessage, Throwable aCause) { - super(aMessage, aCause); - } - - public XMLParserFailure(Throwable aCause) { - super(aCause.getMessage(), aCause); - } -} +package mir.util.xml; + +/** + * + *

Title:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @author not attributable + * @version 1.0 + */ +public class XMLParserFailure extends multex.Failure { + /** + * Comment for serialVersionUID + */ + private static final long serialVersionUID = 1L; + + public XMLParserFailure(String aMessage, Throwable aCause) { + super(aMessage, aCause); + } + + public XMLParserFailure(Throwable aCause) { + super(aCause.getMessage(), aCause); + } +} diff --git a/source/mir/util/xml/XMLReaderTool.java b/source/mir/util/xml/XMLReaderTool.java index fb4859db..84fa8b41 100755 --- a/source/mir/util/xml/XMLReaderTool.java +++ b/source/mir/util/xml/XMLReaderTool.java @@ -120,8 +120,7 @@ public class XMLReaderTool { if (parts.size()==1) return (String) parts.get(0); - else - return (String) parts.get(1); + return (String) parts.get(1); } /** diff --git a/source/mir/util/xml/XMLSAXParserProvider.java b/source/mir/util/xml/XMLSAXParserProvider.java index 0e8a8514..c5ee60ab 100755 --- a/source/mir/util/xml/XMLSAXParserProvider.java +++ b/source/mir/util/xml/XMLSAXParserProvider.java @@ -1,160 +1,161 @@ -package mir.util.xml; - -import java.util.*; - -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.Locator; -import org.xml.sax.SAXParseException; -import mir.util.ExceptionFunctions; - -/** - * - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @author not attributable - * @version 1.0 - */ -class XMLSAXParserProvider implements XMLParserEngine.XMLParserProvider { - private boolean nameSpaceAware; - - public XMLSAXParserProvider(boolean aNameSpaceAware) { - nameSpaceAware = aNameSpaceAware; - } - - public void parse(java.io.Reader aReader, XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure { - try { - javax.xml.parsers.SAXParserFactory parserFactory = javax.xml.parsers.SAXParserFactory.newInstance(); - - parserFactory.setNamespaceAware(true); - parserFactory.setValidating(true); - javax.xml.parsers.SAXParser parser = parserFactory.newSAXParser(); - - parser.parse(new InputSource(aReader), new SAXHandler(aReceiver)); - } - catch (org.xml.sax.SAXException e) { - Throwable t = ExceptionFunctions.traceCauseException(e); - - if (t instanceof XMLParserExc) { - throw (XMLParserExc) t; - } - - if (t instanceof XMLParserFailure) { - throw (XMLParserFailure) t; - } - - if (t instanceof SAXParseException) { - throw new XMLParserExc(t.getMessage()); - } - - throw new XMLParserFailure(t); - } - catch (Throwable t) { - throw new XMLParserFailure(t); - } - } - - private class SAXHandler extends org.xml.sax.helpers.DefaultHandler { - private XMLParserEngine.XMLParserReceiver receiver; - - public SAXHandler(XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure { - super(); - - receiver = aReceiver; - receiver.startDocument(); - } - - public void setDocumentLocator(final Locator aLocator) { - receiver.setLocator( - new XMLParserEngine.XMLLocator() { - public int getLineNr() { - return aLocator.getLineNumber(); - } - - public int getColumnNr() { - return aLocator.getColumnNumber(); - } - } - ); - } - - public void startElement(String aUri, String aLocalName, String aQualifiedName, org.xml.sax.Attributes anAttributes) throws org.xml.sax.SAXException { - try { - Map attributes = new java.util.HashMap(); - - XMLName tag; - if (nameSpaceAware) { - tag = new XMLName(aUri, XMLReaderTool.getPrefixFromQualifiedName(aQualifiedName), aLocalName); - for (int i=0; iTitle:

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @author not attributable + * @version 1.0 + */ +class XMLSAXParserProvider implements XMLParserEngine.XMLParserProvider { + private boolean nameSpaceAware; + + public XMLSAXParserProvider(boolean aNameSpaceAware) { + nameSpaceAware = aNameSpaceAware; + } + + public void parse(java.io.Reader aReader, XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure { + try { + javax.xml.parsers.SAXParserFactory parserFactory = javax.xml.parsers.SAXParserFactory.newInstance(); + + parserFactory.setNamespaceAware(true); + parserFactory.setValidating(true); + javax.xml.parsers.SAXParser parser = parserFactory.newSAXParser(); + + parser.parse(new InputSource(aReader), new SAXHandler(aReceiver)); + } + catch (org.xml.sax.SAXException e) { + Throwable t = ExceptionFunctions.traceCauseException(e); + + if (t instanceof XMLParserExc) { + throw (XMLParserExc) t; + } + + if (t instanceof XMLParserFailure) { + throw (XMLParserFailure) t; + } + + if (t instanceof SAXParseException) { + throw new XMLParserExc(t.getMessage()); + } + + throw new XMLParserFailure(t); + } + catch (Throwable t) { + throw new XMLParserFailure(t); + } + } + + private class SAXHandler extends org.xml.sax.helpers.DefaultHandler { + private XMLParserEngine.XMLParserReceiver receiver; + + public SAXHandler(XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure { + super(); + + receiver = aReceiver; + receiver.startDocument(); + } + + public void setDocumentLocator(final Locator aLocator) { + receiver.setLocator( + new XMLParserEngine.XMLLocator() { + public int getLineNr() { + return aLocator.getLineNumber(); + } + + public int getColumnNr() { + return aLocator.getColumnNumber(); + } + } + ); + } + + public void startElement(String aUri, String aLocalName, String aQualifiedName, org.xml.sax.Attributes anAttributes) throws org.xml.sax.SAXException { + try { + Map attributes = new java.util.HashMap(); + + XMLName tag; + if (nameSpaceAware) { + tag = new XMLName(aUri, XMLReaderTool.getPrefixFromQualifiedName(aQualifiedName), aLocalName); + for (int i=0; i"); - } - catch (XMLParserExc e) { - throw new HTMLParserFailure(e); - } - } - - public void cdata(String aData) { - try { - aReceiver.text(aData); - } - catch (XMLParserExc e) { - throw new HTMLParserFailure(e); - } - } - }); - - aReceiver.endDocument(); - } - catch (IOException e) { - throw new XMLParserFailure(e); - } - catch (HTMLParserExc e) { - throw new XMLParserFailure(e); - } - } -} +package mir.util.xml.html; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import mir.util.xml.XMLName; +import mir.util.xml.XMLParserEngine; +import mir.util.xml.XMLParserExc; +import mir.util.xml.XMLParserFailure; +import mir.util.xml.XMLReaderTool; + +/** + */ + +public class XMLHTMLParserProvider implements XMLParserEngine.XMLParserProvider { + public XMLHTMLParserProvider() { + } + + public void parse(java.io.Reader aReader, final XMLParserEngine.XMLParserReceiver aReceiver) throws XMLParserExc, XMLParserFailure { + HTMLParser parser = new HTMLParser(); + + try { + aReceiver.startDocument(); + + parser.parse(aReader, new HTMLParser.ParserReceiver() { + public void dtd(String aDTD) throws HTMLParserExc { + try { + aReceiver.extra(aDTD); + } + catch (XMLParserExc t) { + throw new HTMLParserFailure(t); + } + } + + public void openTag(String aTag, Map anAttributes) { + Map attributes = new HashMap(); + Iterator i = anAttributes.entrySet().iterator(); + + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + XMLName key = XMLReaderTool.getXMLNameForQualifiedName((String) entry.getKey()); + String value = (String) entry.getValue(); + if (value==null) + value = key.getLocalName(); + + attributes.put(key, value); + } + + try { + aReceiver.startElement(XMLReaderTool.getXMLNameForQualifiedName(aTag), attributes); + } + catch (XMLParserExc e) { + throw new HTMLParserFailure(e); + } + } + + public void closeTag(String aTag) { + try { + aReceiver.endElement(XMLReaderTool.getXMLNameForQualifiedName(aTag)); + } + catch (XMLParserExc e) { + throw new HTMLParserFailure(e); + } + } + + public void comment(String aData) { + try { + aReceiver.extra(""); + } + catch (XMLParserExc e) { + throw new HTMLParserFailure(e); + } + } + + public void cdata(String aData) { + try { + aReceiver.text(aData); + } + catch (XMLParserExc e) { + throw new HTMLParserFailure(e); + } + } + }); + + aReceiver.endDocument(); + } + catch (IOException e) { + throw new XMLParserFailure(e); + } + catch (HTMLParserExc e) { + throw new XMLParserFailure(e); + } + } +} diff --git a/source/mircoders/abuse/FilterEngine.java b/source/mircoders/abuse/FilterEngine.java index 7a61c852..56c72168 100755 --- a/source/mircoders/abuse/FilterEngine.java +++ b/source/mircoders/abuse/FilterEngine.java @@ -1,453 +1,460 @@ -/* - * 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 mircoders.abuse; - -import mir.entity.Entity; -import mir.entity.adapter.EntityAdapter; -import mir.entity.adapter.EntityAdapterModel; -import mir.entity.adapter.EntityIteratorAdapter; -import mir.log.LoggerWrapper; -import mir.storage.StorageObjectExc; -import mir.session.Request; -import mir.config.MirPropertiesConfiguration; -import mircoders.storage.DatabaseFilter; -import mircoders.storage.DatabaseFilterGroup; -import mircoders.global.MirGlobal; - -import java.util.*; -import java.text.SimpleDateFormat; - -public class FilterEngine { - private Map filterTypes; - private List filterTypeIds; - - private List filterGroups; - private Map idToFilterGroup; - private LoggerWrapper logger; - private EntityAdapterModel model; - private SimpleDateFormat dateFormat; - private MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance(); - - public FilterEngine(EntityAdapterModel aModel) { - logger = new LoggerWrapper("Global.Abuse.FilterEngine"); - filterGroups = new ArrayList(); - idToFilterGroup = new HashMap(); - - filterTypes = new HashMap(); - filterTypeIds = new ArrayList(); - try { - Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator(); - while (i.hasNext()) { - FilterType filterType = (FilterType) i.next(); - - filterTypes.put(filterType.getName(), filterType); - filterTypeIds.add(filterType.getName()); - } - } - catch (Throwable t) { - throw new RuntimeException(t.getMessage()); - } - - model = aModel; - - dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setTimeZone(TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone"))); - reload(); - } - - public Filter testPosting(Entity anEntity, Request aRequest) { - Iterator i = filterGroups.iterator(); - while (i.hasNext()) { - FilterGroup group = (FilterGroup) i.next(); - Iterator j = group.getFilters().iterator(); - while (j.hasNext()) { - Filter filter = (Filter) j.next(); - try { - if (filter.test(anEntity, aRequest)) { - return filter; - } - } - catch (Throwable t) { - logger.warn("Exception thrown while testing filter " + filter.getType() + " ( " + filter.getExpression() + ") " + t.toString()); - } - } - } - - return null; - } - - public List getFilterTypes() { - try { - List result = new ArrayList(); - - Iterator i = filterTypeIds.iterator(); - while (i.hasNext()) { - String id = (String) i.next(); - - Map action = new HashMap(); - action.put("resource", id); - action.put("identifier", id); - - result.add(action); - } - - return result; - } - catch (Throwable t) { - throw new RuntimeException("can't get article actions"); - } - } - - public class FilterGroup { - private List filters; - private Entity entity; - private Map idToFilter; - - public FilterGroup(Entity anEntity) { - this (anEntity, Collections.EMPTY_LIST); - } - - public FilterGroup(Entity anEntity, List aFilters) { - entity = anEntity; - filters = new ArrayList(); - idToFilter = new HashMap(); - Iterator i = aFilters.iterator(); - - while (i.hasNext()) { - Entity entity = (Entity) i.next(); - try { - Filter filter = new Filter(entity); - introduceFilter(filter); - } - catch (AbuseExc e) { - } - } - } - - public Entity getEntity() { - return entity; - } - - public EntityAdapter getEntityAdapter() { - return model.makeEntityAdapter("filterGroup", entity); - } - - public List getFilterEntityAdapterList() { - List result = new ArrayList(); - - Iterator i = filters.iterator(); - while (i.hasNext()) { - Filter filter = (Filter) i.next(); - result.add(filter.getEntityAdapter()); - } - - return result; - } - - public List getFilters() { - return filters; - } - - public Filter getFilterForId(String anId) { - Filter result = (Filter) idToFilter.get(anId); - if (result==null) { - throw new NullPointerException("No such filter"); - } - - return result; - } - - private void introduceFilter(Filter aFilter) { - filters.add(aFilter); - idToFilter.put(aFilter.getEntity().getId(), aFilter); - } - - private void removeFilter(Filter aFilter) { - filters.remove(aFilter); - idToFilter.remove(aFilter.getEntity().getId()); - } - - private void deleteFilter(String anId) { - Filter filter = getFilterForId(anId); - removeFilter(filter); - DatabaseFilter.getInstance().delete(anId); - } - - public void populateFilterEntity(Entity anEntity, String aType, String anExpression, - String aComments, String aTag, String anArticleAction, - String aCommentAction) { - - anEntity.setFieldValue("type", aType); - anEntity.setFieldValue("expression", anExpression); - anEntity.setFieldValue("comment", aComments); - anEntity.setFieldValue("tag", aTag); - anEntity.setFieldValue("articleaction", anArticleAction); - anEntity.setFieldValue("commentaction", aCommentAction); - } - - public String updateFilter(String anId, String aType, String anExpression, - String aComments, String aTag, String anArticleAction, - String aCommentAction) { - - try { - getFilterTypeForId(aType).constructFilterInstance(anExpression); - } - catch (AbuseExc e) { - return e.getMessage(); - } - - Entity entity = getFilterForId(anId).getEntity(); - populateFilterEntity(entity, aType, anExpression, aComments, aTag, - anArticleAction, aCommentAction); - entity.update(); - - return ""; - } - - public String createFilter(String aType, String anExpression, - String aComments, String aTag, String anArticleAction, - String aCommentAction) throws StorageObjectExc { - FilterInstance instance; - - try { - instance = getFilterTypeForId(aType).constructFilterInstance(anExpression); - } - catch (AbuseExc e) { - return e.getMessage(); - } - - Entity entity = DatabaseFilter.getInstance().createNewEntity(); - populateFilterEntity(entity, aType, anExpression, aComments, aTag, - anArticleAction, aCommentAction); - entity.setFieldValue("priority", "1"); - entity.setFieldValue("filter_group_id", getEntity().getId()); - entity.insert(); - - Filter filter = new Filter(entity, instance); - introduceFilter(filter); - - return ""; - } - - public String getName() { - return entity.getFieldValue("name"); - } - } - - public class Filter { - private Entity entity; - private FilterInstance instance; - - public Filter(Entity anEntity) throws AbuseExc { - this(anEntity, getFilterTypeForId(anEntity.getFieldValue("type")).constructFilterInstance(anEntity.getFieldValue("expression"))); - } - - public Filter(Entity anEntity, FilterInstance anInstance) { - entity = anEntity; - instance = anInstance; - } - - public Entity getEntity() { - return entity; - } - - public EntityAdapter getEntityAdapter() { - return model.makeEntityAdapter("filter", entity); - } - - public void update(String aType, String anExpression, String aComments, String aTag, - String anArticleAction, String aCommentAction) throws AbuseExc { - - instance = getFilterTypeForId(aType).constructFilterInstance(anExpression); - - entity.setFieldValue("type", aType); - entity.setFieldValue("expression", anExpression); - entity.setFieldValue("tag", aType); - entity.setFieldValue("comment", aComments); - entity.setFieldValue("articleaction", anArticleAction); - entity.setFieldValue("commentaction", aCommentAction); - entity.setFieldValue("last_hit", null); - entity.update(); - } - - public void updateLastHit(Date aDate) { - entity.setFieldValue("last_hit", dateFormat.format(aDate)); - entity.update(); - } - - public String getType() { - return entity.getFieldValue("type"); - } - - public String getExpression() { - return entity.getFieldValue("expression"); - } - - public String getTag() { - return entity.getFieldValue("tag"); - } - - public String getComment() { - return entity.getFieldValue("comment"); - } - - public String getArticleAction() { - return entity.getFieldValue("articleaction"); - } - - public String getCommentAction() { - return entity.getFieldValue("commentaction"); - } - - public FilterInstance getInstance() { - return instance; - } - - public boolean test(Entity anEntity, Request aRequest) { - return instance.test(anEntity, aRequest); - } - } - - public synchronized void reload() { - filterGroups.clear(); - idToFilterGroup.clear(); - - try { - Iterator i = new EntityIteratorAdapter("", "priority asc", 100, model, "filterGroup"); - while (i.hasNext()) { - EntityAdapter entityAdapter = (EntityAdapter) i.next(); - List filters = new ArrayList(); - Iterator j = (Iterator) entityAdapter.get("to_filters"); - while (j.hasNext()) { - filters.add(((EntityAdapter) j.next()).getEntity()); - } - - FilterGroup filterGroup = new FilterGroup(entityAdapter.getEntity(), filters); - introduceFilterGroup(filterGroup); - } - } - catch (Throwable e) { - logger.error("Can't load filters: " + e.getMessage()); - } - } - - public synchronized List getFilterGroups() { - List result = new ArrayList(); - Iterator i = filterGroups.iterator(); - while (i.hasNext()) { - result.add(((FilterGroup) i.next()).getEntityAdapter()); - } - - return result; - } - - public synchronized void updateFilterGroup(String anId, String aName) { - FilterGroup filterGroup = getFilterGroupForId(anId); - filterGroup.getEntity().setFieldValue("name", aName); - filterGroup.getEntity().update(); - } - - public synchronized void addFilterGroup(String aName) throws StorageObjectExc { - Entity entity = DatabaseFilterGroup.getInstance().createNewEntity(); - entity.setFieldValue("name", aName); - entity.setFieldValue("priority", "1"); - entity.insert(); - - FilterGroup filterGroup = new FilterGroup(entity); - introduceFilterGroup(filterGroup); - } - - public synchronized void deleteFilterGroup(String anId) { - - FilterGroup filterGroup = getFilterGroupForId(anId); - removeFilterGroup(filterGroup); - DatabaseFilter.getInstance().deleteByWhereClause("filter_group_id = " + anId); - DatabaseFilterGroup.getInstance().delete(anId); - } - - public synchronized void deleteFilter(String aGroupId, String anId) { - getFilterGroupForId(aGroupId).deleteFilter(anId); - } - - - public synchronized String updateFilter(String aGroupId, String anId, - String aType, String anExpression, - String aComments, - String aTag, - String anArticleAction, - String aCommentAction) { - return getFilterGroupForId(aGroupId).updateFilter(anId, aType, - anExpression, aComments, aTag, anArticleAction, aCommentAction); - } - - public synchronized String addFilter(String aGroupId, - String aType, String anExpression, - String aComments, - String aTag, - String anArticleAction, - String aCommentAction) throws StorageObjectExc { - return getFilterGroupForId(aGroupId).createFilter(aType, anExpression, - aComments, aTag, anArticleAction, aCommentAction); - } - - - public FilterGroup getFilterGroupForId(String anId) { - FilterGroup result = (FilterGroup) idToFilterGroup.get(anId); - if (result == null) { - throw new NullPointerException("No such filter group"); - } - - return result; - } - - public Filter getFilterForId(String aGroupId, String anId) { - return getFilterGroupForId(aGroupId).getFilterForId(anId); - } - - - public List getFilters(String aFilterGroupId) { - return getFilterGroupForId(aFilterGroupId).getFilterEntityAdapterList(); - } - - private void introduceFilterGroup(FilterGroup aFilterGroup) { - filterGroups.add(aFilterGroup); - idToFilterGroup.put(aFilterGroup.getEntity().getId(), aFilterGroup); - } - - private void removeFilterGroup(FilterGroup aFilterGroup) { - filterGroups.remove(aFilterGroup); - idToFilterGroup.remove(aFilterGroup.getEntity().getId()); - } - - private FilterType getFilterTypeForId(String anId) { - return (FilterType) filterTypes.get(anId); - } -} +/* + * 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 mircoders.abuse; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; + +import mir.config.MirPropertiesConfiguration; +import mir.entity.Entity; +import mir.entity.adapter.EntityAdapter; +import mir.entity.adapter.EntityAdapterModel; +import mir.entity.adapter.EntityIteratorAdapter; +import mir.log.LoggerWrapper; +import mir.session.Request; +import mir.storage.StorageObjectExc; +import mircoders.global.MirGlobal; +import mircoders.storage.DatabaseFilter; +import mircoders.storage.DatabaseFilterGroup; + +public class FilterEngine { + private Map filterTypes; + private List filterTypeIds; + + private List filterGroups; + private Map idToFilterGroup; + private LoggerWrapper logger; + private EntityAdapterModel model; + private SimpleDateFormat dateFormat; + private MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance(); + + public FilterEngine(EntityAdapterModel aModel) { + logger = new LoggerWrapper("Global.Abuse.FilterEngine"); + filterGroups = new ArrayList(); + idToFilterGroup = new HashMap(); + + filterTypes = new HashMap(); + filterTypeIds = new ArrayList(); + try { + Iterator i = MirGlobal.localizer().openPostings().getAntiAbuseFilterTypes().iterator(); + while (i.hasNext()) { + FilterType filterType = (FilterType) i.next(); + + filterTypes.put(filterType.getName(), filterType); + filterTypeIds.add(filterType.getName()); + } + } + catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + + model = aModel; + + dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(TimeZone.getTimeZone(configuration.getString("Mir.DefaultTimezone"))); + reload(); + } + + public Filter testPosting(Entity anEntity, Request aRequest) { + Iterator i = filterGroups.iterator(); + while (i.hasNext()) { + FilterGroup group = (FilterGroup) i.next(); + Iterator j = group.getFilters().iterator(); + while (j.hasNext()) { + Filter filter = (Filter) j.next(); + try { + if (filter.test(anEntity, aRequest)) { + return filter; + } + } + catch (Throwable t) { + logger.warn("Exception thrown while testing filter " + filter.getType() + " ( " + filter.getExpression() + ") " + t.toString()); + } + } + } + + return null; + } + + public List getFilterTypes() { + try { + List result = new ArrayList(); + + Iterator i = filterTypeIds.iterator(); + while (i.hasNext()) { + String id = (String) i.next(); + + Map action = new HashMap(); + action.put("resource", id); + action.put("identifier", id); + + result.add(action); + } + + return result; + } + catch (Throwable t) { + throw new RuntimeException("can't get article actions"); + } + } + + public class FilterGroup { + private List filters; + private Entity entity; + private Map idToFilter; + + public FilterGroup(Entity anEntity) { + this (anEntity, Collections.EMPTY_LIST); + } + + public FilterGroup(Entity anEntity, List aFilters) { + entity = anEntity; + filters = new ArrayList(); + idToFilter = new HashMap(); + Iterator i = aFilters.iterator(); + + while (i.hasNext()) { + Entity entity = (Entity) i.next(); + try { + Filter filter = new Filter(entity); + introduceFilter(filter); + } + catch (AbuseExc e) { + } + } + } + + public Entity getEntity() { + return entity; + } + + public EntityAdapter getEntityAdapter() { + return model.makeEntityAdapter("filterGroup", entity); + } + + public List getFilterEntityAdapterList() { + List result = new ArrayList(); + + Iterator i = filters.iterator(); + while (i.hasNext()) { + Filter filter = (Filter) i.next(); + result.add(filter.getEntityAdapter()); + } + + return result; + } + + public List getFilters() { + return filters; + } + + public Filter getFilterForId(String anId) { + Filter result = (Filter) idToFilter.get(anId); + if (result==null) { + throw new NullPointerException("No such filter"); + } + + return result; + } + + private void introduceFilter(Filter aFilter) { + filters.add(aFilter); + idToFilter.put(aFilter.getEntity().getId(), aFilter); + } + + private void removeFilter(Filter aFilter) { + filters.remove(aFilter); + idToFilter.remove(aFilter.getEntity().getId()); + } + + private void deleteFilter(String anId) { + Filter filter = getFilterForId(anId); + removeFilter(filter); + DatabaseFilter.getInstance().delete(anId); + } + + public void populateFilterEntity(Entity anEntity, String aType, String anExpression, + String aComments, String aTag, String anArticleAction, + String aCommentAction) { + + anEntity.setFieldValue("type", aType); + anEntity.setFieldValue("expression", anExpression); + anEntity.setFieldValue("comment", aComments); + anEntity.setFieldValue("tag", aTag); + anEntity.setFieldValue("articleaction", anArticleAction); + anEntity.setFieldValue("commentaction", aCommentAction); + } + + public String updateFilter(String anId, String aType, String anExpression, + String aComments, String aTag, String anArticleAction, + String aCommentAction) { + + try { + getFilterTypeForId(aType).constructFilterInstance(anExpression); + } + catch (AbuseExc e) { + return e.getMessage(); + } + + Entity entity = getFilterForId(anId).getEntity(); + populateFilterEntity(entity, aType, anExpression, aComments, aTag, + anArticleAction, aCommentAction); + entity.update(); + + return ""; + } + + public String createFilter(String aType, String anExpression, + String aComments, String aTag, String anArticleAction, + String aCommentAction) throws StorageObjectExc { + FilterInstance instance; + + try { + instance = getFilterTypeForId(aType).constructFilterInstance(anExpression); + } + catch (AbuseExc e) { + return e.getMessage(); + } + + Entity entity = DatabaseFilter.getInstance().createNewEntity(); + populateFilterEntity(entity, aType, anExpression, aComments, aTag, + anArticleAction, aCommentAction); + entity.setFieldValue("priority", "1"); + entity.setFieldValue("filter_group_id", getEntity().getId()); + entity.insert(); + + Filter filter = new Filter(entity, instance); + introduceFilter(filter); + + return ""; + } + + public String getName() { + return entity.getFieldValue("name"); + } + } + + public class Filter { + private Entity entity; + private FilterInstance instance; + + public Filter(Entity anEntity) throws AbuseExc { + this(anEntity, getFilterTypeForId(anEntity.getFieldValue("type")).constructFilterInstance(anEntity.getFieldValue("expression"))); + } + + public Filter(Entity anEntity, FilterInstance anInstance) { + entity = anEntity; + instance = anInstance; + } + + public Entity getEntity() { + return entity; + } + + public EntityAdapter getEntityAdapter() { + return model.makeEntityAdapter("filter", entity); + } + + public void update(String aType, String anExpression, String aComments, String aTag, + String anArticleAction, String aCommentAction) throws AbuseExc { + + instance = getFilterTypeForId(aType).constructFilterInstance(anExpression); + + entity.setFieldValue("type", aType); + entity.setFieldValue("expression", anExpression); + entity.setFieldValue("tag", aType); + entity.setFieldValue("comment", aComments); + entity.setFieldValue("articleaction", anArticleAction); + entity.setFieldValue("commentaction", aCommentAction); + entity.setFieldValue("last_hit", null); + entity.update(); + } + + public void updateLastHit(Date aDate) { + entity.setFieldValue("last_hit", dateFormat.format(aDate)); + entity.update(); + } + + public String getType() { + return entity.getFieldValue("type"); + } + + public String getExpression() { + return entity.getFieldValue("expression"); + } + + public String getTag() { + return entity.getFieldValue("tag"); + } + + public String getComment() { + return entity.getFieldValue("comment"); + } + + public String getArticleAction() { + return entity.getFieldValue("articleaction"); + } + + public String getCommentAction() { + return entity.getFieldValue("commentaction"); + } + + public FilterInstance getInstance() { + return instance; + } + + public boolean test(Entity anEntity, Request aRequest) { + return instance.test(anEntity, aRequest); + } + } + + public synchronized void reload() { + filterGroups.clear(); + idToFilterGroup.clear(); + + try { + Iterator i = new EntityIteratorAdapter("", "priority asc", 100, model, "filterGroup"); + while (i.hasNext()) { + EntityAdapter entityAdapter = (EntityAdapter) i.next(); + List filters = new ArrayList(); + Iterator j = (Iterator) entityAdapter.get("to_filters"); + while (j.hasNext()) { + filters.add(((EntityAdapter) j.next()).getEntity()); + } + + FilterGroup filterGroup = new FilterGroup(entityAdapter.getEntity(), filters); + introduceFilterGroup(filterGroup); + } + } + catch (Throwable e) { + logger.error("Can't load filters: " + e.getMessage()); + } + } + + public synchronized List getFilterGroups() { + List result = new ArrayList(); + Iterator i = filterGroups.iterator(); + while (i.hasNext()) { + result.add(((FilterGroup) i.next()).getEntityAdapter()); + } + + return result; + } + + public synchronized void updateFilterGroup(String anId, String aName) { + FilterGroup filterGroup = getFilterGroupForId(anId); + filterGroup.getEntity().setFieldValue("name", aName); + filterGroup.getEntity().update(); + } + + public synchronized void addFilterGroup(String aName) throws StorageObjectExc { + Entity entity = DatabaseFilterGroup.getInstance().createNewEntity(); + entity.setFieldValue("name", aName); + entity.setFieldValue("priority", "1"); + entity.insert(); + + FilterGroup filterGroup = new FilterGroup(entity); + introduceFilterGroup(filterGroup); + } + + public synchronized void deleteFilterGroup(String anId) { + + FilterGroup filterGroup = getFilterGroupForId(anId); + removeFilterGroup(filterGroup); + DatabaseFilter.getInstance().deleteByWhereClause("filter_group_id = " + anId); + DatabaseFilterGroup.getInstance().delete(anId); + } + + public synchronized void deleteFilter(String aGroupId, String anId) { + getFilterGroupForId(aGroupId).deleteFilter(anId); + } + + + public synchronized String updateFilter(String aGroupId, String anId, + String aType, String anExpression, + String aComments, + String aTag, + String anArticleAction, + String aCommentAction) { + return getFilterGroupForId(aGroupId).updateFilter(anId, aType, + anExpression, aComments, aTag, anArticleAction, aCommentAction); + } + + public synchronized String addFilter(String aGroupId, + String aType, String anExpression, + String aComments, + String aTag, + String anArticleAction, + String aCommentAction) throws StorageObjectExc { + return getFilterGroupForId(aGroupId).createFilter(aType, anExpression, + aComments, aTag, anArticleAction, aCommentAction); + } + + + public FilterGroup getFilterGroupForId(String anId) { + FilterGroup result = (FilterGroup) idToFilterGroup.get(anId); + if (result == null) { + throw new NullPointerException("No such filter group"); + } + + return result; + } + + public Filter getFilterForId(String aGroupId, String anId) { + return getFilterGroupForId(aGroupId).getFilterForId(anId); + } + + + public List getFilters(String aFilterGroupId) { + return getFilterGroupForId(aFilterGroupId).getFilterEntityAdapterList(); + } + + private void introduceFilterGroup(FilterGroup aFilterGroup) { + filterGroups.add(aFilterGroup); + idToFilterGroup.put(aFilterGroup.getEntity().getId(), aFilterGroup); + } + + private void removeFilterGroup(FilterGroup aFilterGroup) { + filterGroups.remove(aFilterGroup); + idToFilterGroup.remove(aFilterGroup.getEntity().getId()); + } + + private FilterType getFilterTypeForId(String anId) { + return (FilterType) filterTypes.get(anId); + } +} diff --git a/source/mircoders/abuse/IPFilterType.java b/source/mircoders/abuse/IPFilterType.java index e6018317..9cb08679 100755 --- a/source/mircoders/abuse/IPFilterType.java +++ b/source/mircoders/abuse/IPFilterType.java @@ -1,80 +1,80 @@ -/* - * 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 mircoders.abuse; - -import mir.util.InternetFunctions; -import mir.entity.Entity; -import mir.session.Request; - -/** - * A basic ip filter type. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions. - */ -public class IPFilterType extends AbstractFilterType { - public IPFilterType(String aName) { - super(aName); - } - - /** - * - */ - public boolean validate(String anExpression) { - try { - InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression); - return true; - } - catch (Throwable t) { - return false; - } - } - - public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc { - try { - InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression); - } - catch (Throwable t) { - throw new AbuseExc("Invalid expression: " + anExpression); - } - - return new FilterInstance() { - public boolean test(Entity anEntity, Request aRequest) { - try { - return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression); - } - catch (Exception e) { - return false; - } - } - - public String status() { - return ""; - } - }; - } -} +/* + * 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 mircoders.abuse; + +import mir.entity.Entity; +import mir.session.Request; +import mir.util.InternetFunctions; + +/** + * A basic ip filter type. Supports x.x.x.x, x.x.x.x/x and x.x.x.x/x.x.x.x expressions. + */ +public class IPFilterType extends AbstractFilterType { + public IPFilterType(String aName) { + super(aName); + } + + /** + * + */ + public boolean validate(String anExpression) { + try { + InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression); + return true; + } + catch (Throwable t) { + return false; + } + } + + public FilterInstance constructFilterInstance(final String anExpression) throws AbuseExc { + try { + InternetFunctions.isIpAddressInNetwork("1.1.1.1", anExpression); + } + catch (Throwable t) { + throw new AbuseExc("Invalid expression: " + anExpression); + } + + return new FilterInstance() { + public boolean test(Entity anEntity, Request aRequest) { + try { + return InternetFunctions.isIpAddressInNetwork(aRequest.getHeader("ip"), anExpression); + } + catch (Exception e) { + return false; + } + } + + public String status() { + return ""; + } + }; + } +} diff --git a/source/mircoders/abuse/RegularExpressionFilterType.java b/source/mircoders/abuse/RegularExpressionFilterType.java index 13d1db52..fe0e6bbf 100755 --- a/source/mircoders/abuse/RegularExpressionFilterType.java +++ b/source/mircoders/abuse/RegularExpressionFilterType.java @@ -31,13 +31,14 @@ package mircoders.abuse; import gnu.regexp.RE; -import mir.entity.Entity; -import mir.session.Request; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import mir.entity.Entity; +import mir.session.Request; + /** * A regular expression filter. diff --git a/source/mircoders/abuse/ThrottleFilter.java b/source/mircoders/abuse/ThrottleFilter.java index 714f2058..79e86495 100755 --- a/source/mircoders/abuse/ThrottleFilter.java +++ b/source/mircoders/abuse/ThrottleFilter.java @@ -1,151 +1,149 @@ -/* - * 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 mircoders.abuse; - -import mir.entity.Entity; -import mir.session.Request; -import mir.util.StringRoutines; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * A ip-based throttling filter. - * - *

- * Expressions have the form

+ * Expressions have the form

Title:

diff --git a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java index e621cc4e..0009383e 100755 --- a/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicOpenPostingLocalizer.java @@ -29,15 +29,22 @@ */ package mircoders.localizer.basic; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; + import mir.config.MirPropertiesConfiguration; import mir.log.LoggerWrapper; import mir.session.Request; import mir.session.Session; import mir.session.SessionHandler; import mircoders.abuse.FilterType; -import mircoders.abuse.ThrottleFilter; import mircoders.abuse.IPFilterType; import mircoders.abuse.RegularExpressionFilterType; +import mircoders.abuse.ThrottleFilter; import mircoders.entity.EntityComment; import mircoders.entity.EntityContent; import mircoders.global.MirGlobal; @@ -46,8 +53,6 @@ import mircoders.localizer.MirLocalizerExc; import mircoders.localizer.MirLocalizerFailure; import mircoders.localizer.MirOpenPostingLocalizer; -import java.util.*; - public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer { private List afterContentProducerTasks; private List afterCommentProducerTasks; diff --git a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java index 75e7978e..dcd50d74 100755 --- a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java +++ b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java @@ -64,7 +64,7 @@ import mircoders.media.UnsupportedMediaTypeExc; */ public abstract class MirBasicPostingSessionHandler implements SessionHandler { protected static LoggerWrapper logger = new LoggerWrapper("Localizer.OpenPosting"); - protected MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance();; + protected MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance(); /** Previously uploaded files */ protected List attachments; @@ -110,7 +110,7 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler { subsequentRequest(aRequest, aSession, aResponse); } } - }; + } protected void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { initializeSession(aRequest, aSession); @@ -360,16 +360,16 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler { protected void makeInitialResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { aResponse.setResponseGenerator(normalResponseGenerator); - }; + } protected void makeResponse(Request aRequest, Session aSession, Response aResponse, List anErrors) throws SessionExc, SessionFailure { aResponse.setResponseValue("errors", anErrors); aResponse.setResponseGenerator(normalResponseGenerator); - }; + } protected void makeFinalResponse(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { aResponse.setResponseGenerator(finalResponseGenerator); - }; + } protected void makeErrorResponse(Request aRequest, Session aSession, Response aResponse, Throwable anError) throws SessionExc, SessionFailure { Throwable rootCause = ExceptionFunctions.traceCauseException(anError); @@ -386,7 +386,7 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler { new Object[] {anError.getMessage()})); makeResponse(aRequest, aSession, aResponse, errors); } - }; + } protected void makeOpenPostingDisabledResponse(Request aRequest, Session aSession, Response aResponse) { aResponse.setResponseGenerator(configuration.getString("ServletModule.OpenIndy.PostingDisabledTemplate")); @@ -396,13 +396,13 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler { * */ protected void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure { - }; + } public void processAttachment(Request aRequest, Session aSession, Attachment aFile) throws SessionExc, SessionFailure { - }; + } public void processAttachmentError(Request aRequest, Session aSession, Attachment aFile, Throwable anError) { - }; + } protected void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure { - }; + } /** * Determine whether the request shoudl be processed: that is, the validate, @@ -412,10 +412,8 @@ public abstract class MirBasicPostingSessionHandler implements SessionHandler { protected boolean shouldProcessRequest(Request aRequest, Session aSession, List aValidationErrors) throws SessionExc, SessionFailure { if (aRequest.getParameter("post")==null) return false; - else { - validate(aValidationErrors, aRequest, aSession); - return (aValidationErrors == null || aValidationErrors.size() == 0); - } + validate(aValidationErrors, aRequest, aSession); + return (aValidationErrors == null || aValidationErrors.size() == 0); } /** diff --git a/source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java b/source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java index d7747334..e4a16290 100755 --- a/source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicProducerAssistantLocalizer.java @@ -29,6 +29,15 @@ */ package mircoders.localizer.basic; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import mir.config.MirPropertiesConfiguration; import mir.entity.adapter.EntityAdapter; import mir.entity.adapter.EntityIteratorAdapter; @@ -37,27 +46,20 @@ import mir.generator.GeneratorExc; import mir.generator.GeneratorFailure; import mir.log.LoggerWrapper; import mir.misc.StringUtil; -import mir.util.*; +import mir.util.GeneratorDateTimeFunctions; +import mir.util.GeneratorFormatAdapters; import mir.util.generator.ReflectionGeneratorFunctionsAdapter; import mircoders.global.MirGlobal; import mircoders.localizer.MirLocalizerExc; import mircoders.localizer.MirLocalizerFailure; import mircoders.localizer.MirProducerAssistantLocalizer; + import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.w3c.tidy.Tidy; import org.w3c.tidy.Configuration; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.StringWriter; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import org.w3c.tidy.Tidy; public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer { protected LoggerWrapper logger; @@ -129,7 +131,8 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL throw new MirLocalizerFailure(t); } - }; + } + public static class getLanguageIdFunction implements Generator.Function { private Map languageCodeToId; private String otherLanguageId; @@ -173,7 +176,7 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL catch (Throwable t) { throw new GeneratorFailure("getLanguageIdFunction: " + t.getMessage(), t); } - }; + } } @@ -218,8 +221,7 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL private boolean checkAttr(String attrName) { if (attrName.equals("onLoad") || attrName.equals("onClick") || attrName.equals("onFocus") || attrName.equals("onBlur") || attrName.equals("onMouseOver") || attrName.equals("onMouseOut") || attrName.equals("style") || attrName.equals("STYLE") || attrName.equals("height") || attrName.equals("width") || attrName.equals("HEIGHT") || attrName.equals("WIDTH")) return false; - else - return true; + return true; } @@ -251,10 +253,8 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL nodeName.equals("li") ) { return true; - } else { - - return false; } + return false; } private void print(Node node, StringWriter out) throws IOException { diff --git a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java index a1a0982e..541d60b3 100755 --- a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java @@ -30,7 +30,11 @@ package mircoders.localizer.basic; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import mir.entity.adapter.EntityAdapterModel; import mir.generator.Generator; @@ -150,7 +154,7 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { t.getMessage()); throw new MirLocalizerFailure(t); } - }; + } /** * Sets up a {@link ProducerNodeBuilderLibrary} for use by the producer diff --git a/source/mircoders/localizer/basic/MirBasicTranslationPostingHandler.java b/source/mircoders/localizer/basic/MirBasicTranslationPostingHandler.java index 6c5a405b..5072ea07 100755 --- a/source/mircoders/localizer/basic/MirBasicTranslationPostingHandler.java +++ b/source/mircoders/localizer/basic/MirBasicTranslationPostingHandler.java @@ -85,7 +85,7 @@ public class MirBasicTranslationPostingHandler extends MirBasicChildArticlePosti catch (Throwable t) { throw new SessionFailure(t); } - }; + } protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { try { diff --git a/source/mircoders/localizer/basic/MirBasicUtilityFunctions.java b/source/mircoders/localizer/basic/MirBasicUtilityFunctions.java index 1e6b304d..e22c3478 100755 --- a/source/mircoders/localizer/basic/MirBasicUtilityFunctions.java +++ b/source/mircoders/localizer/basic/MirBasicUtilityFunctions.java @@ -1,164 +1,159 @@ -/* - * 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 mircoders.localizer.basic; - -import java.util.Collections; -import java.util.List; - -import mir.util.HTMLRoutines; -import mir.util.JDBCStringRoutines; -import mir.util.ParameterExpander; -import mir.util.RewindableIterator; -import mir.util.StringRoutines; -import mir.util.StructuredContentParser; -import mir.util.SubsetIterator; - -public class MirBasicUtilityFunctions { - public String encodeXML(Object anObject) throws Exception { - return HTMLRoutines.encodeXML(StringRoutines.interpretAsString(anObject)); - } - - public String encodeHTML(Object aString) throws Exception { - return HTMLRoutines.encodeHTML(StringRoutines.interpretAsString(aString)); - } - - public String prettyEncodeHTML(Object aString) throws Exception { - return HTMLRoutines.prettyEncodeHTML(StringRoutines.interpretAsString(aString)); - } - - public String encodeURI(Object aString) throws Exception { - return HTMLRoutines.encodeURL(StringRoutines.interpretAsString(aString)); - } - - public String encodeURI(Object aString, Object anEncoding) throws Exception { - return HTMLRoutines.encodeURL( - StringRoutines.interpretAsString(aString), - StringRoutines.interpretAsString(anEncoding)); - } - - public String subString(Object aString, Object aFrom) throws Exception { - return StringRoutines.interpretAsString(aString).substring(StringRoutines.interpretAsInteger(aFrom)); - } - - public String subString(Object aString, Object aFrom, Object aLength) throws Exception { - int length = StringRoutines.interpretAsInteger(aLength); - String target = StringRoutines.interpretAsString(aString); - if (length<0 || length>target.length()) { - length=target.length(); - } - - return target.substring(StringRoutines.interpretAsInteger(aFrom), length); - } - - public String escapeJDBCString(Object aString) throws Exception { - return JDBCStringRoutines.escapeStringLiteral(StringRoutines.interpretAsString(aString)); - } - - public String constructString(Object aString) throws Exception { - if (aString==null) - return StructuredContentParser.constructStringLiteral(""); - else - return StructuredContentParser.constructStringLiteral(StringRoutines.interpretAsString(aString)); - } - - public Object parseStructuredString(Object aString) throws Exception { - if (aString==null) - return null; - else - return StructuredContentParser.parse(StringRoutines.interpretAsString(aString)); - } - - public boolean isOdd(Object anInteger) throws Exception { - return (StringRoutines.interpretAsInteger(anInteger) & 1) == 1; - } - - public int increment(Object anInteger) throws Exception { - final Integer ONE = new Integer(1); - - return increment(anInteger, ONE); - } - - public int increment(Object anInteger, Object anIncrement) throws Exception { - return StringRoutines.interpretAsInteger(anInteger) + - StringRoutines.interpretAsInteger(anIncrement); - } - - public Object subList(Object aList, Object aSkip) throws Exception { - return subList(aList, aSkip, new Integer(-1)); - } - - public Object subList(Object aList, Object aSkip, Object aMaxSize) throws Exception { - int skip = StringRoutines.interpretAsInteger(aSkip); - int maxSize = StringRoutines.interpretAsInteger(aMaxSize); - - if (aList instanceof RewindableIterator) - return new SubsetIterator((RewindableIterator) aList, skip, maxSize); - else { - List list = (List) aList; - - if (skip>=list.size()) - return Collections.EMPTY_LIST; - if (maxSize<0 || (skip+maxSize)>=list.size()) - return list.subList(skip, list.size()); - else - return list.subList(skip, skip+maxSize); - } - } - - public int listSize(RewindableIterator anIterator) { - anIterator.rewind(); - int result=0; - - while (anIterator.hasNext()) { - result++; - anIterator.next(); - } - - anIterator.rewind(); - - return result; - } - - public int listSize(List aList) { - return aList.size(); - } - - public Object evaluate(Object aTarget, String anExpression) throws Exception { - return ParameterExpander.expandExpression(aTarget, anExpression); - } - - public String regexpreplace(String aString, String anExpression, String aReplacement) { - return StringRoutines.performRegularExpressionReplacement(aString, anExpression, aReplacement); - } - - public boolean regexpmatch(String aString, String anExpression) { - return StringRoutines.performRegularExpressionSearch(aString, anExpression); - } -} +/* + * 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 mircoders.localizer.basic; + +import java.util.Collections; +import java.util.List; + +import mir.util.HTMLRoutines; +import mir.util.JDBCStringRoutines; +import mir.util.ParameterExpander; +import mir.util.RewindableIterator; +import mir.util.StringRoutines; +import mir.util.StructuredContentParser; +import mir.util.SubsetIterator; + +public class MirBasicUtilityFunctions { + public String encodeXML(Object anObject) throws Exception { + return HTMLRoutines.encodeXML(StringRoutines.interpretAsString(anObject)); + } + + public String encodeHTML(Object aString) throws Exception { + return HTMLRoutines.encodeHTML(StringRoutines.interpretAsString(aString)); + } + + public String prettyEncodeHTML(Object aString) throws Exception { + return HTMLRoutines.prettyEncodeHTML(StringRoutines.interpretAsString(aString)); + } + + public String encodeURI(Object aString) throws Exception { + return HTMLRoutines.encodeURL(StringRoutines.interpretAsString(aString)); + } + + public String encodeURI(Object aString, Object anEncoding) throws Exception { + return HTMLRoutines.encodeURL( + StringRoutines.interpretAsString(aString), + StringRoutines.interpretAsString(anEncoding)); + } + + public String subString(Object aString, Object aFrom) throws Exception { + return StringRoutines.interpretAsString(aString).substring(StringRoutines.interpretAsInteger(aFrom)); + } + + public String subString(Object aString, Object aFrom, Object aLength) throws Exception { + int length = StringRoutines.interpretAsInteger(aLength); + String target = StringRoutines.interpretAsString(aString); + if (length<0 || length>target.length()) { + length=target.length(); + } + + return target.substring(StringRoutines.interpretAsInteger(aFrom), length); + } + + public String escapeJDBCString(Object aString) throws Exception { + return JDBCStringRoutines.escapeStringLiteral(StringRoutines.interpretAsString(aString)); + } + + public String constructString(Object aString) throws Exception { + if (aString==null) + return StructuredContentParser.constructStringLiteral(""); + return StructuredContentParser.constructStringLiteral(StringRoutines.interpretAsString(aString)); + } + + public Object parseStructuredString(Object aString) throws Exception { + if (aString==null) + return null; + return StructuredContentParser.parse(StringRoutines.interpretAsString(aString)); + } + + public boolean isOdd(Object anInteger) throws Exception { + return (StringRoutines.interpretAsInteger(anInteger) & 1) == 1; + } + + public int increment(Object anInteger) throws Exception { + final Integer ONE = new Integer(1); + + return increment(anInteger, ONE); + } + + public int increment(Object anInteger, Object anIncrement) throws Exception { + return StringRoutines.interpretAsInteger(anInteger) + + StringRoutines.interpretAsInteger(anIncrement); + } + + public Object subList(Object aList, Object aSkip) throws Exception { + return subList(aList, aSkip, new Integer(-1)); + } + + public Object subList(Object aList, Object aSkip, Object aMaxSize) throws Exception { + int skip = StringRoutines.interpretAsInteger(aSkip); + int maxSize = StringRoutines.interpretAsInteger(aMaxSize); + + if (aList instanceof RewindableIterator) + return new SubsetIterator((RewindableIterator) aList, skip, maxSize); + + List list = (List) aList; + if (skip>=list.size()) + return Collections.EMPTY_LIST; + if (maxSize<0 || (skip+maxSize)>=list.size()) + return list.subList(skip, list.size()); + return list.subList(skip, skip+maxSize); + } + + public int listSize(RewindableIterator anIterator) { + anIterator.rewind(); + int result=0; + + while (anIterator.hasNext()) { + result++; + anIterator.next(); + } + + anIterator.rewind(); + + return result; + } + + public int listSize(List aList) { + return aList.size(); + } + + public Object evaluate(Object aTarget, String anExpression) throws Exception { + return ParameterExpander.expandExpression(aTarget, anExpression); + } + + public String regexpreplace(String aString, String anExpression, String aReplacement) { + return StringRoutines.performRegularExpressionReplacement(aString, anExpression, aReplacement); + } + + public boolean regexpmatch(String aString, String anExpression) { + return StringRoutines.performRegularExpressionSearch(aString, anExpression); + } +} diff --git a/source/mircoders/localizer/basic/MirBasicWriterEngine.java b/source/mircoders/localizer/basic/MirBasicWriterEngine.java index 0cb29227..218a50d4 100755 --- a/source/mircoders/localizer/basic/MirBasicWriterEngine.java +++ b/source/mircoders/localizer/basic/MirBasicWriterEngine.java @@ -74,9 +74,9 @@ public class MirBasicWriterEngine implements WriterEngine { catch (Throwable t) { throw new MirLocalizerFailure("Failure while opening a PrintWriter: " + t.getMessage(), t); } - }; + } public void closeWriter(Object aWriter) { ((PrintWriter) aWriter).close(); - }; + } } \ No newline at end of file diff --git a/source/mircoders/localizer/basic/actions/ArticleTopicAction.java b/source/mircoders/localizer/basic/actions/ArticleTopicAction.java index 7770ff3a..36750166 100755 --- a/source/mircoders/localizer/basic/actions/ArticleTopicAction.java +++ b/source/mircoders/localizer/basic/actions/ArticleTopicAction.java @@ -30,8 +30,8 @@ package mircoders.localizer.basic.actions; import java.util.ArrayList; -import java.util.List; import java.util.Iterator; +import java.util.List; import mir.entity.adapter.EntityAdapter; import mircoders.localizer.MirLocalizerExc; diff --git a/source/mircoders/media/AbstractMediaHandler.java b/source/mircoders/media/AbstractMediaHandler.java index 05db1edc..94cbb9bd 100755 --- a/source/mircoders/media/AbstractMediaHandler.java +++ b/source/mircoders/media/AbstractMediaHandler.java @@ -1,60 +1,58 @@ -/* - * 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 mircoders.media; - -import mir.media.MediaHandler; -import mir.media.MediaExc; -import mir.media.MediaFailure; -import mir.entity.Entity; -import mir.misc.StringUtil; - -import java.io.File; - -public abstract class AbstractMediaHandler implements MediaHandler { - public File getStorageFile(Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure { - return new File(new File(getStoragePath()), getRelativeStorageFile(aMedia, aMediaType)); - } - - public String getRelativeStorageFile(Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure { - String publishPath = aMedia.getFieldValue("publish_path"); - - if (publishPath==null || publishPath.length()==0) { - String extension = aMediaType.getFieldValue("name"); - String mediaFileName = aMedia.getId() + "." + extension; - String date = aMedia.getFieldValue("date"); - String datePath = StringUtil.webdbDate2path(date); - return (new File(datePath, mediaFileName)).getPath(); - } - else { - return publishPath; - } - } - -} +/* + * 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 mircoders.media; + +import java.io.File; + +import mir.entity.Entity; +import mir.media.MediaExc; +import mir.media.MediaFailure; +import mir.media.MediaHandler; +import mir.misc.StringUtil; + +public abstract class AbstractMediaHandler implements MediaHandler { + public File getStorageFile(Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure { + return new File(new File(getStoragePath()), getRelativeStorageFile(aMedia, aMediaType)); + } + + public String getRelativeStorageFile(Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure { + String publishPath = aMedia.getFieldValue("publish_path"); + + if (publishPath==null || publishPath.length()==0) { + String extension = aMediaType.getFieldValue("name"); + String mediaFileName = aMedia.getId() + "." + extension; + String date = aMedia.getFieldValue("date"); + String datePath = StringUtil.webdbDate2path(date); + return (new File(datePath, mediaFileName)).getPath(); + } + return publishPath; + } + +} diff --git a/source/mircoders/media/MediaHandlerGeneric.java b/source/mircoders/media/MediaHandlerGeneric.java index d023b3df..e8e66ca4 100755 --- a/source/mircoders/media/MediaHandlerGeneric.java +++ b/source/mircoders/media/MediaHandlerGeneric.java @@ -29,6 +29,13 @@ */ package mircoders.media; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import javax.servlet.ServletContext; + import mir.config.MirPropertiesConfiguration; import mir.entity.Entity; import mir.log.LoggerWrapper; @@ -38,12 +45,6 @@ import mir.misc.StringUtil; import mir.session.UploadedFile; import mir.util.FileFunctions; -import javax.servlet.ServletContext; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; - /** * This is the Generic MediaHandler. It stores the media data on @@ -62,7 +63,7 @@ import java.io.InputStream; * * @see mir.media.MediaHandler * @author mh - * @version $Id: MediaHandlerGeneric.java,v 1.20.2.7 2004/11/21 22:07:14 zapata Exp $ + * @version $Id: MediaHandlerGeneric.java,v 1.20.2.8 2005/02/10 16:22:23 rhindes Exp $ */ public class MediaHandlerGeneric extends AbstractMediaHandler @@ -146,7 +147,7 @@ public class MediaHandlerGeneric extends AbstractMediaHandler String fileName = aMediaEntity.getId() + "." + aMediaType.getFieldValue("name"); return servletContext.getMimeType(fileName); - }; + } public String getStoragePath() { return configuration.getString("Producer.Media.Path"); diff --git a/source/mircoders/media/MediaHandlerMp3.java b/source/mircoders/media/MediaHandlerMp3.java index 2deb304f..9b4cd048 100755 --- a/source/mircoders/media/MediaHandlerMp3.java +++ b/source/mircoders/media/MediaHandlerMp3.java @@ -29,6 +29,8 @@ */ package mircoders.media; +import java.io.StringReader; + import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MediaExc; @@ -37,8 +39,6 @@ import mir.media.MediaHandler; import mir.misc.FileUtil; import mir.misc.StringUtil; -import java.io.StringReader; - /** * Please note: this media handler produces * 3 media files, the raw .mp3, a .m3u which is @@ -63,7 +63,7 @@ import java.io.StringReader; * * @see mir.media.MediaHandler * @author mh - * @version $Id: MediaHandlerMp3.java,v 1.15.2.5 2004/11/21 22:07:14 zapata Exp $ + * @version $Id: MediaHandlerMp3.java,v 1.15.2.6 2005/02/10 16:22:23 rhindes Exp $ */ public class MediaHandlerMp3 extends MediaHandlerAudio implements MediaHandler diff --git a/source/mircoders/media/MediaHandlerOgg.java b/source/mircoders/media/MediaHandlerOgg.java index d6f84544..07935a35 100755 --- a/source/mircoders/media/MediaHandlerOgg.java +++ b/source/mircoders/media/MediaHandlerOgg.java @@ -67,8 +67,7 @@ import mir.misc.StringUtil; public class MediaHandlerOgg extends MediaHandlerAudio implements MediaHandler { - protected LoggerWrapper logger; - + public MediaHandlerOgg() { logger = new LoggerWrapper("Media.Audio.Ogg"); } diff --git a/source/mircoders/media/MediaHandlerRealAudio.java b/source/mircoders/media/MediaHandlerRealAudio.java index 54aa6247..608ead82 100755 --- a/source/mircoders/media/MediaHandlerRealAudio.java +++ b/source/mircoders/media/MediaHandlerRealAudio.java @@ -49,7 +49,7 @@ import mir.misc.StringUtil; * @see mir.media.MediaHandlerGeneric * @see mir.media.MediaHandler * @author john , mh - * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.6 2005/01/09 20:37:12 zapata Exp $ + * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.7 2005/02/10 16:22:23 rhindes Exp $ */ @@ -64,10 +64,8 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHan // first see if the file exists super.produce(ent, mediaTypeEnt); - String baseName = ent.getId(); 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.getFieldValue("publish_path"); diff --git a/source/mircoders/media/MediaHandlerRealVideo.java b/source/mircoders/media/MediaHandlerRealVideo.java index 0807c39e..26fe197e 100755 --- a/source/mircoders/media/MediaHandlerRealVideo.java +++ b/source/mircoders/media/MediaHandlerRealVideo.java @@ -29,6 +29,9 @@ */ package mircoders.media; +import java.io.File; +import java.io.StringReader; + import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MediaExc; @@ -37,9 +40,6 @@ import mir.media.MediaHandler; import mir.misc.FileUtil; import mir.misc.StringUtil; -import java.io.File; -import java.io.StringReader; - /** @@ -49,7 +49,7 @@ import java.io.StringReader; * * @see mir.media.MediaHandler * @author john , mh - * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.5 2004/11/21 22:07:14 zapata Exp $ + * @version $Id: MediaHandlerRealVideo.java,v 1.19.2.6 2005/02/10 16:22:23 rhindes Exp $ */ @@ -64,10 +64,8 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements MediaHan // first see if the file exists super.produce(ent, mediaTypeEnt); - String baseName = ent.getId(); 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.getFieldValue("publish_path"); diff --git a/source/mircoders/media/MediaHelper.java b/source/mircoders/media/MediaHelper.java index db329397..762cce0a 100755 --- a/source/mircoders/media/MediaHelper.java +++ b/source/mircoders/media/MediaHelper.java @@ -29,14 +29,20 @@ */ package mircoders.media; +import java.util.HashMap; +import java.util.Map; + import mir.entity.Entity; +import mir.media.MediaExc; +import mir.media.MediaFailure; +import mir.media.MediaHandler; import mir.storage.Database; -import java.util.Map; -import java.util.HashMap; -import mircoders.global.*; -import mircoders.storage.*; -import mir.media.*; +import mircoders.global.MirGlobal; import mircoders.localizer.MirLocalizerExc; +import mircoders.storage.DatabaseAudio; +import mircoders.storage.DatabaseImages; +import mircoders.storage.DatabaseOther; +import mircoders.storage.DatabaseVideo; /** * helper class to resolve media handlers using reflection @@ -48,8 +54,7 @@ import mircoders.localizer.MirLocalizerExc; public final class MediaHelper { private static Map nameToMediaHandler = new HashMap(); - private static String defaultMediaHandler = null; - + public static void addHandler(String aName, MediaHandler aHandler) { synchronized (nameToMediaHandler) { nameToMediaHandler.put(aName, aHandler); diff --git a/source/mircoders/media/MediaUploadProcessor.java b/source/mircoders/media/MediaUploadProcessor.java index beb7795e..b3f8b349 100755 --- a/source/mircoders/media/MediaUploadProcessor.java +++ b/source/mircoders/media/MediaUploadProcessor.java @@ -29,6 +29,10 @@ */ package mircoders.media; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Map; + import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.media.MediaFailure; @@ -39,10 +43,6 @@ import mir.storage.Database; import mir.util.FileFunctions; import mircoders.module.ModuleMediaType; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Map; - public class MediaUploadProcessor { private static LoggerWrapper logger = new LoggerWrapper("Media.UploadProcessor"); private static ModuleMediaType mediaTypeModule = new ModuleMediaType(); diff --git a/source/mircoders/media/URLMediaHandler.java b/source/mircoders/media/URLMediaHandler.java index 8401074a..68d54f61 100755 --- a/source/mircoders/media/URLMediaHandler.java +++ b/source/mircoders/media/URLMediaHandler.java @@ -1,14 +1,14 @@ package mircoders.media; +import java.io.File; +import java.io.InputStream; + import mir.entity.Entity; import mir.media.MediaExc; import mir.media.MediaFailure; import mir.media.MediaHandler; import mir.session.UploadedFile; -import java.io.File; -import java.io.InputStream; - /** *

URLMediaHandler

*

Description: diff --git a/source/mircoders/module/ModuleComment.java b/source/mircoders/module/ModuleComment.java index d850cfab..e64ea243 100755 --- a/source/mircoders/module/ModuleComment.java +++ b/source/mircoders/module/ModuleComment.java @@ -29,6 +29,8 @@ */ package mircoders.module; +import java.util.Map; + import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.module.AbstractModule; @@ -37,8 +39,6 @@ import mir.module.ModuleFailure; import mircoders.storage.DatabaseComment; import mircoders.storage.DatabaseContent; -import java.util.Map; - /* * ModuleComment - methods and access for comments @@ -57,7 +57,7 @@ public class ModuleComment extends AbstractModule public void deleteById (String anId) throws ModuleExc, ModuleFailure { try { - Entity theEntity = database.selectById((String)anId); + Entity theEntity = database.selectById(anId); if (theEntity != null) DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media")); diff --git a/source/mircoders/module/ModuleLanguage.java b/source/mircoders/module/ModuleLanguage.java index 2001c778..9997ed6a 100755 --- a/source/mircoders/module/ModuleLanguage.java +++ b/source/mircoders/module/ModuleLanguage.java @@ -29,13 +29,13 @@ */ package mircoders.module; +import mir.entity.Entity; +import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.module.AbstractModule; import mir.module.ModuleExc; import mir.module.ModuleFailure; import mir.util.JDBCStringRoutines; -import mir.entity.Entity; -import mir.entity.EntityList; import mircoders.storage.DatabaseLanguage; /** @@ -70,9 +70,7 @@ public class ModuleLanguage extends AbstractModule { if (list.size()>0) { return list.elementAt(0); } - else { - throw new ModuleExc("No language found for code " + aCode); - } + throw new ModuleExc("No language found for code " + aCode); } catch (Throwable t) { throw new ModuleFailure(t); diff --git a/source/mircoders/module/ModuleMediaType.java b/source/mircoders/module/ModuleMediaType.java index 19850a53..dc82fefa 100755 --- a/source/mircoders/module/ModuleMediaType.java +++ b/source/mircoders/module/ModuleMediaType.java @@ -30,6 +30,8 @@ package mircoders.module; +import java.util.List; + import mir.entity.Entity; import mir.entity.EntityList; import mir.log.LoggerWrapper; @@ -38,8 +40,6 @@ import mir.util.JDBCStringRoutines; import mir.util.StringRoutines; import mircoders.storage.DatabaseMediaType; -import java.util.List; - public class ModuleMediaType extends AbstractModule { static LoggerWrapper logger = new LoggerWrapper("Module.Content"); @@ -65,7 +65,7 @@ public class ModuleMediaType extends AbstractModule { return null; } - return (Entity) mediaTypes.elementAt(0); + return mediaTypes.elementAt(0); } public Entity findMediaTypeForExtension(String anExtension) { @@ -74,8 +74,6 @@ public class ModuleMediaType extends AbstractModule { if (mediaTypes.size() == 0) { return null; } - else { - return (Entity) mediaTypes.elementAt(0); - } + return mediaTypes.elementAt(0); } } \ No newline at end of file diff --git a/source/mircoders/module/ModuleUsers.java b/source/mircoders/module/ModuleUsers.java index bf034471..5aede0bf 100755 --- a/source/mircoders/module/ModuleUsers.java +++ b/source/mircoders/module/ModuleUsers.java @@ -30,6 +30,9 @@ package mircoders.module; +import java.util.HashMap; +import java.util.Map; + import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.module.AbstractModule; @@ -40,9 +43,6 @@ import mircoders.entity.EntityUsers; import mircoders.global.MirGlobal; import mircoders.storage.DatabaseUsers; -import java.util.HashMap; -import java.util.Map; - /* * Users Module - diff --git a/source/mircoders/pdf/PDFGenerator.java b/source/mircoders/pdf/PDFGenerator.java index 049f8b3a..e1a2fa89 100755 --- a/source/mircoders/pdf/PDFGenerator.java +++ b/source/mircoders/pdf/PDFGenerator.java @@ -29,12 +29,18 @@ */ package mircoders.pdf; -import com.lowagie.text.*; -import com.lowagie.text.pdf.*; import gnu.regexp.RE; import gnu.regexp.REException; import gnu.regexp.REMatch; import gnu.regexp.REMatchEnumeration; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import mir.config.MirPropertiesConfiguration; import mir.entity.EntityBrowser; import mir.log.LoggerWrapper; @@ -44,12 +50,20 @@ import mircoders.entity.EntityContent; import mircoders.entity.EntityImages; import mircoders.storage.DatabaseImages; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import com.lowagie.text.BadElementException; +import com.lowagie.text.Document; +import com.lowagie.text.DocumentException; +import com.lowagie.text.Element; +import com.lowagie.text.Font; +import com.lowagie.text.Image; +import com.lowagie.text.PageSize; +import com.lowagie.text.Paragraph; +import com.lowagie.text.Phrase; +import com.lowagie.text.pdf.BaseFont; +import com.lowagie.text.pdf.ColumnText; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfTemplate; +import com.lowagie.text.pdf.PdfWriter; public class PDFGenerator{ @@ -116,11 +130,11 @@ public class PDFGenerator{ footerText = configuration.getString("PDF.Footer.String"); footerFontSize = Integer.parseInt(configuration.getString("PDF.Footer.FontSize")); footerFontFamily = getFontByName(configuration.getString("PDF.Footer.FontFamily")); - footerHeight = Integer.parseInt(configuration.getString("PDF.Footer.Height"));; + footerHeight = Integer.parseInt(configuration.getString("PDF.Footer.Height")); metaFontSize = Integer.parseInt(configuration.getString("PDF.Meta.FontSize")); metaFontFamily = getFontByName(configuration.getString("PDF.Meta.FontFamily")); - metaHeight = Integer.parseInt(configuration.getString("PDF.Meta.Height"));; + metaHeight = Integer.parseInt(configuration.getString("PDF.Meta.Height")); descriptionFontSize = Integer.parseInt(configuration.getString("PDF.Description.FontSize")); descriptionLineHeight = Integer.parseInt(configuration.getString("PDF.Description.LineHeight")); @@ -600,8 +614,7 @@ public class PDFGenerator{ private boolean enoughY(int heightOfBlockToAdd){ if ((currentYPosition - heightOfBlockToAdd - footerHeight) < bottomEdge ) return false; - else - return true; + return true; } diff --git a/source/mircoders/producer/IndexingProducerNode.java b/source/mircoders/producer/IndexingProducerNode.java index db12ed70..8be3d634 100755 --- a/source/mircoders/producer/IndexingProducerNode.java +++ b/source/mircoders/producer/IndexingProducerNode.java @@ -29,12 +29,12 @@ */ package mircoders.producer; +import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Map; -import java.io.File; import mir.entity.Entity; import mir.entity.adapter.EntityAdapter; @@ -42,8 +42,8 @@ import mir.log.LoggerWrapper; import mir.misc.StringUtil; import mir.producer.ProducerFailure; import mir.producer.ProducerNode; -import mir.util.ParameterExpander; import mir.util.FileFunctions; +import mir.util.ParameterExpander; import mircoders.entity.EntityContent; import mircoders.search.AudioSearchTerm; import mircoders.search.ContentSearchTerm; diff --git a/source/mircoders/producer/MediaGeneratingProducerNode.java b/source/mircoders/producer/MediaGeneratingProducerNode.java index 501e8933..4d6f3d83 100755 --- a/source/mircoders/producer/MediaGeneratingProducerNode.java +++ b/source/mircoders/producer/MediaGeneratingProducerNode.java @@ -35,12 +35,12 @@ import java.util.Map; import mir.entity.Entity; import mir.entity.adapter.EntityAdapter; import mir.log.LoggerWrapper; -import mircoders.media.MediaHelper; import mir.media.MediaHandler; import mir.producer.ProducerExc; import mir.producer.ProducerNode; import mir.util.ParameterExpander; import mircoders.entity.EntityUploadedMedia; +import mircoders.media.MediaHelper; import mircoders.storage.DatabaseUploadedMedia; public class MediaGeneratingProducerNode implements ProducerNode { diff --git a/source/mircoders/producer/PDFPreFormattingProducerNode.java b/source/mircoders/producer/PDFPreFormattingProducerNode.java index 4427b679..597872e8 100755 --- a/source/mircoders/producer/PDFPreFormattingProducerNode.java +++ b/source/mircoders/producer/PDFPreFormattingProducerNode.java @@ -31,7 +31,11 @@ package mircoders.producer; import java.io.PrintWriter; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import mir.entity.Entity; import mir.entity.EntityBrowser; diff --git a/source/mircoders/producer/RadicalendarProducerNode.java b/source/mircoders/producer/RadicalendarProducerNode.java index 9dc4abf7..3990b6d2 100755 --- a/source/mircoders/producer/RadicalendarProducerNode.java +++ b/source/mircoders/producer/RadicalendarProducerNode.java @@ -29,7 +29,13 @@ */ package mircoders.producer; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; import mir.log.LoggerWrapper; import mir.producer.ProducerFailure; diff --git a/source/mircoders/producer/UnIndexingProducerNode.java b/source/mircoders/producer/UnIndexingProducerNode.java index 371ece7a..95ed7a5d 100755 --- a/source/mircoders/producer/UnIndexingProducerNode.java +++ b/source/mircoders/producer/UnIndexingProducerNode.java @@ -29,16 +29,16 @@ */ package mircoders.producer; -import java.util.Map; import java.io.File; +import java.util.Map; import mir.entity.Entity; import mir.entity.adapter.EntityAdapter; import mir.log.LoggerWrapper; import mir.producer.ProducerFailure; import mir.producer.ProducerNode; -import mir.util.ParameterExpander; import mir.util.FileFunctions; +import mir.util.ParameterExpander; import mircoders.entity.EntityContent; import mircoders.search.IndexUtil; diff --git a/source/mircoders/producer/reader/SupplementalProducerNodeBuilders.java b/source/mircoders/producer/reader/SupplementalProducerNodeBuilders.java index 783010eb..a0a1a1c9 100755 --- a/source/mircoders/producer/reader/SupplementalProducerNodeBuilders.java +++ b/source/mircoders/producer/reader/SupplementalProducerNodeBuilders.java @@ -29,14 +29,14 @@ */ package mircoders.producer.reader; -import java.util.Map; import java.io.File; +import java.util.Map; import mir.producer.ProducerNode; import mir.producer.reader.DefaultProducerNodeBuilders; import mir.producer.reader.ProducerConfigExc; -import mir.producer.reader.ProducerNodeBuilderLibrary; import mir.producer.reader.ProducerNodeBuilder; +import mir.producer.reader.ProducerNodeBuilderLibrary; import mir.util.xml.XMLParserExc; import mir.util.xml.XMLReaderTool; import mircoders.producer.ContentMarkingProducerNode; @@ -81,11 +81,11 @@ public class SupplementalProducerNodeBuilders { XMLReaderTool.checkAttributes(anAttributes, MARKER_REQUIRED_ATTRIBUTES, MARKER_OPTIONAL_ATTRIBUTES); key = (String) anAttributes.get(MARKER_KEY_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new ContentMarkingProducerNode(key); - }; + } } private final static String INDEXER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE; private final static String INDEXER_INDEX_ATTRIBUTE = "pathToIndex"; @@ -121,11 +121,11 @@ public class SupplementalProducerNodeBuilders { key = (String) anAttributes.get(INDEXER_KEY_ATTRIBUTE); pathToIndex = (String) anAttributes.get(INDEXER_INDEX_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new IndexingProducerNode(indexBasePath, key, pathToIndex); - }; + } } private final static String UNINDEXER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE; @@ -163,11 +163,11 @@ public class SupplementalProducerNodeBuilders { key = (String) anAttributes.get(UNINDEXER_KEY_ATTRIBUTE); pathToIndex = (String) anAttributes.get(UNINDEXER_INDEX_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new UnIndexingProducerNode(indexBasePath, key,pathToIndex); - }; + } } private final static String CONTENT_MODIFIER_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE; @@ -193,11 +193,11 @@ public class SupplementalProducerNodeBuilders { key = (String) anAttributes.get(CONTENT_MODIFIER_KEY_ATTRIBUTE); field = (String) anAttributes.get(CONTENT_MODIFIER_FIELD_ATTRIBUTE); value = (String) anAttributes.get(CONTENT_MODIFIER_VALUE_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new ContentModifyingProducerNode(key, field, value); - }; + } } private final static String MEDIA_KEY_ATTRIBUTE = DefaultProducerNodeBuilders.KEY_ATTRIBUTE; @@ -217,11 +217,11 @@ public class SupplementalProducerNodeBuilders { XMLReaderTool.checkAttributes(anAttributes, MEDIA_REQUIRED_ATTRIBUTES, MEDIA_OPTIONAL_ATTRIBUTES); key = (String) anAttributes.get(MEDIA_KEY_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new MediaGeneratingProducerNode(key); - }; + } } public static class PDFPreFormattingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder { @@ -255,13 +255,11 @@ public class SupplementalProducerNodeBuilders { characterWidthCM = (String) anAttributes.get(PDF_CHAR_WIDTH_ATTRIBUTE); pixelWidthCM = (String) anAttributes.get(PDF_PIXEL_WIDTH_ATTRIBUTE); lineHeightCM = (String) anAttributes.get(PDF_LINE_HEIGHT_ATTRIBUTE); - - - }; + } public ProducerNode constructNode() { return new PDFPreFormattingProducerNode(key,numLinesBetweenImages,contentAreaWidthCM,characterWidthCM,pixelWidthCM,lineHeightCM); - }; + } } public static class PDFGeneratingProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder { @@ -287,11 +285,11 @@ public class SupplementalProducerNodeBuilders { generator = (String) anAttributes.get(PDF_GENERATOR_ATTRIBUTE); destination = (String) anAttributes.get(PDF_DESTINATION_ATTRIBUTE); stylesheet = (String) anAttributes.get(PDF_STYLESHEET_ATTRIBUTE); - }; + } public ProducerNode constructNode() { return new PDFGeneratingProducerNode(generator,destination,stylesheet); - }; + } } public static class RadicalendarProducerNodeBuilder extends DefaultProducerNodeBuilders.AbstractProducerNodeBuilder { diff --git a/source/mircoders/search/AudioSearchTerm.java b/source/mircoders/search/AudioSearchTerm.java index e4aefc6b..1fc2fdc7 100755 --- a/source/mircoders/search/AudioSearchTerm.java +++ b/source/mircoders/search/AudioSearchTerm.java @@ -30,7 +30,10 @@ package mircoders.search; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -67,9 +70,7 @@ public class AudioSearchTerm extends SearchTerm{ if (wanted != null && wanted.equals("y")){ return matchField + ":" + "\"" + wanted + "\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ diff --git a/source/mircoders/search/ContentSearchTerm.java b/source/mircoders/search/ContentSearchTerm.java index 8ea3d6f3..9b74640b 100755 --- a/source/mircoders/search/ContentSearchTerm.java +++ b/source/mircoders/search/ContentSearchTerm.java @@ -91,9 +91,7 @@ public class ContentSearchTerm extends SearchTerm{ } } } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ diff --git a/source/mircoders/search/ImagesSearchTerm.java b/source/mircoders/search/ImagesSearchTerm.java index 10673d89..c509060b 100755 --- a/source/mircoders/search/ImagesSearchTerm.java +++ b/source/mircoders/search/ImagesSearchTerm.java @@ -35,7 +35,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; -import java.util.Vector; import javax.servlet.http.HttpServletRequest; @@ -84,9 +83,7 @@ public class ImagesSearchTerm extends SearchTerm{ if (wanted != null && wanted.equals("y")){ return matchField + ":y"; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ diff --git a/source/mircoders/search/IndexUtil.java b/source/mircoders/search/IndexUtil.java index 55104c5d..2716aa2e 100755 --- a/source/mircoders/search/IndexUtil.java +++ b/source/mircoders/search/IndexUtil.java @@ -30,13 +30,14 @@ package mircoders.search; -import java.io.IOException; import java.io.File; +import java.io.IOException; + +import mircoders.entity.EntityContent; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.store.FSDirectory; -import mircoders.entity.EntityContent; /** * Some utility functions for article (un)indexing diff --git a/source/mircoders/search/KeywordSearchTerm.java b/source/mircoders/search/KeywordSearchTerm.java index dfee6884..3486f71d 100755 --- a/source/mircoders/search/KeywordSearchTerm.java +++ b/source/mircoders/search/KeywordSearchTerm.java @@ -67,9 +67,7 @@ public class KeywordSearchTerm extends SearchTerm{ if (wanted != null && !(wanted.equals(""))){ return matchField + ":" + "\"" + wanted + "\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ result.put(templateVariable,doc.get(dataField)); diff --git a/source/mircoders/search/MediaSearchTerm.java b/source/mircoders/search/MediaSearchTerm.java index 7d16cd20..7ac26962 100755 --- a/source/mircoders/search/MediaSearchTerm.java +++ b/source/mircoders/search/MediaSearchTerm.java @@ -55,9 +55,7 @@ public class MediaSearchTerm extends SearchTerm{ if (wanted != null && (wanted.equals("hasImages") || wanted.equals("hasAudio") || wanted.equals("hasVideo") )){ return wanted + ":\"y\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ diff --git a/source/mircoders/search/SearchTerm.java b/source/mircoders/search/SearchTerm.java index 6ed50799..6e7bdca9 100755 --- a/source/mircoders/search/SearchTerm.java +++ b/source/mircoders/search/SearchTerm.java @@ -31,8 +31,11 @@ package mircoders.search; import java.util.Map; + import javax.servlet.http.HttpServletRequest; + import mir.entity.Entity; + import org.apache.lucene.document.Document; diff --git a/source/mircoders/search/TextSearchTerm.java b/source/mircoders/search/TextSearchTerm.java index 334a4243..3b5cd44e 100755 --- a/source/mircoders/search/TextSearchTerm.java +++ b/source/mircoders/search/TextSearchTerm.java @@ -67,9 +67,7 @@ public class TextSearchTerm extends SearchTerm{ if (wanted != null && !(wanted.equals(""))){ return matchField + ":" + "\"" + wanted + "\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ result.put(templateVariable, doc.get(dataField)); diff --git a/source/mircoders/search/TopicMatrixSearchTerm.java b/source/mircoders/search/TopicMatrixSearchTerm.java index e6be2a19..1d41b659 100755 --- a/source/mircoders/search/TopicMatrixSearchTerm.java +++ b/source/mircoders/search/TopicMatrixSearchTerm.java @@ -74,9 +74,7 @@ public class TopicMatrixSearchTerm extends SearchTerm{ if (queryTerm.equals("")){ return null; } - else { - return "( "+queryTerm+ " )"; - } + return "( "+queryTerm+ " )"; } diff --git a/source/mircoders/search/TopicSearchTerm.java b/source/mircoders/search/TopicSearchTerm.java index cc1e2793..1421002c 100755 --- a/source/mircoders/search/TopicSearchTerm.java +++ b/source/mircoders/search/TopicSearchTerm.java @@ -61,9 +61,7 @@ public class TopicSearchTerm extends SearchTerm{ if (wanted != null && !(wanted.equals(""))){ return matchField + ":" + "\"" + wanted + "\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ diff --git a/source/mircoders/search/UnStoredSearchTerm.java b/source/mircoders/search/UnStoredSearchTerm.java index d0aa297d..55db890a 100755 --- a/source/mircoders/search/UnStoredSearchTerm.java +++ b/source/mircoders/search/UnStoredSearchTerm.java @@ -61,9 +61,7 @@ public class UnStoredSearchTerm extends SearchTerm{ if (wanted != null && !(wanted.equals(""))){ return matchField + ":" + "\"" + wanted + "\""; } - else { - return null; - } + return null; } public void returnMeta(Map result,Document doc){ return; diff --git a/source/mircoders/search/VideoSearchTerm.java b/source/mircoders/search/VideoSearchTerm.java index 40c1934d..caa9e274 100755 --- a/source/mircoders/search/VideoSearchTerm.java +++ b/source/mircoders/search/VideoSearchTerm.java @@ -29,7 +29,10 @@ */ package mircoders.search; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -68,9 +71,8 @@ public class VideoSearchTerm extends SearchTerm { if ((wanted != null) && wanted.equals("y")) { return matchField + ":" + "\"" + wanted + "\""; - } else { - return null; } + return null; } public void returnMeta(Map result, Document doc) { diff --git a/source/mircoders/servlet/ServletHelper.java b/source/mircoders/servlet/ServletHelper.java index 1fa09018..7963a03c 100755 --- a/source/mircoders/servlet/ServletHelper.java +++ b/source/mircoders/servlet/ServletHelper.java @@ -1,172 +1,171 @@ -/* - * 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 mircoders.servlet; - -import java.io.PrintWriter; -import java.io.IOException; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import mir.config.MirPropertiesConfiguration; -import mir.entity.adapter.EntityAdapter; -import mir.generator.Generator; -import mir.generator.GeneratorHelper; -import mir.log.LoggerWrapper; -import mir.servlet.ServletModuleExc; -import mir.servlet.ServletModuleFailure; -import mircoders.entity.EntityUsers; -import mircoders.global.MirGlobal; - - -public class ServletHelper { - private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper"); - - public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc { - return makeGenerationData(aRequest, aResponse, aLocales, "etc/bundles/adminlocal", "bundles/admin"); - } - - public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc { - return makeGenerationData(aRequest, aResponse, aLocales, aBundle, aBundle); - } - - public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc { - try { - MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance(); - Map result = GeneratorHelper.makeBasicGenerationData(aLocales, aBundle, aDefaultBundle); - if (configuration.getString("Mir.Admin.ShowLoggedinUsers").equals("1")) { - result.put("loggedinusers", MirGlobal.getLoggedInUsers()); - } - else { - result.put("loggedinusers", null); - } - result.put("systemstatus", MirGlobal.getStatus()); - - // ML: hackish - ((Map) result.get("config")).put("actionRoot", - aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir")); - - result.put("returnurl", null); - result.put("login_user", getUserAdapter(aRequest)); - - return result; - } - catch (Throwable t) { - throw new ServletModuleFailure(t); - } - } - - public static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc { - logger.debug("generator used: " + aGenerator); - - Generator generator; - - try { - generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator); - - generator.generate(aWriter, aGenerationData, logger); - } - catch (Throwable t) { - throw new ServletModuleFailure(t); - } - } - - public static void generateOpenPostingResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc { - Generator generator; - - try { - generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator); - - generator.generate(aWriter, aGenerationData, logger); - } - catch (Throwable t) { - throw new ServletModuleFailure(t); - } - } - - public static void generateInfoMessage(HttpServletRequest aRequest, HttpServletResponse aResponse, - Locale[] aLocales, String aBundle, String aDefaultBundle, String aMessage, String anArgument1, String anArgument2) throws ServletModuleExc { - Map responseData = makeGenerationData(aRequest, aResponse, aLocales, aBundle, aDefaultBundle); - responseData.put("message", aMessage); - responseData.put("argument1", anArgument1); - responseData.put("argument2", anArgument2); - - try { - generateResponse(aResponse.getWriter(), responseData, "infomessage.template"); - } - catch (IOException e) { - throw new ServletModuleFailure(e); - } - } - - public static void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure { - try { - aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/servlet/Mir?"+aQuery)); - } - catch (IOException t) { - throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t); - } - } - - public static void redirect(HttpServletResponse aResponse, String aModule, String aMethod) throws ServletModuleExc, ServletModuleFailure { - redirect(aResponse, "module="+aModule+"&do="+aMethod); - } - - public static void setUser(HttpServletRequest aRequest, EntityUsers aUser) { - if (aUser!=null) - aRequest.getSession().setAttribute("login.uid", aUser); - else - aRequest.getSession().removeAttribute("login.uid"); - } - - public static EntityUsers getUser(HttpServletRequest aRequest) { - return (EntityUsers) aRequest.getSession().getAttribute("login.uid"); - } - - public static EntityAdapter getUserAdapter(HttpServletRequest aRequest) { - try { - return MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter( "user", (EntityUsers) aRequest.getSession().getAttribute("login.uid")); - } - catch (Throwable t) { - throw new ServletModuleFailure (t); - } - } - - public static String getUserName(HttpServletRequest aRequest) { - EntityUsers user = getUser(aRequest); - - if (user!=null) - return user.getFieldValue("login"); - else - return "nobody"; - } -} +/* + * 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 mircoders.servlet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import mir.config.MirPropertiesConfiguration; +import mir.entity.adapter.EntityAdapter; +import mir.generator.Generator; +import mir.generator.GeneratorHelper; +import mir.log.LoggerWrapper; +import mir.servlet.ServletModuleExc; +import mir.servlet.ServletModuleFailure; +import mircoders.entity.EntityUsers; +import mircoders.global.MirGlobal; + + +public class ServletHelper { + private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper"); + + public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc { + return makeGenerationData(aRequest, aResponse, aLocales, "etc/bundles/adminlocal", "bundles/admin"); + } + + public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc { + return makeGenerationData(aRequest, aResponse, aLocales, aBundle, aBundle); + } + + public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc { + try { + MirPropertiesConfiguration configuration = MirPropertiesConfiguration.instance(); + Map result = GeneratorHelper.makeBasicGenerationData(aLocales, aBundle, aDefaultBundle); + if (configuration.getString("Mir.Admin.ShowLoggedinUsers").equals("1")) { + result.put("loggedinusers", MirGlobal.getLoggedInUsers()); + } + else { + result.put("loggedinusers", null); + } + result.put("systemstatus", MirGlobal.getStatus()); + + // ML: hackish + ((Map) result.get("config")).put("actionRoot", + aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir")); + + result.put("returnurl", null); + result.put("login_user", getUserAdapter(aRequest)); + + return result; + } + catch (Throwable t) { + throw new ServletModuleFailure(t); + } + } + + public static void generateResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc { + logger.debug("generator used: " + aGenerator); + + Generator generator; + + try { + generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator(aGenerator); + + generator.generate(aWriter, aGenerationData, logger); + } + catch (Throwable t) { + throw new ServletModuleFailure(t); + } + } + + public static void generateOpenPostingResponse(PrintWriter aWriter, Map aGenerationData, String aGenerator) throws ServletModuleExc { + Generator generator; + + try { + generator = MirGlobal.localizer().generators().makeOpenPostingGeneratorLibrary().makeGenerator(aGenerator); + + generator.generate(aWriter, aGenerationData, logger); + } + catch (Throwable t) { + throw new ServletModuleFailure(t); + } + } + + public static void generateInfoMessage(HttpServletRequest aRequest, HttpServletResponse aResponse, + Locale[] aLocales, String aBundle, String aDefaultBundle, String aMessage, String anArgument1, String anArgument2) throws ServletModuleExc { + Map responseData = makeGenerationData(aRequest, aResponse, aLocales, aBundle, aDefaultBundle); + responseData.put("message", aMessage); + responseData.put("argument1", anArgument1); + responseData.put("argument2", anArgument2); + + try { + generateResponse(aResponse.getWriter(), responseData, "infomessage.template"); + } + catch (IOException e) { + throw new ServletModuleFailure(e); + } + } + + public static void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure { + try { + aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/servlet/Mir?"+aQuery)); + } + catch (IOException t) { + throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t); + } + } + + public static void redirect(HttpServletResponse aResponse, String aModule, String aMethod) throws ServletModuleExc, ServletModuleFailure { + redirect(aResponse, "module="+aModule+"&do="+aMethod); + } + + public static void setUser(HttpServletRequest aRequest, EntityUsers aUser) { + if (aUser!=null) + aRequest.getSession().setAttribute("login.uid", aUser); + else + aRequest.getSession().removeAttribute("login.uid"); + } + + public static EntityUsers getUser(HttpServletRequest aRequest) { + return (EntityUsers) aRequest.getSession().getAttribute("login.uid"); + } + + public static EntityAdapter getUserAdapter(HttpServletRequest aRequest) { + try { + return MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter( "user", (EntityUsers) aRequest.getSession().getAttribute("login.uid")); + } + catch (Throwable t) { + throw new ServletModuleFailure (t); + } + } + + public static String getUserName(HttpServletRequest aRequest) { + EntityUsers user = getUser(aRequest); + + if (user!=null) + return user.getFieldValue("login"); + return "nobody"; + } +} diff --git a/source/mircoders/servlet/ServletModuleAbuse.java b/source/mircoders/servlet/ServletModuleAbuse.java index a44e5417..c5bd8c93 100755 --- a/source/mircoders/servlet/ServletModuleAbuse.java +++ b/source/mircoders/servlet/ServletModuleAbuse.java @@ -30,6 +30,11 @@ package mircoders.servlet; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.log.LoggerWrapper; import mir.servlet.ServletModule; import mir.servlet.ServletModuleExc; @@ -40,10 +45,6 @@ import mir.util.URLBuilder; import mircoders.abuse.FilterEngine; import mircoders.global.MirGlobal; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Map; - public class ServletModuleAbuse extends ServletModule { private static ServletModuleAbuse instance = new ServletModuleAbuse(); private String editFilterTemplate; diff --git a/source/mircoders/servlet/ServletModuleAdmin.java b/source/mircoders/servlet/ServletModuleAdmin.java index 568983bf..38cf70a9 100755 --- a/source/mircoders/servlet/ServletModuleAdmin.java +++ b/source/mircoders/servlet/ServletModuleAdmin.java @@ -32,6 +32,7 @@ package mircoders.servlet; import java.io.IOException; import java.io.Writer; import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/source/mircoders/servlet/ServletModuleComment.java b/source/mircoders/servlet/ServletModuleComment.java index 40cdd78d..89ce6981 100755 --- a/source/mircoders/servlet/ServletModuleComment.java +++ b/source/mircoders/servlet/ServletModuleComment.java @@ -30,6 +30,15 @@ package mircoders.servlet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.entity.adapter.EntityAdapterModel; import mir.entity.adapter.EntityIteratorAdapter; import mir.log.LoggerWrapper; @@ -37,16 +46,16 @@ import mir.servlet.ServletModule; import mir.servlet.ServletModuleExc; import mir.servlet.ServletModuleFailure; import mir.servlet.ServletModuleUserExc; -import mir.util.*; +import mir.util.CachingRewindableIterator; +import mir.util.HTTPRequestParser; +import mir.util.JDBCStringRoutines; +import mir.util.SQLQueryBuilder; +import mir.util.URLBuilder; import mircoders.entity.EntityComment; import mircoders.global.MirGlobal; import mircoders.module.ModuleComment; import mircoders.storage.DatabaseComment; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.*; - /* * ServletModuleComment - controls navigation for Comments * diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index e2a7042f..d2a56d44 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -30,6 +30,18 @@ package mircoders.servlet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.entity.adapter.EntityAdapter; import mir.entity.adapter.EntityAdapterModel; import mir.entity.adapter.EntityIteratorAdapter; @@ -39,7 +51,11 @@ import mir.misc.StringUtil; import mir.servlet.ServletModule; import mir.servlet.ServletModuleExc; import mir.servlet.ServletModuleFailure; -import mir.util.*; +import mir.util.HTTPRequestParser; +import mir.util.JDBCStringRoutines; +import mir.util.SQLQueryBuilder; +import mir.util.StringRoutines; +import mir.util.URLBuilder; import mircoders.entity.EntityContent; import mircoders.entity.EntityUsers; import mircoders.global.MirGlobal; @@ -47,10 +63,6 @@ import mircoders.module.ModuleContent; import mircoders.storage.DatabaseContent; import mircoders.storage.DatabaseContentToTopics; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.*; - /** * Article admin interface code */ diff --git a/source/mircoders/servlet/ServletModuleFileEdit.java b/source/mircoders/servlet/ServletModuleFileEdit.java index c8e0c2ec..93033474 100755 --- a/source/mircoders/servlet/ServletModuleFileEdit.java +++ b/source/mircoders/servlet/ServletModuleFileEdit.java @@ -37,7 +37,12 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.FilenameFilter; import java.io.StringWriter; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -55,8 +60,8 @@ import mir.util.URLBuilder; * Allows one to do a basic edit of a file in a directory specified * in the config file. * - * @author $Author: zapata $ - * @version $Revision: 1.13.2.8 $ $Date: 2005/01/09 20:37:13 $ + * @author $Author: rhindes $ + * @version $Revision: 1.13.2.9 $ $Date: 2005/02/10 16:22:27 $ * */ @@ -289,7 +294,7 @@ public class ServletModuleFileEdit extends ServletModule // TODO read array char[] c = new char[4096]; - int read;; + int read; while ( (read=in.read(c)) != -1) out.write(c, 0, read); in.close(); diff --git a/source/mircoders/servlet/ServletModuleHidden.java b/source/mircoders/servlet/ServletModuleHidden.java index 03606308..2aa81ef8 100755 --- a/source/mircoders/servlet/ServletModuleHidden.java +++ b/source/mircoders/servlet/ServletModuleHidden.java @@ -29,6 +29,13 @@ */ package mircoders.servlet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.entity.adapter.EntityIteratorAdapter; import mir.log.LoggerWrapper; import mir.servlet.ServletModule; @@ -41,12 +48,6 @@ import mir.util.JDBCStringRoutines; import mircoders.global.MirGlobal; import mircoders.module.ModuleContent; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; - /* * ServletModuleHidden - output of so called "censored" articles * @author mh diff --git a/source/mircoders/servlet/ServletModuleLocalizer.java b/source/mircoders/servlet/ServletModuleLocalizer.java index 582334f8..e5b92b8d 100755 --- a/source/mircoders/servlet/ServletModuleLocalizer.java +++ b/source/mircoders/servlet/ServletModuleLocalizer.java @@ -29,6 +29,14 @@ */ package mircoders.servlet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.log.LoggerWrapper; import mir.servlet.ServletModule; import mir.servlet.ServletModuleExc; @@ -39,10 +47,6 @@ import mircoders.global.MirGlobal; import mircoders.module.ModuleComment; import mircoders.module.ModuleContent; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.*; - public class ServletModuleLocalizer extends ServletModule { private static ServletModuleLocalizer instance = new ServletModuleLocalizer(); public static ServletModule getInstance() { return instance; } diff --git a/source/mircoders/servlet/ServletModuleMediaType.java b/source/mircoders/servlet/ServletModuleMediaType.java index 94007f76..62ac870f 100755 --- a/source/mircoders/servlet/ServletModuleMediaType.java +++ b/source/mircoders/servlet/ServletModuleMediaType.java @@ -32,7 +32,6 @@ package mircoders.servlet; import mir.log.LoggerWrapper; import mir.servlet.ServletModule; import mircoders.module.ModuleMediaType; -import mircoders.storage.DatabaseMediaType; public class ServletModuleMediaType extends ServletModule { diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 6de49f4e..2ec9ec23 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -50,7 +50,6 @@ import java.util.Locale; import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.Vector; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -121,7 +120,7 @@ import org.apache.lucene.search.Searcher; * open-postings to the newswire * * @author mir-coders group - * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.14 2005/01/23 15:36:05 zapata Exp $ + * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.15 2005/02/10 16:22:27 rhindes Exp $ * */ diff --git a/source/mircoders/servlet/ServletModuleProducer.java b/source/mircoders/servlet/ServletModuleProducer.java index 03b45560..c5b02dc3 100755 --- a/source/mircoders/servlet/ServletModuleProducer.java +++ b/source/mircoders/servlet/ServletModuleProducer.java @@ -29,6 +29,18 @@ */ package mircoders.servlet; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.generator.Generator; import mir.log.LoggerWrapper; import mir.producer.ProducerFactory; @@ -37,12 +49,6 @@ import mir.servlet.ServletModuleFailure; import mir.util.HTTPRequestParser; import mircoders.global.MirGlobal; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.*; - public class ServletModuleProducer extends ServletModule { private static ServletModuleProducer instance = new ServletModuleProducer(); diff --git a/source/mircoders/servlet/ServletModuleUsers.java b/source/mircoders/servlet/ServletModuleUsers.java index 367ab53f..ae3f66f8 100755 --- a/source/mircoders/servlet/ServletModuleUsers.java +++ b/source/mircoders/servlet/ServletModuleUsers.java @@ -30,6 +30,15 @@ package mircoders.servlet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import mir.entity.adapter.EntityAdapterModel; import mir.entity.adapter.EntityIteratorAdapter; import mir.log.LoggerWrapper; @@ -45,10 +54,6 @@ import mircoders.global.MirGlobal; import mircoders.module.ModuleUsers; import mircoders.storage.DatabaseUsers; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.*; - /** * * @@ -135,8 +140,7 @@ public class ServletModuleUsers extends ServletModule return newPassword; } - else - return null; + return null; } public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse) diff --git a/source/mircoders/storage/DatabaseArticleType.java b/source/mircoders/storage/DatabaseArticleType.java index 9921ee34..0b36989f 100755 --- a/source/mircoders/storage/DatabaseArticleType.java +++ b/source/mircoders/storage/DatabaseArticleType.java @@ -41,7 +41,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; public class DatabaseArticleType extends Database { diff --git a/source/mircoders/storage/DatabaseAudio.java b/source/mircoders/storage/DatabaseAudio.java index 9ab4a686..68b25e4b 100755 --- a/source/mircoders/storage/DatabaseAudio.java +++ b/source/mircoders/storage/DatabaseAudio.java @@ -29,14 +29,14 @@ */ package mircoders.storage; +import java.util.GregorianCalendar; + import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.misc.StringUtil; import mir.storage.Database; import mir.storage.StorageObjectFailure; -import java.util.GregorianCalendar; - public class DatabaseAudio extends Database { private static DatabaseAudio instance; diff --git a/source/mircoders/storage/DatabaseBreaking.java b/source/mircoders/storage/DatabaseBreaking.java index a4b07df9..e058f508 100755 --- a/source/mircoders/storage/DatabaseBreaking.java +++ b/source/mircoders/storage/DatabaseBreaking.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseComment.java b/source/mircoders/storage/DatabaseComment.java index ab545b6b..12e8da1b 100755 --- a/source/mircoders/storage/DatabaseComment.java +++ b/source/mircoders/storage/DatabaseComment.java @@ -36,7 +36,6 @@ import java.sql.Statement; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseCommentStatus.java b/source/mircoders/storage/DatabaseCommentStatus.java index 337d92b8..46bc65b0 100755 --- a/source/mircoders/storage/DatabaseCommentStatus.java +++ b/source/mircoders/storage/DatabaseCommentStatus.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; public class DatabaseCommentStatus extends Database { diff --git a/source/mircoders/storage/DatabaseCommentToMedia.java b/source/mircoders/storage/DatabaseCommentToMedia.java index aa6267ec..9f8807c4 100755 --- a/source/mircoders/storage/DatabaseCommentToMedia.java +++ b/source/mircoders/storage/DatabaseCommentToMedia.java @@ -31,24 +31,20 @@ package mircoders.storage; import java.sql.Connection; -import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; -import mir.storage.StorageObjectExc; import mir.storage.StorageObjectFailure; -import mircoders.entity.EntityComment; import mircoders.entity.EntityUploadedMedia; /** * implements abstract DB connection to the comment_x_media SQL table * * @author RK, mir-coders group - * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.9 2005/01/23 15:36:05 zapata Exp $ + * @version $Id: DatabaseCommentToMedia.java,v 1.3.2.10 2005/02/10 16:22:22 rhindes Exp $ * */ diff --git a/source/mircoders/storage/DatabaseContent.java b/source/mircoders/storage/DatabaseContent.java index c5283a5c..cf0258fb 100755 --- a/source/mircoders/storage/DatabaseContent.java +++ b/source/mircoders/storage/DatabaseContent.java @@ -35,7 +35,6 @@ import java.sql.Statement; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseContentToMedia.java b/source/mircoders/storage/DatabaseContentToMedia.java index 8188465e..bcdc80ec 100755 --- a/source/mircoders/storage/DatabaseContentToMedia.java +++ b/source/mircoders/storage/DatabaseContentToMedia.java @@ -31,24 +31,20 @@ package mircoders.storage; import java.sql.Connection; -import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import mir.entity.EntityList; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; -import mir.storage.StorageObjectExc; import mir.storage.StorageObjectFailure; -import mircoders.entity.EntityContent; 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.8 2005/01/23 15:36:05 zapata Exp $ + * @version $Id: DatabaseContentToMedia.java,v 1.19.2.9 2005/02/10 16:22:22 rhindes Exp $ * */ diff --git a/source/mircoders/storage/DatabaseContentToTopics.java b/source/mircoders/storage/DatabaseContentToTopics.java index 18ae6523..d3f55719 100755 --- a/source/mircoders/storage/DatabaseContentToTopics.java +++ b/source/mircoders/storage/DatabaseContentToTopics.java @@ -30,14 +30,6 @@ package mircoders.storage; -import mir.entity.EntityList; -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.Database; -import mir.storage.StorageObjectFailure; -import mircoders.entity.EntityContent; -import mircoders.entity.EntityTopics; - import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; @@ -46,6 +38,13 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; +import mir.entity.EntityList; +import mir.log.LoggerWrapper; +import mir.storage.Database; +import mir.storage.StorageObjectFailure; +import mircoders.entity.EntityContent; +import mircoders.entity.EntityTopics; + /** * This class implements the 1-n-relation between * content and topic diff --git a/source/mircoders/storage/DatabaseFilter.java b/source/mircoders/storage/DatabaseFilter.java index 6c34f7c6..3a7fe733 100755 --- a/source/mircoders/storage/DatabaseFilter.java +++ b/source/mircoders/storage/DatabaseFilter.java @@ -1,58 +1,57 @@ -/* - * 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 mircoders.storage; - -/** - * - */ - -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.Database; - -public class DatabaseFilter extends Database { - private static DatabaseFilter instance; - - public synchronized static DatabaseFilter getInstance() { - if (instance == null) { - instance = new DatabaseFilter(); - } - - return instance; - } - - private DatabaseFilter() { - super(); - - logger = new LoggerWrapper("Database.Filter"); - mainTable = "filter"; - } -} +/* + * 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 mircoders.storage; + +/** + * + */ + +import mir.log.LoggerWrapper; +import mir.storage.Database; + +public class DatabaseFilter extends Database { + private static DatabaseFilter instance; + + public synchronized static DatabaseFilter getInstance() { + if (instance == null) { + instance = new DatabaseFilter(); + } + + return instance; + } + + private DatabaseFilter() { + super(); + + logger = new LoggerWrapper("Database.Filter"); + mainTable = "filter"; + } +} diff --git a/source/mircoders/storage/DatabaseFilterGroup.java b/source/mircoders/storage/DatabaseFilterGroup.java index e6c1696a..e91e7f5e 100755 --- a/source/mircoders/storage/DatabaseFilterGroup.java +++ b/source/mircoders/storage/DatabaseFilterGroup.java @@ -1,57 +1,56 @@ -/* - * 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 mircoders.storage; - -/** - * - */ - -import mir.log.LoggerWrapper; -import mir.storage.Database; -import mir.storage.Database; - -public class DatabaseFilterGroup extends Database { - private static DatabaseFilterGroup instance; - - public synchronized static DatabaseFilterGroup getInstance() { - if (instance == null) { - instance = new DatabaseFilterGroup(); - } - return instance; - } - - private DatabaseFilterGroup() { - super(); - - logger = new LoggerWrapper("Database.FilterGroup"); - mainTable="filter_group"; - } -} +/* + * 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 mircoders.storage; + +/** + * + */ + +import mir.log.LoggerWrapper; +import mir.storage.Database; + +public class DatabaseFilterGroup extends Database { + private static DatabaseFilterGroup instance; + + public synchronized static DatabaseFilterGroup getInstance() { + if (instance == null) { + instance = new DatabaseFilterGroup(); + } + return instance; + } + + private DatabaseFilterGroup() { + super(); + + logger = new LoggerWrapper("Database.FilterGroup"); + mainTable="filter_group"; + } +} diff --git a/source/mircoders/storage/DatabaseImageColor.java b/source/mircoders/storage/DatabaseImageColor.java index 545f0db3..7b0ebda0 100755 --- a/source/mircoders/storage/DatabaseImageColor.java +++ b/source/mircoders/storage/DatabaseImageColor.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; /** * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle diff --git a/source/mircoders/storage/DatabaseImageFormat.java b/source/mircoders/storage/DatabaseImageFormat.java index e25ee771..6a42f0d4 100755 --- a/source/mircoders/storage/DatabaseImageFormat.java +++ b/source/mircoders/storage/DatabaseImageFormat.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; /** * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle diff --git a/source/mircoders/storage/DatabaseImageLayout.java b/source/mircoders/storage/DatabaseImageLayout.java index 2a3c882e..066db53e 100755 --- a/source/mircoders/storage/DatabaseImageLayout.java +++ b/source/mircoders/storage/DatabaseImageLayout.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; /** * Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle diff --git a/source/mircoders/storage/DatabaseImageType.java b/source/mircoders/storage/DatabaseImageType.java index 377767fd..78bd2f99 100755 --- a/source/mircoders/storage/DatabaseImageType.java +++ b/source/mircoders/storage/DatabaseImageType.java @@ -31,7 +31,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; /** * diff --git a/source/mircoders/storage/DatabaseImages.java b/source/mircoders/storage/DatabaseImages.java index 8b9a70b6..87ac2d82 100755 --- a/source/mircoders/storage/DatabaseImages.java +++ b/source/mircoders/storage/DatabaseImages.java @@ -36,7 +36,6 @@ import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.misc.StringUtil; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseLanguage.java b/source/mircoders/storage/DatabaseLanguage.java index f9ba4a25..bb0eac8c 100755 --- a/source/mircoders/storage/DatabaseLanguage.java +++ b/source/mircoders/storage/DatabaseLanguage.java @@ -39,13 +39,16 @@ package mircoders.storage; * @version 1.0 */ -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import mir.entity.Entity; import mir.entity.EntityBrowser; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; diff --git a/source/mircoders/storage/DatabaseMediaType.java b/source/mircoders/storage/DatabaseMediaType.java index 0b1ed4cd..b8f3397e 100755 --- a/source/mircoders/storage/DatabaseMediaType.java +++ b/source/mircoders/storage/DatabaseMediaType.java @@ -31,7 +31,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseMediafolder.java b/source/mircoders/storage/DatabaseMediafolder.java index bbf4ecb0..d4d113e4 100755 --- a/source/mircoders/storage/DatabaseMediafolder.java +++ b/source/mircoders/storage/DatabaseMediafolder.java @@ -36,7 +36,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; public class DatabaseMediafolder extends Database { private static DatabaseMediafolder instance; diff --git a/source/mircoders/storage/DatabaseMessages.java b/source/mircoders/storage/DatabaseMessages.java index aeb8a16f..87e5bfd4 100755 --- a/source/mircoders/storage/DatabaseMessages.java +++ b/source/mircoders/storage/DatabaseMessages.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; /** diff --git a/source/mircoders/storage/DatabaseOther.java b/source/mircoders/storage/DatabaseOther.java index 2931809a..6fe2936d 100755 --- a/source/mircoders/storage/DatabaseOther.java +++ b/source/mircoders/storage/DatabaseOther.java @@ -36,7 +36,6 @@ import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.misc.StringUtil; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseRights.java b/source/mircoders/storage/DatabaseRights.java index 2f38d94e..0d018d54 100755 --- a/source/mircoders/storage/DatabaseRights.java +++ b/source/mircoders/storage/DatabaseRights.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseTopics.java b/source/mircoders/storage/DatabaseTopics.java index 49c84d19..a478fef5 100755 --- a/source/mircoders/storage/DatabaseTopics.java +++ b/source/mircoders/storage/DatabaseTopics.java @@ -30,13 +30,16 @@ package mircoders.storage; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import mir.entity.Entity; import mir.entity.EntityBrowser; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseUploadedMedia.java b/source/mircoders/storage/DatabaseUploadedMedia.java index 72bf3b55..0e173ded 100755 --- a/source/mircoders/storage/DatabaseUploadedMedia.java +++ b/source/mircoders/storage/DatabaseUploadedMedia.java @@ -36,7 +36,6 @@ import mir.entity.Entity; import mir.entity.EntityBrowser; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; public class DatabaseUploadedMedia extends Database { diff --git a/source/mircoders/storage/DatabaseUsers.java b/source/mircoders/storage/DatabaseUsers.java index 02bc85ef..66ffa864 100755 --- a/source/mircoders/storage/DatabaseUsers.java +++ b/source/mircoders/storage/DatabaseUsers.java @@ -32,7 +32,6 @@ package mircoders.storage; import mir.log.LoggerWrapper; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/mircoders/storage/DatabaseVideo.java b/source/mircoders/storage/DatabaseVideo.java index 6e253a20..7bcdaef5 100755 --- a/source/mircoders/storage/DatabaseVideo.java +++ b/source/mircoders/storage/DatabaseVideo.java @@ -36,7 +36,6 @@ import mir.entity.Entity; import mir.log.LoggerWrapper; import mir.misc.StringUtil; import mir.storage.Database; -import mir.storage.Database; import mir.storage.StorageObjectFailure; /** diff --git a/source/tool/BundleTool.java b/source/tool/BundleTool.java index 0b007d4f..9a766432 100755 --- a/source/tool/BundleTool.java +++ b/source/tool/BundleTool.java @@ -48,7 +48,6 @@ public class BundleTool { public static void compare(String aMaster, String aSlave) { PropertiesManipulator master; PropertiesManipulator slave; - PropertiesManipulator result; try { master = PropertiesManipulator.readProperties( diff --git a/source/tool/ImageTool.java b/source/tool/ImageTool.java index ff68b2c9..beadd1c1 100755 --- a/source/tool/ImageTool.java +++ b/source/tool/ImageTool.java @@ -4,7 +4,6 @@ import java.awt.Transparency; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.SampleModel; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -- 2.11.0