From 36c394492096600d855a59bba3e19142b37272e5 Mon Sep 17 00:00:00 2001 From: zapata Date: Thu, 15 May 2003 17:14:59 +0000 Subject: [PATCH] more experimental rss code. Not finished yet though. --- bundles/admin_it.properties | 579 +++++++++++++++++++++ etc/producer/RSS.template | 18 +- source/default.properties | 3 + source/mir/generator/FreemarkerGenerator.java | 21 +- source/mir/producer/RSSProducerNode.java | 19 +- .../reader/DefaultProducerNodeBuilders.java | 36 ++ source/mir/rss/RSSChannel.java | 84 --- source/mir/rss/RSSData.java | 62 ++- source/mir/rss/RSSItem.java | 72 --- source/mir/rss/RSSReader.java | 329 ++++++++---- source/mir/rss/RSSToMapConverter.java | 79 --- source/mir/util/ParameterExpander.java | 55 +- source/mir/util/XMLReader.java | 85 ++- templates/admin/FUNCTIONS.template | 19 + templates/admin/commentlist.template | 256 +++++---- templates/admin/contentlist.template | 4 +- templates/admin/linksimcslist.template | 108 ---- templates/admin/messagelist.template | 14 +- 18 files changed, 1162 insertions(+), 681 deletions(-) create mode 100755 bundles/admin_it.properties delete mode 100755 source/mir/rss/RSSChannel.java delete mode 100755 source/mir/rss/RSSItem.java delete mode 100755 source/mir/rss/RSSToMapConverter.java delete mode 100755 templates/admin/linksimcslist.template diff --git a/bundles/admin_it.properties b/bundles/admin_it.properties new file mode 100755 index 00000000..089a12b3 --- /dev/null +++ b/bundles/admin_it.properties @@ -0,0 +1,579 @@ +########## admin ####### +# language: italiano +# $Id: admin_it.properties,v 1.1 2003/05/15 17:14:59 zapata Exp $ + +# missing (master value = "English") +languagename = italiano + +# general +yes = si +no = no +dontcare = uguale +all = tutto +month = mese +year = anno +# changed! (it was "file") +file = documento +new = nuovo +by = da +help = aiuto + + +# actions +insert = inserisci +save = salva +# changed! (it was "edit") +edit = edita +delete = cancella +add = aggiungi +filter = filtra +# changed! (it was "attacca") +attach = allega +list = sfoglia +back = indietro +cancel = annulla +preview = anteprima +# changed! (it was "reset") +reset = azzera +administer = amministratore +search = cerca + + +# special +fileedit = fileEdit + + +# records +records = entrate +show_from_to = da {0} a {1} +# changed! (it was "non risultano entrate!") +no_matches_found = nessuna corrispondenza trovata! +list.next = prossimo +list.previous = precedente + + +# media - used by image, audio, video and other media +media.created = creato +media.changed = ultima modifica +media.published = pubblicato +media.format = formato +media.rights = Copyright +media.type = tipo +# changed! (it was "media folder") +media.mediafolder = cartella media +media.title = titolo +media.size = grandezza +media.description = descrizione +media.date = data +media.location = luogo di origine +media.creator = autore +media.keywords = parola chiave +media.comment = commento interno +# changed! in bibliography *slang* is "fonte", that actually means "source" (it was "origine") +media.source = fonte +# changed! (it was "da pubblicare" which means "to be published") <-- correct? +media.is_published = pubblicato +media.icon = icona +media.nr_of_media = numero dei media da pubblicare (max 20) +media.nr_of_media.submit = clicca + +medialist.search_text_in = cerca questa parola in + + +# image +image.htmltitle = immagine +# changed! (it was "immagini") +imagelist.htmltitle = lista delle immagini + + +# audio +audio.htmltitle = audio +audiolist.htmltitle = lista dei file audio + + +# video +video.htmltitle = video +videolist.htmltitle = lista dei video + + +# other +# changed! (it was "lista di altri media") +other_media.htmltitle = altro media +other_medialist.htmltitle = lista di altri media + + +# breaking +breaking.htmltitle = ultima notizia +breaking.textinfo = (max. 5 linee / 250 caratteri) +breaking.text = testo +breaking.date = data + +breakinglist.htmltitle = ultime notizie + + +# comment +comment.htmltitle = commento +comment.date = data +comment.title = titolo +comment.published = pubblicato +comment.text = testo +comment.address = indirizzo +comment.phone = telefono +comment.email = email +comment.url = url +comment.creator = autore +comment.article = dell'articolo +comment.html = HTML +comment.status = stato +comment.language = lingua + +comment.operation.hide = nascondi +comment.operation.unhide = rendi visibile + + +#commentlist +commentlist.htmltitle = lista dei commenti +commentlist.published = pubblicato +commentlist.hidden = rimosso +commentlist.allcomments = tutti i commenti a questo articolo +commentlist.search = vai! +commentlist.activate = attiva i cambiamenti +commentlist.order = ordina +commentlist.order.datedesc = data (disc.) +commentlist.order.dateasc = data (asc.) +commentlist.order.articletitle = titolo dell'articolo + +commentsearch.field = cerca +commentsearch.field.title = titolo +commentsearch.field.creator = autore +commentsearch.field.description = descrizione +commentsearch.value = valore + +commentsearch.publishedstate = stato di pubblicazione +commentsearch.publishedstate.hidden = nascosto +commentsearch.publishedstate.published = pubblicato + +commentsearch.status = stato + +commentsearch.order = ordina +commentsearch.order.datedesc = data (desc.) +commentsearch.order.dateasc = data (asc.) +commentsearch.order.articletitle = titolo dell'articolo + +commentsearch.searchbutton = cerca + + +# confirm +confirm.htmltitle = conferma cancella +confirm.really_delete = vuoi davvero cancellare questa entrata? +# missing (master value = "This will erase the entry from the database unrecoverably.") +confirm.text = L'articolo verrˆ cancellato definitivamente dalla banca dati. + + +# content +content.htmltitle = articolo +content.owner = proprietario +content.language = lingua +content.articletype = tipo di articolo +# not sure "tema" (theme) is the best translation... +content.topic = tema +content.title = titolo lungo +content.subtitle = sottotitolo +# not sure about that (context = contesto) +content.edittitle = contesto +content.location = provenienza +content.creator = autore +content.creator.email = Email +content.creator.url = Web +content.creator.address = indirizzo +content.creator.telephone = telefono +content.abstract = introduzione +content.content = contenuto +content.html = in HTML? +content.comment = commento interno +content.internal = (interno) + +content.attachments = aggiungi +content.images = immagini +content.audio = audio +content.video = video +content.other = altri media +content.media = media +content.addimage = aggiungi immagine +content.uploadimage = carica immagine +content.addaudio = aggiungi audio +content.uploadaudio = carica audio +content.addvideo = aggiungi video +content.uploadvideo = carica video +content.addother = aggiungi altri media +content.uploadother = carica altri media + +content.creationdate = data +content.modificationdate = ultima modifica +content.status = stato +content.type = tipo di articolo +content.import_date = data d'importo +content.lastchange_date = ultima modifica +content.create_date = data +content.published = pubblicato +content.comments = commenti + +content.family = Bambini & Genitori +content.children = Bambini +content.viewchildren = vedi +content.parent = Genitore +content.viewparent = vedi +content.clearparent = deseleziona +content.selectparent = seleziona + +content.operation.hide = nascondi +content.operation.unhide = rendi visibile +# missing (master value = "newswire") no idea... maybe "colonna delle notizie"? (news column) +content.operation.newswire = + +contentsearch.value = cerca +contentsearch.field = campo +contentsearch.field.title = titolo +contentsearch.field.creator = autore +contentsearch.field.contents = contenuto + +# missing (master value = "publication state") +contentsearch.publishedstate = stato di pubblicazione +# missing (master value = "hidden") +contentsearch.publishedstate.hidden = nascosto +# missing (master value = "published") +contentsearch.publishedstate.published = pubblicato + +# missing (master value = "article type") +contentsearch.articletype = tipo di articolo + +contentsearch.order = ordine: +contentsearch.order.datedesc = recenti prima +contentsearch.order.dateasc = vecchi prima +contentsearch.order.title = titolo +contentsearch.order.creator = autore +contentsearch.searchbutton = cerca + + +#contentlist +contentlist.htmltitle = lista degli articoli +contentlist.comments = commenti +contentlist.select = seleziona + + +# language +language.htmltitle = lingue +language.name = lingua +language.code = codice della lingua + +languagelist.htmltitle = lista delle lingue + +# login +login.htmltitle = login +login.info = quest'area \u008f unicamente accessibile a gruppi autorizzati. Se desideri collaborare come editore, per favore contattaci +login.title = login +login.name = login +login.password = password +login.language = lingua +login.submit = OK + + +# mediafolder +mediafolder.htmltitle = mediafolder +mediafolder.date = data +mediafolder.name = nome +mediafolder.location = luogo di origine +mediafolder.keywords = parola chiave +mediafolder.comment = commento + +# changed! (it was "lista dei mediaFolder") +mediafolderlist.htmltitle = lista delle cartelle media + + +# message +message.htmltitle = messaggio +message.date = data +message.title = titolo +message.creator = autore +message.text = testo +message.textinfo = (max. 5 linee / 250 caratteri) + +messagelist.htmltitle = lista dei messaggi + +# admin start page +# changed! (it was "admin") +start.htmltitle = amministrazione + +start.content.new = nuovo articolo +start.show = mostra +start.open_by_id = apri id + +# changed! (it was "articoli rimossi") +start.content.hidden = articoli nascosti +start.content.not_published = articoli rimossi +start.content.with_media = articoli con media +start.content.last_changes = ultimi cambiamenti +start.content.with_comments = con commento interno +start.content.all = tutti +start.content.search = cerca + +# missing (master value = "{0}") ??? +start.allarticlesoftype = + +start.producers.title = AGGIORNARE MANUALMENTE +# changed! (it was "aggiornare tutto il nuovo") <-- not *really* italian +start.producers.produceAllNew = Aggiornare Tutto +# changed! (it was "Advanced Page") +start.producers.advanced = Aggiornamento Avanzato (usare con cautela) + +start.administer.title = AMMINISTRA +start.administer.comments = commenti + +start.breaking.title = ULTIMA NOTIZIA +# missing (master value = "LIST") +start.list.title = +# missing (master value = "edit include files") +start.fileedit.includes.title = +# missing (master value = "ADD / EDIT") +start.addandedit.title = aggiungi / +# missing (master value = "EXTRA") +start.extra.title = +# missing (master value = "SEARCH") +start.search.title = +start.other_media.title = MATERIALE DA ALTRI MEDIA +start.images.title = IMMAGINI +start.video.title = VIDEO +start.audio.title = AUDIO +# missing (master value = "MEDIA") +start.media.title = +start.mediafolder.title = MEDIAFOLDER +start.languages.title = LINGUA +start.imcs.title = IMCS +start.messageboard.title = colonna messaggi interni +start.messageboard.no_messages = non ci sono messaggi + +# missing (master value = "super-user functions (use with care!)") +start.superusermenu = + + +# topic +topic.htmltitle = tema +topic.title = nome +topic.description = descrizione +topic.filename = nome della cartella +topic.main_url = home page +topic.archive_url = URL dell' archivio + +topiclist.htmltitle = lista dei temi + + +# users +user.htmltitle = utente +user.login = login +user.password = password +# missing (master value = "Password (confirmation)") +user.password2 = +user.admin = admin + +userlist.htmltitle = lista degli utenti + + +#articletype +# missing (master value = "Article type") +articletype.htmltitle = +# missing (master value = "id") +articletype.id = +# missing (master value = "Name") +articletype.name = + +# missing (master value = "Article types") +articletypelist.htmltitle = + + + +#commentstatus +# missing (master value = "Comment status") +commentstatus.htmltitle = +# missing (master value = "id") +commentstatus.id = +# missing (master value = "Name") +commentstatus.name = + +# missing (master value = "Comment status values") +commentstatuslist.htmltitle = + + + +#file editing +fileedit.htmltitle = Edit file +fileedit.filename = nome del file +# missing (master value = "Subdirectory") +fileedit.subdirectory = + +fileeditlist.htmltitle = Editable files +fileeditlist.filename = nome del file +# missing (master value = "Subdirectory") +fileeditlist.dirname = + + +#producers +producer.producer = Producer name +producer.verb.name = nome del processo +producer.verb.description = descrizione del processo +producer.verb.enqueue = in coda + +producer.job.name = lavoro +producer.job.status = stato +producer.job.date = ultimo cambiamento +producer.job.cancel = annulla +producer.job.abort = uccidi +# missing (master value = "Queue is empty") +producer.job.empty = + +producer.jobqueue.title = lavori in corso +producer.jobqueue.refresh = aggiorna +producer.producerlist.title = aggiungi un luovo lavoro + +producerqueue.htmltitle = aggiornato manualmente + + +#superusermenu +# missing (master value = "Super-user functions") +superusermenu.htmltitle = +# missing (master value = "MANAGE") +superusermenu.manage = +# missing (master value = "topics") +superusermenu.topics = +# missing (master value = "article types") +superusermenu.articletypes = +# missing (master value = "comment status values") +superusermenu.comment_statuses = +# missing (master value = "users") +superusermenu.users = +# missing (master value = "languages") +superusermenu.languages = +# missing (master value = "apply anti-abuse measures") +superusermenu.abuse = +# missing (master value = "IMCS (obsolete)") +superusermenu.imcs = + + +#abuse +# missing (master value = "anti-abuse measures") +abuse.htmltitle = + +# missing (master value = "Setting") +abuse.setting = +# missing (master value = "Value") +abuse.value = + +# missing (master value = "Turn off open posting") +abuse.disableopenpostings = +# missing (master value = "Require a password for open postings") +abuse.openpostingpassword = +# missing (master value = "Log IPs for open postings") +abuse.logpostings = +# missing (master value = "Logging buffer size") +abuse.logsize = +# missing (master value = "Use cookies for blocked users") +abuse.cookies = +# missing (master value = "Action for blocked article") +abuse.articleaction = +# missing (master value = "Action for blocked comment") +abuse.commentaction = + +# missing (master value = "Show the IP log") +abuse.showlog = +# missing (master value = "Manage filters") +abuse.showfilters = + +# missing (master value = "Time") +abuse.log.time = +# missing (master value = "IP number") +abuse.log.address = +# missing (master value = "Object") +abuse.log.object = +# missing (master value = "Browser") +abuse.log.browser = + +# missing (master value = "Filters") +abuse.filters = +# missing (master value = "Type") +abuse.filter.type = +# missing (master value = "IP Number") +abuse.filtertype.ip = +# missing (master value = "Regular expression") +abuse.filtertype.regexp = +# missing (master value = "Expression") +abuse.filter.expression = + + +# head +head.start = inizio +head.logout = uscire +head.help = aiuto +head.search = cerca +head.logged_in = sei connesso + +# foot +foot.top = sopra + + +########## dynamic values ########## + +# (users can add new types, how to translate these) +# suggestion if not in bundle use value as Text + + +# Article types +# missing (master value = "Open posting") +articletypes.openposting = +# missing (master value = "Newswire") +articletypes.newswire = +# missing (master value = "Feature") +articletypes.feature = +# missing (master value = "Topic-special") +articletypes.topicspecial = +# missing (master value = "Startpage-special") +articletypes.startspecial = + +# Comment status values +# missing (master value = "normal") +commentstatus.normal = +# missing (master value = "good") +commentstatus.good = +# missing (master value = "bad") +commentstatus.bad = + + + +########## error ########## +error.htmltitle = il sistema ha causato un errore +error.title = ahi! ahi! ahi! +error.text = Pu\u0098 succedere. Se il messaggio seguente non ti \u008e chiaro, potresti {1}: +error.text2 = Per favore spedisci un e-mail con il testo che appare in rosso e una descrizione dettagliata al seguente indirizzo {1}. Grazie! + +usererror.htmltitle = manca qualchecosa +usererror.title = ahi! ahi! ahi! +usererror.text = i dati che hai introdotto hanno causato il seguente errore: +usererror.what_to_do = Per favore, schiaccia il bottone indietro e riprova + +# missing (master value = "The format of the media you uploaded is not supported") +media.error.unsupportedformat = +# missing (master value = "The new password must be entered twice") +user.error.missingpasswords = +# missing (master value = "The passwords are not equal") +user.error.passwordmismatch = +# missing (master value = "A password must be entered") +user.error.missingpassword = + + +########## infomessages ########## +# missing (master value = "Information") +infomessage.htmltitle = +infomessage.produceAllNewAddedToQueue = la tua richiesta \u008e stata aggiunta alla coda. + +########## HTML-charset ########## +# missing (master value = "utf-8") +htmlcharset = + diff --git a/etc/producer/RSS.template b/etc/producer/RSS.template index 26e7c32c..3637fd3f 100755 --- a/etc/producer/RSS.template +++ b/etc/producer/RSS.template @@ -1,9 +1,3 @@ - - Template file for an rdf file. - - Variables: - - - - Indymedia-XX - ${config["Producer.ProductionHost"]} - Highlights from Indymedia-XX, a revolutionary expirement in democratic media - IMC Features Working Group &lt;features@someindymedia.org&gt; + + ${utility.encodeXML(channeltitle)} + ${utility.encodeXML(channellink)} + ${utility.encodeXML(channeldescription)} + ${utility.encodeXML(channelpublisher)} Open Content License, http://www.opencontent.org ${config.now.dc} - + diff --git a/source/default.properties b/source/default.properties index 0a1aac46..ef6d5bf6 100755 --- a/source/default.properties +++ b/source/default.properties @@ -152,6 +152,9 @@ ServletModule.OpenIndy.DefaultMediaUploadItems=1 # the url of the static site Producer.ProductionHost=http://indy.code-fu.de +# the url of the public site +Producer.PublicationHost=http://indy.code-fu.de + # Produrce.StorageRoot is the directory, in which # the generated HTML pages will be stored Producer.StorageRoot=/pub/Dokumente/Indymedia/de-tech/Mir/produced diff --git a/source/mir/generator/FreemarkerGenerator.java b/source/mir/generator/FreemarkerGenerator.java index 11d86109..97ee1e32 100755 --- a/source/mir/generator/FreemarkerGenerator.java +++ b/source/mir/generator/FreemarkerGenerator.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.generator; @@ -39,7 +39,7 @@ import java.util.Vector; import mir.log.LoggerWrapper; import mir.util.RewindableIterator; -import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.beanutils.*; import freemarker.template.FileTemplateCache; import freemarker.template.SimpleScalar; @@ -336,7 +336,10 @@ public class FreemarkerGenerator implements Generator { public TemplateModel get(String aKey) throws TemplateModelException { try { - return makeAdapter(PropertyUtils.getSimpleProperty(object, aKey)); + if (PropertyUtils.isReadable(object, aKey)) + return makeAdapter(PropertyUtils.getSimpleProperty(object, aKey)); + else + return makeAdapter(MethodUtils.invokeExactMethod(object, "get", aKey)); } catch (Throwable t) { throw new TemplateModelException(t.getMessage()); diff --git a/source/mir/producer/RSSProducerNode.java b/source/mir/producer/RSSProducerNode.java index 05c77e64..ac41f288 100755 --- a/source/mir/producer/RSSProducerNode.java +++ b/source/mir/producer/RSSProducerNode.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.producer; @@ -33,8 +33,7 @@ import java.util.Map; import mir.log.LoggerWrapper; import mir.rss.RSSData; -import mir.rss.RSSReader; -import mir.rss.RSSToMapConverter; +import mir.rss.*; import mir.util.ExceptionFunctions; import mir.util.ParameterExpander; @@ -55,7 +54,7 @@ public class RSSProducerNode implements ProducerNode { ParameterExpander.setValueForKey(aValueMap, expandedKey, null); RSSReader reader = new RSSReader(); RSSData rssData = reader.parseUrl(expandedUrl); - ParameterExpander.setValueForKey(aValueMap, expandedKey, RSSToMapConverter.convertRSSData(rssData)); + ParameterExpander.setValueForKey(aValueMap, expandedKey, rssData); } catch (Throwable t) { Throwable s = ExceptionFunctions.traceCauseException(t); diff --git a/source/mir/producer/reader/DefaultProducerNodeBuilders.java b/source/mir/producer/reader/DefaultProducerNodeBuilders.java index 3cd24f97..b458fed1 100755 --- a/source/mir/producer/reader/DefaultProducerNodeBuilders.java +++ b/source/mir/producer/reader/DefaultProducerNodeBuilders.java @@ -78,6 +78,7 @@ public class DefaultProducerNodeBuilders { aBuilderLibrary.registerBuilder("While", LoopProducerNodeBuilder.class); aBuilderLibrary.registerBuilder("RSS", RSSProducerNodeBuilder.class); + aBuilderLibrary.registerBuilder("RDFAggregate", RDFAggregatorProducerNodeBuilder.class); aBuilderLibrary.registerBuilder("FreeQuery", FreeQueryProducerNodeBuilder.class); @@ -773,6 +774,41 @@ public class DefaultProducerNodeBuilders { //////////////////////////////////////////////////////////////////////////////// + public static class RDFAggregatorProducerNodeBuilder extends AbstractProducerNodeBuilder { + private final static String RDF_AGGREGATOR_KEY_ATTRIBUTE = KEY_ATTRIBUTE; + private final static String RDF_AGGREGATOR_SOURCE_ATTRIBUTE = "source"; + private final static String RDF_AGGREGATOR_ORDER_ATTRIBUTE = ORDER_ATTRIBUTE; + private final static String RDF_AGGREGATOR_FILTER_ATTRIBUTE = "filter"; + + private final static String[] RDF_AGGREGATOR_REQUIRED_ATTRIBUTES = { RDF_AGGREGATOR_KEY_ATTRIBUTE, RDF_AGGREGATOR_SOURCE_ATTRIBUTE }; + private final static String[] RDF_AGGREGATOR_OPTIONAL_ATTRIBUTES = { RDF_AGGREGATOR_ORDER_ATTRIBUTE, RDF_AGGREGATOR_FILTER_ATTRIBUTE }; + private final static String[] RDF_AGGREGATOR_SUBNODES = { }; + + private String key; + private String source; + private String order; + private String filter; + + public RDFAggregatorProducerNodeBuilder() { + super(RDF_AGGREGATOR_SUBNODES); + } + + public void setAttributes(Map anAttributes) throws ProducerConfigExc, XMLReader.XMLReaderExc { + XMLReaderTool.checkAttributes(anAttributes, RDF_AGGREGATOR_REQUIRED_ATTRIBUTES, RDF_AGGREGATOR_OPTIONAL_ATTRIBUTES); + + key = (String) anAttributes.get( RDF_AGGREGATOR_KEY_ATTRIBUTE ); + 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); + }; + } + +//////////////////////////////////////////////////////////////////////////////// + public static class ScriptedProducerParameterNodeBuilder implements ProducerNodeBuilder { private String parameterName; private String scriptedNodeName; diff --git a/source/mir/rss/RSSChannel.java b/source/mir/rss/RSSChannel.java deleted file mode 100755 index 0f1709e5..00000000 --- a/source/mir/rss/RSSChannel.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.rss; - -import java.util.List; -import java.util.Vector; - -public class RSSChannel { - private String title; - private String link; - private String description; - private String identifier; - private List items; - - protected RSSChannel(String anIdentifier) { - items = new Vector(); - identifier = anIdentifier; - } - - protected void addItem(RSSItem anItem) { - items.add(anItem); - }; - - protected void setItems(List anItems) { - items.clear(); - items.addAll(anItems); - }; - - public List getItems() { - return items; - } - - public String getTitle() { - return title; - } - - public void setTitle(String aTitle) { - title = aTitle; - } - - public String getLink() { - return link; - } - - public void setLink(String aLink) { - link = aLink; - } - - public String getDescription() { - return description; - } - - public void setDescription(String aDescription) { - description = aDescription; - } - -} diff --git a/source/mir/rss/RSSData.java b/source/mir/rss/RSSData.java index 184dcf37..a5e6181c 100755 --- a/source/mir/rss/RSSData.java +++ b/source/mir/rss/RSSData.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.rss; @@ -35,34 +35,46 @@ import java.util.Map; import java.util.Vector; public class RSSData { - private List items; - private Map item; - private RSSChannel channel; + private List resources; + private Map rdfClassToResources; + private Map identifierToResource; protected RSSData() { - items = new Vector(); - item = new HashMap(); - channel = null; + resources = new Vector(); + rdfClassToResources = new HashMap(); + identifierToResource = new HashMap(); } - protected void addItem(RSSItem anItem) { - items.add(anItem); - item.put(anItem.getIdentifier(), anItem); - }; + public List getAllResources() { + return resources; + } - public void setChannel(RSSChannel aChannel) { - channel = aChannel; + public void addResource(RDFResource aResource) { + resources.add(aResource); + List resourcesForClass = (List) rdfClassToResources.get(aResource.getRdfClass()); + if (resourcesForClass==null) { + resourcesForClass = new Vector(); + rdfClassToResources.put(aResource.getRdfClass(), resourcesForClass); + } + resourcesForClass.add(aResource); + if (aResource.getIdentifier()!=null) + identifierToResource.put(aResource.getIdentifier(), aResource); } - public RSSChannel getChannel() { - return channel; + public List getResourcesForRdfClass(String aClass) { + return (List) rdfClassToResources.get(aClass); } - public List getItems() { - return items; + public RDFResource getResourceForIdentifier(String anIdentifier) { + return (RDFResource) identifierToResource.get(anIdentifier); } - public Map getItem() { - return item; + public Object get(String aKey) { + Object result = getResourceForIdentifier(aKey); + + if (result==null) + return getResourcesForRdfClass(aKey); + else + return result; } } diff --git a/source/mir/rss/RSSItem.java b/source/mir/rss/RSSItem.java deleted file mode 100755 index 7b18a5e1..00000000 --- a/source/mir/rss/RSSItem.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.rss; - - -public class RSSItem { - private String title; - private String link; - private String description; - private String identifier; - - protected RSSItem(String anIdentifier) { - identifier = anIdentifier; - } - - public String getIdentifier() { - return identifier; - } - - public String getTitle() { - return title; - } - - public void setTitle(String aTitle) { - title = aTitle; - } - - public String getLink() { - return link; - } - - public void setLink(String aLink) { - link = aLink; - } - - public String getDescription() { - return description; - } - - public void setDescription(String aDescription) { - description = aDescription; - } - -} - diff --git a/source/mir/rss/RSSReader.java b/source/mir/rss/RSSReader.java index 80436080..5a678255 100755 --- a/source/mir/rss/RSSReader.java +++ b/source/mir/rss/RSSReader.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.rss; @@ -32,11 +32,12 @@ package mir.rss; import java.io.InputStream; import java.net.URL; import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Vector; +import java.text.*; import mir.util.XMLReader; -import mir.util.XMLReaderTool; +import mir.util.*; /** * @@ -49,12 +50,50 @@ import mir.util.XMLReaderTool; */ public class RSSReader { + private static final String RDF_NAMESPACE_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + private static final String RSS_1_0_NAMESPACE_URI = "http://purl.org/rss/1.0/"; + private static final String DUBLINCORE_NAMESPACE_URI = "http://purl.org/dc/elements/1.1/"; + private static final String EVENT_NAMESPACE_URI = "http://purl.org/rss/1.0/modules/event/"; + private static final String TAXONOMY_NAMESPACE_URI = "http://web.resource.org/rss/1.0/modules/taxonomy/"; + + private static final XMLReader.XMLName RDF_ABOUT_PARAMETER = new XMLReader.XMLName(RDF_NAMESPACE_URI, "about"); + private static final XMLReader.XMLName RDF_SEQUENCE_TAG = new XMLReader.XMLName(RDF_NAMESPACE_URI, "Seq"); + private static final XMLReader.XMLName RDF_BAG_PARAMETER = new XMLReader.XMLName(RDF_NAMESPACE_URI, "Bag"); + + private static final XMLReader.XMLName RSS_CHANNEL_TAG = new XMLReader.XMLName(RSS_1_0_NAMESPACE_URI, "channel"); + private static final XMLReader.XMLName RSS_ITEM_TAG = new XMLReader.XMLName(RSS_1_0_NAMESPACE_URI, "item"); + private static final XMLReader.XMLName RSS_ITEMS_TAG = new XMLReader.XMLName(RSS_1_0_NAMESPACE_URI, "items"); + + private List modules; + private Map namespaceURItoModule; + private Map moduleToPrefix; + private RSSModule rdfModule; + public RSSReader() { + modules = new Vector(); + namespaceURItoModule = new HashMap(); + moduleToPrefix = new HashMap(); + + registerModule(new RSSBasicModule(RDF_NAMESPACE_URI, "RDF module"), "rdf"); + registerModule(new RSSBasicModule(RSS_1_0_NAMESPACE_URI, "RSS 1.0 module"), "rss"); + + RSSBasicModule dcModule = new RSSBasicModule(DUBLINCORE_NAMESPACE_URI, "Dublin Core RSS module 1.1"); + dcModule.addProperty("date", dcModule.W3CDTF_PROPERTY_TYPE); + registerModule(dcModule, "dc"); + + registerModule(new RSSBasicModule(EVENT_NAMESPACE_URI, "Event RSS module"), "ev"); + registerModule(new RSSBasicModule(TAXONOMY_NAMESPACE_URI, "Taxonomy RSS module"), "taxo"); + } + + public void registerModule(RSSModule aModule, String aPrefix) { + modules.add(aModule); + namespaceURItoModule.put(aModule.getNamespaceURI(), aModule); + moduleToPrefix.put(aModule, aPrefix); } public RSSData parseInputStream(InputStream aStream) throws RSSExc, RSSFailure { try { - XMLReader xmlReader = new XMLReader(); + XMLReader xmlReader = new XMLReader(true); RSSData result = new RSSData(); xmlReader.parseInputStream(aStream, new RootSectionHandler(result)); @@ -79,15 +118,15 @@ public class RSSReader { } } - private static class RootSectionHandler extends XMLReader.AbstractSectionHandler { + private class RootSectionHandler extends XMLReader.AbstractSectionHandler { private RSSData data; public RootSectionHandler(RSSData aData) { data = aData; } - public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { - if (XMLReaderTool.getLocalNameFromQualifiedName(aTag).equals("RDF")) { + public XMLReader.SectionHandler startElement(XMLReader.XMLName aTag, Map anAttributes) throws XMLReader.XMLReaderExc { + if (aTag.getLocalName().equals("RDF")) { return new RDFSectionHandler(data); } else @@ -106,38 +145,24 @@ public class RSSReader { }; } - private static class RDFSectionHandler extends XMLReader.AbstractSectionHandler { + private class RDFSectionHandler extends XMLReader.AbstractSectionHandler { private RSSData data; + public RDFSectionHandler(RSSData aData) { data = aData; } - public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { - String identifier = (String) anAttributes.get("rdf:about"); + public XMLReader.SectionHandler startElement(XMLReader.XMLName aTag, Map anAttributes) throws XMLReader.XMLReaderExc { + String identifier = (String) anAttributes.get(RDF_ABOUT_PARAMETER); + String rdfClass = makeQualifiedName(aTag); - if (aTag.equals("channel")) { - if (identifier==null) - throw new XMLReader.XMLReaderFailure(new RSSExc("Missing rdf:about")); - else - return new ChannelSectionHandler(identifier); - } - else if (aTag.equals("item")) { - if (identifier==null) - throw new XMLReader.XMLReaderFailure(new RSSExc("Missing rdf:about")); - else - return new ItemSectionHandler(identifier); - } - else - return new DiscardingSectionHandler(); + return new RDFResourceSectionHandler(rdfClass, identifier); }; public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc { - if (aHandler instanceof ItemSectionHandler) { - data.addItem(((ItemSectionHandler) aHandler).getItem()); - } - else if (aHandler instanceof ChannelSectionHandler) { - data.setChannel(((ChannelSectionHandler) aHandler).getChannel()); + if (aHandler instanceof RDFResourceSectionHandler) { + data.addResource(((RDFResourceSectionHandler) aHandler).getResource()); } }; @@ -150,41 +175,69 @@ public class RSSReader { }; } - private static class ChannelSectionHandler extends XMLReader.AbstractSectionHandler { + private XMLReader.SectionHandler makePropertyValueSectionHandler(XMLReader.XMLName aTag, Map anAttributes) { + RSSModule module = (RSSModule) namespaceURItoModule.get(aTag.getNamespaceURI()); + + if (aTag.getLocalName().equals("date")) + aTag = aTag; + + + if (module!=null) { + RSSModule.RSSModuleProperty property = module.getPropertyForName(aTag.getLocalName()); + + if (property!=null) { + switch (property.getType()) { + case + RSSModule.PCDATA_PROPERTY_TYPE: + return new PCDATASectionHandler(); + case + RSSModule.RDFCOLLECTION_PROPERTY_TYPE: + return new RDFCollectionSectionHandler(); +// case +// RSSModule.RDF_PROPERTY_TYPE: +// return new RDFValueSectionHandler(); + case + RSSModule.W3CDTF_PROPERTY_TYPE: + return new DateSectionHandler(); + } + } + + } + + return new FlexiblePropertyValueSectionHandler(); + } + + private String makeQualifiedName(XMLReader.XMLName aName) { + String result=aName.getLocalName(); + RSSModule module = (RSSModule) namespaceURItoModule.get(aName.getNamespaceURI()); + if (module!=null) { + String prefix = (String) moduleToPrefix.get(module); + + if (prefix!=null && prefix.length()>0) + result = prefix+":"+result; + } + + return result; + } + + private class RDFResourceSectionHandler extends XMLReader.AbstractSectionHandler { private String image; - private String currentTag; - private RSSChannel channel; + private XMLReader.XMLName currentTag; + private RDFResource resource; - public ChannelSectionHandler(String anIdentifier) { - channel = new RSSChannel(anIdentifier); + public RDFResourceSectionHandler(String anRDFClass, String anIdentifier) { + resource = new RDFResource(anRDFClass, anIdentifier); } - public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { + public XMLReader.SectionHandler startElement(XMLReader.XMLName aTag, Map anAttributes) throws XMLReader.XMLReaderExc { currentTag = aTag; - if (currentTag.equals("items")) { - return new ChannelItemsSectionHandler(); - } - else if (currentTag.equals("description") || - currentTag.equals("link") || - currentTag.equals("title")) { - return new PCDATASectionHandler(); - } - return new DiscardingSectionHandler(); + return makePropertyValueSectionHandler(aTag, anAttributes); }; public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc { - if (currentTag.equals("items")) { - channel.setItems(((ChannelItemsSectionHandler) aHandler).getItems()); - } - if (currentTag.equals("description")) { - channel.setDescription(((PCDATASectionHandler) aHandler).getData()); - } - else if (currentTag.equals("title")) { - channel.setTitle(((PCDATASectionHandler) aHandler).getData()); - } - else if (currentTag.equals("link")) { - channel.setLink(((PCDATASectionHandler) aHandler).getData()); + if (aHandler instanceof PropertyValueSectionHandler) { + resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getValue()); } }; @@ -196,20 +249,65 @@ public class RSSReader { public void finishSection() throws XMLReader.XMLReaderExc { }; - public RSSChannel getChannel () { - return channel; + public RDFResource getResource() { + return resource; + } + } + + private abstract class PropertyValueSectionHandler extends XMLReader.AbstractSectionHandler { + public abstract Object getValue(); + } + + private class FlexiblePropertyValueSectionHandler extends PropertyValueSectionHandler { + private StringBuffer stringData; + private Object structuredData; + + public FlexiblePropertyValueSectionHandler() { + stringData = new StringBuffer(); + structuredData=null; + } + + public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { + if (aTag.equals(RDF_SEQUENCE_TAG)) + return new RDFSequenceSectionHandler(); + else + return new DiscardingSectionHandler(); + }; + + public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc { + if (aHandler instanceof RDFSequenceSectionHandler) { + structuredData= ((RDFSequenceSectionHandler) aHandler).getItems(); + } + }; + + public void characters(String aCharacters) throws XMLReader.XMLReaderExc { + stringData.append(aCharacters); + }; + + public void finishSection() throws XMLReader.XMLReaderExc { + }; + + public String getData() { + return stringData.toString(); + } + + public Object getValue() { + if (structuredData==null) + return stringData.toString(); + else + return structuredData; } } - private static class ChannelItemsSectionHandler extends XMLReader.AbstractSectionHandler { + private class RDFCollectionSectionHandler extends PropertyValueSectionHandler { private List items; - public ChannelItemsSectionHandler() { + public RDFCollectionSectionHandler() { items = new Vector(); } public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { - if (aTag.equals("rdf:Seq")) + if (aTag.equals(RDF_SEQUENCE_TAG)) return new RDFSequenceSectionHandler(); else return new DiscardingSectionHandler(); @@ -232,57 +330,46 @@ public class RSSReader { public List getItems() { return items; } + + public Object getValue() { + return items; + } } - private static class ItemSectionHandler extends XMLReader.AbstractSectionHandler { - private String currentTag; - private RSSItem item; + private class PCDATASectionHandler extends PropertyValueSectionHandler { + private StringBuffer data; - public ItemSectionHandler(String anIdentifier) { - item = new RSSItem(anIdentifier); + public PCDATASectionHandler() { + data = new StringBuffer(); } public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { - currentTag = aTag; - - if (currentTag.equals("description") || - currentTag.equals("link") || - currentTag.equals("title")) { - return new PCDATASectionHandler(); - } - - return new DiscardingSectionHandler(); + throw new XMLReader.XMLReaderFailure(new RSSExc("No subtags allowed here")); }; public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc { - if (currentTag.equals("description")) { - item.setDescription(((PCDATASectionHandler) aHandler).getData()); - } - else if (currentTag.equals("title")) { - item.setTitle(((PCDATASectionHandler) aHandler).getData()); - } - else if (currentTag.equals("link")) { - item.setLink(((PCDATASectionHandler) aHandler).getData()); - } }; public void characters(String aCharacters) throws XMLReader.XMLReaderExc { - if (aCharacters.trim().length()>0) - throw new XMLReader.XMLReaderExc("No character data allowed here"); + data.append(aCharacters); }; public void finishSection() throws XMLReader.XMLReaderExc { }; - public RSSItem getItem() { - return item; - }; + public String getData() { + return data.toString(); + } + + public Object getValue() { + return data.toString(); + } } - private static class PCDATASectionHandler extends XMLReader.AbstractSectionHandler { + private class DateSectionHandler extends PropertyValueSectionHandler { private StringBuffer data; - public PCDATASectionHandler() { + public DateSectionHandler() { data = new StringBuffer(); } @@ -300,13 +387,49 @@ public class RSSReader { public void finishSection() throws XMLReader.XMLReaderExc { }; - public String getData() { - return data.toString(); + private final static String SPACE = "[\t\n\r ]*"; + private final static String NUMBER = "[0-9]*"; + private final static String SIGN = "[-+]"; + + public Object getValue() { + try { + String expression = data.toString().trim(); + SimpleParser parser = new SimpleParser(expression); + + String year=""; + String month=""; + String day=""; + String hour=""; + String minutes=""; + + year = parser.parse(NUMBER); + parser.skip("-"); + month = parser.parse(NUMBER); + parser.skip("-"); + day = parser.parse(NUMBER); + parser.skip("T"); + hour = parser.parse(NUMBER); + parser.skip(":"); + minutes = parser.parse(NUMBER); + + SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + d.setLenient(true); + expression = year + "-" + month + "-" + day + " " + hour + ":" + minutes; + + System.out.println(expression); + + Date result = d.parse(expression); + + return result; + } + catch (Throwable t) { + return null; + } } } - private static class RDFSequenceSectionHandler extends XMLReader.AbstractSectionHandler { + private class RDFSequenceSectionHandler extends XMLReader.AbstractSectionHandler { private List items; public RDFSequenceSectionHandler() { @@ -338,7 +461,7 @@ public class RSSReader { } } - private static class RDFLiteralSectionHandler extends XMLReader.AbstractSectionHandler { + private class RDFLiteralSectionHandler extends PropertyValueSectionHandler { private StringBuffer data; private String tag; @@ -368,9 +491,13 @@ public class RSSReader { public void finishSection() throws XMLReader.XMLReaderExc { }; + + public Object getValue() { + return data.toString(); + } } - private static class DiscardingSectionHandler extends XMLReader.AbstractSectionHandler { + private class DiscardingSectionHandler extends XMLReader.AbstractSectionHandler { public XMLReader.SectionHandler startElement(String aTag, Map anAttributes) throws XMLReader.XMLReaderExc { return this; }; diff --git a/source/mir/rss/RSSToMapConverter.java b/source/mir/rss/RSSToMapConverter.java deleted file mode 100755 index a9852e80..00000000 --- a/source/mir/rss/RSSToMapConverter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.rss; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -public class RSSToMapConverter { - private RSSToMapConverter() { - } - - public static Map convertRSSItem(RSSItem anItem) { - Map result = new HashMap(); - - result.put("title", anItem.getTitle()); - result.put("description", anItem.getDescription()); - result.put("link", anItem.getLink()); - - return result; - } - - public static Map convertRSSData(RSSData anRSSData) { - Map result = new HashMap(); - - Map channel = null; - if (anRSSData.getChannel()!=null) { - channel = new HashMap(); - channel.put("title", anRSSData.getChannel().getTitle()); - channel.put("description", anRSSData.getChannel().getDescription()); - channel.put("link", anRSSData.getChannel().getLink()); - - List items = new Vector(); - Iterator i = anRSSData.getChannel().getItems().iterator(); - - while (i.hasNext()) { - RSSItem item = (RSSItem) anRSSData.getItem().get(i.next()); - if (item!=null) { - items.add(convertRSSItem(item)); - } - } - - channel.put("items", items); - } - result.put("channel", channel); - result.put("data", anRSSData); - - return result; - } -} \ No newline at end of file diff --git a/source/mir/util/ParameterExpander.java b/source/mir/util/ParameterExpander.java index 13787282..fa60689e 100755 --- a/source/mir/util/ParameterExpander.java +++ b/source/mir/util/ParameterExpander.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.util; @@ -35,9 +35,12 @@ import java.util.List; import java.util.Map; import java.util.Vector; +import org.apache.commons.beanutils.*; + +import multex.Exc; + import mir.generator.Generator; import mir.generator.GeneratorExc; -import multex.Exc; public class ParameterExpander { final static String NODE_SEPARATOR = "."; @@ -574,6 +577,28 @@ public class ParameterExpander { return result; } + private Object evaluateObjectField(Object anObject, Object aField) { + if (anObject instanceof Map) { + return ((Map) anObject).get(aField); + } + else if ((aField instanceof String) && PropertyUtils.isReadable(anObject, (String) aField)) { + try { + return PropertyUtils.getProperty(anObject, (String) aField); + } + catch (Throwable t) { + throw new RuntimeException(t.getMessage()); + } + } + else { + try { + return MethodUtils.invokeExactMethod(anObject, "get", aField); + } + catch (Throwable t) { + throw new RuntimeException("Invalid reference of " + aField + "into " + anObject); + } + } + } + private Object parseVariable() { boolean done; Token token; @@ -591,23 +616,13 @@ public class ParameterExpander { if (!(token instanceof RightSquareBraceToken)) throw new RuntimeException("] expected"); - if (currentValue instanceof Map) { - currentValue = ((Map) currentValue).get(qualifier); - } - else { - throw new RuntimeException("cannot reference into anything other than a map ('"+qualifier+"')"); - } + currentValue = evaluateObjectField(currentValue, qualifier); } else if (token instanceof IdentifierToken) { scanner.scan(); qualifier = ((IdentifierToken) token).getName(); - if (currentValue instanceof Map) { - currentValue = ((Map) currentValue).get(qualifier); - } - else { - throw new RuntimeException("cannot reference into anything other than a map ('"+qualifier+"')"); - } + currentValue = evaluateObjectField(currentValue, qualifier); } else if (token instanceof LeftParenthesisToken) { if (currentValue instanceof Generator.GeneratorFunction) { diff --git a/source/mir/util/XMLReader.java b/source/mir/util/XMLReader.java index 2947bfe4..19628c8e 100755 --- a/source/mir/util/XMLReader.java +++ b/source/mir/util/XMLReader.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mir.util; @@ -77,7 +77,7 @@ public class XMLReader { try { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - parserFactory.setNamespaceAware(namespaceAware); + parserFactory.setNamespaceAware(true); parserFactory.setValidating(true); XMLReaderHandler handler = new XMLReaderHandler(parserFactory, aRootHandler); @@ -133,16 +133,21 @@ public class XMLReader { } } - public void startElement(String aUri, String aTag, String aQualifiedName, Attributes anAttributes) throws SAXException { + public void startElement(String aUri, String aLocalName, String aQualifiedName, Attributes anAttributes) throws SAXException { Map attributesMap; int i; try { attributesMap = new HashMap(); - for (i=0; i + +previous next links + + +

+ + [ < ] ${lang("list.previous")} + + +    + + + ${lang("list.next")} [ > ] + +

+
+
+ + multifunctional help - popup or not - big or small designs diff --git a/templates/admin/commentlist.template b/templates/admin/commentlist.template index c3b0695e..38fce1bb 100755 --- a/templates/admin/commentlist.template +++ b/templates/admin/commentlist.template @@ -7,6 +7,7 @@ + @@ -66,152 +67,133 @@ - -
- - - -

-   (${lang("commentlist.activate")}) -

- - - - - + + + + + +

+   (${lang("commentlist.activate")}) +

+
+ + + +
+ + + + - - - - - - - - - - class="listrow1"class="listrow2"> - - - class="listrow1"class="listrow2"> + + + - - - - - - - - - - - - -
+ ${lang("comment.date")} + - - [ ${lang("list.previous")} ]  - - - [ ${lang("list.next")} ]  - + ${lang("comment.article")} / ${lang("comment.title")} / ${lang("comment.creator")} / ${lang("comment.text")} + +  
- ${lang("comment.date")} - - ${lang("comment.article")} / ${lang("comment.title")} / ${lang("comment.creator")} / ${lang("comment.text")} - -   -
- ${entry.creationdate.formatted["dd.MM.yyyy HH:mm"]}
- ${lang("commentlist.hidden")}-
-
- ${lang("comment.status")}:
- - - ${lang("commentstatus." + entry.status.name)} - - - - - -
- - -
- ${lang("comment.article")}: - - ${utility.encodeHTML(entry.to_content.title)} - - (${lang("articletypes."+entry.to_content.article_type.name)}) - - [ + + +
+ ${entry.creationdate.formatted["dd.MM.yyyy HH:mm"]}
+ ${lang("commentlist.hidden")}-
+
+ ${lang("comment.status")}:
+ + + ${lang("commentstatus." + entry.status.name)} + + + - + +
+ + + - - - - ${entry.title}   - - ${lang("by")}: ${entry.creator} - -
- ${utility.encodeHTML(entry.description)} - -
URL: ${entry.main_url}
-
- - - - [ ${lang("comment.operation."+op)} ] - - - - - ${lang("comment.operation."+op)} - - - - - -  |  - ${lang("edit")} - -
-   - - [${lang("delete")}] - -
- ${count} ${lang("records")} / ${lang("show_from_to", from, to)} -
- - [ ${lang("list.previous")} ]  - - - [ ${lang("list.next")} ]  - -
- - -

-   (${lang("commentlist.activate")}) -

- -
+
+ + + ${lang("comment.operation."+op)} + + + + + +  |  + ${lang("edit")} + + + + +   + + [${lang("delete")}] + + + + + + + + ${count} ${lang("records")} / ${lang("show_from_to", from, to)} + + + + + +

+   (${lang("commentlist.activate")}) +

+ +
+ + -

${lang("no_matches_found")}

+

${lang("no_matches_found")}

diff --git a/templates/admin/contentlist.template b/templates/admin/contentlist.template index 26482dd7..f1b25039 100755 --- a/templates/admin/contentlist.template +++ b/templates/admin/contentlist.template @@ -38,7 +38,7 @@
- + @@ -128,7 +128,7 @@ - + diff --git a/templates/admin/linksimcslist.template b/templates/admin/linksimcslist.template deleted file mode 100755 index 6d6c2f4d..00000000 --- a/templates/admin/linksimcslist.template +++ /dev/null @@ -1,108 +0,0 @@ - - - ${config["Mir.Name"]} | ${lang("linkimcslist.htmltitle")} - - - - - - - -
- - - -
- - - - - - - - - - - - - -
${lang("linkimcslist.search_in")}:${lang("linkimcs.parent")}:${lang("linkimcs.language")}: 
- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - class="list1"class="list2" > - - - - - - - - - - - - -
- ${lang("linkimcs.name")} - ${lang("linkimcs.parent")} - ${lang("linkimcs.url")} - ${lang("linkimcs.sort_by")} - ${lang("linkimcs.language")} -  
${entry.title} ${parent}${entry.url}${entry.sortpriority}${data.language} ${lang("delete")} - | ${lang("edit")} -
- ${data.count} ${lang("records")} / ${lang("show_from_to", data.from, data.to)} 
-

- - ${lang("list.previous")}  - - -${lang("list.next")} - - - -

${lang("no_matches_found")}

-
- - - diff --git a/templates/admin/messagelist.template b/templates/admin/messagelist.template index c487cb68..42cb1812 100755 --- a/templates/admin/messagelist.template +++ b/templates/admin/messagelist.template @@ -51,13 +51,13 @@ -

- - [ ${lang("list.previous")} ]  - - - [ ${lang("list.next")} ] - +

+ + [ ${lang("list.previous")} ]  + + + [ ${lang("list.next")} ] +

${lang("no_matches_found")}

-- 2.11.0