########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48.2.19 2003/12/14 16:37:06 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.20 2003/12/21 13:32:01 zapata Exp $
languagename=English
comment.status=Status
comment.language=Language
comment.allcomments=All comments
+comment.comment=Internal Comment
+comment.comment.info=(internal)
comment.operation.hide=hide
comment.operation.unhide=unhide
content.html=HTML
content.comment=Internal Comment
content.internal=(internal)
+content.keywords=Keywords
+content.lockedby=Locked by {0}
+content.lock=Lock
+content.unlock=Unlock
+content.forcelock=Force lock
content.attachments=Attachments
content.images=Images
user.password=Password
user.password2=Password (confirmation)
user.admin=Admin
+user.is_disabled=Disabled ?
+user.creationdate=Creation date
+user.lastlogindate=Last login
+user.email=Email address
+user.comment=Comment
+user.profile=Profile
+
+
+
userlist.htmltitle=Users
abuse.log.filterexpression=Expression
abuse.filters = Filters
-abuse.filters.movedown = move down
-abuse.filters.moveup = move up
+abuse.filters.movedown = down
+abuse.filters.moveup = up
abuse.filter.type = Type
abuse.filter.expression = Expression
+++ /dev/null
-#!/usr/bin/perl -w
-use Pg;
-
-#if (!defined($ARGV[0])) {
-# print "Usage: $0 name_of_filelist_file\n";
-# exit 1;
-#}
-
-#$dump="$ARGV[0]";
-
-my $conn = Pg::connectdb("dbname=indy3 user=postgres
-host=localhost");
-( PGRES_CONNECTION_OK eq $conn->status )
- and print "Pg::connectdb ........... ok\n"
- or die "Pg::connectdb ........... not ok: ", $conn->errorMessage;
-
-
- #open(DUMP,"$dump") || die "can't open dump file $dump";
-
- #$basedir="/cdrom";
-
-Pg::doQuery($conn, "select content_data from content", \@ary);
-
-for $i ( 0 .. $#ary ) {
- for $j ( 0 .. $#{$ary[$i]} ) {
- print "$ary[$i][$j]\t";
- }
- print "\n";
-}
-
-#while(<DUMP>) {
-# chomp;
-# next if (/^$/ || /^\s*$/);
-#
-# # exception liste einlesen...
-#
-#
-# # hier insert:
-#
-# $conn->exec("BEGIN");
-# $oid= $conn->lo_import("$filename");
-# print $conn->errorMessage."\n";
-# print "trying to insert icon\n";
-# $ioid= $conn->lo_import("/tmp/iconblob.jpg");
-# print $conn->errorMessage."\n";
-# $sql="INSERT INTO images
-#(title,date,place,author,to_img_layout,to_img_type,is_classified,to_media_f
-#older,to_img_color,comment,webdb_create,img_width,img_height,image_data,ico
-#n_data) ".
-# "VALUES ('".$titel."','20010108','".$ort.
-# "','Hoch die Kampf
-#dem','".$layout."','1','0','2','2','".$comment."',now(),'".$img_width."','"
-#.$img_height.
-# "','".$oid."','".$ioid."')";
-# print $sql."\n";
-# $conn->exec( $sql );
-# print $conn->errorMessage."\n";
-# $conn->exec("END");
-#
-#
-#
-#}
-## end of while
-#
-
-
-
"password" character varying(255) NOT NULL,
"is_admin" boolean DEFAULT '0' NOT NULL,
"comment" text,
- Constraint "webdb_users_pkey" Primary Key ("id")
+ "is_disabled" boolean DEFAULT '0' NOT NULL,
+ "email" character varying(255) DEFAULT '' NOT NULL,
+ "profile" text,
+ "webdb_create" timestamp with time zone NOT NULL,
+ "lastlogin" timestamp with time zone,
+ CONSTRAINT "webdb_users_pkey" Primary Key ("id")
);
"to_language" integer DEFAULT '0' NOT NULL,
"to_media" integer NOT NULL,
"to_comment_status" smallint,
- "checksum" integer,
+ "comment" text,
"is_html" boolean DEFAULT '0' NOT NULL,
Constraint "comment_pkey" Primary Key ("id")
);
-CREATE INDEX "comment_checksum_index" on "comment" using btree ( "checksum" "int4_ops" );
CREATE INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
CREATE INDEX idx_comment_webdb_create on comment(webdb_create);
CREATE INDEX "idx_comment_tomedia_ispublished" on "comment" using btree ( "to_media" "int4_ops", "is_published" "bool_ops" );
--
CREATE SEQUENCE "media_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-CREATE TABLE "media" (
+
+--
+-- uploaded_media
+--
+
+CREATE TABLE "uploaded_media" (
"id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
"title" character varying(255),
"subtitle" character varying(255),
"description" text,
"comment" text,
"source" character varying(255),
- "publish_date" timestamp with time zone,
"publish_server" character varying(255),
"publish_path" character varying(255),
"is_published" boolean DEFAULT '0' NOT NULL,
"is_produced" boolean DEFAULT '0' NOT NULL,
- "to_feature" integer DEFAULT '0' NOT NULL,
"to_media_folder" integer DEFAULT '0' NOT NULL,
"to_media_type" smallint DEFAULT '0' NOT NULL,
"to_publisher" integer NOT NULL,
"to_rights" integer DEFAULT '0',
"webdb_create" timestamp with time zone NOT NULL,
"webdb_lastchange" timestamp with time zone,
- "to_media" integer
-);
-
---
--- uploaded_media
---
-
-CREATE TABLE "uploaded_media" (
"icon_is_produced" boolean DEFAULT '0' NOT NULL,
"icon_path" character varying(255),
- "size" integer
-)
-INHERITS ("media");
+ "size" integer,
+ Constraint "uploaded_media_pkey" Primary Key ("id")
+);
CREATE UNIQUE INDEX "idx_uploaded_media_id" on "uploaded_media" using btree ( "id" "int4_ops" );
CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using btree ( "id" "int4_ops", "is_published" "bool_ops" );
)
INHERITS ("uploaded_media");
-CREATE INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
+CREATE INDEX "idx_images_is_published" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
--
--
CREATE TABLE "content" (
+ "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
+ "title" character varying(255),
+ "subtitle" character varying(255),
+ "edittitle" character varying(255),
+ "date" character(8) NOT NULL,
+ "creator" character varying(80),
+ "creator_main_url" character varying(255),
+ "creator_email" character varying(80),
+ "creator_address" character varying(80),
+ "creator_phone" character varying(80),
+ "description" text,
+ "comment" text,
+ "source" character varying(255),
+ "is_published" boolean DEFAULT '0' NOT NULL,
+ "is_produced" boolean DEFAULT '0' NOT NULL,
+ "to_publisher" integer NOT NULL,
+ "to_language" integer DEFAULT '0',
+ "to_rights" integer DEFAULT '0',
+ "webdb_create" timestamp with time zone NOT NULL,
+ "webdb_lastchange" timestamp with time zone,
"content_data" text,
"is_html" boolean DEFAULT '0' NOT NULL,
"to_article_type" smallint DEFAULT '0' NOT NULL,
"to_content" integer,
- "checksum" integer
-)
-INHERITS ("media");
+ "keywords" text,
+ "to_locking_user" integer,
+ Constraint "content_pkey" Primary Key ("id")
+);
+
-CREATE INDEX "content_checksum_index" on "content" using btree ( "checksum" "int4_ops" );
CREATE INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
CREATE INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
CREATE INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
echo "grant all on language to $3;" >> ${SCRIPT_FILE}
echo "grant all on rights to $3;" >> ${SCRIPT_FILE}
echo "grant all on article_type to $3;" >> ${SCRIPT_FILE}
-echo "grant all on media to $3;" >> ${SCRIPT_FILE}
echo "grant all on breaking to $3;" >> ${SCRIPT_FILE}
echo "grant all on messages to $3;" >> ${SCRIPT_FILE}
echo "grant all on comment_status to $3;" >> ${SCRIPT_FILE}
+++ /dev/null
-The dupetrigger
-
-MOTIVATION
-
-Often, users commit their comments and articles multiple times if they
-don't believe the comment has been inserted into the databases. This is
-clearly one of the disadvantages of the otherwise clever caching strategy
-used by Mir. Without proper handling, this duplicate content will enlarge
-the database and make the appearance of the generated web pages be less
-satisfactory.
-
-
-SOLUTIONS
-
-There are two approaches to get rid of these duplicate entries
-(hereafter called "dupes"). The first approach is the dupetrigger that
-ensures that no entries in a given table are the same. This is the approach
-currently pursued in Mir. If this trigger cannot be compiled or doesn't work
-for any reason, you may work-around this problem by issuing the following
-commands on your psql prompt:
-
-CREATE UNIQUE INDEX idx_content_dupe ON content (title, subtitle, creator, description, content_data);
-CREATE UNIQUE INDEX idx_comment_dupe ON comment (creator, to_media, description, title);
-
-Please note that this approach will work but the implications on the Mir
-software have not been tested, yet. Maybe Mir will respond with an error
-or with other unexpected behaviour, but it should do no harm to the
-database. The dupetrigger has been tested with Mir and is currently being
-operated on de.indymedia.org.
-
-
-HOW TO INSTALL THE DUPE TRIGGER
-
-To install the trigger do the following:
-
-# cp Makefile-dist Makefile
-
-# edit Makefile
-(and change pathnames and PGVERSION if neccessary).
-
-# make
-(This makes the trigger binary and places it in INSTALLDIR with permissions 644)
-
-# edit postgresql.script
-(And change the path to dupetrigger.so to INSTALLDIR)
-
-# psql -Upostgres -f postgresql.script Mir
-(This installs the the trigger binary and creates a new trigger.)
+++ /dev/null
-# Makefile
-
-# Set the following directory so that it contains spi.h and trigger.h
-PGINC=/usr/include/postgresql/server
-
-#PGVERSION=-DPG70
-#PGVERSION=-DPG71
-PGVERSION=-DPG72
-
-# If changed, also change postgresql.script
-INSTALLDIR=/var/lib/postgres/data
-
-
-
-CC=gcc
-CFLAGS=-I$(PGINC) $(PGVERSION)
-
-install: dupetrigger.so
- cp dupetrigger.so $(INSTALLDIR)
- chmod 644 $(INSTALLDIR)/dupetrigger.so
- #
- # Now, change the path to dupetrigger.so in postgresql.script to the
- # absolute path where dupetrigger.so is installed (${INSTALLDIR})
-
-dupetrigger.so: dupetrigger.o
- $(CC) -shared -dynamic -o dupetrigger.so dupetrigger.o
-
-clean:
- rm -rf dupetrigger.o dupetrigger.so
-
-
-tidy: clean
- rm -rf *~
-
\ No newline at end of file
+++ /dev/null
-Dupe check Trigger
-by Matthias "Trigger Hippy" Jordan <mjordan@code-fu.de>
-
-The files in this directory are needed to create a PostgreSQL trigger that
-is used to ensure that no comment and no article is posted twice. This
-happens very often by accident and is very disturbing so we have to prevent
-this somehow. Because Indymedia databases will hopefully grow big very fast,
-we want to do this check as fast as possible.
-
-So Mir simply issues the INSERT. By this INSERT statement, a trigger gets,
-well, triggered that calculates a CRC-32 checksum of the comment and
-searches for rows with the same checksum. If it finds the checksum, the
-INSERT gets aborted. If the checksum isn't found, it is appended to the row
-and the INSERT is executed.
-
-The trigger works for INSERTs and UPDATEs.
+++ /dev/null
-//
-//
-// This File contructs a PostgreSQL trigger.
-//
-// USAGE:
-// dupecheck(debug, column1, column2, ...);
-//
-// debug: if "yes" dupecheck generates debug output
-// columns: the names of the columns that are used to calculate the
-// checksum
-//
-//
-// The trigger is normally fired BEFORE an INSERT or UPDATE of an
-// article or comment. It first calculates a CRC-32 checksum of the
-// specified columns of the row to be inserted or updated and
-// checks whether there exists already another row with the same
-// checksum. In this case, the trigger returns NULL and thus,
-// aborts the SQL command.
-//
-// Author: Matthias Jordan <mjordan@code-fu.de>
-//
-
-
-#include "executor/spi.h"
-#include "commands/trigger.h"
-#include "string.h"
-
-
-
-#ifndef PG70
- extern Datum dupecheck(PG_FUNCTION_ARGS);
- PG_FUNCTION_INFO_V1(dupecheck);
-#else
- extern Datum dupecheck(void);
-#endif
-
-
-
-
-
-//
-//
-// CRC32 stuff
-//
-
-// crc32 table based on the following polynom
-#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
-
-u_long crc32_table[256] =
- {0x0000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
- 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
- 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
- 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
- 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
- 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
- 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
- 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
- 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
- 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
- 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
- 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
- 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x54bf6a4,
- 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
- 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
- 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
- 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
- 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
- 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
- 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
- 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
- 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
- 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
- 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
- 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
- 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0xe56f0ff,
- 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
- 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
- 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
- 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
- 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
- 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
- 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
- 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
- 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
- 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0xfdc1bec,
- 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
- 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
- 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
- 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
- 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
- 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
- 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4};
-
-
-static u_long crc32(u_char *buf, unsigned len)
-{
- u_char *p;
- u_long crc;
-
- crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
- for (p = buf; len > 0; ++p, --len)
- {
- crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p];
- }
- return ~crc; /* transmit complement, per CRC-32 spec */
-} /* crc32 */
-
-
-
-
-
-//
-//
-// Trigger stuff
-//
-
-
-
-
-#ifndef PG70
-Datum dupecheck(PG_FUNCTION_ARGS)
-{
- TriggerData *trigdata = (TriggerData *) fcinfo->context;
-#else
-Datum dupecheck(void)
-{
- TriggerData *trigdata = CurrentTriggerData;
-#endif
- TupleDesc tupdesc;
- HeapTuple rettuple;
- bool isnull,
- debug_on;
- int ret = 0, i, fnumber;
- u_long rowstrlen = 0,
- crc;
- char **items, // will point to a malloc'ed array
- *rowstring,
- *query,
- **args,
- *relation;
- int num,
- nargs,
- nitems;
-
- /* Make sure trigdata is pointing at what I expect */
-#ifdef PG70
- if (!CurrentTriggerData)
-#else
- if (!CALLED_AS_TRIGGER(fcinfo))
-#endif
- elog(ERROR, "dupecheck: not fired by trigger manager");
- /* tuple to return to Executor */
- if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
- rettuple = trigdata->tg_newtuple;
- else
- rettuple = trigdata->tg_trigtuple;
-
- if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
- return PointerGetDatum(NULL);
-
-
- // Initialize arguments and see whether the arguments are ok.
- args = trigdata->tg_trigger->tgargs;
- nargs = trigdata->tg_trigger->tgnargs;
-
- if (nargs < 2)
- {
- elog(DEBUG, "dupecheck: USAGE: dupeckeck(debug, col1, col2, ...)");
- return PointerGetDatum(NULL);
- }
-
- debug_on = !strcmp("yes", args[0]);
-
- tupdesc = trigdata->tg_relation->rd_att;
-
- /* Connect to SPI manager */
- if ((ret = SPI_connect()) != SPI_OK_CONNECT)
- {
- elog(NOTICE, "dupecheck: SPI_connect returned error %d", ret);
- }
-
- // Now we are connected to the database's SPI manager
- // We will now construct a string of some important row values.
- // First, we determine how long the string will be to allocate memory
- // To include an additional item, add another SPI_getvalue line and
- // increase maxitems above by 1
-
-
- // Allocate array for the argument pointers
- nitems = nargs - 1; // don't take the debug parameter as a row name;
- items = (char **) malloc(sizeof(char*) * nitems);
- if (items == NULL)
- {
- SPI_finish();
- return PointerGetDatum(NULL);
- }
-
- // Collect arguments
- for (i = 1; (i < nargs); i++)
- {
- items[i-1] = SPI_getvalue(rettuple, tupdesc, SPI_fnumber(tupdesc, args[i]));
- if (debug_on)
- {
- elog(DEBUG, "dupecheck: Argument %d: row %s -> %s\n", i, args[i], items[i-1]);
- }
- }
-
-
- // Find out length of row string to be constructed
- for (i=0; (i < nitems); i++)
- {
- if (items[i] != NULL)
- {
- rowstrlen += strlen(items[i]);
- }
- }
-
- rowstring = malloc(rowstrlen+1); // add space for 0-terminator
- if (rowstring == NULL)
- {
- free(items);
- SPI_finish();
- return PointerGetDatum(NULL);
- }
-
- // Construct row string
- *rowstring = 0;
- for (i=0; (i < nitems); i++)
- {
- if (items[i] != NULL)
- {
- strcat(rowstring, items[i]);
- }
- }
-
- // rowstring now contains the data of the maxitems important
- // items of the table record. Now we calculate the CRC-32 checksum
- // of the rowstring
-
- crc = crc32(rowstring, rowstrlen);
-
- // Now we allocate some space and construct the SQL query
- relation = SPI_getrelname(trigdata->tg_relation);
- query = malloc(40 + strlen(relation) + 11 + 2 + 1); // SELECT part + relation + crc32 + "';" + 0-term
- if (query == NULL)
- {
- // Big problem
- free(items);
- free(rowstring);
- SPI_finish();
- return PointerGetDatum(NULL);
- }
-
- sprintf(query, "SELECT count(*) FROM %s WHERE checksum='%ld';", relation, crc);
- if (debug_on)
- {
- elog(DEBUG, "dupecheck: %s", query);
- }
- ret = SPI_exec(query, 2);
-
- if ((ret == SPI_OK_SELECT) && (SPI_processed > 0))
- {
-#ifdef PG72
- num = (int) DatumGetInt64(SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull));
-#else
- num = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull);
-#endif
- }
-
- if ((ret == SPI_OK_SELECT) && (num > 0) && !(TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)))
- {
- elog(NOTICE, "dupecheck: UBD in %s detected, dupe dropped", relation);
- rettuple = NULL; // reject operation
- }
- else
- {
- // The checksum wasn't found. So we modify the tuple to be
- // inserted and add the fresh checksum.
- int attnum;
- Datum value;
- char nulls = 0;
-
- if (debug_on)
- {
- elog(NOTICE, "dupecheck: Adding checksum to row");
- }
- attnum = SPI_fnumber(tupdesc, "checksum");
- value = (Datum) crc;
- rettuple = SPI_modifytuple(trigdata->tg_relation, rettuple, 1, &attnum, &value, &nulls);
- }
-
- free(items);
- free(rowstring);
- free(query);
- SPI_finish();
- return PointerGetDatum(rettuple);
-}
-
+++ /dev/null
-DROP TRIGGER commdupetrigger ON comment;
-DROP TRIGGER contentdupetrigger ON content;
-DROP FUNCTION dupecheck();
-CREATE FUNCTION dupecheck() RETURNS OPAQUE AS '/var/lib/postgres/data/dupetrigger.so' LANGUAGE 'C';
-CREATE TRIGGER contentdupetrigger BEFORE INSERT OR UPDATE ON content FOR EACH ROW EXECUTE PROCEDURE dupecheck("no", "title", "subtitle", "creator", "description", "content_data");
-CREATE TRIGGER commdupetrigger BEFORE INSERT OR UPDATE ON comment FOR EACH ROW EXECUTE PROCEDURE dupecheck("no", "creator", "to_media", "description", "title");
--- \connect - postgres
-INSERT INTO "webdb_users" VALUES (1,'open','','f');
-INSERT INTO "webdb_users" VALUES (2,'redaktion','indymedia','t');
-INSERT INTO "webdb_users" VALUES (3,'tollendorf','indymedia','t');
-INSERT INTO "webdb_users" VALUES (4,'admin','indymedia','t');
+INSERT INTO webdb_users(login, password, is_admin, comment, is_disabled, email, profile, webdb_create)
+VALUES ('open', '', 'f', 'Default open posting user', 'f', '', '', now());
+
+INSERT INTO webdb_users(login, password, is_admin, comment, is_disabled, email, profile, webdb_create)
+VALUES ('admin', 'indymedia', 't', 'Default admin user', 'f', '', '', now());
+++ /dev/null
-#!/usr/bin/perl
-
-################################################################
-### codec
-###
-### $VER: 2.1 (8bit,quoted-printable,perlish)$
-### USAGE: $codec=&Codec::new('perlish');
-### $encoded=$codec->encode($clear);
-### $clear=$codec->decode($encoded);
-
-package Codec;
-
-
-$VERSION="1.1";
-
-sub new {
- my($type)=shift;
- my($res);
-
- return undef unless (defined $encode{$type});
-
- $$res{'encode'}=$encode{$type};
- $$res{'decode'}=$decode{$type};
- $$res{'type'}=$type;
-
- bless $res, "Codec";
-
- return $res;
- }
-
-sub reset {
- }
-
-sub encode {
- my($obj,$str)=@_;
- return &{$$obj{'encode'}}($str);
- }
-
-sub decode {
- my($obj,$str)=@_;
- return &{$$obj{'decode'}}($str);
- }
-
-sub name {
- my($obj)=shift;
- return $$obj{'type'};
- }
-
-################################################################
-### local
-
-$crlf=pack("CC",13,10);
-
-################################################################
-### id
-
-$encode{'8bit'}=sub { return $_[0]; };
-$decode{'8bit'}=sub { return $_[0]; };
-
-################################################################
-### perlish
-
-sub quote_perlish {
- my($str)=@_;
-
- $str=~s/\\/\\\\/g;
-
- $str=~s/\"/\\042/g;
- $str=~s/\'/\\047/g;
-
- $str=~s/\@/\\@/g;
- $str=~s/([\x80-\xFF])/sprintf("\\x%02x",ord($1))/eg;
- $str=~s/([\x00-\x20])/sprintf("\\x%02x",ord($1))/eg;
- return $str;
- }
-
-sub convert_perlish {
- my($item)=shift;
- my($type,$key,$value,@res,$entry);
-
- $type=ref($item);
-
- if ((!defined $type)||($type eq "")) {
- return "\042"."e_perlish($item)."\042";
- }
- else {
- if ($type eq "HASH") {
- while (($key,$value)=each %$item) {
- $entry="\042"."e_perlish($key)."\042";
- $entry.="=>";
- $entry.=&convert_perlish($value);
- push(@res,$entry);
- }
- return "{".join(",",@res)."}";
- }
- if ($type eq "ARRAY") {
- foreach $value (@$item) {
- push(@res,&convert_perlish($value));
- }
- return "[".join(",",@res)."]";
- }
- if ($type eq "SCALAR") {
- return "\042"."e_perlish($item)."\042";
- }
- return "";
- }
- };
-
-$encode{'perlish'}=\&convert_perlish;
-
-$decode{'perlish'}=sub {
- my($str)=shift;
- my($res);
-
- return eval($str);
- };
-
-################################################################
-### quoted-printable
-
-$encode{'quoted-printable'}=sub {
- my($str)=shift;
- my(@lines,$item);
-
-
- $str=~s/=/=3D/g;
- $str=~s/([\x00-\x1F\x80-\xFF])/sprintf("=%02X",ord($1))/eg;
-
- if (length($str)>75) {
- while (length($str)>75) {
- if (substr($str,73,1) eq "=") {
- push(@lines,substr($str,0,73)."="); ### soft break
- $str=substr($str,73);
- }
- elsif (substr($str,74,1) eq "=") {
- push(@lines,substr($str,0,74)."="); ### soft break
- $str=substr($str,74);
- }
- else {
- push(@lines,substr($str,0,75)."="); ### soft break
- $str=substr($str,75);
- }
- }
- push(@lines,$str);
- $str=join($HTTP::crlf,@lines);
- }
-
- return $str;
- };
-
-$decode{'quoted-printable'}=sub {
- $_[0]=~s/=([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
- $_[0]=~s/=$crlf//g;
- return $_[0];
- };
-1;
+++ /dev/null
-#
-# convert.pl
-#
-
-sub mk_workfile {
- my($props)=shift;
- local(*HANLDE);
- my($now,$count,$dir,$prefix);
-
- $dir=$$props{'convert'}{'work_dir'};
- $prefix=$$props{'convert'}{'work_prefix'};
- $now=time;
- $count=0;
-
- while (-f $dir.$prefix.$now.".".$count) { $count++; }
-
- ## fast touch
- if (sysopen(HANDLE,$dir.$prefix.$now.".".$count,O_CREATE|O_RDWR)) { close(HANDLE); }
-
- return $dir.$prefix.$now.".".$count;
- }
-
-sub html_to_text {
- my($props,$text)=@_;
- local(*HANDLE);
- my($file,$result);
-
- $file=&mk_workfile($props);
- if (open(HANDLE,">".$file)) {
- print HANDLE $text;
- close(HANDLE);
- }
- else {
- ## error - do not convert
- return $text;
- }
- if (open(HANDLE,$$props{'bin'}{'html_to_text'}.$file."|")) {
- while (<HANDLE>) {
- $result.=$_;
- }
- close(HANDLE);
- unlink($file);
- return $result;
- }
- else {
- unlink($file);
- return $text;
- }
- }
-
-1;
+++ /dev/null
-#!/usr/bin/perl
-
-#
-# Logfile Module (3.6.1998)
-#
-# USAGE: tie *HANDLE, 'Logfile', '<filename>', '<modulename';
-#
-# $VER: 1.1$
-#
-
-package Logfile;
-
-$LOCK_EX=2;
-$LOCK_UN=8;
-
-sub mkname {
- my($name)=shift;
- my @timestr=localtime(time);
-
- $name=~s/\%d/$timestr[3]/eg;
- $name=~s/\%m/$timestr[4]+1/eg;
- $name=~s/\%y/$timestr[5]+1900/eg;
-
- return $name;
- }
-
-# no reading from logfile
-sub READLINE { return undef; }
-sub READ { return undef; }
-sub GETC { return undef; }
-
-sub PRINT {
- my $obj=shift;
- my @text=@_;
- my @timestr=localtime(time);
-
- local(*OUT);
-
- if ((scalar(@text)>1) && ($text[0]=~/^\d+$/)) {
- my($level)=shift(@text);
- return if ($level<$$obj{'loglevel'});
- }
-
- if (open(OUT,">>".$$obj{'filename'})) {
- flock(OUT,$LOCK_EX);
- seek(OUT,0,2);
- printf OUT ("%02d.%02d.%s %02d:%02d:%02d [%d] %s: %s",
- ($timestr[3]),
- ($timestr[4]+1),
- ($timestr[5]+1900),
- $timestr[2],$timestr[1],$timestr[0],
- $$,$$obj{'module'},
- join("",@text));
- flock(OUT,$LOCK_UN);
- close(OUT);
- }
- }
-
-sub TIEHANDLE {
- my $obj;
- shift;
- $$obj{'filename'}=&mkname(shift);
- $$obj{'module'}=shift;
- $$obj{'loglevel'}=(shift || 0);
-
- bless $obj, 'Logfile';
-
- return $obj;
- }
-1;
+++ /dev/null
-#!/usr/bin/perl
-
-###########################################################
-### property module
-###
-### $VER: 2.1$
-
-package Property;
-
-sub compile {
- my ($value)=shift;
- $value=~s/\$\((\w+)\)/$ENV{$1}/e;
- return $value;
- }
-
-sub append {
- my($hash,$file)=@_;
- local(*FH);
- my($line,$cat,$slot,$key,$value,$from,$to);
-
- $cat="public";
- if (open(FH,$file)) {
- while (<FH>) {
- s/[\r\n]+//g;
- next if /^\s*$/;
- next if /^#/;
-
- if (/^\[(\w+)\]/) {
- $cat=$1;
- $$hash{$cat}{'_'}=$cat;
- next;
- }
- if (/^\[(\w+)\]\s*=\>\s*\[(\w+)\]$/) {
- $$hash{$2}=$$hash{$1};
- next;
- }
- if (/([^=\s]+)\s*=\s*(.*?)\s*$/) {
- $$hash{$cat}{$1}=$2;
- next;
- }
- if (/([^=\s]+)\s*:\s*(.*)/) {
- $key=$1; $value=$2;
- $value=&compile($value);
- $$hash{$cat}{$key}=$value;
- next;
- }
- if (/([^\<\s]+)\s*\<\<\s*(.*)/) {
- $slot=$1;
- undef @collect;
- while (<FH>) {
- last if substr($_,0,2) eq "<<";
- push(@collect,$_);
- }
- $$hash{$cat}{$slot}=join("\n",@collect);
- }
- }
- close(FH);
- }
- else { print "CANNOT OPEN $file --- $!\n"; }
- }
-
-sub read {
- my($file)=shift;
- my($hash)={};
-
- &append($hash,$file);
- return $hash;
- }
-
-1;
+++ /dev/null
-#!/usr/bin/perl
-
-################################################################
-### Preprocessor
-###
-### m
-###
-### $VER: 3.1.1 (% notation)$
-
-require "codec.pl";
-
-###########################################################
-### token stuff
-
-package TokenStream;
-
-sub new {
- local(*IN,$intro,$outro)=@_;
-
- $$stream{'handle'}=*IN;
- $$stream{'buffer'}=[];
- $$stream{'intro'}=$intro;
- $$stream{'outro'}=$outro;
-
- bless $stream, "TokenStream";
-
- return $stream;
- }
-
-sub fetch {
- my($stream)=shift;
- my($token,$old);
- local(*IN);
-
- if (defined ($token=shift(@{$$stream{'buffer'}}))) {
- return $token;
- }
- else {
- $old=$/;
- $/=$$stream{'outro'};
- *IN=$$stream{'handle'};
-
- $token=<IN>;
-
- if (($index=index($token,$$stream{'intro'}))>0) {
- push(@{$$stream{'buffer'}},substr($token,$index));
- $token=substr($token,0,$index);
- }
-
- $/=$old;
-
- return $token;
- }
- }
-
-sub feed {
- my($stream,$value)=@_;
-
- if (ref $value) {
- unshift(@{$$stream{'buffer'}},@$value);
- }
- else {
- unshift(@{$$stream{'buffer'}},$value);
- }
- }
-
-###########################################################
-### prepro stuff
-
-package Subst;
-
-###########################################################
-### local fun :-)
-
-$localfun{'store'}=sub {
- my($args,$env,$stream)=@_;
- my($token,$field,$count);
-
- # print "STORE $$args[1]\n";
-
- $field=$$args[1];
- $count=0;
-
- $$env{$field}{'_data'}=[];
- while (($token=$stream->fetch) && ($token ne "<%/store%>")) {
- push(@{$$env{$field}{'_data'}},$token);
- $count++;
- }
- $$env{$field}{'_pos'}=0;
- $$env{$field}{'_size'}=$count;
- };
-
-$localfun{'reset'}=sub {
- my($args)=shift;
-
- $$env{$$args[1]}{'_pos'}=0;
- };
-
-$localfun{'insert'}=sub {
- my($args,$env,$stream)=@_;
-
- #print main::DEBUG "INSERT $$args[1] size=",scalar(@{$$env{$$args[1]}{'_data'}})," time=$$env{$$args[1]}{'_pos'}\n";
-
- $stream->feed($$env{$$args[1]}{'_data'});
- $$env{$$args[1]}{'_pos'}++;
- };
-
-$localfun{'loop'}=sub {
- my($args,$env,$stream)=@_;
- my($token,@loop,$count);
-
-
- $count=$$args[1];
- #print "LOOP $count\n";
- while (($token=$stream->fetch) && ($token ne "<%/loop%>")) {
- push(@loop,$token);
- }
- while ($count--) {
- $stream->feed(\@loop);
- }
- };
-
-sub clone {
- my(@data)=@_;
- return \@data;
- }
-
-$localfun{'load'}=sub {
- my($args,$env,$stream)=@_;
- my(@temp,$count);
-
- # print "<!-- LOAD: $$args[2] into $$args[1] -->";
-
- $$env{$$args[1]}{'_data'}=[];
- $count=0;
- if (open(LOAD,$$args[2])) {
- while (<LOAD>) {
- chomp;
- #print "ROW: $_\n";
- @temp=split(/\t/);
- push(@{$$env{$$args[1]}{'_data'}},&clone(@temp));
- undef @temp;
- $count++;
- }
- close(LOAD);
- }
- $$env{$$args[1]}{'_size'}=$count;
- $$env{$$args[1]}{'_pos'}=0;
-
- # print "LOAD $$args[2] into $$args[1] ($count)\n";
- };
-
-$localfun{'loadvalues'}=sub {
- my($args,$env,$stream)=@_;
- local(*LOAD);
- my($cat)="public";
- my($slot,$key,$value,@collect);
-
- if (open(LOAD,$$args[1])) {
- while (<LOAD>) {
- s/[\r\n]+//g;
- next if /^\s*$/;
- next if /^#/;
-
- if (/^\[(\w+)\]/) {
- $cat=$1;
- next;
- }
- if (/^\[(\w+)\]\s*=\>\s*\[(\w+)\]$/) {
- $$env{$2}=$$env{$1};
- next;
- }
- if (/([^=\s]+)\s*=\s*(.*?)\s*$/) {
- $$env{$cat}{$1}=$2;
- next;
- }
- if (/([^=\s]+)\s*:\s*(.*)/) {
- $key=$1; $value=$2;
- $value=~s/\$\((\w+)\)/$ENV{$value}/e;
- $$env{$cat}{$key}=$value;
- next;
- }
- if (/([^\<\s]+)\s*\<\<\s*(.*)/) {
- $slot=$1;
- undef @collect;
- while (<LOAD>) {
- last if substr($_,0,2) eq "<<";
- push(@collect,$_);
- }
- $$env{$cat}{$slot}=join("\n",@collect);
- }
- }
- close(LOAD);
- }
- else {
- print "Cannot loadvalues ".$$args[1]."\n";
- }
- };
-
-$localfun{'bind'}=sub {
- my($args,$env,$stream)=@_;
- my($temp,$name,$var,$t,$item);
-
- shift(@$args); # function name
- $name=shift(@$args);
- $var=shift(@$args);
-
- #print "BIND from $name [$$env{$name}{'_pos'}] to $var : ";
-
- if ($$env{$name}{'_pos'}<$$env{$name}{'_size'}) {
- $t=0;
- $temp=$$env{$name}{'_data'}[$$env{$name}{'_pos'}];
- foreach $item (@$args) {
- #print "\t$item=$$temp[$t]\n";
- $$env{$var}{$item}=$$temp[$t++];
- }
- $$env{$name}{'_pos'}++;
- }
- else {
- undef $$env{$var};
- }
- };
-
-### version 3.1 functions
-
-$localfun{'incr'}=sub {
- my($args)=shift;
-
- #print main::DEBUG "INCR $$args[1]\n";
-
- $$env{$$args[1]}{'_pos'}++;
- };
-
-$localfun{'alias'}=sub {
- my($args,$env,$stream)=@_;
- my($temp,$name,$var,$t,$item);
-
- shift(@$args); # function name
- $name=shift(@$args);
- $var=shift(@$args);
-
- #print main::DEBUG "ALIAS from $name [$$env{$name}{'_pos'}] to $var\n";
-
- if ($$env{$name}{'_pos'}<$$env{$name}{'_size'}) {
- $$env{$var}=$$env{$name}{'_data'}[$$env{$name}{'_pos'}];
- }
- else {
- undef $$env{$var};
- }
- };
-
-$localfun{'keyvalue'}=sub {
- my($args,$env,$stream)=@_;
- my($from,$to,@buffer,$key,$value);
-
- shift(@$args); # function name
- $from=shift(@$args);
- $to=shift(@$args);
-
-
- while (($key,$value)=each %{$$env{$from}}) {
- push(@buffer,{'key' => $key, 'value' => $value});
- }
- $$env{$to}{'_data'}=\@buffer;
- $$env{$to}{'_pos'}=0;
- $$env{$to}{'_size'}=scalar(@buffer);
-
- #print main::DEBUG "keyvalue $from into $to ",scalar(@buffer),"\n";
- };
-
-$localfun{'set'}=sub {
- my($args,$env,$stream)=@_;
- my($name,$value);
-
- shift(@$args); # function name
- $name=shift(@$args);
- $value=shift(@$args);
-
- $$env{'_flags'}{$name}=$value;
- };
-
-###########################################################
-### if fun ??
-
-$iffun{'ifdef'}=sub {
- my($args,$env)=@_;
- return ((defined (&getvalue($env,$$args[1]))) ? 0 : 1);
- };
-
-$iffun{'ifnz'}=sub {
- my($args,$env)=@_;
- return (&getvalue($env,$$args[1]) ? 0 : 1);
- };
-
-$iffun{'ifequal'}=sub {
- my($args,$env)=@_;
- return ((&getvalue($env,$$args[1]) eq $$args[2]) ? 0 : 1);
- };
-
-$iffun{'ifmember'}=sub {
- my($args,$env)=@_;
- return ((index($$args[1],$$args[2])<0) ? 1 : 0);
- };
-
-$iffun{'ifdecr'}=sub {
- my($args,$env)=@_;
-
- if ($$args[1]=~/(\S+)\.(\S+)/) {
- return (($$env{$1}{$2}-- > 0) ? 0 : 1);
- }
- else {
- return (($$env{$$args[1]}-- > 0) ? 0 : 1);
- }
- };
-
-$iffun{'ifiter'}=sub {
- my($args,$env)=@_;
-
- if ($$args[2]=~/(\d+)\.(\d+)/) {
- return (($$env{$$args[1]}{'_pos'} % $1) != $2);
- }
- else {
- return (($$env{$$args[1]}{'_pos'} % $$argv[2]) != 0);
- }
- };
-
-
-### version 3.1 functions
-
-$iffun{'ifplus'}=sub {
- my($args,$env)=@_;
- return ((&getvalue($env,$$args[1])>0) ? 0 : 1);
- };
-
-$iffun{'ifminus'}=sub {
- my($args,$env)=@_;
- return ((&getvalue($env,$$args[1])<0) ? 0 : 1);
- };
-
-$iffun{'ifpluszero'}=sub {
- my($args,$env)=@_;
- return ((&getvalue($env,$$args[1])>=0) ? 0 : 1);
- };
-
-$iffun{'ifminuszero'}=sub {
- my($args,$env)=@_;
- return ((&getvalue($env,$$args[1])<=0) ? 0 : 1);
- };
-
-
-###########################################################
-### process
-
-sub process {
- local(*IN,*OUT,$env,$post)=@_;
- my($token,$ignore,@temp,$templine,$stream);
-
- $logfile=$$env{'logfile'};
-
- $stream=&TokenStream::new(*IN,"<%","%>");
-
- return undef unless defined $stream;
-
- #if (!defined $post) { $post=sub { print OUT $_[0] unless $_[0]=~/^\s*$/; }; }
- if (!defined $post) { $post=sub { print OUT $_[0]; }; }
-
- $ignore=0;
-
- while ($token=$stream->fetch) {
- # if-endif
- if ($token eq "<%endif%>") {
- $ignore-- if $ignore>0;
- next;
- }
-
- if (($ignore>0) && (substr($token,0,4) eq "<%if")) {
- $ignore++;
- next;
- }
-
- if ($token eq "<%else%>") {
- ($ignore == 0) && ($ignore=1, next);
- ($ignore == 1) && ($ignore=0, next);
- }
-
- next if $ignore;
-
- #$token=~s/\^(\'?[\w.]+)(\\)?/&getvalue($env,$1)/eg;
- #$token=~s/\^(\[\w+\])?([\w.]+)(\\)?/&getvalue($env,$2,$1)/eg;
- $token=~s/\^(\[\w+\])?([\w\x5b\x5d.]+)(\\)?/&getvalue($env,$2,$1)/eg;
-
- # handle none-special case
- if (substr($token,0,2) ne "<%") {
- &$post($token);
- next;
- }
-
- @temp=split(/\s+/,substr($token,2,-2));
-
- if (defined $iffun{$temp[0]}) {
- $ignore=&{$iffun{$temp[0]}}(\@temp,$env);
- next;
- }
-
- if (defined $localfun{$temp[0]}) {
- &{$localfun{$temp[0]}}(\@temp,$env,$stream);
- next;
- }
-
- &$post($token);
- }
- }
-
-###########################################################
-### binding
-
-$perlish=&Codec::new('perlish');
-
-$convert{'[perl]'}=sub { return $perlish->encode(@_); };
-
-$convert{'[scalar]'}=sub { return scalar($_[0]); };
-
-$convert{'[javastyle]'}=sub {
- my($value)=shift;
- $value=lc($value);
- substr($value,0,1)=uc(substr($value,0,1));
- return $value;
- };
-
-sub getvalue {
- my($env,$key,$fun)=@_;
- my($convert,$value);
-
-# $key=~s/\./\'\}\{\'/g;
-# $value=eval "\$\$env{'$key'}";
-
- $key=~s/\./\'\}\{\'/g;
- $key="{'".$key."'}";
- $key=~s/(\[\d+\])\'\}/\'\}$1/g;
- $value=eval "\$\$env$key";
-
- if ((defined $fun) && (defined $convert{$fun})) { return &{$convert{$fun}}($value); }
- else { return $value; }
- }
-
-1;
-- This script updates all sequences in a postgres mir database\r
\r
-select setval('media_id_seq', (select max(id) from media));\r
+select \r
+ CASE WHEN (select max(id) from content)>(select max(id) from uploaded_media)\r
+ THEN setval('media_id_seq', (select max(id) from content))\r
+ ELSE setval('media_id_seq', (select max(id) from uploaded_media))\r
+ END;\r
select setval('media_folder_id_seq', (select max(id) from media_folder));\r
select setval('topic_id_seq', (select max(id) from topic));\r
select setval('webdb_users_id_seq', (select max(id) from webdb_users));\r
select setval('comment_status_id_seq',(select max(id) from comment_status));\r
select setval('article_type_id_seq', (select max(id) from article_type));\r
select setval('language_id_seq', (select max(id) from language));\r
-\r
-\r
-\r
-\r
+++ /dev/null
-\connect - postgres
-
-CREATE SEQUENCE "media_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
-DROP TABLE "media_type";
-
-CREATE TABLE "media_type" (
- "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL,
- "name" character varying(80) NOT NULL,
- "mime_type" character varying(40) NOT NULL,
- "classname" character varying(80) NOT NULL,
- "tablename" character varying(80) NOT NULL,
- "dcname" character varying(20)
-);
-
-
-CREATE TABLE "uploaded_media" (
-
-) INHERITS ("media");
-
--- /dev/null
+-- update script 2003-11-22 by Zapata
+-- * added a bunch of fields to webdb_user: is_disabled, email, profile, creation date,
+-- last login date
+-- This script will terminate with an error the second time it's run,
+-- so running this script when it isn't needed can't do any harm.
+--
+
+BEGIN TRANSACTION;
+
+ALTER TABLE "webdb_users" RENAME TO "webdb_users_old";
+DROP INDEX "webdb_users_pkey";
+
+CREATE TABLE "webdb_users" (
+ "id" integer DEFAULT nextval('webdb_users_id_seq'::text) NOT NULL,
+ "login" character varying(16) NOT NULL,
+ "password" character varying(255) NOT NULL,
+ "is_admin" boolean DEFAULT '0' NOT NULL,
+ "comment" text,
+ "is_disabled" boolean DEFAULT '0' NOT NULL,
+ "email" character varying(255) DEFAULT '' NOT NULL,
+ "profile" text,
+ "webdb_create" timestamp with time zone NOT NULL,
+ "lastlogin" timestamp with time zone,
+ CONSTRAINT "webdb_users_pkey" Primary Key ("id")
+);
+
+INSERT INTO "webdb_users" (
+ "id",
+ "login",
+ "password",
+ "is_admin",
+ "comment",
+ "is_disabled",
+ "email",
+ "profile",
+ "webdb_create",
+ "lastlogin"
+)
+SELECT
+ "id",
+ "login",
+ "password",
+ "is_admin",
+ '',
+ 'f',
+ '',
+ '',
+ now(),
+ null
+FROM "webdb_users_old";
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='webdb_users_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='webdb_users_old')
+WHERE
+ relname = 'webdb_users';
+
+
+-- to prevent this script from being run successfully for a second time
+INSERT INTO webdb_users_old(login, password, is_admin) values('','','t');
+
+DROP TABLE "webdb_users_old";
+
+-- that's it!
+
+COMMIT TRANSACTION;
--- /dev/null
+-- update script 2003-11-25 by Zapata
+-- * Clean up comments
+-- * added a comment field for internal comments
+-- This script will terminate with an error the second time it's run,
+-- so running this script when it isn't needed is prevented from doing do any harm.
+
+BEGIN TRANSACTION;
+
+----------------------
+-- COMMENT changes
+----------------------
+
+ALTER TABLE "comment" RENAME TO "comment_old";
+DROP INDEX comment_pkey;
+DROP INDEX comment_checksum_index;
+DROP INDEX idx_comment_to_media;
+DROP INDEX idx_comment_webdb_create;
+DROP INDEX idx_comment_tomedia_ispublished;
+DROP INDEX idx_comment_id;
+
+CREATE TABLE "comment" (
+ "id" integer DEFAULT nextval('comment_id_seq'::text) NOT NULL,
+ "title" character varying(80) NOT NULL,
+ "creator" character varying(80) NOT NULL,
+ "description" text NOT NULL,
+ "main_url" character varying(255),
+ "email" character varying(80),
+ "address" character varying(80),
+ "phone" character varying(20),
+ "webdb_create" timestamp with time zone NOT NULL,
+ "webdb_lastchange" timestamp with time zone,
+ "is_published" boolean DEFAULT '1' NOT NULL,
+ "to_language" integer DEFAULT '0' NOT NULL,
+ "to_media" integer NOT NULL,
+ "to_comment_status" smallint,
+ "comment" text,
+ "is_html" boolean DEFAULT '0' NOT NULL,
+ Constraint "comment_pkey" Primary Key ("id")
+);
+
+CREATE INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
+CREATE INDEX idx_comment_webdb_create on comment(webdb_create);
+CREATE INDEX "idx_comment_tomedia_ispublished" on "comment" using btree ( "to_media" "int4_ops", "is_published" "bool_ops" );
+CREATE UNIQUE INDEX "idx_comment_id" on "comment" using btree ( "id" "int4_ops" );
+
+INSERT INTO "comment" (
+ "id",
+ "title",
+ "creator",
+ "description",
+ "main_url",
+ "email",
+ "address",
+ "phone",
+ "webdb_create",
+ "webdb_lastchange",
+ "is_published",
+ "to_language",
+ "to_media",
+ "to_comment_status",
+ "is_html",
+ "comment")
+select
+ "id",
+ "title",
+ "creator",
+ "description",
+ "main_url",
+ "email",
+ "address",
+ "phone",
+ "webdb_create",
+ "webdb_lastchange",
+ "is_published",
+ "to_language",
+ "to_media",
+ "to_comment_status",
+ "is_html",
+ ''
+from comment_old;
+
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='comment_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='comment_old')
+WHERE
+ relname = 'comment';
+
+-- to prevent this script from being run successfully for a second time
+INSERT INTO comment_old(to_media, description, checksum, title, creator, webdb_create) values(1, '', 1, '', '', now());
+
+DROP TABLE comment_old;
+
+-- thats it!
+
+COMMIT TRANSACTION;
--- /dev/null
+-- update script 2003-11-25 by Zapata
+-- * Removal of media (uploaded_media and content are now independently)
+-- * Clean up of content
+-- * Added a field for content-locking
+-- * Added a keywords field for content
+-- This script will terminate with an error the second time it's run,
+-- so running this script when it isn't needed is prevented from doing do any harm.
+
+DROP INDEX idx_content_webdb_create;
+DROP INDEX idx_othermedia_is_published_produced;
+DROP INDEX idx_othermedia_id;
+DROP INDEX idx_video_id;
+
+BEGIN TRANSACTION;
+
+----------------------
+-- CONTENT changes
+----------------------
+
+ALTER TABLE "content" RENAME TO "content_old";
+
+DROP INDEX "content_checksum_index";
+DROP INDEX "idx_content_to_article_type";
+DROP INDEX "idx_content_is_produced";
+DROP INDEX "idx_content_is_published__to_ar";
+DROP INDEX "idx_content_is_published__id";
+DROP INDEX "idx_content_is_pub__to_art__to_";
+DROP INDEX "idx_content_id";
+DROP INDEX "idx_content_is_published";
+
+CREATE TABLE "content" (
+ "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
+ "title" character varying(255),
+ "subtitle" character varying(255),
+ "edittitle" character varying(255),
+ "date" character(8) NOT NULL,
+ "creator" character varying(80),
+ "creator_main_url" character varying(255),
+ "creator_email" character varying(80),
+ "creator_address" character varying(80),
+ "creator_phone" character varying(80),
+ "description" text,
+ "comment" text,
+ "source" character varying(255),
+ "is_published" boolean DEFAULT '0' NOT NULL,
+ "is_produced" boolean DEFAULT '0' NOT NULL,
+ "to_publisher" integer NOT NULL,
+ "to_language" integer DEFAULT '0',
+ "to_rights" integer DEFAULT '0',
+ "webdb_create" timestamp with time zone NOT NULL,
+ "webdb_lastchange" timestamp with time zone,
+ "content_data" text,
+ "is_html" boolean DEFAULT '0' NOT NULL,
+ "to_article_type" smallint DEFAULT '0' NOT NULL,
+ "to_content" integer,
+ "keywords" text,
+ "to_locking_user" integer,
+ Constraint "content_pkey" Primary Key ("id")
+);
+
+
+CREATE INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
+CREATE INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
+CREATE INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
+CREATE INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
+CREATE INDEX "idx_content_is_pub__to_art__to_" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops", "id" "int4_ops" );
+CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" );
+CREATE INDEX "idx_content_is_published" on "content" using btree ( "is_published" "bool_ops" );
+
+INSERT INTO "content" (
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "is_published",
+ "is_produced",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "content_data",
+ "is_html",
+ "to_article_type",
+ "to_content",
+ "keywords")
+select
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "is_published",
+ "is_produced",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "content_data",
+ "is_html",
+ "to_article_type",
+ "to_content",
+ ''
+from content_old;
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='content_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='content_old')
+WHERE
+ relname = 'content';
+
+DROP table content_old;
+
+--
+-- uploaded_media
+--
+
+ALTER TABLE "uploaded_media" RENAME TO "uploaded_media_old";
+DROP INDEX "idx_uploaded_media_id";
+DROP INDEX "idx_uploaded_media_is_published";
+
+CREATE TABLE "uploaded_media" (
+ "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
+ "title" character varying(255),
+ "subtitle" character varying(255),
+ "edittitle" character varying(255),
+ "date" character(8) NOT NULL,
+ "creator" character varying(80),
+ "creator_main_url" character varying(255),
+ "creator_email" character varying(80),
+ "creator_address" character varying(80),
+ "creator_phone" character varying(20),
+ "description" text,
+ "comment" text,
+ "source" character varying(255),
+ "publish_server" character varying(255),
+ "publish_path" character varying(255),
+ "is_published" boolean DEFAULT '0' NOT NULL,
+ "is_produced" boolean DEFAULT '0' NOT NULL,
+ "to_media_folder" integer DEFAULT '0' NOT NULL,
+ "to_media_type" smallint DEFAULT '0' NOT NULL,
+ "to_publisher" integer NOT NULL,
+ "to_language" integer DEFAULT '0',
+ "to_rights" integer DEFAULT '0',
+ "webdb_create" timestamp with time zone NOT NULL,
+ "webdb_lastchange" timestamp with time zone,
+ "icon_is_produced" boolean DEFAULT '0' NOT NULL,
+ "icon_path" character varying(255),
+ "size" integer,
+ Constraint "uploaded_media_pkey" Primary Key ("id")
+);
+
+CREATE UNIQUE INDEX "idx_uploaded_media_id" on "uploaded_media" using btree ( "id" "int4_ops" );
+CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using btree ( "id" "int4_ops", "is_published" "bool_ops" );
+
+--
+-- images
+--
+
+ALTER TABLE "images" RENAME TO "images_old";
+DROP INDEX "idx_images_is_published__icon_i";
+DROP INDEX "idx_images_id";
+
+
+CREATE TABLE "images" (
+ "image_data" oid,
+ "icon_data" oid,
+ "year" character varying(40),
+ "img_width" smallint,
+ "img_height" smallint,
+ "to_img_format" smallint DEFAULT '0' NOT NULL,
+ "to_img_layout" smallint DEFAULT '0' NOT NULL,
+ "to_img_type" smallint DEFAULT '0' NOT NULL,
+ "to_img_color" smallint DEFAULT '0' NOT NULL,
+ "icon_width" smallint,
+ "icon_height" smallint
+)
+INHERITS ("uploaded_media");
+
+CREATE INDEX "idx_images_is_published" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
+CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
+
+INSERT INTO images(
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size",
+ "image_data",
+ "icon_data",
+ "year",
+ "img_width",
+ "img_height",
+ "to_img_format",
+ "to_img_layout",
+ "to_img_type",
+ "to_img_color",
+ "icon_width",
+ "icon_height"
+)
+SELECT
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size",
+ "image_data",
+ "icon_data",
+ "year",
+ "img_width",
+ "img_height",
+ "to_img_format",
+ "to_img_layout",
+ "to_img_type",
+ "to_img_color",
+ "icon_width",
+ "icon_height"
+FROM images_old;
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='images_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='images_old')
+WHERE
+ relname = 'images';
+
+DROP table images_old;
+
+--
+-- audio
+--
+
+ALTER TABLE "audio" RENAME TO "audio_old";
+DROP INDEX "idx_audio_is_published_produced";
+DROP INDEX "idx_audio_id";
+
+CREATE TABLE "audio" (
+ "kbits" smallint
+)
+INHERITS ("uploaded_media");
+
+CREATE INDEX "idx_audio_is_published_produced" on "audio" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
+CREATE UNIQUE INDEX "idx_audio_id" on "audio" using btree ( "id" "int4_ops" );
+
+INSERT INTO audio(
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size",
+ "kbits"
+)
+SELECT
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size",
+ "kbits"
+FROM audio_old;
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='audio_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='audio_old')
+WHERE
+ relname = 'audio';
+
+DROP table audio_old;
+
+--
+-- video
+--
+
+DROP INDEX "idx_video_is_published_produced";
+ALTER TABLE "video" RENAME TO "video_old";
+
+CREATE TABLE "video" (
+)
+INHERITS ("uploaded_media");
+
+CREATE INDEX "idx_video_is_published_produced" on "video" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
+
+INSERT INTO video(
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size"
+)
+SELECT
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size"
+FROM video_old;
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='video_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='video_old')
+WHERE
+ relname = 'video';
+
+DROP table video_old;
+
+
+--
+-- other_media
+--
+
+ALTER TABLE "other_media" RENAME TO "other_media_old";
+
+CREATE TABLE "other_media" (
+)
+INHERITS ("uploaded_media");
+
+INSERT INTO other_media(
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size"
+)
+SELECT
+ "id",
+ "title",
+ "subtitle",
+ "edittitle",
+ "date",
+ "creator",
+ "creator_main_url",
+ "creator_email",
+ "creator_address",
+ "creator_phone",
+ "description",
+ "comment",
+ "source",
+ "publish_server",
+ "publish_path",
+ "is_published",
+ "is_produced",
+ "to_media_folder",
+ "to_media_type",
+ "to_publisher",
+ "to_language",
+ "to_rights",
+ "webdb_create",
+ "webdb_lastchange",
+ "icon_is_produced",
+ "icon_path",
+ "size"
+FROM other_media_old;
+
+UPDATE pg_class
+SET
+ relowner = (SELECT relowner FROM pg_class WHERE relname='other_media_old'),
+ relacl = (SELECT relacl FROM pg_class WHERE relname='other_media_old')
+WHERE
+ relname = 'other_media';
+
+DROP table other_media_old;
+
+DROP table uploaded_media_old;
+DROP table media;
+
+-- that's it!
+
+COMMIT TRANSACTION;
+
+CREATE INDEX idx_content_webdb_create on content(webdb_create);
+CREATE INDEX "idx_othermedia_is_published_produced" on "other_media" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
+CREATE UNIQUE INDEX "idx_othermedia_id" on "other_media" using btree ( "id" "int4_ops" );
+CREATE UNIQUE INDEX "idx_video_id" on "video" using btree ( "id" "int4_ops" );
+
+
+++ /dev/null
-<html>
-<head>
-<title>
-^tablename
-</title>
-<head>
-
-<body bgcolor="#FFFFFF">
-<include "head.template">
-<form method="post" action="${actionRoot}">
- <input type=hidden name=module value=^tablename_javastyle>
- <input type="hidden" name="id" value="${id}">
- <if new>
- <input type="hidden" name="do" value="insert">
- <else>
- <input type="hidden" name="do" value="update">
- </if>
-<table border="0">
-
-
-<!list metadata>
- <tr>
- <td align="right" bgcolor="#000000"><font color="#ffffff"><B>^metadata.name :</B></font></td>
- <td>
- <input type="text" size="40" name="^metadata.name" value="${^metadata.name}">
- </td>
- </tr>
-<end-list>
-
-
- <tr>
- <td colspan="2" align="right"> <font color="#ffffff"><if new>
- <input type="submit" name="save" value="einfügen">
- <else>
- <input type="submit" name="save" value="speichern">
- </if> </font></form></font>
- </td>
- <tr>
-</table>
-<include "foot.template">
-</body>
-</html>
+++ /dev/null
-#!/usr/bin/perl
-
-#
-# wizard
-#
-
-use DBI;
-
-$0=~m#[^/]+$#;
-$cmdpath=$`;
-if ($cmdpath eq "") { $cmdpath="./"; }
-unshift(@INC,$cmdpath."lib");
-
-require "codec.pl";
-require "subst.pl";
-
-sub USAGE {
- print "USAGE: wizard.pl dsn user passwd table dir\n";
- exit(0);
- }
-
-$dsn=shift(@ARGV) || &USAGE;
-if (($dsn eq "-h") || ($dsn eq "--help")) { &USAGE; }
-$user=shift(@ARGV) || &USAGE;
-$passwd=shift(@ARGV) || &USAGE;
-if ($passwd eq "-") { $passwd=""; }
-$table=shift(@ARGV) || &USAGE;
-$dir=shift(@ARGV) || &USAGE;
-
-$dbh=DBI->connect($dsn,$user,$passwd);
-if (!defined $dsn) {
- print "Error: cannot connect $dsn\n";
- &USAGE;
- }
-
-$tables=$dbh->table_info;
-while ($hash=$tables->fetchrow_hashref) {
- #print $$hash{'TABLE_NAME'}."\n";
-
- if ($$hash{'TABLE_NAME'} eq $table) {
-
- $sth=$dbh->prepare("show fields from ".$$hash{'TABLE_NAME'});
- $sth->execute;
- while ($fieldhash=$sth->fetchrow_hashref) {
- #print "\t".$$fieldhash{'Field'}.":".$$fieldhash{'Type'}."\n";
- push(@data,[$$fieldhash{'Field'},$$fieldhash{'Type'}]);
- }
- $sth->finish;
- }
- }
-
-$$env{'fields'}{'_data'}=\@data;
-$$env{'fields'}{'_pos'}=0;
-$$env{'fields'}{'_size'}=scalar(@data);
-
-$$env{'tablename'}=$table;
-
-print "prosessing files in $dir\n";
-
-chdir $dir;
-
-if (opendir(DIR,".")) {
- while ($file=readdir(DIR)) {
- next unless (-f $file);
- if ($file=~/\.template$/) {
- $newfile=$`;
- print "\t$file -> $newfile\n";
- if (open(IN,$file)) {
- if (open(OUT,">$newfile")) {
- &Subst::process(*IN,*OUT,$env);
- close(OUT);
- }
- close(IN);
- }
- }
- }
- closedir(DIR);
- }
-
-
-
-
-
/**
* Mir.java - main servlet, that dispatches to servletmodules
*
- * @author $Author: rk $
- * @version $Id: Mir.java,v 1.49.2.8 2003/10/23 14:55:26 rk Exp $
+ * @author $Author: zapata $
+ * @version $Id: Mir.java,v 1.49.2.9 2003/12/21 13:32:02 zapata Exp $
*
*/
public class Mir extends AbstractServlet {
if (user!=null) {
ServletHelper.setUser(aRequest, user);
- aRequest.getSession().setAttribute("sessiontracker", new SessionTracker(username));
+ usersModule.recordLogin(user);
+ aRequest.getSession().setAttribute("sessiontracker", new SessionTracker(username, user.getId()));
}
}
private class SessionTracker implements HttpSessionBindingListener {
private String name;
+ private String id;
- public SessionTracker(String aUserName) {
+ public SessionTracker(String aUserName, String anId) {
name = aUserName;
+ id = anId;
}
public void valueBound(HttpSessionBindingEvent anEvent) {
- MirGlobal.registerLogin(name);
+ MirGlobal.registerLogin(name, id);
}
public void valueUnbound(HttpSessionBindingEvent anEvent) {
- MirGlobal.registerLogout(name);
+ MirGlobal.registerLogout(name, id);
}
}
}
# Which usernames have admin priviliges (, seperated usernames)
AccessControl.SuperUsers = admin
+# Locking enabled?
+AccessControl.LockingEnabled = 0
+
+# If locking enabled, should users lock articles before they
+# can edit?
+AccessControl.LockingOptional = 1
+
# the templates
Mir.Localizer.Producer.GeneratorLibrary= default=freemarker(etc/producer/)
Mir.Localizer.Admin.GeneratorLibrary= default=freemarker(templates/admin/)
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
+import mir.util.*;
/**
* Base class the entities are derived from. Provides base functionality of
* an entity. Entities are used to represent rows of a database table.<p>
*
- * @version $Id: Entity.java,v 1.21.2.5 2003/10/23 14:55:28 rk Exp $
+ * @version $Id: Entity.java,v 1.21.2.6 2003/12/21 13:32:03 zapata Exp $
* @author rk
*
*/
throw new StorageObjectFailure("Storage Object Exception in entity", e);
}
+
+ /**
+ * Helper method to append a line to a field
+ */
+ public void appendLineToField(String aFieldName, String aLine) {
+ StringBuffer fieldContent = new StringBuffer();
+ try {
+ fieldContent.append(StringRoutines.interpretAsString(getValue(aFieldName)));
+ }
+ catch (Throwable t) {
+ }
+ if (fieldContent.length() > 0 && fieldContent.charAt(fieldContent.length() - 1) != '\n') {
+ fieldContent.append('\n');
+ }
+
+ fieldContent.append(aLine);
+ setValueForProperty(aFieldName, fieldContent.toString());
+ }
}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.entity;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Set;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.StorageObject;\r
-import mir.storage.store.StorableObject;\r
-import mir.storage.store.StoreContainerType;\r
-import mir.storage.store.StoreIdentifier;\r
-import mir.storage.store.StoreUtil;\r
-\r
-/**\r
- *\r
- * Container class for lists of Entities.\r
- * Now implements @see mir.storage.store.StorableObject.\r
- *\r
- * @author <RK>\r
- * first version 27.6.1999\r
- *\r
- * @version 1.1 (cleaned up)\r
- */\r
-public class EntityList implements StorableObject {\r
- protected static MirPropertiesConfiguration configuration;\r
- protected LoggerWrapper logger;\r
- private ArrayList theEntityArrayList = new ArrayList();\r
- private String whereClause, orderClause;\r
- private StorageObject theStorage;\r
- private int count, offset, limit;\r
- private int offsetnext = -1, offsetprev = -1;\r
-\r
- static {\r
- try {\r
- configuration = MirPropertiesConfiguration.instance();\r
- }\r
- catch (PropertiesConfigExc e) {\r
- throw new RuntimeException("Unable to get configuration: " + e.getMessage());\r
- }\r
- }\r
-\r
- /**\r
- * Constructor.\r
- */\r
- public EntityList(){\r
- logger = new LoggerWrapper("Entity.List");\r
- }\r
-\r
-/* get/set EntityClass of Objects stored in EntityList */\r
- public void setStorage(StorageObject storage) { this.theStorage=storage; }\r
- public StorageObject getStorage() { return theStorage; }\r
-\r
- public void setLimit(int limit) { this.limit = limit; }\r
-\r
- /**\r
- * Sets the WHERE clause that fetched the Entities of this EntityList from the database.\r
- * @param wc The string that contains the WHERE clause\r
- */\r
- public void setWhere(String wc) {\r
- this.whereClause = wc;\r
- }\r
-\r
- /**\r
- * Returns the WHERE clause that returned this EntityList from the database\r
- * @return whereClause The WHERE clause\r
- */\r
- public String getWhere() {\r
- return whereClause;\r
- }\r
-\r
-\r
- /**\r
- * Sets the sorting criterium of this EntityList\r
- * @param oc\r
- */\r
- public void setOrder(String oc) {\r
- this.orderClause = oc;\r
- }\r
-\r
- /**\r
- * Returns the sorting criterium.\r
- * @return orderClause The sort order\r
- */\r
- public String getOrder() {\r
- return orderClause;\r
- }\r
-\r
- /**\r
- * Sets the number of rows that match the WHERE clause\r
- * @param i The number of rows that match the WHERE clause\r
- */\r
- public void setCount(int i) {\r
- this.count = i;\r
- }\r
-\r
- /**\r
- * Returns the number of rows that match the WHERE clause\r
- * @return The number of rows ...\r
- */\r
- public int getCount() {\r
- return count;\r
- }\r
-\r
- /**\r
- * Sets the offset\r
- * @param i The offset\r
- */\r
- public void setOffset(int i) {\r
- offset = i;\r
- }\r
-\r
- /**\r
- * Returns the offset\r
- * @return offset\r
- */\r
- public int getOffset() {\r
- return offset;\r
- }\r
-\r
- /**\r
- * Sets the offset of the next batch of Entities.\r
- * @param i The next offset\r
- */\r
- public void setNextBatch(int i) {\r
- offsetnext = i;\r
- }\r
-\r
- /**\r
- * Returns the offset of the next batch of Entities.\r
- * @return offset of the next batch\r
- */\r
- public int getNextBatch() {\r
- return offsetnext;\r
- }\r
-\r
- /**\r
- * Returns whether there is a next batch within the WHERE clause\r
- * @return true if yes, false if no.\r
- */\r
- public boolean hasNextBatch() {\r
- return (offsetnext >= 0);\r
- }\r
-\r
- /**\r
- * Sets the offset of the previous batch.\r
- * @param i the previous offset\r
- */\r
- public void setPrevBatch(int i) {\r
- offsetprev = i;\r
- }\r
-\r
- /**\r
- * Returns the offset of the previous batch.\r
- * @return offset of the previous batch\r
- */\r
- public int getPrevBatch() {\r
- return offsetprev;\r
- }\r
-\r
- /**\r
- * Returns whether there is a previous batch.\r
- * @return true if yes, false if no\r
- */\r
- public boolean hasPrevBatch() {\r
- return (offsetprev >= 0);\r
- }\r
-\r
- /**\r
- * Returns the start index of the batch.\r
- * @return\r
- */\r
- public int getFrom() {\r
- return offset+1;\r
- }\r
-\r
- /**\r
- * Returns the end index of the batch.\r
- * @return\r
- */\r
- public int getTo() {\r
- if (hasNextBatch())\r
- return offsetnext;\r
- else\r
- return count;\r
- }\r
-\r
- /**\r
- * Inserts an Entity into the EntityList.\r
- * @param anEntity The entity to be inserted.\r
- */\r
-\r
- public void add (Entity anEntity) {\r
- if (anEntity!=null)\r
- theEntityArrayList.add(anEntity);\r
- else\r
- logger.warn("EntityList: add called with empty Entity");\r
- }\r
-\r
-\r
- /**\r
- * @return The number of Entities in the EntityList.\r
- */\r
-\r
- public int size() {\r
- return theEntityArrayList.size();\r
- }\r
-\r
-\r
- /**\r
- * Returns the element at position i in the EntityList as Entity\r
- * @param i the position of the element in question\r
- * @return The element at position i.\r
- */\r
-\r
- public Entity elementAt(int i) {\r
- /** @todo check if i is in list.size() */\r
- return (Entity)theEntityArrayList.get(i);\r
- }\r
-\r
-\r
-\r
-// Methods to implement StorableObject\r
-\r
- public Set getNotifyOnReleaseSet() { return null; }\r
-\r
- public StoreIdentifier getStoreIdentifier() {\r
- if ( theStorage!=null ) {\r
- return\r
- new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,\r
- StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),\r
- whereClause, orderClause, offset, limit ));\r
- }\r
- logger.warn("EntityList could not return StoreIdentifier");\r
- return null;\r
- }\r
-\r
-}\r
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.entity;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.log.LoggerWrapper;
+import mir.storage.StorageObject;
+import mir.storage.store.StorableObject;
+import mir.storage.store.StoreContainerType;
+import mir.storage.store.StoreIdentifier;
+import mir.storage.store.StoreUtil;
+
+/**
+ *
+ * Container class for lists of Entities.
+ * Now implements @see mir.storage.store.StorableObject.
+ *
+ * @author <RK>
+ * first version 27.6.1999
+ *
+ * @version 1.1 (cleaned up)
+ */
+public class EntityList implements StorableObject {
+ protected static MirPropertiesConfiguration configuration;
+ protected LoggerWrapper logger;
+ private ArrayList theEntityArrayList = new ArrayList();
+ private String whereClause, orderClause;
+ private StorageObject theStorage;
+ private int count, offset, limit;
+ private int offsetnext = -1, offsetprev = -1;
+
+ static {
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ }
+ catch (PropertiesConfigExc e) {
+ throw new RuntimeException("Unable to get configuration: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public EntityList(){
+ logger = new LoggerWrapper("Entity.List");
+ }
+
+/* get/set EntityClass of Objects stored in EntityList */
+ public void setStorage(StorageObject storage) { this.theStorage=storage; }
+ public StorageObject getStorage() { return theStorage; }
+
+ public void setLimit(int limit) { this.limit = limit; }
+
+ /**
+ * Sets the WHERE clause that fetched the Entities of this EntityList from the database.
+ * @param wc The string that contains the WHERE clause
+ */
+ public void setWhere(String wc) {
+ this.whereClause = wc;
+ }
+
+ /**
+ * Returns the WHERE clause that returned this EntityList from the database
+ * @return whereClause The WHERE clause
+ */
+ public String getWhere() {
+ return whereClause;
+ }
+
+
+ /**
+ * Sets the sorting criterium of this EntityList
+ * @param oc
+ */
+ public void setOrder(String oc) {
+ this.orderClause = oc;
+ }
+
+ /**
+ * Returns the sorting criterium.
+ * @return orderClause The sort order
+ */
+ public String getOrder() {
+ return orderClause;
+ }
+
+ /**
+ * Sets the number of rows that match the WHERE clause
+ * @param i The number of rows that match the WHERE clause
+ */
+ public void setCount(int i) {
+ this.count = i;
+ }
+
+ /**
+ * Returns the number of rows that match the WHERE clause
+ * @return The number of rows ...
+ */
+ public int getCount() {
+ return count;
+ }
+
+ /**
+ * Sets the offset
+ * @param i The offset
+ */
+ public void setOffset(int i) {
+ offset = i;
+ }
+
+ /**
+ * Returns the offset
+ * @return offset
+ */
+ public int getOffset() {
+ return offset;
+ }
+
+ /**
+ * Sets the offset of the next batch of Entities.
+ * @param i The next offset
+ */
+ public void setNextBatch(int i) {
+ offsetnext = i;
+ }
+
+ /**
+ * Returns the offset of the next batch of Entities.
+ * @return offset of the next batch
+ */
+ public int getNextBatch() {
+ return offsetnext;
+ }
+
+ /**
+ * Returns whether there is a next batch within the WHERE clause
+ * @return true if yes, false if no.
+ */
+ public boolean hasNextBatch() {
+ return (offsetnext >= 0);
+ }
+
+ /**
+ * Sets the offset of the previous batch.
+ * @param i the previous offset
+ */
+ public void setPrevBatch(int i) {
+ offsetprev = i;
+ }
+
+ /**
+ * Returns the offset of the previous batch.
+ * @return offset of the previous batch
+ */
+ public int getPrevBatch() {
+ return offsetprev;
+ }
+
+ /**
+ * Returns whether there is a previous batch.
+ * @return true if yes, false if no
+ */
+ public boolean hasPrevBatch() {
+ return (offsetprev >= 0);
+ }
+
+ /**
+ * Returns the start index of the batch.
+ * @return
+ */
+ public int getFrom() {
+ return offset+1;
+ }
+
+ /**
+ * Returns the end index of the batch.
+ * @return
+ */
+ public int getTo() {
+ if (hasNextBatch())
+ return offsetnext;
+ else
+ return count;
+ }
+
+ /**
+ * Inserts an Entity into the EntityList.
+ * @param anEntity The entity to be inserted.
+ */
+
+ public void add (Entity anEntity) {
+ if (anEntity!=null)
+ theEntityArrayList.add(anEntity);
+ else
+ logger.warn("EntityList: add called with empty Entity");
+ }
+
+
+ /**
+ * @return The number of Entities in the EntityList.
+ */
+
+ public int size() {
+ return theEntityArrayList.size();
+ }
+
+
+ /**
+ * Returns the element at position i in the EntityList as Entity
+ * @param i the position of the element in question
+ * @return The element at position i.
+ */
+
+ public Entity elementAt(int i) {
+ /** @todo check if i is in list.size() */
+ return (Entity)theEntityArrayList.get(i);
+ }
+
+
+
+// Methods to implement StorableObject
+
+ public Set getNotifyOnReleaseSet() { return null; }
+
+ public StoreIdentifier getStoreIdentifier() {
+ if ( theStorage!=null ) {
+ return
+ new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,
+ StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),
+ whereClause, orderClause, offset, limit ));
+ }
+ logger.warn("EntityList could not return StoreIdentifier");
+ return null;
+ }
+
+}
*/
package mir.entity.adapter;
-import java.util.Calendar;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.TimeZone;\r
-\r
-import mir.entity.Entity;\r
-import mir.misc.StringUtil;\r
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import mir.entity.Entity;
+import mir.misc.StringUtil;
import mir.util.GeneratorFormatAdapters;
+/**
+ * <code>EntityAdapterDefinition</code> defines the fields for an entity adapter of
+ * a particular "type". Custom calculated fields can be defined.
+ *
+ */
public class EntityAdapterDefinition {
private Map calculatedFields;
calculatedFields = new HashMap();
}
+ /**
+ *
+ *
+ * @param anEntity the entity that will be wrapped by the entity adapter
+ * @param aModel the base model
+ * @return the resulting entity adapter
+ */
public EntityAdapter makeEntityAdapter(Entity anEntity, EntityAdapterModel aModel) {
return new EntityAdapter(anEntity, this, aModel);
}
+ /**
+ *
+ * @param aFieldName
+ * @return the <code>CalculatedField</code> if it exists. <code>null</code> otherwise
+ */
public CalculatedField getCalculatedField(String aFieldName) {
return (CalculatedField) calculatedFields.get(aFieldName);
}
+ /**
+ *
+ * @param aFieldName
+ * @return
+ */
public boolean hasCalculatedField(String aFieldName) {
return calculatedFields.containsKey(aFieldName);
}
+ /**
+ *
+ * @param aFieldName
+ * @param aField
+ */
public void addCalculatedField(String aFieldName, CalculatedField aField) {
calculatedFields.put(aFieldName, aField);
}
+ /**
+ * To add a calculated field based on a "mir" date field: a string field of the form yyyyMMdd[hhmm]
+ *
+ * @param aDestinationFieldName
+ * @param aSourceFieldName
+ * @param aDefaultTimezone
+ */
public void addMirDateField(String aDestinationFieldName, String aSourceFieldName, String aDefaultTimezone) {
addCalculatedField(aDestinationFieldName, new MirDateField(aSourceFieldName, aDefaultTimezone));
}
+ /**
+ * Adds a calculated field based on a db date field
+ *
+ * @param aDestinationFieldName the field name of the calculated field
+ * @param aSourceFieldName the field name of the entity (must be a date field)
+ * @param aDefaultTimezone the default timezone to use
+ */
public void addDBDateField(String aDestinationFieldName, String aSourceFieldName, String aDefaultTimezone) {
addCalculatedField(aDestinationFieldName, new DBDateField(aSourceFieldName, aDefaultTimezone));
}
+ /**
+ * a calculated field: field gets its value from other fields.
+ */
public interface CalculatedField {
+ /**
+ * Method to retrieve the calculated value of the field.
+ *
+ * @param anEntityAdapter the entity
+ * @return the value of the field.
+ */
public Object getValue(EntityAdapter anEntityAdapter);
}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.entity.adapter;\r
-\r
-import java.util.AbstractList;\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.entity.EntityBrowser;\r
-\r
-public class EntityListAdapter extends AbstractList {\r
- private int skip;\r
- private int maximumLength;\r
- private EntityBrowser browser;\r
- private EntityAdapterModel model;\r
- private String definition;\r
- private boolean exhausted = false;\r
- private boolean skipped = false;\r
-\r
- private List cache;\r
-\r
- protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aSkip, int aMaximumLength) {\r
- model = aModel;\r
- definition = aDefinition;\r
- browser = aBrowser;\r
- skip = aSkip;\r
- maximumLength = aMaximumLength;\r
- cache = new Vector();\r
- }\r
-\r
- protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aMaximumLength) {\r
- this(aModel, aDefinition, aBrowser, 0, aMaximumLength);\r
- }\r
-\r
- protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser) {\r
- this(aModel, aDefinition, aBrowser, 0, -1);\r
- }\r
-\r
- private void skip() {\r
- int i;\r
-\r
- try {\r
- if (!skipped) {\r
- for(i=0; i<skip; i++)\r
- if (browser.hasNext())\r
- browser.next();\r
- }\r
- skipped=true;\r
- }\r
- catch (Throwable t) {\r
- throw new RuntimeException(t.getMessage());\r
- }\r
- }\r
-\r
- private void fetchNext() {\r
- try {\r
- if (!exhausted) {\r
- if (browser.hasNext())\r
- cache.add(model.makeEntityAdapter(definition, (Entity) browser.next()));\r
-\r
- exhausted = !browser.hasNext() || (maximumLength>0 && cache.size()>=maximumLength) ;\r
- }\r
- }\r
- catch (Throwable t) {\r
- throw new RuntimeException(t.getMessage());\r
- }\r
-\r
- }\r
-\r
- private void exhaust() {\r
- skip();\r
-\r
- while (!exhausted)\r
- fetchNext();\r
- }\r
-\r
- private void fetchUntil(int anIndex) {\r
- skip();\r
-\r
- while (!exhausted && anIndex>=cache.size())\r
- fetchNext();\r
- }\r
-\r
- public int size() {\r
- exhaust();\r
-\r
- return cache.size();\r
- }\r
-\r
- public Object get(int anIndex) {\r
- fetchUntil(anIndex);\r
- return cache.get(anIndex);\r
- }\r
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.entity.adapter;
+
+import java.util.AbstractList;
+import java.util.List;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.entity.EntityBrowser;
+
+public class EntityListAdapter extends AbstractList {
+ private int skip;
+ private int maximumLength;
+ private EntityBrowser browser;
+ private EntityAdapterModel model;
+ private String definition;
+ private boolean exhausted = false;
+ private boolean skipped = false;
+
+ private List cache;
+
+ protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aSkip, int aMaximumLength) {
+ model = aModel;
+ definition = aDefinition;
+ browser = aBrowser;
+ skip = aSkip;
+ maximumLength = aMaximumLength;
+ cache = new Vector();
+ }
+
+ protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser, int aMaximumLength) {
+ this(aModel, aDefinition, aBrowser, 0, aMaximumLength);
+ }
+
+ protected EntityListAdapter(EntityAdapterModel aModel, String aDefinition, EntityBrowser aBrowser) {
+ this(aModel, aDefinition, aBrowser, 0, -1);
+ }
+
+ private void skip() {
+ int i;
+
+ try {
+ if (!skipped) {
+ for(i=0; i<skip; i++)
+ if (browser.hasNext())
+ browser.next();
+ }
+ skipped=true;
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.getMessage());
+ }
+ }
+
+ private void fetchNext() {
+ try {
+ if (!exhausted) {
+ if (browser.hasNext())
+ cache.add(model.makeEntityAdapter(definition, (Entity) browser.next()));
+
+ exhausted = !browser.hasNext() || (maximumLength>0 && cache.size()>=maximumLength) ;
+ }
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.getMessage());
+ }
+
+ }
+
+ private void exhaust() {
+ skip();
+
+ while (!exhausted)
+ fetchNext();
+ }
+
+ private void fetchUntil(int anIndex) {
+ skip();
+
+ while (!exhausted && anIndex>=cache.size())
+ fetchNext();
+ }
+
+ public int size() {
+ exhaust();
+
+ return cache.size();
+ }
+
+ public Object get(int anIndex) {
+ fetchUntil(anIndex);
+ return cache.get(anIndex);
+ }
}
\ No newline at end of file
Template template = (Template) templateCache.getItem(anIdentifier, "template");
if (template==null) {
- throw new GeneratorExc("FreemarkerGeneratorLibrary: Can't find template "+templateCache.getDirectory()+anIdentifier);
+ throw new GeneratorExc("FreemarkerGeneratorLibrary: Can't find template "+templateCache.getDirectory()+"/"+anIdentifier);
}
return new FreemarkerGenerator(template);
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.generator;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.Map;\r
-\r
-import mir.generator.tal.MirExpressionParser;\r
-import mir.generator.tal.TALTemplate;\r
-import mir.generator.tal.TALTemplateEngine;\r
-import mir.log.LoggerWrapper;\r
-\r
-public class TALGenerator implements Generator {\r
- private String templateIdentifier;\r
- private TALGeneratorLibrary library;\r
- private static LoggerWrapper logger = new LoggerWrapper("Generator.velocity");\r
-\r
- public TALGenerator(String aTemplate, TALGeneratorLibrary aLibrary) {\r
- templateIdentifier = aTemplate;\r
- library = aLibrary;\r
- }\r
-\r
- public void generate(Object anOutputWriter, Map aValues, LoggerWrapper aLogger) throws GeneratorExc, GeneratorFailure {\r
- TALTemplate template;\r
-\r
- try {\r
- template = library.engine.loadTemplate(templateIdentifier);\r
- if (template == null) {\r
- throw new GeneratorExc("TALGeneratorLibrary: Can't find template " + templateIdentifier);\r
- }\r
- template.processTemplate(aValues, (PrintWriter) anOutputWriter);\r
- }\r
- catch (Throwable t) {\r
- throw new GeneratorFailure(t);\r
- }\r
- }\r
-\r
- public static class TALGeneratorLibrary implements GeneratorLibrary {\r
- private TALTemplateEngine engine;\r
-\r
- public TALGeneratorLibrary(String aTemplateRoot) throws GeneratorExc, GeneratorFailure {\r
- engine = new TALTemplateEngine(new MirExpressionParser(), aTemplateRoot);\r
- }\r
-\r
- public Generator makeGenerator(String anIdentifier) throws GeneratorExc, GeneratorFailure {\r
- return new TALGenerator(anIdentifier, this);\r
- }\r
- }\r
-\r
- public static class TALGeneratorLibraryFactory implements GeneratorLibraryFactory {\r
- private String basePath;\r
-\r
- public TALGeneratorLibraryFactory(String aBasePath) {\r
- basePath = aBasePath;\r
- }\r
-\r
- public GeneratorLibrary makeLibrary(String anInitializationString) throws GeneratorExc, GeneratorFailure {\r
- return new TALGeneratorLibrary(basePath+anInitializationString);\r
- };\r
- }\r
-}\r
+/*
+ * 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;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+import mir.generator.tal.MirExpressionParser;
+import mir.generator.tal.TALTemplate;
+import mir.generator.tal.TALTemplateEngine;
+import mir.log.LoggerWrapper;
+
+public class TALGenerator implements Generator {
+ private String templateIdentifier;
+ private TALGeneratorLibrary library;
+ private static LoggerWrapper logger = new LoggerWrapper("Generator.velocity");
+
+ public TALGenerator(String aTemplate, TALGeneratorLibrary aLibrary) {
+ templateIdentifier = aTemplate;
+ library = aLibrary;
+ }
+
+ public void generate(Object anOutputWriter, Map aValues, LoggerWrapper aLogger) throws GeneratorExc, GeneratorFailure {
+ TALTemplate template;
+
+ try {
+ template = library.engine.loadTemplate(templateIdentifier);
+ if (template == null) {
+ throw new GeneratorExc("TALGeneratorLibrary: Can't find template " + templateIdentifier);
+ }
+ template.processTemplate(aValues, (PrintWriter) anOutputWriter);
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure(t);
+ }
+ }
+
+ public static class TALGeneratorLibrary implements GeneratorLibrary {
+ private TALTemplateEngine engine;
+
+ public TALGeneratorLibrary(String aTemplateRoot) throws GeneratorExc, GeneratorFailure {
+ engine = new TALTemplateEngine(new MirExpressionParser(), aTemplateRoot);
+ }
+
+ public Generator makeGenerator(String anIdentifier) throws GeneratorExc, GeneratorFailure {
+ return new TALGenerator(anIdentifier, this);
+ }
+ }
+
+ public static class TALGeneratorLibraryFactory implements GeneratorLibraryFactory {
+ private String basePath;
+
+ public TALGeneratorLibraryFactory(String aBasePath) {
+ basePath = aBasePath;
+ }
+
+ public GeneratorLibrary makeLibrary(String anInitializationString) throws GeneratorExc, GeneratorFailure {
+ return new TALGeneratorLibrary(basePath+anInitializationString);
+ };
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.generator;\r
-\r
-import java.io.PrintWriter;\r
-import java.io.StringWriter;\r
-import java.util.AbstractList;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.beanutils.MethodUtils;\r
-import org.apache.commons.beanutils.PropertyUtils;\r
-import org.apache.velocity.Template;\r
-import org.apache.velocity.VelocityContext;\r
-import org.apache.velocity.app.VelocityEngine;\r
-import org.apache.velocity.context.Context;\r
-import org.apache.velocity.exception.ParseErrorException;\r
-import org.apache.velocity.exception.ResourceNotFoundException;\r
-import org.apache.velocity.runtime.RuntimeServices;\r
-import org.apache.velocity.runtime.log.LogSystem;\r
-import mir.log.LoggerWrapper;\r
-import mir.util.GeneratorFormatAdapters;\r
-import mir.util.RewindableIterator;\r
-\r
-public class VelocityGenerator implements Generator {\r
- private String templateIdentifier;\r
- private VelocityGeneratorLibrary library;\r
- private static LoggerWrapper logger = new LoggerWrapper("Generator.velocity");\r
-\r
- /**\r
- *\r
- * @param aTemplate\r
- * @param aLibrary\r
- */\r
-\r
- public VelocityGenerator(String aTemplate, VelocityGeneratorLibrary aLibrary) {\r
- templateIdentifier = aTemplate;\r
- library = aLibrary;\r
- }\r
-\r
- /**\r
- *\r
- * @param anOutputWriter\r
- * @param aValues\r
- * @param aLogger\r
- * @throws GeneratorExc\r
- * @throws GeneratorFailure\r
- */\r
- public void generate(Object anOutputWriter, Map aValues, LoggerWrapper aLogger) throws GeneratorExc, GeneratorFailure {\r
- Template template;\r
- Context context = makeMapAdapter(aValues);\r
- StringWriter stringWriter = new StringWriter();\r
-\r
- try {\r
- template = library.engine.getTemplate(templateIdentifier);\r
- if (template == null) {\r
- throw new GeneratorExc("VelocityGeneratorLibrary: Can't find template " + templateIdentifier);\r
- }\r
- template.merge(context, stringWriter);\r
-\r
- ( (PrintWriter) anOutputWriter).print(stringWriter.toString());\r
- }\r
- catch (ResourceNotFoundException t) {\r
- throw new GeneratorExc("VelocityGeneratorLibrary: Can't find template " + templateIdentifier);\r
- }\r
- catch (ParseErrorException t) {\r
- ( (PrintWriter) anOutputWriter).print(t.toString());\r
- }\r
- catch (Throwable t) {\r
- throw new GeneratorFailure(t);\r
- }\r
-\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class ContextAdapter implements Context {\r
- public boolean containsKey(java.lang.Object key) {\r
- return false;\r
- }\r
-\r
- public Object get(java.lang.String key) {\r
- return null;\r
- }\r
-\r
- public Object[] getKeys() {\r
- return new Object[] {};\r
- }\r
-\r
- public Object put(java.lang.String key, java.lang.Object value) {\r
- return null;\r
- }\r
-\r
- public Object remove(java.lang.Object key) {\r
- return null;\r
- }\r
- }\r
-\r
- /**\r
- *\r
- * @param aMap\r
- * @return\r
- */\r
- private static Context makeMapAdapter(Map aMap) {\r
- return new MapAdapter(aMap);\r
- }\r
-\r
- /**\r
- *\r
- * @param anIterator\r
- * @return\r
- */\r
- private static List makeIteratorAdapter(Iterator anIterator) {\r
- return new IteratorAdapter(anIterator);\r
- }\r
-\r
- /**\r
- *\r
- * @param aList\r
- * @return\r
- */\r
- private static List makeListAdapter(List aList) {\r
- return new ListAdapter(aList);\r
- }\r
-\r
- /**\r
- *\r
- * @param aFunction\r
- * @return\r
- */\r
- private static Object makeFunctionAdapter(Generator.GeneratorFunction aFunction) {\r
- return new FunctionAdapter(aFunction);\r
- }\r
-\r
- /**\r
- *\r
- * @param anObject\r
- * @return\r
- */\r
- private static Object makeBeanAdapter(Object anObject) {\r
- return new BeanAdapter(anObject);\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private interface VelocityAdapter {\r
- public Object getOriginal();\r
- }\r
-\r
- /**\r
- *\r
- * @param anObject\r
- * @return\r
- */\r
- public static Object unmakeAdapter(Object anObject) {\r
- if (anObject instanceof VelocityAdapter) {\r
- return ((VelocityAdapter) anObject).getOriginal();\r
- }\r
- else\r
- return anObject;\r
- }\r
-\r
- /**\r
- *\r
- * @param anObject\r
- * @return\r
- */\r
- public static Object makeAdapter(Object anObject) {\r
- if (anObject == null)\r
- return null;\r
-\r
- if (anObject instanceof Context)\r
- return anObject;\r
-\r
- else if (anObject instanceof Generator.GeneratorFunction)\r
- return makeFunctionAdapter((Generator.GeneratorFunction) anObject);\r
- else if (anObject instanceof Integer)\r
- return anObject;\r
- else if (anObject instanceof Boolean)\r
- return anObject;\r
- else if (anObject instanceof String)\r
- return anObject;\r
- else if (anObject instanceof Map)\r
- return makeMapAdapter((Map) anObject);\r
- else if (anObject instanceof Iterator)\r
- return makeIteratorAdapter((Iterator) anObject);\r
- else if (anObject instanceof List)\r
- return makeListAdapter(((List) anObject));\r
- else if (anObject instanceof Number)\r
- return makeAdapter(new GeneratorFormatAdapters.NumberFormatAdapter((Number) anObject));\r
- else if (anObject instanceof Date)\r
- return makeAdapter(new GeneratorFormatAdapters.DateFormatAdapter((Date) anObject));\r
- else\r
- return makeBeanAdapter(anObject);\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- public static class FunctionAdapter implements VelocityAdapter {\r
- private GeneratorFunction function;\r
-\r
- public Object getOriginal() {\r
- return function;\r
- }\r
-\r
- private FunctionAdapter(GeneratorFunction aFunction) {\r
- function = aFunction;\r
- }\r
-\r
- public Object call(Object aParameters[]) throws GeneratorExc {\r
- List parameters = new Vector();\r
-\r
- for (int i = 0; i<aParameters.length; i++) {\r
- parameters.add(unmakeAdapter(aParameters[i]));\r
- }\r
-\r
- return makeAdapter(function.perform(parameters));\r
- }\r
-\r
- public Object call() throws GeneratorExc {\r
- return makeAdapter(function.perform(new Vector()));\r
- }\r
-\r
- public Object call(Object anObject) throws GeneratorExc {\r
- return call(new Object[] { anObject });\r
- }\r
-\r
- public Object call(Object anObject1, Object anObject2) throws GeneratorExc {\r
- return call(new Object[] { anObject1, anObject2 });\r
- }\r
-\r
- public Object call(Object anObject1, Object anObject2, Object anObject3) throws GeneratorExc {\r
- return call(new Object[] { anObject1, anObject2, anObject3 });\r
- }\r
-\r
- public Object call(Object anObject1, Object anObject2, Object anObject3, Object anObject4) throws GeneratorExc {\r
- return call(new Object[] { anObject1, anObject2, anObject3, anObject4 });\r
- }\r
- }\r
-\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class MapAdapter implements Context, VelocityAdapter {\r
- private Map map;\r
- private Map valuesCache;\r
-\r
- private MapAdapter(Map aMap) {\r
- map = aMap;\r
- valuesCache = new HashMap();\r
- }\r
-\r
- public Object getOriginal() {\r
- return map;\r
- }\r
-\r
- public boolean containsKey(Object aKey) {\r
- return map.containsKey(aKey);\r
- }\r
-\r
- public Object get(String aKey) {\r
- try {\r
- if (!valuesCache.containsKey(aKey)) {\r
- Object value = map.get(aKey);\r
-\r
- if (value == null && !map.containsKey(aKey)) {\r
- return "no key "+aKey+" available";\r
- }\r
- else\r
- valuesCache.put(aKey, makeAdapter(value));\r
- }\r
-\r
- return valuesCache.get(aKey);\r
- }\r
- catch (Throwable t) {\r
- throw new GeneratorFailure(t);\r
- }\r
- }\r
-\r
- public Object[] getKeys() {\r
- return new Object[] {};\r
- }\r
-\r
- public Object put(String aKey, Object aValue) {\r
- valuesCache.remove(aKey);\r
- map.put(aKey, unmakeAdapter(aValue));\r
-\r
- return aValue;\r
- }\r
-\r
- public Object remove(java.lang.Object key) {\r
- return null;\r
- }\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class IteratorAdapter extends AbstractList implements VelocityAdapter {\r
- private Iterator iterator;\r
- private List valuesCache;\r
- private int position;\r
-\r
- private IteratorAdapter(Iterator anIterator) {\r
- iterator = anIterator;\r
-\r
- valuesCache = new Vector();\r
- position=0;\r
-\r
-\r
- if (iterator instanceof RewindableIterator) {\r
- ((RewindableIterator) iterator).rewind();\r
- }\r
- }\r
-\r
- private void getUntil(int anIndex) {\r
- while ((anIndex==-1 || valuesCache.size()<=anIndex) && iterator.hasNext())\r
- {\r
- valuesCache.add(makeAdapter(iterator.next()));\r
- }\r
- };\r
-\r
- public Object getOriginal() {\r
- return iterator;\r
- }\r
-\r
- public Object get(int anIndex) {\r
- Object result;\r
-\r
- getUntil(anIndex);\r
-\r
- if (anIndex<valuesCache.size())\r
- {\r
- result = valuesCache.get(anIndex);\r
-\r
- return result;\r
- }\r
- else\r
- throw new RuntimeException( "Iterator out of bounds" );\r
- }\r
-\r
- public int size() {\r
- getUntil(-1);\r
- return valuesCache.size();\r
- }\r
-\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class ListAdapter extends AbstractList implements VelocityAdapter {\r
- private List list;\r
- private List valuesCache;\r
- private int position;\r
-\r
- private ListAdapter(List aList) {\r
- list = aList;\r
-\r
- valuesCache = new Vector();\r
- position=0;\r
- }\r
-\r
- private void getUntil(int anIndex) {\r
- while ((anIndex==-1 || valuesCache.size()<=anIndex) && valuesCache.size()<list.size())\r
- {\r
- valuesCache.add(makeAdapter(list.get(valuesCache.size())));\r
- }\r
- };\r
-\r
- public Object getOriginal() {\r
- return list;\r
- }\r
-\r
- public Object get(int anIndex) {\r
- Object result;\r
-\r
- getUntil(anIndex);\r
-\r
- if (anIndex<valuesCache.size())\r
- {\r
- result = valuesCache.get(anIndex);\r
-\r
- return result;\r
- }\r
- else\r
- throw new RuntimeException( "Iterator out of bounds" );\r
- }\r
-\r
- public int size() {\r
- return list.size();\r
- }\r
-\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class BeanAdapter implements Context, VelocityAdapter {\r
- private Object object;\r
-\r
- public BeanAdapter(Object anObject) {\r
- object = anObject;\r
- }\r
-\r
- public boolean containsKey(Object key) {\r
- return true;\r
- }\r
-\r
- public Object getOriginal() {\r
- return object;\r
- }\r
-\r
- public Object get(String aKey) {\r
- try {\r
- if (PropertyUtils.isReadable(object, aKey))\r
- return makeAdapter(PropertyUtils.getSimpleProperty(object, aKey));\r
- else\r
- return makeAdapter(MethodUtils.invokeExactMethod(object, "get", aKey));\r
- }\r
- catch (Throwable t) {\r
- throw new GeneratorFailure(t);\r
- }\r
- }\r
-\r
- public Object[] getKeys() {\r
- return new Object[] {};\r
- }\r
-\r
- public Object put(String aKey, Object aValue) {\r
- try {\r
- if (PropertyUtils.isWriteable(object, aKey))\r
- PropertyUtils.setSimpleProperty(object, aKey, unmakeAdapter(aValue));\r
- else\r
- MethodUtils.invokeExactMethod(object, "set", new Object[] {aKey, unmakeAdapter(aValue)});\r
-\r
- return this;\r
- }\r
- catch (Throwable t) {\r
- throw new GeneratorFailure(t);\r
- }\r
- }\r
-\r
- public Object remove(Object aKey) {\r
- throw new RuntimeException("BeanAdapter.remove not supported");\r
- }\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- private static class VelocityLoggerWrapper implements LogSystem {\r
- private LoggerWrapper logger;\r
-\r
- public VelocityLoggerWrapper(LoggerWrapper aLogger) {\r
- logger = aLogger;\r
- }\r
-\r
- public void init(RuntimeServices aRuntimeServices) {\r
- }\r
-\r
- public void logVelocityMessage(int aLevel, String aMessage) {\r
- switch (aLevel) {\r
- case DEBUG_ID:\r
- logger.debug(aMessage);\r
- break;\r
- case ERROR_ID:\r
- logger.error(aMessage);\r
- break;\r
- case INFO_ID:\r
- logger.info(aMessage);\r
- break;\r
- default:\r
- logger.warn(aMessage);\r
- break;\r
- }\r
- }\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- public static class VelocityGeneratorLibrary implements GeneratorLibrary {\r
- private VelocityEngine engine;\r
-\r
- public VelocityGeneratorLibrary(String aTemplateRoot) throws GeneratorExc, GeneratorFailure {\r
- try {\r
- engine = new VelocityEngine();\r
- try {\r
- engine.setProperty(VelocityEngine.RESOURCE_LOADER, "file");\r
- }\r
- catch (Throwable t) {\r
- logger.error(VelocityEngine.RESOURCE_LOADER);\r
- }\r
-\r
- try {\r
- engine.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");\r
- }\r
- catch (Throwable t) {\r
- logger.error("file.resource.loader.class");\r
- }\r
-\r
- try {\r
- engine.setProperty("file.resource.loader.path", aTemplateRoot);\r
- }\r
- catch (Throwable t) {\r
- logger.error("file.resource.loader.path");\r
-\r
- }\r
- try {\r
- engine.setProperty("file.resource.loader.cache", "true");\r
- }\r
- catch (Throwable t) {\r
- logger.error("file.resource.loader.cache");\r
-\r
- }\r
- try {\r
- engine.setProperty("file.resource.loader.modificationCheckInterval", "10");\r
- }\r
- catch (Throwable t) {\r
- logger.error("file.resource.loader.modificationCheckInterval");\r
-\r
- }\r
-\r
- try {\r
- engine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new VelocityLoggerWrapper(logger));\r
- }\r
- catch (Throwable t) {\r
- logger.error(VelocityEngine.RUNTIME_LOG_LOGSYSTEM);\r
-\r
- }\r
- engine.init();\r
- }\r
- catch (Throwable t) {\r
- t.printStackTrace(logger.asPrintWriter(logger.ERROR_MESSAGE));\r
-\r
- logger.error("Failed to set up a VelocityGeneratorLibrary: " + t.toString());\r
- throw new GeneratorFailure(t);\r
- }\r
- }\r
-\r
- public Generator makeGenerator(String anIdentifier) throws GeneratorExc, GeneratorFailure {\r
- return new VelocityGenerator(anIdentifier, this);\r
- }\r
- }\r
-\r
- /**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
- public static class VelocityGeneratorLibraryFactory implements GeneratorLibraryFactory {\r
- private String basePath;\r
-\r
- public VelocityGeneratorLibraryFactory(String aBasePath) {\r
- basePath = aBasePath;\r
- }\r
-\r
- public GeneratorLibrary makeLibrary(String anInitializationString) throws GeneratorExc, GeneratorFailure {\r
- return new VelocityGeneratorLibrary(basePath+anInitializationString);\r
- };\r
- }\r
-}\r
+/*
+ * 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;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.AbstractList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.context.Context;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogSystem;
+import mir.log.LoggerWrapper;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.RewindableIterator;
+
+public class VelocityGenerator implements Generator {
+ private String templateIdentifier;
+ private VelocityGeneratorLibrary library;
+ private static LoggerWrapper logger = new LoggerWrapper("Generator.velocity");
+
+ /**
+ *
+ * @param aTemplate
+ * @param aLibrary
+ */
+
+ public VelocityGenerator(String aTemplate, VelocityGeneratorLibrary aLibrary) {
+ templateIdentifier = aTemplate;
+ library = aLibrary;
+ }
+
+ /**
+ *
+ * @param anOutputWriter
+ * @param aValues
+ * @param aLogger
+ * @throws GeneratorExc
+ * @throws GeneratorFailure
+ */
+ public void generate(Object anOutputWriter, Map aValues, LoggerWrapper aLogger) throws GeneratorExc, GeneratorFailure {
+ Template template;
+ Context context = makeMapAdapter(aValues);
+ StringWriter stringWriter = new StringWriter();
+
+ try {
+ template = library.engine.getTemplate(templateIdentifier);
+ if (template == null) {
+ throw new GeneratorExc("VelocityGeneratorLibrary: Can't find template " + templateIdentifier);
+ }
+ template.merge(context, stringWriter);
+
+ ( (PrintWriter) anOutputWriter).print(stringWriter.toString());
+ }
+ catch (ResourceNotFoundException t) {
+ throw new GeneratorExc("VelocityGeneratorLibrary: Can't find template " + templateIdentifier);
+ }
+ catch (ParseErrorException t) {
+ ( (PrintWriter) anOutputWriter).print(t.toString());
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure(t);
+ }
+
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class ContextAdapter implements Context {
+ public boolean containsKey(java.lang.Object key) {
+ return false;
+ }
+
+ public Object get(java.lang.String key) {
+ return null;
+ }
+
+ public Object[] getKeys() {
+ return new Object[] {};
+ }
+
+ public Object put(java.lang.String key, java.lang.Object value) {
+ return null;
+ }
+
+ public Object remove(java.lang.Object key) {
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @param aMap
+ * @return
+ */
+ private static Context makeMapAdapter(Map aMap) {
+ return new MapAdapter(aMap);
+ }
+
+ /**
+ *
+ * @param anIterator
+ * @return
+ */
+ private static List makeIteratorAdapter(Iterator anIterator) {
+ return new IteratorAdapter(anIterator);
+ }
+
+ /**
+ *
+ * @param aList
+ * @return
+ */
+ private static List makeListAdapter(List aList) {
+ return new ListAdapter(aList);
+ }
+
+ /**
+ *
+ * @param aFunction
+ * @return
+ */
+ private static Object makeFunctionAdapter(Generator.GeneratorFunction aFunction) {
+ return new FunctionAdapter(aFunction);
+ }
+
+ /**
+ *
+ * @param anObject
+ * @return
+ */
+ private static Object makeBeanAdapter(Object anObject) {
+ return new BeanAdapter(anObject);
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private interface VelocityAdapter {
+ public Object getOriginal();
+ }
+
+ /**
+ *
+ * @param anObject
+ * @return
+ */
+ public static Object unmakeAdapter(Object anObject) {
+ if (anObject instanceof VelocityAdapter) {
+ return ((VelocityAdapter) anObject).getOriginal();
+ }
+ else
+ return anObject;
+ }
+
+ /**
+ *
+ * @param anObject
+ * @return
+ */
+ public static Object makeAdapter(Object anObject) {
+ if (anObject == null)
+ return null;
+
+ if (anObject instanceof Context)
+ return anObject;
+
+ else if (anObject instanceof Generator.GeneratorFunction)
+ return makeFunctionAdapter((Generator.GeneratorFunction) anObject);
+ else if (anObject instanceof Integer)
+ return anObject;
+ else if (anObject instanceof Boolean)
+ return anObject;
+ else if (anObject instanceof String)
+ return anObject;
+ else if (anObject instanceof Map)
+ return makeMapAdapter((Map) anObject);
+ else if (anObject instanceof Iterator)
+ return makeIteratorAdapter((Iterator) anObject);
+ else if (anObject instanceof List)
+ return makeListAdapter(((List) anObject));
+ else if (anObject instanceof Number)
+ return makeAdapter(new GeneratorFormatAdapters.NumberFormatAdapter((Number) anObject));
+ else if (anObject instanceof Date)
+ return makeAdapter(new GeneratorFormatAdapters.DateFormatAdapter((Date) anObject));
+ else
+ return makeBeanAdapter(anObject);
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ public static class FunctionAdapter implements VelocityAdapter {
+ private GeneratorFunction function;
+
+ public Object getOriginal() {
+ return function;
+ }
+
+ private FunctionAdapter(GeneratorFunction aFunction) {
+ function = aFunction;
+ }
+
+ public Object call(Object aParameters[]) throws GeneratorExc {
+ List parameters = new Vector();
+
+ for (int i = 0; i<aParameters.length; i++) {
+ parameters.add(unmakeAdapter(aParameters[i]));
+ }
+
+ return makeAdapter(function.perform(parameters));
+ }
+
+ public Object call() throws GeneratorExc {
+ return makeAdapter(function.perform(new Vector()));
+ }
+
+ public Object call(Object anObject) throws GeneratorExc {
+ return call(new Object[] { anObject });
+ }
+
+ public Object call(Object anObject1, Object anObject2) throws GeneratorExc {
+ return call(new Object[] { anObject1, anObject2 });
+ }
+
+ public Object call(Object anObject1, Object anObject2, Object anObject3) throws GeneratorExc {
+ return call(new Object[] { anObject1, anObject2, anObject3 });
+ }
+
+ public Object call(Object anObject1, Object anObject2, Object anObject3, Object anObject4) throws GeneratorExc {
+ return call(new Object[] { anObject1, anObject2, anObject3, anObject4 });
+ }
+ }
+
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class MapAdapter implements Context, VelocityAdapter {
+ private Map map;
+ private Map valuesCache;
+
+ private MapAdapter(Map aMap) {
+ map = aMap;
+ valuesCache = new HashMap();
+ }
+
+ public Object getOriginal() {
+ return map;
+ }
+
+ public boolean containsKey(Object aKey) {
+ return map.containsKey(aKey);
+ }
+
+ public Object get(String aKey) {
+ try {
+ if (!valuesCache.containsKey(aKey)) {
+ Object value = map.get(aKey);
+
+ if (value == null && !map.containsKey(aKey)) {
+ return "no key "+aKey+" available";
+ }
+ else
+ valuesCache.put(aKey, makeAdapter(value));
+ }
+
+ return valuesCache.get(aKey);
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure(t);
+ }
+ }
+
+ public Object[] getKeys() {
+ return new Object[] {};
+ }
+
+ public Object put(String aKey, Object aValue) {
+ valuesCache.remove(aKey);
+ map.put(aKey, unmakeAdapter(aValue));
+
+ return aValue;
+ }
+
+ public Object remove(java.lang.Object key) {
+ return null;
+ }
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class IteratorAdapter extends AbstractList implements VelocityAdapter {
+ private Iterator iterator;
+ private List valuesCache;
+ private int position;
+
+ private IteratorAdapter(Iterator anIterator) {
+ iterator = anIterator;
+
+ valuesCache = new Vector();
+ position=0;
+
+
+ if (iterator instanceof RewindableIterator) {
+ ((RewindableIterator) iterator).rewind();
+ }
+ }
+
+ private void getUntil(int anIndex) {
+ while ((anIndex==-1 || valuesCache.size()<=anIndex) && iterator.hasNext())
+ {
+ valuesCache.add(makeAdapter(iterator.next()));
+ }
+ };
+
+ public Object getOriginal() {
+ return iterator;
+ }
+
+ public Object get(int anIndex) {
+ Object result;
+
+ getUntil(anIndex);
+
+ if (anIndex<valuesCache.size())
+ {
+ result = valuesCache.get(anIndex);
+
+ return result;
+ }
+ else
+ throw new RuntimeException( "Iterator out of bounds" );
+ }
+
+ public int size() {
+ getUntil(-1);
+ return valuesCache.size();
+ }
+
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class ListAdapter extends AbstractList implements VelocityAdapter {
+ private List list;
+ private List valuesCache;
+ private int position;
+
+ private ListAdapter(List aList) {
+ list = aList;
+
+ valuesCache = new Vector();
+ position=0;
+ }
+
+ private void getUntil(int anIndex) {
+ while ((anIndex==-1 || valuesCache.size()<=anIndex) && valuesCache.size()<list.size())
+ {
+ valuesCache.add(makeAdapter(list.get(valuesCache.size())));
+ }
+ };
+
+ public Object getOriginal() {
+ return list;
+ }
+
+ public Object get(int anIndex) {
+ Object result;
+
+ getUntil(anIndex);
+
+ if (anIndex<valuesCache.size())
+ {
+ result = valuesCache.get(anIndex);
+
+ return result;
+ }
+ else
+ throw new RuntimeException( "Iterator out of bounds" );
+ }
+
+ public int size() {
+ return list.size();
+ }
+
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class BeanAdapter implements Context, VelocityAdapter {
+ private Object object;
+
+ public BeanAdapter(Object anObject) {
+ object = anObject;
+ }
+
+ public boolean containsKey(Object key) {
+ return true;
+ }
+
+ public Object getOriginal() {
+ return object;
+ }
+
+ public Object get(String aKey) {
+ try {
+ if (PropertyUtils.isReadable(object, aKey))
+ return makeAdapter(PropertyUtils.getSimpleProperty(object, aKey));
+ else
+ return makeAdapter(MethodUtils.invokeExactMethod(object, "get", aKey));
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure(t);
+ }
+ }
+
+ public Object[] getKeys() {
+ return new Object[] {};
+ }
+
+ public Object put(String aKey, Object aValue) {
+ try {
+ if (PropertyUtils.isWriteable(object, aKey))
+ PropertyUtils.setSimpleProperty(object, aKey, unmakeAdapter(aValue));
+ else
+ MethodUtils.invokeExactMethod(object, "set", new Object[] {aKey, unmakeAdapter(aValue)});
+
+ return this;
+ }
+ catch (Throwable t) {
+ throw new GeneratorFailure(t);
+ }
+ }
+
+ public Object remove(Object aKey) {
+ throw new RuntimeException("BeanAdapter.remove not supported");
+ }
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ private static class VelocityLoggerWrapper implements LogSystem {
+ private LoggerWrapper logger;
+
+ public VelocityLoggerWrapper(LoggerWrapper aLogger) {
+ logger = aLogger;
+ }
+
+ public void init(RuntimeServices aRuntimeServices) {
+ }
+
+ public void logVelocityMessage(int aLevel, String aMessage) {
+ switch (aLevel) {
+ case DEBUG_ID:
+ logger.debug(aMessage);
+ break;
+ case ERROR_ID:
+ logger.error(aMessage);
+ break;
+ case INFO_ID:
+ logger.info(aMessage);
+ break;
+ default:
+ logger.warn(aMessage);
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ public static class VelocityGeneratorLibrary implements GeneratorLibrary {
+ private VelocityEngine engine;
+
+ public VelocityGeneratorLibrary(String aTemplateRoot) throws GeneratorExc, GeneratorFailure {
+ try {
+ engine = new VelocityEngine();
+ try {
+ engine.setProperty(VelocityEngine.RESOURCE_LOADER, "file");
+ }
+ catch (Throwable t) {
+ logger.error(VelocityEngine.RESOURCE_LOADER);
+ }
+
+ try {
+ engine.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
+ }
+ catch (Throwable t) {
+ logger.error("file.resource.loader.class");
+ }
+
+ try {
+ engine.setProperty("file.resource.loader.path", aTemplateRoot);
+ }
+ catch (Throwable t) {
+ logger.error("file.resource.loader.path");
+
+ }
+ try {
+ engine.setProperty("file.resource.loader.cache", "true");
+ }
+ catch (Throwable t) {
+ logger.error("file.resource.loader.cache");
+
+ }
+ try {
+ engine.setProperty("file.resource.loader.modificationCheckInterval", "10");
+ }
+ catch (Throwable t) {
+ logger.error("file.resource.loader.modificationCheckInterval");
+
+ }
+
+ try {
+ engine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new VelocityLoggerWrapper(logger));
+ }
+ catch (Throwable t) {
+ logger.error(VelocityEngine.RUNTIME_LOG_LOGSYSTEM);
+
+ }
+ engine.init();
+ }
+ catch (Throwable t) {
+ t.printStackTrace(logger.asPrintWriter(logger.ERROR_MESSAGE));
+
+ logger.error("Failed to set up a VelocityGeneratorLibrary: " + t.toString());
+ throw new GeneratorFailure(t);
+ }
+ }
+
+ public Generator makeGenerator(String anIdentifier) throws GeneratorExc, GeneratorFailure {
+ return new VelocityGenerator(anIdentifier, this);
+ }
+ }
+
+ /**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+ public static class VelocityGeneratorLibraryFactory implements GeneratorLibraryFactory {
+ private String basePath;
+
+ public VelocityGeneratorLibraryFactory(String aBasePath) {
+ basePath = aBasePath;
+ }
+
+ public GeneratorLibrary makeLibrary(String anInitializationString) throws GeneratorExc, GeneratorFailure {
+ return new VelocityGeneratorLibrary(basePath+anInitializationString);
+ };
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mir.generator.tal;\r
-\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import mir.generator.tal.interfaces.TALExpressionParser;\r
-import mir.util.ParameterExpander;\r
-import mir.util.RewindableIterator;\r
-\r
-public class MirExpressionParser implements TALExpressionParser {\r
- public Object preparseExpression(String anExpression) {\r
- return anExpression;\r
- }\r
- public Object preparseStringExpression(String anExpression) {\r
- return anExpression;\r
- }\r
-\r
- public Object preparseBooleanExpression(String anExpression) {\r
- return anExpression;\r
- }\r
-\r
- public Object preparseReferenceExpression(String anExpression) {\r
- return anExpression;\r
- }\r
-\r
- public Object preparseListExpression(String anExpression) {\r
- return anExpression;\r
- }\r
-\r
- public Object preparseTRUE() {\r
- return "1==1";\r
- }\r
-\r
- public Object preparseFALSE() {\r
- return "0==1";\r
- }\r
-\r
- public Object evaluateExpression(Object aContext, Object aPreparsedExpression) {\r
- try {\r
- return ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public String evaluateStringExpression(Object aContext, Object aPreparsedExpression) {\r
- try {\r
- return ParameterExpander.evaluateStringExpression(aContext, (String) aPreparsedExpression);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public boolean evaluateBooleanExpression(Object aContext, Object aPreparsedExpression) {\r
- try {\r
- return ParameterExpander.evaluateBooleanExpression(aContext, (String) aPreparsedExpression);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public Iterator evaluateListExpression(Object aContext, Object aPreparsedExpression) {\r
- try {\r
- Object list = ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression);\r
-\r
- if (list instanceof List)\r
- return ((List) list).iterator();\r
-\r
- if (list instanceof RewindableIterator) {\r
- ((RewindableIterator) list).rewind();\r
- return (RewindableIterator) list;\r
- }\r
-\r
- if (list instanceof Iterator) {\r
- return (Iterator) list;\r
- }\r
-\r
- throw new TALExc("Not a list: " + list);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public void processAssignment(Object aContext, Object aPreparsedReferenceExpression, Object aPreparsedExpression) {\r
- try {\r
- ParameterExpander.setValueForKey( (Map) aContext, (String) aPreparsedReferenceExpression, ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression));\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public void processDirectAssignment(Object aContext, Object aPreparsedReferenceExpression, Object aValue) {\r
- try {\r
- ParameterExpander.setValueForKey( (Map) aContext, (String) aPreparsedReferenceExpression, aValue);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public void processPseudoAssignment(Object aContext, String aName, Object aValue) {\r
- try {\r
- ParameterExpander.setValueForKey( (Map) aContext, aName, aValue);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+import mir.util.ParameterExpander;
+import mir.util.RewindableIterator;
+
+public class MirExpressionParser implements TALExpressionParser {
+ public Object preparseExpression(String anExpression) {
+ return anExpression;
+ }
+ public Object preparseStringExpression(String anExpression) {
+ return anExpression;
+ }
+
+ public Object preparseBooleanExpression(String anExpression) {
+ return anExpression;
+ }
+
+ public Object preparseReferenceExpression(String anExpression) {
+ return anExpression;
+ }
+
+ public Object preparseListExpression(String anExpression) {
+ return anExpression;
+ }
+
+ public Object preparseTRUE() {
+ return "1==1";
+ }
+
+ public Object preparseFALSE() {
+ return "0==1";
+ }
+
+ public Object evaluateExpression(Object aContext, Object aPreparsedExpression) {
+ try {
+ return ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public String evaluateStringExpression(Object aContext, Object aPreparsedExpression) {
+ try {
+ return ParameterExpander.evaluateStringExpression(aContext, (String) aPreparsedExpression);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public boolean evaluateBooleanExpression(Object aContext, Object aPreparsedExpression) {
+ try {
+ return ParameterExpander.evaluateBooleanExpression(aContext, (String) aPreparsedExpression);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public Iterator evaluateListExpression(Object aContext, Object aPreparsedExpression) {
+ try {
+ Object list = ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression);
+
+ if (list instanceof List)
+ return ((List) list).iterator();
+
+ if (list instanceof RewindableIterator) {
+ ((RewindableIterator) list).rewind();
+ return (RewindableIterator) list;
+ }
+
+ if (list instanceof Iterator) {
+ return (Iterator) list;
+ }
+
+ throw new TALExc("Not a list: " + list);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public void processAssignment(Object aContext, Object aPreparsedReferenceExpression, Object aPreparsedExpression) {
+ try {
+ ParameterExpander.setValueForKey( (Map) aContext, (String) aPreparsedReferenceExpression, ParameterExpander.evaluateExpression(aContext, (String) aPreparsedExpression));
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public void processDirectAssignment(Object aContext, Object aPreparsedReferenceExpression, Object aValue) {
+ try {
+ ParameterExpander.setValueForKey( (Map) aContext, (String) aPreparsedReferenceExpression, aValue);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public void processPseudoAssignment(Object aContext, String aName, Object aValue) {
+ try {
+ ParameterExpander.setValueForKey( (Map) aContext, aName, aValue);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.generator.tal;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.generator.tal.interfaces.TALExpressionParser;\r
-import mir.util.HTMLRoutines;\r
-\r
-/**\r
- * {@link http://dev.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4}\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class TALTemplate {\r
- private TemplateNode rootNode;\r
- private TALExpressionParser parser;\r
-\r
- public TALTemplate(TALExpressionParser aParser, TemplateNode aRootNode) {\r
- rootNode = aRootNode;\r
- parser = aParser;\r
- }\r
-\r
- public void processTemplate(Object aContext, PrintWriter aDestination) {\r
- StringBuffer output = new StringBuffer();\r
-\r
- rootNode.process(parser, aContext, output);\r
- aDestination.print(output);\r
- }\r
-\r
- public interface TemplateNode {\r
- public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination);\r
- }\r
-\r
- public static class CompositeTemplateNode\r
- implements TemplateNode {\r
- private List parts;\r
-\r
- public CompositeTemplateNode() {\r
- parts = new Vector();\r
- }\r
-\r
- public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {\r
- Iterator i = parts.iterator();\r
-\r
- while (i.hasNext()) {\r
- ((TemplateNode) i.next()).process(aParser, aContext, aDestination);\r
- }\r
- }\r
-\r
- public void appendSubNode(TemplateNode aNode) {\r
- if (aNode instanceof CompositeTemplateNode) {\r
- Iterator i = ((CompositeTemplateNode) aNode).parts.iterator();\r
- while (i.hasNext()) {\r
- appendSubNode((TemplateNode) i.next());\r
- }\r
- }\r
- else if (aNode instanceof PlainTextTemplateNode && parts.size()>0 &&\r
- (parts.get(parts.size()-1) instanceof PlainTextTemplateNode)) {\r
-\r
- ((PlainTextTemplateNode) parts.get(parts.size()-1)).appendText(((PlainTextTemplateNode) aNode).getText());\r
- }\r
- else {\r
- parts.add(aNode);\r
- }\r
- }\r
- }\r
-\r
- public static class PlainTextTemplateNode\r
- implements TemplateNode {\r
- private String text;\r
-\r
- public PlainTextTemplateNode() {\r
- this("");\r
- }\r
-\r
- public PlainTextTemplateNode(String aText) {\r
- text = aText;\r
- }\r
-\r
- public void appendText(String aText) {\r
- text = text + aText;\r
- }\r
-\r
- protected String getText() {\r
- return text;\r
- }\r
-\r
- public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {\r
- aDestination.append(text);\r
- }\r
- }\r
-\r
- public static class SmartTemplateNode implements TemplateNode {\r
- private String tag;\r
- private Map fixedAttributes;\r
- private Map attributeModifiers;\r
-\r
- private List definitions;\r
- private Object condition;\r
-\r
- private Object repeatVariable;\r
- private Object repeatExpression;\r
- private Object contentExpression;\r
- private Object omitTagExpression;\r
- private Object errorExpression;\r
-\r
- private TemplateNode body;\r
-\r
- public SmartTemplateNode(String aTag) {\r
- tag = aTag;\r
-\r
- fixedAttributes = new HashMap();\r
- attributeModifiers = new HashMap();\r
-\r
- definitions = new Vector();\r
- condition = null;\r
-\r
- repeatVariable = null;\r
- repeatExpression = null;\r
- contentExpression = null;\r
- omitTagExpression = null;\r
-\r
- body = null;\r
- }\r
-\r
- public void setBody(TemplateNode aBody) {\r
- body = aBody;\r
- }\r
-\r
- public void addFixedAttribute(String aKey, String aValue) {\r
- fixedAttributes.put(aKey, aValue);\r
- }\r
-\r
- public void addModifiedAttribute(String aKey, Object aValue) {\r
- attributeModifiers.put(aKey, aValue);\r
- }\r
-\r
- public void addDefinition(Object aKey, Object aValue) {\r
- definitions.add(new Definition(aKey, aValue));\r
- }\r
-\r
- public void setCondition(Object aCondition) {\r
- condition = aCondition;\r
- }\r
-\r
- public void setRepeat(Object aRepeatVariable, Object aRepeatExpression) {\r
- repeatVariable = aRepeatVariable;\r
- repeatExpression = aRepeatExpression;\r
- }\r
-\r
- public void setContent(Object aContentExpression) {\r
- contentExpression = aContentExpression;\r
- }\r
-\r
- public void setOmitTag(Object anOmitTagExpression) {\r
- omitTagExpression = anOmitTagExpression;\r
- }\r
-\r
- public void setError(Object anErrorExpression) {\r
- errorExpression = anErrorExpression;\r
- }\r
-\r
- public static class Definition {\r
- private Object variable;\r
- private Object expression;\r
-\r
- public Definition(Object aVariable, Object anExpression) {\r
- variable = aVariable;\r
- expression = anExpression;\r
- }\r
-\r
- public Object getVariable() {\r
- return variable;\r
- }\r
-\r
- public Object getExpression() {\r
- return expression;\r
- }\r
- }\r
-\r
- public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {\r
- Iterator i;\r
-\r
- i = definitions.iterator();\r
- while (i.hasNext()) {\r
- Definition d = (Definition) i.next();\r
- aParser.processAssignment(aContext, d.getVariable(), d.getExpression());\r
- }\r
-\r
- if (condition == null || aParser.evaluateBooleanExpression(aContext, condition)) {\r
- if (repeatExpression != null) {\r
- i = aParser.evaluateListExpression(aContext, repeatExpression);\r
-\r
- while (i.hasNext()) {\r
- aParser.processDirectAssignment(aContext, repeatVariable, i.next());\r
- innerProcess(aParser, aContext, aDestination);\r
- }\r
- }\r
- else {\r
- innerProcess(aParser, aContext, aDestination);\r
- }\r
- }\r
- };\r
-\r
- private void innerProcess(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {\r
- boolean omitTag = false;\r
- if (omitTagExpression != null)\r
- omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression);\r
-\r
- if (!omitTag) {\r
- Map generatedAttributes = new HashMap(fixedAttributes);\r
-\r
- Iterator i = attributeModifiers.keySet().iterator();\r
- while (i.hasNext()) {\r
- Map.Entry entry = (Map.Entry) i.next();\r
-\r
- generatedAttributes.put(entry.getKey(), aParser.evaluateStringExpression(aContext, entry.getValue()));\r
- }\r
-\r
- aDestination.append("<");\r
- aDestination.append(tag);\r
-\r
- i = generatedAttributes.entrySet().iterator();\r
- while (i.hasNext()) {\r
- Map.Entry entry = (Map.Entry) i.next();\r
- aDestination.append(" ");\r
- aDestination.append(entry.getKey());\r
- aDestination.append("=");\r
- aDestination.append("\"");\r
- aDestination.append(HTMLRoutines.encodeHTML( (String) entry.getValue()));\r
- aDestination.append("\"");\r
- }\r
- aDestination.append(">");\r
- }\r
-\r
- StringBuffer destination = aDestination;\r
- if (errorExpression != null) {\r
- destination = new StringBuffer();\r
- }\r
- try {\r
- if (contentExpression != null) {\r
- destination.append(aParser.evaluateStringExpression(aContext, contentExpression));\r
- }\r
- else {\r
- if (body != null)\r
- body.process(aParser, aContext, destination);\r
- }\r
- }\r
- catch (RuntimeException t) {\r
- if (errorExpression != null) {\r
- try {\r
- destination.delete(0, destination.length());\r
-\r
- aParser.processPseudoAssignment(aContext, "exception", t);\r
- destination.append(aParser.evaluateStringExpression(aContext, errorExpression));\r
- }\r
- catch (Throwable s) {\r
- }\r
- }\r
- else\r
- throw t;\r
- }\r
- finally {\r
- if (errorExpression != null) {\r
- aDestination.append(destination);\r
- }\r
- }\r
- if (!omitTag) {\r
- aDestination.append("</");\r
- aDestination.append(tag);\r
- aDestination.append(">");\r
- }\r
- }\r
- }\r
+/*
+ * 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;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+import mir.util.HTMLRoutines;
+
+/**
+ * {@link http://dev.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4}
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class TALTemplate {
+ private TemplateNode rootNode;
+ private TALExpressionParser parser;
+
+ public TALTemplate(TALExpressionParser aParser, TemplateNode aRootNode) {
+ rootNode = aRootNode;
+ parser = aParser;
+ }
+
+ public void processTemplate(Object aContext, PrintWriter aDestination) {
+ StringBuffer output = new StringBuffer();
+
+ rootNode.process(parser, aContext, output);
+ aDestination.print(output);
+ }
+
+ public interface TemplateNode {
+ public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination);
+ }
+
+ public static class CompositeTemplateNode
+ implements TemplateNode {
+ private List parts;
+
+ public CompositeTemplateNode() {
+ parts = new Vector();
+ }
+
+ public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {
+ Iterator i = parts.iterator();
+
+ while (i.hasNext()) {
+ ((TemplateNode) i.next()).process(aParser, aContext, aDestination);
+ }
+ }
+
+ public void appendSubNode(TemplateNode aNode) {
+ if (aNode instanceof CompositeTemplateNode) {
+ Iterator i = ((CompositeTemplateNode) aNode).parts.iterator();
+ while (i.hasNext()) {
+ appendSubNode((TemplateNode) i.next());
+ }
+ }
+ else if (aNode instanceof PlainTextTemplateNode && parts.size()>0 &&
+ (parts.get(parts.size()-1) instanceof PlainTextTemplateNode)) {
+
+ ((PlainTextTemplateNode) parts.get(parts.size()-1)).appendText(((PlainTextTemplateNode) aNode).getText());
+ }
+ else {
+ parts.add(aNode);
+ }
+ }
+ }
+
+ public static class PlainTextTemplateNode
+ implements TemplateNode {
+ private String text;
+
+ public PlainTextTemplateNode() {
+ this("");
+ }
+
+ public PlainTextTemplateNode(String aText) {
+ text = aText;
+ }
+
+ public void appendText(String aText) {
+ text = text + aText;
+ }
+
+ protected String getText() {
+ return text;
+ }
+
+ public void process(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {
+ aDestination.append(text);
+ }
+ }
+
+ public static class SmartTemplateNode 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 SmartTemplateNode(String aTag) {
+ tag = aTag;
+
+ fixedAttributes = new HashMap();
+ attributeModifiers = new HashMap();
+
+ definitions = new Vector();
+ 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) {
+ 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);
+ }
+ }
+ else {
+ innerProcess(aParser, aContext, aDestination);
+ }
+ }
+ };
+
+ private void innerProcess(TALExpressionParser aParser, Object aContext, StringBuffer aDestination) {
+ boolean omitTag = false;
+ if (omitTagExpression != null)
+ omitTag = aParser.evaluateBooleanExpression(aContext, omitTagExpression);
+
+ if (!omitTag) {
+ Map generatedAttributes = new HashMap(fixedAttributes);
+
+ Iterator i = attributeModifiers.keySet().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("\"");
+ }
+ aDestination.append(">");
+ }
+
+ StringBuffer destination = aDestination;
+ if (errorExpression != null) {
+ destination = new StringBuffer();
+ }
+ try {
+ if (contentExpression != null) {
+ destination.append(aParser.evaluateStringExpression(aContext, contentExpression));
+ }
+ else {
+ if (body != null)
+ body.process(aParser, aContext, destination);
+ }
+ }
+ catch (RuntimeException t) {
+ if (errorExpression != null) {
+ try {
+ destination.delete(0, destination.length());
+
+ aParser.processPseudoAssignment(aContext, "exception", t);
+ destination.append(aParser.evaluateStringExpression(aContext, errorExpression));
+ }
+ catch (Throwable s) {
+ }
+ }
+ else
+ throw t;
+ }
+ finally {
+ if (errorExpression != null) {
+ aDestination.append(destination);
+ }
+ }
+ if (!omitTag) {
+ aDestination.append("</");
+ aDestination.append(tag);
+ aDestination.append(">");
+ }
+ }
+ }
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mir.generator.tal;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-\r
-import mir.generator.tal.interfaces.TALExpressionParser;\r
-\r
-public class TALTemplateEngine {\r
- private TALExpressionParser expressionParser;\r
- private String basePath;\r
- private CachingFileLoader loader;\r
-\r
- public TALTemplateEngine(TALExpressionParser anExpressionParser, String aBasePath) {\r
- expressionParser = anExpressionParser;\r
- basePath = aBasePath;\r
- loader = new CachingFileLoader(100, new TemplateFactory());\r
- }\r
-\r
- public TALTemplate loadTemplate(String aName) throws IOException {\r
- File location = new File(basePath, aName);\r
- return (TALTemplate) loader.retrieveFile(location.getCanonicalPath());\r
- }\r
-\r
- private class TemplateFactory implements CachingFileLoader.CachedFileObjectFactory {\r
- public Object constructObject(InputStream aStream) {\r
- try {\r
- return TALTemplateParser.parseInputStream(aStream, expressionParser);\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
- }\r
+/*
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+
+public class TALTemplateEngine {
+ private TALExpressionParser expressionParser;
+ private String basePath;
+ private CachingFileLoader loader;
+
+ public TALTemplateEngine(TALExpressionParser anExpressionParser, String aBasePath) {
+ expressionParser = anExpressionParser;
+ basePath = aBasePath;
+ loader = new CachingFileLoader(100, new TemplateFactory());
+ }
+
+ public TALTemplate loadTemplate(String aName) throws IOException {
+ File location = new File(basePath, aName);
+ return (TALTemplate) loader.retrieveFile(location.getCanonicalPath());
+ }
+
+ private class TemplateFactory implements CachingFileLoader.CachedFileObjectFactory {
+ public Object constructObject(InputStream aStream) {
+ try {
+ return TALTemplateParser.parseInputStream(aStream, expressionParser);
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+ }
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.generator.tal;\r
-\r
-import java.io.InputStream;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import mir.generator.tal.interfaces.TALExpressionParser;\r
-import mir.util.HTMLRoutines;\r
-import mir.util.StringRoutines;\r
-import mir.util.XMLReader;\r
-import mir.util.XMLReader.AbstractSectionHandler;\r
-\r
-public class TALTemplateParser {\r
- private int bal;\r
- private static final String TAL_PREFIX = "tal";\r
-\r
- public static TALTemplate parseString(String aData, TALExpressionParser aParser) throws TALExc, TALFailure {\r
- try {\r
- TALHandler handler = new TALHandler(aParser);\r
- XMLReader reader = new XMLReader(false);\r
-\r
- reader.parseString(true, aData, handler);\r
-\r
- return new TALTemplate(aParser, handler.getNode());\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- public static TALTemplate parseInputStream(InputStream anInputStream, TALExpressionParser aParser) throws TALExc, TALFailure {\r
- try {\r
- TALHandler handler = new TALHandler(aParser);\r
- XMLReader reader = new XMLReader(false);\r
-\r
- reader.parseInputStream(true, anInputStream, handler);\r
-\r
- return new TALTemplate(aParser, handler.getNode());\r
- }\r
- catch (Throwable t) {\r
- throw new TALFailure(t);\r
- }\r
- }\r
-\r
- private static String normalizeXMLName(XMLReader.XMLName aName) {\r
- String result = aName.getLocalName();\r
- if (aName.getPrefix().length() > 0)\r
- result = aName.getPrefix() + ":" + result;\r
-\r
- return result;\r
- }\r
-\r
-\r
-\r
- private static final String CONDITION_ATTRIBUTE = "condition";\r
- private static final String REPEAT_ATTRIBUTE = "repeat";\r
- private static final String CONTENT_ATTRIBUTE = "content";\r
- private static final String ERROR_ATTRIBUTE = "on-error";\r
- private static final String REPLACE_ATTRIBUTE = "replace";\r
- private static final String DEFINITION_ATTRIBUTE = "define";\r
- private static final String ONERROR_ATTRIBUTE = "onerror";\r
- private static final String OMITTAG_ATTRIBUTE = "omit-tag";\r
- private static final String ATTRIBUTE_ATTRIBUTE = "attributes";\r
-\r
-\r
- protected static class TALHandler extends XMLReader.AbstractSectionHandler {\r
- private TALTemplate.CompositeTemplateNode compositeNode;\r
- private StringBuffer data;\r
- private TALExpressionParser parser;\r
- private TALTemplate.SmartTemplateNode smartNode;\r
- private boolean smartTag;\r
- private String currentTag;\r
-\r
- public TALHandler(TALExpressionParser aParser) {\r
- parser = aParser;\r
- data = new StringBuffer();\r
- compositeNode = new TALTemplate.CompositeTemplateNode();\r
- }\r
-\r
- private void flushData() {\r
- if (data.length()!=0) {\r
- compositeNode.appendSubNode(new TALTemplate.PlainTextTemplateNode(data.toString()));\r
- data.delete(0, data.length());\r
- }\r
- }\r
-\r
- public XMLReader.SectionHandler startElement(XMLReader.XMLName aTag, Map anAttributes) throws XMLReader.XMLReaderExc {\r
- smartTag = false;\r
-\r
- currentTag = normalizeXMLName(aTag);\r
-\r
- smartTag = (aTag.getPrefix().equals(TAL_PREFIX));\r
-\r
- Iterator i = anAttributes.keySet().iterator();\r
-\r
- while (!smartTag && i.hasNext()) {\r
- String name = (String) i.next();\r
- smartTag = smartTag || (name.startsWith(TAL_PREFIX+":"));\r
- }\r
-\r
- if (!smartTag) {\r
- appendCode("<"+currentTag);\r
- i = anAttributes.entrySet().iterator();\r
-\r
- while (i.hasNext()) {\r
- Map.Entry entry = (Map.Entry) i.next();\r
-\r
- appendCode(" "+ entry.getKey());\r
- appendCode("=\"");\r
- appendText((String) entry.getValue());\r
- appendCode("\"");\r
- }\r
- appendCode(">");\r
- }\r
- else {\r
- smartNode = new TALTemplate.SmartTemplateNode(currentTag);\r
- if (aTag.getPrefix().equals(TAL_PREFIX))\r
- smartNode.setOmitTag(parser.preparseTRUE());\r
-\r
- i = anAttributes.entrySet().iterator();\r
- while (i.hasNext()) {\r
- Map.Entry entry = (Map.Entry) i.next();\r
- String fullAttributeName = (String) entry.getKey();\r
- List attributeParts = StringRoutines.separateString(fullAttributeName, ":");\r
- String prefix = "";\r
- String name = "";\r
- if (attributeParts.size()==2) {\r
- name = (String) attributeParts.get(1);\r
- prefix = (String) attributeParts.get(0);\r
- }\r
- else {\r
- name = (String) attributeParts.get(0);\r
- }\r
-\r
- if (!prefix.equals(TAL_PREFIX)) {\r
- smartNode.addFixedAttribute(fullAttributeName, (String) entry.getValue());\r
- }\r
- else {\r
- if (name.equalsIgnoreCase(DEFINITION_ATTRIBUTE)) {\r
- List definitions = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');\r
-\r
- Iterator j = definitions.iterator(); {\r
- List parts = StringRoutines.separateString((String) i.next(), " ");\r
-\r
- if (parts.size()==2) {\r
- smartNode.addDefinition(parser.preparseReferenceExpression((String) parts.get(0)), parser.preparseExpression((String) parts.get(1)));\r
- }\r
- }\r
- }\r
- else if (name.equalsIgnoreCase(CONDITION_ATTRIBUTE)) {\r
- smartNode.setCondition(parser.preparseBooleanExpression((String) entry.getValue()));\r
- }\r
- else if (name.equalsIgnoreCase(CONTENT_ATTRIBUTE)) {\r
- smartNode.setContent(parser.preparseStringExpression((String) entry.getValue()));\r
- }\r
- else if (name.equalsIgnoreCase(ERROR_ATTRIBUTE)) {\r
- smartNode.setError(parser.preparseStringExpression((String) entry.getValue()));\r
- }\r
- else if (name.equalsIgnoreCase(OMITTAG_ATTRIBUTE)) {\r
- if (((String) entry.getValue()).trim().length()==0)\r
- smartNode.setOmitTag(parser.preparseTRUE());\r
- else\r
- smartNode.setOmitTag(parser.preparseBooleanExpression((String) entry.getValue()));\r
- }\r
- else if (name.equalsIgnoreCase(REPLACE_ATTRIBUTE)) {\r
- smartNode.setOmitTag(parser.preparseTRUE());\r
- smartNode.setContent(parser.preparseStringExpression((String) entry.getValue()));\r
- }\r
- else if (name.equalsIgnoreCase(REPEAT_ATTRIBUTE)) {\r
- List parts = StringRoutines.separateString((String) entry.getValue(), " ");\r
-\r
- if (parts.size()==2) {\r
- smartNode.setRepeat(parser.preparseReferenceExpression((String) parts.get(0)), parser.preparseExpression((String) parts.get(1)));\r
- }\r
- }\r
- else if (name.equalsIgnoreCase(ATTRIBUTE_ATTRIBUTE)) {\r
- List attributes = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');\r
-\r
- Iterator j = attributes.iterator(); {\r
- List parts = StringRoutines.separateString((String) i.next(), " ");\r
-\r
- if (parts.size()==2) {\r
- smartNode.addModifiedAttribute((String) parts.get(0), parser.preparseExpression((String) parts.get(1)));\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- flushData();\r
-\r
- return new TALHandler(parser);\r
- };\r
-\r
- public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {\r
- if (!smartTag) {\r
- appendSubNode(((TALHandler) aHandler).getNode());\r
- appendCode("</"+currentTag+">");\r
- }\r
- else {\r
- smartNode.setBody(((TALHandler) aHandler).getNode());\r
- appendSubNode(smartNode);\r
- smartNode=null;\r
- }\r
- };\r
-\r
- protected void appendSubNode(TALTemplate.TemplateNode aNode) {\r
- compositeNode.appendSubNode(aNode);\r
- }\r
-\r
- protected void appendCode(String aCode) {\r
- data.append(aCode);\r
- }\r
-\r
- protected void appendText(String aText) {\r
- data.append(HTMLRoutines.encodeHTML(aText));\r
- }\r
-\r
- public void finishSection() throws XMLReader.XMLReaderExc {\r
- flushData();\r
- }\r
-\r
- public TALTemplate.TemplateNode getNode() {\r
- return compositeNode;\r
- }\r
-\r
- public void characters(String aCharacters) throws XMLReader.XMLReaderExc {\r
- appendText(aCharacters);\r
- }\r
- }\r
-}\r
+/*
+ * 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;
+
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import mir.generator.tal.interfaces.TALExpressionParser;
+import mir.util.HTMLRoutines;
+import mir.util.StringRoutines;
+import mir.util.XMLReader;
+import mir.util.XMLReader.AbstractSectionHandler;
+
+public class TALTemplateParser {
+ private int bal;
+ private static final String TAL_PREFIX = "tal";
+
+ public static TALTemplate parseString(String aData, TALExpressionParser aParser) throws TALExc, TALFailure {
+ try {
+ TALHandler handler = new TALHandler(aParser);
+ XMLReader reader = new XMLReader(false);
+
+ reader.parseString(true, aData, handler);
+
+ return new TALTemplate(aParser, handler.getNode());
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ public static TALTemplate parseInputStream(InputStream anInputStream, TALExpressionParser aParser) throws TALExc, TALFailure {
+ try {
+ TALHandler handler = new TALHandler(aParser);
+ XMLReader reader = new XMLReader(false);
+
+ reader.parseInputStream(true, anInputStream, handler);
+
+ return new TALTemplate(aParser, handler.getNode());
+ }
+ catch (Throwable t) {
+ throw new TALFailure(t);
+ }
+ }
+
+ private static String normalizeXMLName(XMLReader.XMLName aName) {
+ String result = aName.getLocalName();
+ if (aName.getPrefix().length() > 0)
+ result = aName.getPrefix() + ":" + result;
+
+ return result;
+ }
+
+
+
+ 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 ONERROR_ATTRIBUTE = "onerror";
+ private static final String OMITTAG_ATTRIBUTE = "omit-tag";
+ private static final String ATTRIBUTE_ATTRIBUTE = "attributes";
+
+
+ protected static class TALHandler extends XMLReader.AbstractSectionHandler {
+ private TALTemplate.CompositeTemplateNode compositeNode;
+ private StringBuffer data;
+ private TALExpressionParser parser;
+ private TALTemplate.SmartTemplateNode smartNode;
+ private boolean smartTag;
+ private String currentTag;
+
+ public TALHandler(TALExpressionParser aParser) {
+ parser = aParser;
+ data = new StringBuffer();
+ compositeNode = new TALTemplate.CompositeTemplateNode();
+ }
+
+ private void flushData() {
+ if (data.length()!=0) {
+ compositeNode.appendSubNode(new TALTemplate.PlainTextTemplateNode(data.toString()));
+ data.delete(0, data.length());
+ }
+ }
+
+ public XMLReader.SectionHandler startElement(XMLReader.XMLName aTag, Map anAttributes) throws XMLReader.XMLReaderExc {
+ smartTag = false;
+
+ currentTag = normalizeXMLName(aTag);
+
+ smartTag = (aTag.getPrefix().equals(TAL_PREFIX));
+
+ Iterator i = anAttributes.keySet().iterator();
+
+ while (!smartTag && i.hasNext()) {
+ String name = (String) i.next();
+ smartTag = smartTag || (name.startsWith(TAL_PREFIX+":"));
+ }
+
+ if (!smartTag) {
+ appendCode("<"+currentTag);
+ i = anAttributes.entrySet().iterator();
+
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ appendCode(" "+ entry.getKey());
+ appendCode("=\"");
+ appendText((String) entry.getValue());
+ appendCode("\"");
+ }
+ appendCode(">");
+ }
+ else {
+ smartNode = new TALTemplate.SmartTemplateNode(currentTag);
+ if (aTag.getPrefix().equals(TAL_PREFIX))
+ smartNode.setOmitTag(parser.preparseTRUE());
+
+ i = anAttributes.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry entry = (Map.Entry) i.next();
+ String fullAttributeName = (String) entry.getKey();
+ List attributeParts = StringRoutines.separateString(fullAttributeName, ":");
+ String prefix = "";
+ String name = "";
+ if (attributeParts.size()==2) {
+ name = (String) attributeParts.get(1);
+ prefix = (String) attributeParts.get(0);
+ }
+ else {
+ name = (String) attributeParts.get(0);
+ }
+
+ if (!prefix.equals(TAL_PREFIX)) {
+ smartNode.addFixedAttribute(fullAttributeName, (String) entry.getValue());
+ }
+ else {
+ if (name.equalsIgnoreCase(DEFINITION_ATTRIBUTE)) {
+ List definitions = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');
+
+ Iterator j = definitions.iterator(); {
+ List parts = StringRoutines.separateString((String) i.next(), " ");
+
+ if (parts.size()==2) {
+ smartNode.addDefinition(parser.preparseReferenceExpression((String) parts.get(0)), parser.preparseExpression((String) parts.get(1)));
+ }
+ }
+ }
+ else if (name.equalsIgnoreCase(CONDITION_ATTRIBUTE)) {
+ smartNode.setCondition(parser.preparseBooleanExpression((String) entry.getValue()));
+ }
+ else if (name.equalsIgnoreCase(CONTENT_ATTRIBUTE)) {
+ smartNode.setContent(parser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.equalsIgnoreCase(ERROR_ATTRIBUTE)) {
+ smartNode.setError(parser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.equalsIgnoreCase(OMITTAG_ATTRIBUTE)) {
+ if (((String) entry.getValue()).trim().length()==0)
+ smartNode.setOmitTag(parser.preparseTRUE());
+ else
+ smartNode.setOmitTag(parser.preparseBooleanExpression((String) entry.getValue()));
+ }
+ else if (name.equalsIgnoreCase(REPLACE_ATTRIBUTE)) {
+ smartNode.setOmitTag(parser.preparseTRUE());
+ smartNode.setContent(parser.preparseStringExpression((String) entry.getValue()));
+ }
+ else if (name.equalsIgnoreCase(REPEAT_ATTRIBUTE)) {
+ List parts = StringRoutines.separateString((String) entry.getValue(), " ");
+
+ if (parts.size()==2) {
+ smartNode.setRepeat(parser.preparseReferenceExpression((String) parts.get(0)), parser.preparseExpression((String) parts.get(1)));
+ }
+ }
+ else if (name.equalsIgnoreCase(ATTRIBUTE_ATTRIBUTE)) {
+ List attributes = StringRoutines.splitStringWithEscape((String) entry.getValue(), ';', '\\');
+
+ Iterator j = attributes.iterator(); {
+ List parts = StringRoutines.separateString((String) i.next(), " ");
+
+ if (parts.size()==2) {
+ smartNode.addModifiedAttribute((String) parts.get(0), parser.preparseExpression((String) parts.get(1)));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ flushData();
+
+ return new TALHandler(parser);
+ };
+
+ public void endElement(XMLReader.SectionHandler aHandler) throws XMLReader.XMLReaderExc {
+ if (!smartTag) {
+ appendSubNode(((TALHandler) aHandler).getNode());
+ appendCode("</"+currentTag+">");
+ }
+ else {
+ smartNode.setBody(((TALHandler) aHandler).getNode());
+ appendSubNode(smartNode);
+ smartNode=null;
+ }
+ };
+
+ protected void appendSubNode(TALTemplate.TemplateNode aNode) {
+ compositeNode.appendSubNode(aNode);
+ }
+
+ protected void appendCode(String aCode) {
+ data.append(aCode);
+ }
+
+ protected void appendText(String aText) {
+ data.append(HTMLRoutines.encodeHTML(aText));
+ }
+
+ public void finishSection() throws XMLReader.XMLReaderExc {
+ flushData();
+ }
+
+ public TALTemplate.TemplateNode getNode() {
+ return compositeNode;
+ }
+
+ public void characters(String aCharacters) throws XMLReader.XMLReaderExc {
+ appendText(aCharacters);
+ }
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.generator.tal;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class TALTest {\r
- public static void main(String args[]) {\r
- try {\r
- TALTemplateParser parser = new TALTemplateParser();\r
- MirExpressionParser expressionParser = new MirExpressionParser();\r
- Map test = new HashMap();\r
- test.put("name", "zapata");\r
-\r
- TALTemplate template = parser.parseString("<td tal:on-error='exception.message'><tal:test tal:content='name.bla'></tal:test><h1 tal:content=\"name\">test</h1></TD>", expressionParser);\r
- PrintWriter o = new PrintWriter(System.out);\r
- template.processTemplate(test, o);\r
- o.close();\r
- }\r
- catch (Throwable t) {\r
- System.out.println("Exception: " + t.toString());\r
- t.printStackTrace(System.out);\r
- }\r
-\r
- }\r
+/*
+ * 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;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+public class TALTest {
+ public static void main(String args[]) {
+ try {
+ int b=4;
+ int c=6;
+ int a = b = c;
+
+ TALTemplateParser parser = new TALTemplateParser();
+ MirExpressionParser expressionParser = new MirExpressionParser();
+ Map test = new HashMap();
+ test.put("name", "zapata");
+
+ TALTemplate template = parser.parseString("<td tal:on-error='exception.message'><tal:test tal:content='name.bla'></tal:test><h1 tal:content=\"name\">test</h1></TD>", expressionParser);
+ PrintWriter o = new PrintWriter(System.out);
+ template.processTemplate(test, o);
+ o.close();
+ }
+ catch (Throwable t) {
+ System.out.println("Exception: " + t.toString());
+ t.printStackTrace(System.out);
+ }
+
+ }
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mir.media;\r
-\r
-import java.io.InputStream;\r
-import java.util.List;\r
-\r
-import mir.entity.Entity;\r
-\r
-/**\r
- * Interface for Media handling in Mir. All media handlers\r
- * must implement this interface. Each specific media type,\r
- * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video\r
- * has special needs when it comes to representation on the various\r
- * pages (article, list, summary), must be stored differently and has a\r
- * different URL, etc... This interface allows Mir to support\r
- * an infinite (I hope) number of media types. Once this is done,\r
- * no code at any other level in Mir needs to be changed other than\r
- * adding the content-type <-> media handler name mapping in the\r
- * media_type table. The following is an example of the media_type\r
- * table:\r
- * <p>\r
- * id | name | mime_type | classname | tablename | dcname<br>\r
- *---+---------+--------------------------+-----------+---------------+-------<br>\r
- * 2 | unknown | application/octet-stream | -- | UploadedMedia | <br>\r
- * 3 | jpg | image/gif | ImagesGif | Images | <br>\r
- * 4 | mp3 | audio/mp3 | Audio | UploadedMedia | <br>\r
- * <p>\r
- * The "id" field is used as a mapping in the table that contains the media type\r
- * to the media_type table. For example, the images table has a to_media_type\r
- * field that contains the id in the media_type table.\r
- * <p>\r
- * The "name" field is used for various display/filenaming purposes. it should\r
- * match a valid file extension name for a media_type (we could have used the\r
- * content-type map for this....).\r
- * <p>\r
- * The "mime_type" field is the most important as it does maps the type to Java\r
- * classes (the storage and media_handler name). We call those classes using\r
- * reflection. This way, once a Handler for a specific media type is implemented\r
- * and entered into the media_type table, no other Mir code needs to be modified.\r
- * <p>\r
- * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)\r
- * we use it to call the MediaHandler methods via reflection.\r
- * <p>\r
- * The "tablename" is the name of the database storage classes (e.g DatabaseImages\r
- * and EntityImages). We use this to fetch/storage the media (meta)data in the db.\r
- * <p?\r
- * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google\r
- * to learn more.\r
- * <p>\r
- * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from\r
- * ) and just override the things that need to be specific. see MediaHandlerAudio\r
- *\r
- * @author <mh@nadir.org>, the Mir-coders group\r
- * @version $Id: MediaHandler.java,v 1.1.2.1 2003/12/14 16:37:06 zapata Exp $\r
- */\r
-\r
-public interface MediaHandler {\r
- /**\r
- * Takes the uploaded media data itself, along with the media Entity\r
- * which contains the Media metadata plus the MediaType entity containing\r
- * all the info for the specific media type itself. It's job is store the\r
- * Media data (content) itself, this could be on the local filesystem, in the\r
- * DB or even on a remote host. It then inserts the MetaData in the DB.\r
- * @param InputStream, a stream of the uploaded data.\r
- * @param ent, an Entity holding the media MetaData\r
- * @param mediaType, an Entity holding the media_table entry\r
- * @return boolean, success/fail\r
- * @see mir.entity.Entity\r
- */\r
- public void store(InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;\r
-\r
- public void produce(Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;\r
- /**\r
- * Get's the media data from storage and returns it as an InputStream\r
- * Not very useful for most media types as they are stored in a file,\r
- * but very usefull for ones stored in the DB as it is necessary to get\r
- * it first before making a file out of it (in Producer*).\r
- * @param ent, an Entity holding the media MetaData\r
- * @param mediaType, an Entity holding the media_table entry\r
- * @return java.io.InputStream\r
- * @see mir.entity.Entity\r
- */\r
- public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * Pretty much like get() above. But get's the specific Icon\r
- * representation. useful for media stored in the DB.\r
- * @param ent, an Entity holding the media MetaData\r
- * @return java.io.InputStream\r
- * @see mir.entity.Entity\r
- */\r
- public InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure;\r
-\r
-\r
- /**\r
- *\r
- * @param ent\r
- * @return\r
- * @throws MediaExc\r
- * @throws MediaFailure\r
- */\r
- public String getThumbnailMimeType(Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * gets the final content representation for the media\r
- * in the form of a URL (String) that allows someone to\r
- * download, look at or listen to the media. (HREF, img src\r
- * streaming link, etc..)\r
- * It should use the helper functions in the StringUtil class to\r
- * build URL's safely, eliminating any *illegal* user input.\r
- * @param ent, an Entity holding the media MetaData\r
- * @param mediaTypeEnt, an Entity holding the media_table entry\r
- * @return String, the url.\r
- * @see mir.entity.Entity\r
- * @see mir.misc.StringUtil\r
- */\r
- public List getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * Returns the absolute filesystem path to where the media\r
- * content should be stored. This path is usually defined\r
- * in the configuration wich is accessible through the MirConfig\r
- * class.\r
- * @return String, the path.\r
- * @see mir.misc.MirConfig\r
- */\r
- public String getStoragePath () throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * Returns the *relative* filesystem path to where the media\r
- * icon content should be stored. It is relative to the path\r
- * returned by getStoragePath()\r
- * This path is usually defined\r
- * in the configuration wich is accessible through the MirConfig\r
- * class.\r
- * @return String, the path.\r
- * @see mir.misc.MirConfig\r
- */\r
- public String getIconStoragePath () throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * Returns the base URL to that the media is accessible from\r
- * to the end user. This could be a URL to another host.\r
- * This is used in the Metadata stored in the DB and later on\r
- * ,the templates use it.\r
- * It is usually defined\r
- * in the configuration witch is accessible through the MirConfig\r
- * class.\r
- * @return String, the base URL to the host.\r
- * @see mir.misc.MirConfig\r
- */\r
- public String getPublishHost () throws MediaExc, MediaFailure;\r
-\r
- /**\r
- * Returns the file name of the Icon representing the media type.\r
- * It is used in the summary view.\r
- * It is usually defined\r
- * in the configuration wich is accessible through the MirConfig\r
- * class.\r
- * @return String, the icon filename.\r
- * @see mir.misc.MirConfig\r
- */\r
- public String getBigIconName ();\r
-\r
- /**\r
- * Returns the file name of the small Icon representing\r
- * the media type.\r
- * It is used in the right hand newswire list of the startpage.\r
- * It is usually defined\r
- * in the configuration wich is accessible through the MirConfig\r
- * class.\r
- * @return String, the icon filename.\r
- * @see mir.misc.MirConfig\r
- */\r
- public String getTinyIconName ();\r
-\r
- /**\r
- * Returns the IMG SRC "ALT" text to be used\r
- * for the Icon representations\r
- * @return String, the ALT text.\r
- */\r
- public String getIconAltName ();\r
-\r
- /**\r
- * returns a brief text dscription of what this\r
- * media type is.\r
- * @return String\r
- */\r
- public String getDescr (Entity mediaTypeEnt);\r
-\r
-}\r
-\r
-\r
+/*
+ * 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.media;
+
+import java.io.InputStream;
+import java.util.List;
+
+import mir.entity.Entity;
+
+/**
+ * Interface for Media handling in Mir. All media handlers
+ * must implement this interface. Each specific media type,
+ * be it Gif, Jpeg, Mp3 audio, Real Audio or quicktime video
+ * has special needs when it comes to representation on the various
+ * pages (article, list, summary), must be stored differently and has a
+ * different URL, etc... This interface allows Mir to support
+ * an infinite (I hope) number of media types. Once this is done,
+ * no code at any other level in Mir needs to be changed other than
+ * adding the content-type <-> media handler name mapping in the
+ * media_type table. The following is an example of the media_type
+ * table:
+ * <p>
+ * id | name | mime_type | classname | tablename | dcname<br>
+ *---+---------+--------------------------+-----------+---------------+-------<br>
+ * 2 | unknown | application/octet-stream | -- | UploadedMedia | <br>
+ * 3 | jpg | image/gif | ImagesGif | Images | <br>
+ * 4 | mp3 | audio/mp3 | Audio | UploadedMedia | <br>
+ * <p>
+ * The "id" field is used as a mapping in the table that contains the media type
+ * to the media_type table. For example, the images table has a to_media_type
+ * field that contains the id in the media_type table.
+ * <p>
+ * The "name" field is used for various display/filenaming purposes. it should
+ * match a valid file extension name for a media_type (we could have used the
+ * content-type map for this....).
+ * <p>
+ * The "mime_type" field is the most important as it does maps the type to Java
+ * classes (the storage and media_handler name). We call those classes using
+ * reflection. This way, once a Handler for a specific media type is implemented
+ * and entered into the media_type table, no other Mir code needs to be modified.
+ * <p>
+ * The "classname" field is the name of the media handler (e.g MediaHandlerAudio)
+ * we use it to call the MediaHandler methods via reflection.
+ * <p>
+ * The "tablename" is the name of the database storage classes (e.g DatabaseImages
+ * and EntityImages). We use this to fetch/storage the media (meta)data in the db.
+ * <p?
+ * The "dcname" field is as of yet unused. Do search for "Dublin Core" on google
+ * to learn more.
+ * <p>
+ * Most media handlers should just extend MediaHandlerGeneric (i.e inherit from
+ * ) and just override the things that need to be specific. see MediaHandlerAudio
+ *
+ * @author <mh@nadir.org>, the Mir-coders group
+ * @version $Id: MediaHandler.java,v 1.1.2.2 2003/12/21 13:32:03 zapata Exp $
+ */
+
+public interface MediaHandler {
+ /**
+ * Takes the uploaded media data itself, along with the media Entity
+ * which contains the Media metadata plus the MediaType entity containing
+ * all the info for the specific media type itself. It's job is store the
+ * Media data (content) itself, this could be on the local filesystem, in the
+ * DB or even on a remote host. It then inserts the MetaData in the DB.
+ * @param InputStream, a stream of the uploaded data.
+ * @param ent, an Entity holding the media MetaData
+ * @param mediaType, an Entity holding the media_table entry
+ * @return boolean, success/fail
+ * @see mir.entity.Entity
+ */
+ public void store(InputStream in, Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;
+
+ public void produce(Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure;
+ /**
+ * Get's the media data from storage and returns it as an InputStream
+ * Not very useful for most media types as they are stored in a file,
+ * but very usefull for ones stored in the DB as it is necessary to get
+ * it first before making a file out of it (in Producer*).
+ * @param ent, an Entity holding the media MetaData
+ * @param mediaType, an Entity holding the media_table entry
+ * @return java.io.InputStream
+ * @see mir.entity.Entity
+ */
+ public InputStream getMedia (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
+
+ /**
+ * Pretty much like get() above. But get's the specific Icon
+ * representation. useful for media stored in the DB.
+ * @param ent, an Entity holding the media MetaData
+ * @return java.io.InputStream
+ * @see mir.entity.Entity
+ */
+ public InputStream getThumbnail(Entity ent) throws MediaExc, MediaFailure;
+
+
+ /**
+ *
+ * @param ent
+ * @return
+ * @throws MediaExc
+ * @throws MediaFailure
+ */
+ public String getThumbnailMimeType(Entity aMediaEntity, Entity aMediaType) throws MediaExc, MediaFailure;
+
+ /**
+ * gets the final content representation for the media
+ * in the form of a URL (String) that allows someone to
+ * download, look at or listen to the media. (HREF, img src
+ * streaming link, etc..)
+ * It should use the helper functions in the StringUtil class to
+ * build URL's safely, eliminating any *illegal* user input.
+ * @param ent, an Entity holding the media MetaData
+ * @param mediaTypeEnt, an Entity holding the media_table entry
+ * @return String, the url.
+ * @see mir.entity.Entity
+ * @see mir.misc.StringUtil
+ */
+ public List getURL (Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure;
+
+ /**
+ * Returns the absolute filesystem path to where the media
+ * content should be stored. This path is usually defined
+ * in the configuration wich is accessible through the MirConfig
+ * class.
+ * @return String, the path.
+ * @see mir.misc.MirConfig
+ */
+ public String getStoragePath () throws MediaExc, MediaFailure;
+
+ /**
+ * Returns the *relative* filesystem path to where the media
+ * icon content should be stored. It is relative to the path
+ * returned by getStoragePath()
+ * This path is usually defined
+ * in the configuration wich is accessible through the MirConfig
+ * class.
+ * @return String, the path.
+ * @see mir.misc.MirConfig
+ */
+ public String getIconStoragePath () throws MediaExc, MediaFailure;
+
+ /**
+ * Returns the base URL to that the media is accessible from
+ * to the end user. This could be a URL to another host.
+ * This is used in the Metadata stored in the DB and later on
+ * ,the templates use it.
+ * It is usually defined
+ * in the configuration witch is accessible through the MirConfig
+ * class.
+ * @return String, the base URL to the host.
+ * @see mir.misc.MirConfig
+ */
+ public String getPublishHost () throws MediaExc, MediaFailure;
+
+ /**
+ * Returns the file name of the Icon representing the media type.
+ * It is used in the summary view.
+ * It is usually defined
+ * in the configuration wich is accessible through the MirConfig
+ * class.
+ * @return String, the icon filename.
+ * @see mir.misc.MirConfig
+ */
+ public String getBigIconName ();
+
+ /**
+ * Returns the file name of the small Icon representing
+ * the media type.
+ * It is used in the right hand newswire list of the startpage.
+ * It is usually defined
+ * in the configuration wich is accessible through the MirConfig
+ * class.
+ * @return String, the icon filename.
+ * @see mir.misc.MirConfig
+ */
+ public String getTinyIconName ();
+
+ /**
+ * Returns the IMG SRC "ALT" text to be used
+ * for the Icon representations
+ * @return String, the ALT text.
+ */
+ public String getIconAltName ();
+
+ /**
+ * returns a brief text dscription of what this
+ * media type is.
+ * @return String
+ */
+ public String getDescr (Entity mediaTypeEnt);
+
+}
+
+
*/
package mir.module;
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.entity.EntityList;\r
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.entity.EntityList;
import mir.storage.StorageObject;
limit = (String) anAttributes.get(ENUMERATION_LIMIT_ATTRIBUTE);
skip = (String) anAttributes.get(ENUMERATION_SKIP_ATTRIBUTE);
extraTables = StringRoutines.splitString(XMLReaderTool.getStringAttributeWithDefault(anAttributes, ENUMERATION_EXTRATABLES_ATTRIBUTE,"").trim(), ",");
- List parts = StringRoutines.splitString(definition.trim()," ");
- if (parts.size()>0) definition=(String)parts.get(0);
- if (parts.size()>1) mainTablePrefix=(String)parts.get(1);
+ if (definition!=null) {
+ 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() {
skip = (String) anAttributes.get(LIST_SKIP_ATTRIBUTE);
extraTables = StringRoutines.splitString(XMLReaderTool.getStringAttributeWithDefault(anAttributes, LIST_EXTRATABLES_ATTRIBUTE,"").trim(), ",");
List parts = StringRoutines.splitString(definition.trim()," ");
- if (parts.size()>0) definition=(String)parts.get(0);
+ if (parts.size()>0) definition=(String)parts.get(0);
if (parts.size()>1) mainTablePrefix=(String)parts.get(1);
-
+
};
public ProducerNode constructNode() {
batchSize = XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_BATCHSIZE_ATTRIBUTE, "20" );
minBatchSize = XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_MINBATCHSIZE_ATTRIBUTE, "0" );
skip = XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_SKIP_ATTRIBUTE, "0" );
- process = XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_PROCESS_ATTRIBUTE, "-1" );
+ process = XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_PROCESS_ATTRIBUTE, "-1" );
extraTables = StringRoutines.splitString(XMLReaderTool.getStringAttributeWithDefault(anAttributes, BATCHER_EXTRATABLES_ATTRIBUTE,"").trim(), ",");
List parts = StringRoutines.splitString(definition.trim()," ");
- if (parts.size()>0) definition=(String)parts.get(0);
+ if (parts.size()>0) definition=(String)parts.get(0);
if (parts.size()>1) mainTablePrefix=(String)parts.get(1);
};
*/
package mir.rss;
-import java.util.HashMap;\r
+import java.util.HashMap;
import java.util.Map;
public class RDFResource {
*/
public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleExc, ServletModuleFailure {
try {
- aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?"+aQuery));
+ aResponse.sendRedirect(aResponse.encodeRedirectURL(MirPropertiesConfiguration.instance().getString("RootUri") + "/servlet/Mir?"+aQuery));
}
catch (Throwable t) {
throw new ServletModuleFailure("ServletModule.redirect: " +t.getMessage(), t);
import mir.config.MirPropertiesConfiguration;
import mir.log.LoggerWrapper;
import mircoders.entity.EntityUsers;
+import mircoders.module.*;
+import mircoders.storage.*;
public class AccessControl {
private UserAccessControl user;
private GeneralAccessControl general;
+ private ArticleAccessControl article;
protected LoggerWrapper logger = new LoggerWrapper("Global.AccessControl");
protected MirPropertiesConfiguration configuration;
user = new UserAccessControl(configuration.getVector("AccessControl.SuperUsers"));
general = new GeneralAccessControl();
+ article = new ArticleAccessControl(
+ configuration.getString("AccessControl.LockingEnabled", "0").equals("1"),
+ configuration.getString("AccessControl.LockingOptional", "0").equals("1"));
}
catch (Throwable t) {
throw new RuntimeException(t.toString());
return general;
}
+ public ArticleAccessControl article() {
+ return article;
+ }
+
public class GeneralAccessControl {
public boolean mayDeleteArticles(EntityUsers aSubject) {
return configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1");
return superusers.contains(aSubject.getValue("login"));
}
+ protected boolean isSuperUser(EntityUsers aUser) {
+ return superusers.contains(aUser.getValue("login"));
+ }
+
public void assertMayEditUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
try {
if (!mayEditUser(aSubject, anObject))
}
}
}
+
+ public class ArticleAccessControl {
+ private ModuleContent contentModule;
+ private boolean lockingEnabled;
+ private boolean lockingOptional;
+
+ public ArticleAccessControl(boolean aLockingEnabled, boolean aLockingOptional) {
+ contentModule = new ModuleContent(DatabaseContent.getInstance());
+ lockingEnabled = aLockingEnabled;
+ lockingOptional = aLockingOptional;
+ }
+
+ public boolean mayEditArticle(EntityUsers aSubject, String anArticleId) {
+ String userId = aSubject.getId();
+
+ if (userId==null)
+ return false;
+ if (!lockingEnabled)
+ return true;
+
+ String lockingUser = contentModule.queryArticleLock(anArticleId);
+
+ return userId.equals(lockingUser) || ((lockingUser==null) && lockingOptional);
+ }
+
+ public boolean mayLockArticle(EntityUsers aSubject, String anArticleId) {
+ String userId = aSubject.getId();
+
+ if (userId==null)
+ return false;
+ if (!lockingEnabled)
+ return false;
+
+ String lockingUser = contentModule.queryArticleLock(anArticleId);
+
+ return (lockingUser==null);
+ }
+
+ public boolean mayForceLockArticle(EntityUsers aSubject, String anArticleId) {
+ String userId = aSubject.getId();
+
+ if (userId==null)
+ return false;
+ if (!lockingEnabled)
+ return false;
+
+ String lockingUser = contentModule.queryArticleLock(anArticleId);
+
+ return (lockingUser!=null) && !userId.equals(lockingUser) && user().isSuperUser(aSubject);
+ }
+
+ public boolean mayUnlockArticle(EntityUsers aSubject, String anArticleId) {
+ String userId = aSubject.getId();
+
+ if (userId==null)
+ return false;
+ if (!lockingEnabled)
+ return false;
+
+ String lockingUser = contentModule.queryArticleLock(anArticleId);
+
+ return userId.equals(lockingUser);
+ }
+ }
}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.entity;\r
-\r
-import java.sql.Connection;\r
-import java.sql.SQLException;\r
-import java.sql.Statement;\r
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-import mir.util.StringRoutines;\r
-import mircoders.storage.DatabaseContentToMedia;\r
-\r
-/**\r
- * this class implements mapping of one line of the database table content\r
- * to a java object\r
- *\r
- * @version $Id: EntityContent.java,v 1.19.2.3 2003/09/19 23:34:20 zapata Exp $\r
- * @author mir-coders group\r
- *\r
- */\r
-\r
-\r
-public class EntityContent extends Entity\r
-{\r
- // constructors\r
-\r
- public EntityContent()\r
- {\r
- super();\r
-\r
- logger = new LoggerWrapper("Entity.Content");\r
- }\r
-\r
- public EntityContent(StorageObject theStorage) {\r
- this();\r
-\r
- setStorage(theStorage);\r
- }\r
-\r
- //\r
- // methods\r
-\r
- /**\r
- * set is_produced flag for the article\r
- */\r
-\r
- public void setProduced(boolean yesno) throws StorageObjectFailure\r
- {\r
- String value = (yesno) ? "1":"0";\r
- if (value.equals( getValue("is_produced") )) return;\r
-\r
- Connection con=null;Statement stmt=null;\r
- String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";\r
- try {\r
- con = theStorageObject.getPooledCon();\r
- /** @todo should be preparedStatement: faster!! */\r
- stmt = con.createStatement();\r
- theStorageObject.executeUpdate(stmt,sql);\r
- }\r
- catch (StorageObjectFailure e) {\r
- throwStorageObjectFailure(e, "\n -- set produced failed");\r
- }\r
- catch (SQLException e) {\r
- throwStorageObjectFailure(e, "\n -- set produced failed");\r
- }\r
- finally {\r
- theStorageObject.freeConnection(con,stmt);\r
- }\r
- }\r
-\r
- /**\r
- * Deattaches media from an article\r
- *\r
- * @param anArticleId\r
- * @param aMediaId\r
- * @throws StorageObjectFailure\r
- */\r
- public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure\r
- {\r
- if (aMediaId!=null){\r
- try{\r
- DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);\r
- }\r
- catch (Exception e){\r
- throwStorageObjectFailure(e, "\n -- failed to get instance");\r
- }\r
-\r
- setProduced(false);\r
- }\r
- }\r
-\r
- /**\r
- * Attaches media to an article\r
- *\r
- * @param mid\r
- * @throws StorageObjectFailure\r
- */\r
-\r
- public void attach(String aMediaId) throws StorageObjectFailure\r
- {\r
- if (aMediaId!=null) {\r
- try{\r
- DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);\r
- }\r
- catch(StorageObjectFailure e){\r
- throwStorageObjectFailure(e, "attach: could not get the instance");\r
- }\r
- setProduced(false);\r
- }\r
- else {\r
- logger.error("EntityContent: attach without mid");\r
- }\r
- }\r
-\r
- /**\r
- * overridden method setValues to patch creator_main_url\r
- */\r
- public void setValues(Map theStringValues) {\r
- if (theStringValues != null) {\r
- if (theStringValues.containsKey("creator_main_url")){\r
- if (((String)theStringValues.get("creator_main_url")).equalsIgnoreCase("http://")){\r
- theStringValues.remove("creator_main_url");\r
- }\r
- else if (!((String)theStringValues.get("creator_main_url")).startsWith("http://")){\r
- theStringValues.put("creator_main_url","http://"+((String)theStringValues.get("creator_main_url")));\r
- }\r
- }\r
- }\r
- super.setValues(theStringValues);\r
- }\r
-\r
- public void appendToComments(String aLine) {\r
- StringBuffer comment = new StringBuffer();\r
- try {\r
- comment.append(StringRoutines.interpretAsString(getValue("comment")));\r
- }\r
- catch (Throwable t) {\r
- }\r
- if (comment.length() > 0 && comment.charAt(comment.length() - 1) != '\n') {\r
- comment.append('\n');\r
- }\r
-\r
- comment.append(aLine);\r
- setValueForProperty("comment", comment.toString());\r
- }\r
-\r
-\r
-\r
-}\r
+/*
+ * 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.entity;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+import mir.util.StringRoutines;
+import mircoders.storage.DatabaseContentToMedia;
+
+/**
+ * this class implements mapping of one line of the database table content
+ * to a java object
+ *
+ * @version $Id: EntityContent.java,v 1.19.2.4 2003/12/21 13:32:04 zapata Exp $
+ * @author mir-coders group
+ *
+ */
+
+
+public class EntityContent extends Entity
+{
+ // constructors
+
+ public EntityContent()
+ {
+ super();
+
+ logger = new LoggerWrapper("Entity.Content");
+ }
+
+ public EntityContent(StorageObject theStorage) {
+ this();
+
+ setStorage(theStorage);
+ }
+
+ //
+ // methods
+
+ /**
+ * set is_produced flag for the article
+ */
+
+ public void setProduced(boolean yesno) throws StorageObjectFailure
+ {
+ String value = (yesno) ? "1":"0";
+ if (value.equals( getValue("is_produced") )) return;
+
+ Connection con=null;Statement stmt=null;
+ String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";
+ try {
+ con = theStorageObject.getPooledCon();
+ /** @todo should be preparedStatement: faster!! */
+ stmt = con.createStatement();
+ theStorageObject.executeUpdate(stmt,sql);
+ }
+ catch (StorageObjectFailure e) {
+ throwStorageObjectFailure(e, "\n -- set produced failed");
+ }
+ catch (SQLException e) {
+ throwStorageObjectFailure(e, "\n -- set produced failed");
+ }
+ finally {
+ theStorageObject.freeConnection(con,stmt);
+ }
+ }
+
+ /**
+ * Deattaches media from an article
+ *
+ * @param anArticleId
+ * @param aMediaId
+ * @throws StorageObjectFailure
+ */
+ public void dettach(String anArticleId, String aMediaId) throws StorageObjectFailure
+ {
+ if (aMediaId!=null){
+ try{
+ DatabaseContentToMedia.getInstance().delete(anArticleId, aMediaId);
+ }
+ catch (Exception e){
+ throwStorageObjectFailure(e, "\n -- failed to get instance");
+ }
+
+ setProduced(false);
+ }
+ }
+
+ /**
+ * Attaches media to an article
+ *
+ * @param mid
+ * @throws StorageObjectFailure
+ */
+
+ public void attach(String aMediaId) throws StorageObjectFailure
+ {
+ if (aMediaId!=null) {
+ try{
+ DatabaseContentToMedia.getInstance().addMedia(getId(),aMediaId);
+ }
+ catch(StorageObjectFailure e){
+ throwStorageObjectFailure(e, "attach: could not get the instance");
+ }
+ setProduced(false);
+ }
+ else {
+ logger.error("EntityContent: attach without mid");
+ }
+ }
+
+ /**
+ * overridden method setValues to patch creator_main_url
+ */
+ public void setValues(Map theStringValues) {
+ if (theStringValues != null) {
+ if (theStringValues.containsKey("creator_main_url")){
+ if (((String)theStringValues.get("creator_main_url")).equalsIgnoreCase("http://")){
+ theStringValues.remove("creator_main_url");
+ }
+ else if (!((String)theStringValues.get("creator_main_url")).startsWith("http://")){
+ theStringValues.put("creator_main_url","http://"+((String)theStringValues.get("creator_main_url")));
+ }
+ }
+ }
+ super.setValues(theStringValues);
+ }
+}
+++ /dev/null
-/*
- * 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.entity;
-
-import mir.entity.Entity;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseContent;
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK
- * @version 29.6.1999
- */
-
-
-public class EntityFeature extends Entity
-{
- public EntityFeature()
- {
- super();
- }
-
- public EntityFeature(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- public void update() throws StorageObjectFailure{
- super.update();
- DatabaseContent dbContent = DatabaseContent.getInstance();
- dbContent.setUnproduced("to_feature="+getId());
- }
-}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.entity;\r
-\r
-import java.sql.SQLException;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mircoders.media.MediaHelper;\r
-import mir.media.MediaHandler;\r
-import mir.misc.NumberUtils;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-import mircoders.storage.DatabaseUploadedMedia;\r
-\r
-/**\r
- *\r
- * @author mh, mir-coders group\r
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.4 2003/12/14 16:37:07 zapata Exp $\r
- */\r
-\r
-\r
-public class EntityUploadedMedia extends Entity {\r
- public EntityUploadedMedia() {\r
- super();\r
-\r
- logger = new LoggerWrapper("Entity.UploadedMedia");\r
- }\r
-\r
- public EntityUploadedMedia(StorageObject theStorage) {\r
- this();\r
-\r
- setStorage(theStorage);\r
- }\r
-\r
- public void update() throws StorageObjectFailure {\r
- super.update();\r
-\r
- try {\r
- theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");\r
- theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");\r
- }\r
- catch (SQLException e) {\r
- throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");\r
- }\r
- }\r
-\r
- public void setValues(Map theStringValues) {\r
- if (theStringValues != null) {\r
- if (!theStringValues.containsKey("is_published"))\r
- theStringValues.put("is_published", "0");\r
- }\r
- super.setValues(theStringValues);\r
- }\r
-\r
-\r
- /**\r
- * fetches the MediaType entry assiciated w/ this media\r
- *\r
- * @return mir.entity.Entity\r
- */\r
- public Entity getMediaType() throws StorageObjectFailure {\r
- Entity ent = null;\r
- try {\r
- ent = DatabaseUploadedMedia.getInstance().getMediaType(this);\r
- }\r
- catch (StorageObjectFailure e) {\r
- throwStorageObjectFailure(e, "get MediaType failed -- ");\r
- }\r
- return ent;\r
- }\r
-}\r
+/*
+ * 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.entity;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mircoders.media.MediaHelper;
+import mir.media.MediaHandler;
+import mir.misc.NumberUtils;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+import mircoders.storage.DatabaseUploadedMedia;
+
+/**
+ *
+ * @author mh, mir-coders group
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.5 2003/12/21 13:32:04 zapata Exp $
+ */
+
+
+public class EntityUploadedMedia extends Entity {
+ public EntityUploadedMedia() {
+ super();
+
+ logger = new LoggerWrapper("Entity.UploadedMedia");
+ }
+
+ public EntityUploadedMedia(StorageObject theStorage) {
+ this();
+
+ setStorage(theStorage);
+ }
+
+ public void update() throws StorageObjectFailure {
+ super.update();
+
+ try {
+ theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from content_x_media where content_id=content.id and media_id=" + getId()+")");
+ theStorageObject.executeUpdate( "update content set is_produced='0' where exists(select * from comment_x_media, comment where comment_x_media.comment_id=comment.id and comment.to_media=content.id and comment_x_media.media_id=" + getId()+")");
+ }
+ catch (SQLException e) {
+ throwStorageObjectFailure(e, "EntityUploadedMedia :: update :: failed!! ");
+ }
+ }
+
+ public void setValues(Map theStringValues) {
+ if (theStringValues != null) {
+ if (!theStringValues.containsKey("is_published"))
+ theStringValues.put("is_published", "0");
+ }
+ super.setValues(theStringValues);
+ }
+
+
+ /**
+ * fetches the MediaType entry assiciated w/ this media
+ *
+ * @return mir.entity.Entity
+ */
+ public Entity getMediaType() throws StorageObjectFailure {
+ Entity ent = null;
+ try {
+ ent = DatabaseUploadedMedia.getInstance().getMediaType(this);
+ }
+ catch (StorageObjectFailure e) {
+ throwStorageObjectFailure(e, "get MediaType failed -- ");
+ }
+ return ent;
+ }
+}
if (filterRule != null) {
logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression() + "'");
filterRule.setLastHit(new GregorianCalendar().getTime());
+
+ StringBuffer line = new StringBuffer();
+
+ line.append(DateTimeFunctions.advancedDateFormat(
+ configuration.getString("Mir.DefaultDateTimeFormat"),
+ (new GregorianCalendar()).getTime(), configuration.getString("Mir.DefaultTimezone")));
+
+ line.append(" ");
+ line.append("filter");
+
+ line.append(" ");
+ line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
+ aComment.appendLineToField("comment", line.toString());
+
MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction());
setCookie(aResponse);
save();
line.append(" ");
line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
- anArticle.appendToComments(line.toString());
+ anArticle.appendLineToField("comment", line.toString());
MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction());
setCookie(aResponse);
jobCleanupTreshold = 900; // seconds
queueRunner = new JobQueueRunner(logger);
thread = new Thread(queueRunner);
+ thread.setDaemon(true);
thread.start();
}
logger.debug(" starting job ("+job.getIdentifier()+"): " +job.getDescription());
job.runJob();
logger.debug(" finished job ("+job.getIdentifier()+"): " +job.getDescription());
+ job=null;
}
else {
try {
static private Map articleOperations;
static private Map commentOperations;
static private Map loggedInUsers = new HashMap();
+ static private Map loggedInUserIds = new HashMap();
static private LoggerWrapper logger = new LoggerWrapper("Global");
static private LoggerWrapper adminUsageLogger = new LoggerWrapper("AdminUsage");
}
}
+ public static boolean isUserLoggedIn(String anId) {
+ synchronized (loggedInUserIds) {
+ return loggedInUserIds.containsKey(anId);
+ }
+ }
public static List getLoggedInUsers() {
List result = new Vector();
return result;
}
- public static void registerLogin(String aName) {
- modifyLoggedInCount(aName, 1);
+ public static void registerLogin(String aName, String anId) {
+ modifyLoggedInCount(aName, anId, 1);
}
- public static void registerLogout(String aName) {
- modifyLoggedInCount(aName, -1);
+ public static void registerLogout(String aName, String anId) {
+ modifyLoggedInCount(aName, anId, -1);
}
- private static void modifyLoggedInCount(String aName, int aModifier) {
+ private static void modifyLoggedInCount(String aName, String anId, int aModifier) {
synchronized (loggedInUsers) {
Integer count = (Integer) loggedInUsers.get(aName);
if (count==null)
loggedInUsers.put(aName, new Integer(count.intValue() + aModifier));
}
}
+
+ synchronized (loggedInUserIds) {
+ Integer count = (Integer) loggedInUserIds.get(anId);
+ if (count==null)
+ count = new Integer(0);
+
+ if (count.intValue()+aModifier<=0) {
+ loggedInUserIds.remove(anId);
+ }
+ else {
+ loggedInUserIds.put(anId, new Integer(count.intValue() + aModifier));
+ }
+ }
}
public static void logAdminUsage(EntityUsers aUser, String anObject, String aDescription) {
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.global;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.log.LoggerToWriterAdapter;\r
-import mir.log.LoggerWrapper;\r
-import mir.producer.Producer;\r
-import mir.producer.ProducerFactory;\r
-import mir.util.GeneratorFormatAdapters;\r
-import mir.util.StringRoutines;\r
-import multex.Exc;\r
-import multex.Failure;\r
-\r
-public class ProducerEngine {\r
-// private Map producers;\r
- private JobQueue producerJobQueue;\r
- private LoggerWrapper logger;\r
-\r
-\r
- protected ProducerEngine() {\r
- logger = new LoggerWrapper("Producer");\r
- producerJobQueue = new JobQueue(new LoggerWrapper("Producer.Queue"));\r
- }\r
-\r
- public void addJob(String aProducerFactory, String aVerb) {\r
- producerJobQueue.appendJob(new ProducerJob(aProducerFactory, aVerb), aProducerFactory+"."+aVerb);\r
- }\r
-\r
- public void cancelJobs(List aJobs) {\r
- producerJobQueue.cancelJobs(aJobs);\r
- };\r
-\r
- public void cancelAllJobs() {\r
- producerJobQueue.cancelAllJobs();\r
- };\r
-\r
- public void addTask(ProducerTask aTask) {\r
- addJob(aTask.getProducer(), aTask.getVerb());\r
- }\r
-\r
- public void addTasks(List aTasks) {\r
- Iterator i = aTasks.iterator();\r
-\r
- while (i.hasNext()) {\r
- addTask((ProducerTask) i.next());\r
- }\r
- }\r
-\r
- private String convertStatus(JobQueue.JobInfo aJob) {\r
- switch (aJob.getStatus()) {\r
- case JobQueue.STATUS_ABORTED:\r
- return "aborted";\r
- case JobQueue.STATUS_CANCELLED:\r
- return "cancelled";\r
- case JobQueue.STATUS_CREATED:\r
- return "created";\r
- case JobQueue.STATUS_PENDING:\r
- return "pending";\r
- case JobQueue.STATUS_PROCESSED:\r
- return "processed";\r
- case JobQueue.STATUS_PROCESSING:\r
- return "processing";\r
- }\r
- return "unknown";\r
- }\r
-\r
- private Map convertJob(JobQueue.JobInfo aJob) {\r
- try {\r
- Map result = new HashMap();\r
- result.put("identifier", aJob.getIdentifier());\r
- result.put("description", aJob.getDescription());\r
- result.put("priority", new Integer(aJob.getPriority()));\r
- result.put("runningtime", new Double( (double) aJob.getRunningTime() / 1000));\r
- result.put("status", convertStatus(aJob));\r
- result.put("lastchange", new GeneratorFormatAdapters.DateFormatAdapter(aJob.getLastChange(), MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));\r
- result.put("finished", new Boolean(\r
- aJob.getStatus() == JobQueue.STATUS_PROCESSED ||\r
- aJob.getStatus() == JobQueue.STATUS_CANCELLED ||\r
- aJob.getStatus() == JobQueue.STATUS_ABORTED));\r
-\r
- return result;\r
- }\r
- catch (Throwable t) {\r
- throw new RuntimeException(t.toString());\r
- }\r
- }\r
-\r
- private List convertJobInfoList(List aJobInfoList) {\r
- List result = new Vector();\r
-\r
- Iterator i = aJobInfoList.iterator();\r
-\r
- while (i.hasNext())\r
- result.add(convertJob((JobQueue.JobInfo) i.next()));\r
-\r
- return result;\r
- }\r
-\r
- public List getQueueStatus() {\r
- return convertJobInfoList(producerJobQueue.getJobsInfo());\r
- }\r
-\r
- private class ProducerJob implements JobQueue.Job {\r
- private String factoryName;\r
- private String verb;\r
- private Producer producer;\r
-\r
- public ProducerJob(String aFactory, String aVerb) {\r
- factoryName = aFactory;\r
- verb = aVerb;\r
- producer=null;\r
- }\r
-\r
- public String getFactoryName() {\r
- return factoryName;\r
- }\r
-\r
- public String getVerb() {\r
- return verb;\r
- }\r
-\r
- public void abort() {\r
- if (producer!=null) {\r
- producer.abort();\r
- }\r
- }\r
-\r
- public boolean run() {\r
- ProducerFactory factory;\r
- long startTime;\r
- long endTime;\r
- boolean result = false;\r
- Map startingMap = new HashMap();\r
- Map mirMap = new HashMap();\r
- mirMap.put("producer", factoryName);\r
- mirMap.put("verb", verb);\r
-\r
- startingMap.put("Mir", mirMap);\r
-\r
- startTime = System.currentTimeMillis();\r
- logger.info("Producing job: "+factoryName+"."+verb);\r
-\r
- try {\r
- factory = MirGlobal.localizer().producers().getFactoryForName( factoryName );\r
-\r
- if (factory!=null) {\r
- MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(startingMap);\r
-\r
- synchronized(factory) {\r
- producer = factory.makeProducer(verb, startingMap);\r
- }\r
- if (producer!=null) {\r
- result = producer.produce(logger);\r
- }\r
- }\r
- }\r
- catch (Throwable t) {\r
- logger.error("Exception occurred while producing " + factoryName + "." + verb + t.getMessage());\r
- t.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, LoggerWrapper.ERROR_MESSAGE)));\r
- }\r
- endTime = System.currentTimeMillis();\r
- logger.info("Done producing job: " + factoryName + "." + verb + ", time elapsed:" + (endTime-startTime) + " ms");\r
-\r
- return result;\r
- }\r
-\r
- boolean isAborted() {\r
- return false;\r
- }\r
- }\r
-\r
- public static class ProducerEngineExc extends Exc {\r
- public ProducerEngineExc(String aMessage) {\r
- super(aMessage);\r
- }\r
- }\r
-\r
- public static class ProducerEngineRuntimeExc extends Failure {\r
- public ProducerEngineRuntimeExc(String msg, Exception cause){\r
- super(msg,cause);\r
- }\r
- }\r
-\r
- public static class ProducerTask {\r
- private String producer;\r
- private String verb;\r
-\r
- public ProducerTask(String aProducer, String aVerb) {\r
- producer = aProducer;\r
- verb = aVerb;\r
- }\r
-\r
- public String getVerb() {\r
- return verb;\r
- }\r
-\r
- public String getProducer() {\r
- return producer;\r
- }\r
-\r
- public static List parseProducerTaskList(String aList) throws ProducerEngineExc {\r
- Iterator i;\r
- List result = new Vector();\r
-\r
- i = StringRoutines.splitString(aList, ";").iterator();\r
- while (i.hasNext()) {\r
- String taskExpression = ((String) i.next()).trim();\r
-\r
- if (taskExpression.length()>0) {\r
- List parts = StringRoutines.splitString(taskExpression, ".");\r
-\r
- if (parts.size() != 2)\r
- throw new ProducerEngineExc("Invalid producer expression: '" + taskExpression + "'");\r
- else\r
- result.add(new ProducerEngine.ProducerTask( (String) parts.get(0), (String) parts.get(1)));\r
- }\r
- }\r
-\r
- return result;\r
- }\r
- }\r
+/*
+ * 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.global;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.log.LoggerToWriterAdapter;
+import mir.log.LoggerWrapper;
+import mir.producer.Producer;
+import mir.producer.ProducerFactory;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.StringRoutines;
+import multex.Exc;
+import multex.Failure;
+
+public class ProducerEngine {
+// private Map producers;
+ private JobQueue producerJobQueue;
+ private LoggerWrapper logger;
+
+
+ protected ProducerEngine() {
+ logger = new LoggerWrapper("Producer");
+ producerJobQueue = new JobQueue(new LoggerWrapper("Producer.Queue"));
+ }
+
+ public void addJob(String aProducerFactory, String aVerb) {
+ producerJobQueue.appendJob(new ProducerJob(aProducerFactory, aVerb), aProducerFactory+"."+aVerb);
+ }
+
+ public void cancelJobs(List aJobs) {
+ producerJobQueue.cancelJobs(aJobs);
+ };
+
+ public void cancelAllJobs() {
+ producerJobQueue.cancelAllJobs();
+ };
+
+ public void addTask(ProducerTask aTask) {
+ addJob(aTask.getProducer(), aTask.getVerb());
+ }
+
+ public void addTasks(List aTasks) {
+ Iterator i = aTasks.iterator();
+
+ while (i.hasNext()) {
+ addTask((ProducerTask) i.next());
+ }
+ }
+
+ private String convertStatus(JobQueue.JobInfo aJob) {
+ switch (aJob.getStatus()) {
+ case JobQueue.STATUS_ABORTED:
+ return "aborted";
+ case JobQueue.STATUS_CANCELLED:
+ return "cancelled";
+ case JobQueue.STATUS_CREATED:
+ return "created";
+ case JobQueue.STATUS_PENDING:
+ return "pending";
+ case JobQueue.STATUS_PROCESSED:
+ return "processed";
+ case JobQueue.STATUS_PROCESSING:
+ return "processing";
+ }
+ return "unknown";
+ }
+
+ private Map convertJob(JobQueue.JobInfo aJob) {
+ try {
+ Map result = new HashMap();
+ result.put("identifier", aJob.getIdentifier());
+ result.put("description", aJob.getDescription());
+ result.put("priority", new Integer(aJob.getPriority()));
+ result.put("runningtime", new Double( (double) aJob.getRunningTime() / 1000));
+ result.put("status", convertStatus(aJob));
+ result.put("lastchange", new GeneratorFormatAdapters.DateFormatAdapter(aJob.getLastChange(), MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));
+ result.put("finished", new Boolean(
+ aJob.getStatus() == JobQueue.STATUS_PROCESSED ||
+ aJob.getStatus() == JobQueue.STATUS_CANCELLED ||
+ aJob.getStatus() == JobQueue.STATUS_ABORTED));
+
+ return result;
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.toString());
+ }
+ }
+
+ private List convertJobInfoList(List aJobInfoList) {
+ List result = new Vector();
+
+ Iterator i = aJobInfoList.iterator();
+
+ while (i.hasNext())
+ result.add(convertJob((JobQueue.JobInfo) i.next()));
+
+ return result;
+ }
+
+ public List getQueueStatus() {
+ return convertJobInfoList(producerJobQueue.getJobsInfo());
+ }
+
+ private class ProducerJob implements JobQueue.Job {
+ private String factoryName;
+ private String verb;
+ private Producer producer;
+
+ public ProducerJob(String aFactory, String aVerb) {
+ factoryName = aFactory;
+ verb = aVerb;
+ producer=null;
+ }
+
+ public String getFactoryName() {
+ return factoryName;
+ }
+
+ public String getVerb() {
+ return verb;
+ }
+
+ public void abort() {
+ if (producer!=null) {
+ producer.abort();
+ }
+ }
+
+ public boolean run() {
+ ProducerFactory factory;
+ long startTime;
+ long endTime;
+ boolean result = false;
+ Map startingMap = new HashMap();
+ Map mirMap = new HashMap();
+ mirMap.put("producer", factoryName);
+ mirMap.put("verb", verb);
+
+ startingMap.put("Mir", mirMap);
+
+ startTime = System.currentTimeMillis();
+ logger.info("Producing job: "+factoryName+"."+verb);
+
+ try {
+ factory = MirGlobal.localizer().producers().getFactoryForName( factoryName );
+
+ if (factory!=null) {
+ MirGlobal.localizer().producerAssistant().initializeGenerationValueSet(startingMap);
+
+ synchronized(factory) {
+ producer = factory.makeProducer(verb, startingMap);
+ }
+ if (producer!=null) {
+ result = producer.produce(logger);
+ }
+ }
+ }
+ catch (Throwable t) {
+ logger.error("Exception occurred while producing " + factoryName + "." + verb + t.getMessage());
+ t.printStackTrace(new PrintWriter(new LoggerToWriterAdapter(logger, LoggerWrapper.ERROR_MESSAGE)));
+ }
+ endTime = System.currentTimeMillis();
+ logger.info("Done producing job: " + factoryName + "." + verb + ", time elapsed:" + (endTime-startTime) + " ms");
+
+ return result;
+ }
+
+ boolean isAborted() {
+ return false;
+ }
+ }
+
+ public static class ProducerEngineExc extends Exc {
+ public ProducerEngineExc(String aMessage) {
+ super(aMessage);
+ }
+ }
+
+ public static class ProducerEngineRuntimeExc extends Failure {
+ public ProducerEngineRuntimeExc(String msg, Exception cause){
+ super(msg,cause);
+ }
+ }
+
+ public static class ProducerTask {
+ private String producer;
+ private String verb;
+
+ public ProducerTask(String aProducer, String aVerb) {
+ producer = aProducer;
+ verb = aVerb;
+ }
+
+ public String getVerb() {
+ return verb;
+ }
+
+ public String getProducer() {
+ return producer;
+ }
+
+ public static List parseProducerTaskList(String aList) throws ProducerEngineExc {
+ Iterator i;
+ List result = new Vector();
+
+ i = StringRoutines.splitString(aList, ";").iterator();
+ while (i.hasNext()) {
+ String taskExpression = ((String) i.next()).trim();
+
+ if (taskExpression.length()>0) {
+ List parts = StringRoutines.splitString(taskExpression, ".");
+
+ if (parts.size() != 2)
+ throw new ProducerEngineExc("Invalid producer expression: '" + taskExpression + "'");
+ else
+ result.add(new ProducerEngine.ProducerTask( (String) parts.get(0), (String) parts.get(1)));
+ }
+ }
+
+ return result;
+ }
+ }
}
\ No newline at end of file
*/
public String makePasswordDigest(String aPassword);
+ /**
+ * Allows different "generators" (templates) to be used for certain pages
+ *
+ * @param aPage The identifier of the page
+ * @param aUser the user (can be used to allow different users to see different pages
+ * @param aDefault The default generator
+ * @return
+ */
+ public String getAdminPageGenerator(String aPage, Map aTemplateData, EntityAdapter aUser, String aDefault);
/**
*
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer;\r
-\r
-import mir.entity.Entity;\r
-import mir.session.Request;\r
-\r
-/**\r
- *\r
- *\r
- * <p>Title: Anti-abuse filter type</p>\r
- * <p>Description: Interface to define filter types for the anti-abuse system\r
- * </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: Mir coders</p>\r
- * @author Zapata\r
- * @version 1.0\r
- */\r
-\r
-public interface MirAntiAbuseFilterType {\r
- /**\r
- * The identifying name of the filter type. Must be unique.\r
- *\r
- * @return\r
- */\r
- public String getName();\r
-\r
- /**\r
- * Must return <code>true</code> if the expression is valid for this filter. <code>false</code> if not.\r
- * @param anExpression\r
- * @return\r
- */\r
- public boolean validate(String anExpression);\r
-\r
- /**\r
- * Must return <code>true</code> if the posting matches the filter.\r
- * @param anExpression\r
- * @return\r
- */\r
- public boolean test(String anExpression, Entity anEntity, Request aRequest);\r
+/*
+ * 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;
+
+import mir.entity.Entity;
+import mir.session.Request;
+
+/**
+ *
+ *
+ * <p>Title: Anti-abuse filter type</p>
+ * <p>Description: Interface to define filter types for the anti-abuse system
+ * </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: Mir coders</p>
+ * @author Zapata
+ * @version 1.0
+ */
+
+public interface MirAntiAbuseFilterType {
+ /**
+ * The identifying name of the filter type. Must be unique.
+ *
+ * @return
+ */
+ public String getName();
+
+ /**
+ * Must return <code>true</code> if the expression is valid for this filter. <code>false</code> if not.
+ * @param anExpression
+ * @return
+ */
+ public boolean validate(String anExpression);
+
+ /**
+ * Must return <code>true</code> if the posting matches the filter.
+ * @param anExpression
+ * @return
+ */
+ public boolean test(String anExpression, Entity anEntity, Request aRequest);
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.localizer;\r
-\r
-import mir.entity.adapter.EntityAdapterModel;\r
-import mir.generator.Generator;\r
-import mir.generator.WriterEngine;\r
-\r
-public class MirCachingLocalizerDecorator implements MirLocalizer {\r
- private MirLocalizer localizer;\r
- private MirProducerLocalizer producerLocalizer;\r
- private MirGeneratorLocalizer generatorLocalizer;\r
- private MirOpenPostingLocalizer openPostingsLocalizer;\r
- private MirProducerAssistantLocalizer producerAssistantLocalizer;\r
- private MirDataModelLocalizer dataModelLocalizer;\r
- private MirAdminInterfaceLocalizer adminInterfaceLocalizer;\r
- private MirMediaLocalizer mediaLocalizer;\r
-\r
- public MirCachingLocalizerDecorator(MirLocalizer aLocalizer) {\r
- localizer = aLocalizer;\r
- }\r
-\r
- public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (producerLocalizer==null) {\r
- producerLocalizer = localizer.producers();\r
- }\r
-\r
- return producerLocalizer;\r
- }\r
-\r
- public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (generatorLocalizer==null) {\r
- generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());\r
- }\r
-\r
- return generatorLocalizer;\r
- }\r
-\r
- public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (openPostingsLocalizer==null) {\r
- openPostingsLocalizer = localizer.openPostings();\r
- }\r
-\r
- return openPostingsLocalizer;\r
- }\r
-\r
- public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (producerAssistantLocalizer==null) {\r
- producerAssistantLocalizer = localizer.producerAssistant();\r
- }\r
-\r
- return producerAssistantLocalizer;\r
- }\r
-\r
- public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (dataModelLocalizer==null) {\r
- dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());\r
- }\r
-\r
- return dataModelLocalizer;\r
- }\r
-\r
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (adminInterfaceLocalizer==null) {\r
- adminInterfaceLocalizer = localizer.adminInterface();\r
- }\r
-\r
- return adminInterfaceLocalizer;\r
- };\r
-\r
- public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {\r
- if (mediaLocalizer==null) {\r
- mediaLocalizer = localizer.media();\r
- }\r
-\r
- return mediaLocalizer;\r
- }\r
-\r
- private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {\r
- private MirDataModelLocalizer master;\r
- private EntityAdapterModel adapterModel;\r
-\r
- public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {\r
- master = aMaster;\r
- adapterModel = null;\r
- }\r
-\r
- public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {\r
- if (adapterModel==null) {\r
- adapterModel = master.adapterModel();\r
- }\r
-\r
- return adapterModel;\r
- };\r
-\r
- }\r
-\r
- private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {\r
- private MirGeneratorLocalizer master;\r
- private WriterEngine writerEngine;\r
- private Generator.GeneratorLibrary producerGeneratorLibrary;\r
- private Generator.GeneratorLibrary adminGeneratorLibrary;\r
- private Generator.GeneratorLibrary openPostingGeneratorLibrary;\r
-\r
- public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {\r
- master = aMaster;\r
- }\r
-\r
- public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {\r
- if (writerEngine==null) {\r
- writerEngine = master.makeWriterEngine();\r
- }\r
-\r
- return writerEngine;\r
- };\r
-\r
- public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
- if (producerGeneratorLibrary==null) {\r
- producerGeneratorLibrary = master.makeProducerGeneratorLibrary();\r
- }\r
-\r
- return producerGeneratorLibrary;\r
- };\r
-\r
- public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
- if (adminGeneratorLibrary==null) {\r
- adminGeneratorLibrary = master.makeAdminGeneratorLibrary();\r
- }\r
-\r
- return adminGeneratorLibrary;\r
- };\r
-\r
- public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {\r
- if (openPostingGeneratorLibrary==null) {\r
- openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();\r
- }\r
-\r
- return openPostingGeneratorLibrary;\r
- };\r
- }\r
-\r
+/*
+ * 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;
+
+import mir.entity.adapter.EntityAdapterModel;
+import mir.generator.Generator;
+import mir.generator.WriterEngine;
+
+public class MirCachingLocalizerDecorator implements MirLocalizer {
+ private MirLocalizer localizer;
+ private MirProducerLocalizer producerLocalizer;
+ private MirGeneratorLocalizer generatorLocalizer;
+ private MirOpenPostingLocalizer openPostingsLocalizer;
+ private MirProducerAssistantLocalizer producerAssistantLocalizer;
+ private MirDataModelLocalizer dataModelLocalizer;
+ private MirAdminInterfaceLocalizer adminInterfaceLocalizer;
+ private MirMediaLocalizer mediaLocalizer;
+
+ public MirCachingLocalizerDecorator(MirLocalizer aLocalizer) {
+ localizer = aLocalizer;
+ }
+
+ public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
+ if (producerLocalizer==null) {
+ producerLocalizer = localizer.producers();
+ }
+
+ return producerLocalizer;
+ }
+
+ public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
+ if (generatorLocalizer==null) {
+ generatorLocalizer = new MirCachingGeneratorLocalizer(localizer.generators());
+ }
+
+ return generatorLocalizer;
+ }
+
+ public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
+ if (openPostingsLocalizer==null) {
+ openPostingsLocalizer = localizer.openPostings();
+ }
+
+ return openPostingsLocalizer;
+ }
+
+ public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
+ if (producerAssistantLocalizer==null) {
+ producerAssistantLocalizer = localizer.producerAssistant();
+ }
+
+ return producerAssistantLocalizer;
+ }
+
+ public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
+ if (dataModelLocalizer==null) {
+ dataModelLocalizer = new MirCachingDatamodelLocalizer(localizer.dataModel());
+ }
+
+ return dataModelLocalizer;
+ }
+
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
+ if (adminInterfaceLocalizer==null) {
+ adminInterfaceLocalizer = localizer.adminInterface();
+ }
+
+ return adminInterfaceLocalizer;
+ };
+
+ public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {
+ if (mediaLocalizer==null) {
+ mediaLocalizer = localizer.media();
+ }
+
+ return mediaLocalizer;
+ }
+
+ private static class MirCachingDatamodelLocalizer implements MirDataModelLocalizer {
+ private MirDataModelLocalizer master;
+ private EntityAdapterModel adapterModel;
+
+ public MirCachingDatamodelLocalizer(MirDataModelLocalizer aMaster) {
+ master = aMaster;
+ adapterModel = null;
+ }
+
+ public EntityAdapterModel adapterModel() throws MirLocalizerExc, MirLocalizerFailure {
+ if (adapterModel==null) {
+ adapterModel = master.adapterModel();
+ }
+
+ return adapterModel;
+ };
+
+ }
+
+ private static class MirCachingGeneratorLocalizer implements MirGeneratorLocalizer {
+ private MirGeneratorLocalizer master;
+ private WriterEngine writerEngine;
+ private Generator.GeneratorLibrary producerGeneratorLibrary;
+ private Generator.GeneratorLibrary adminGeneratorLibrary;
+ private Generator.GeneratorLibrary openPostingGeneratorLibrary;
+
+ public MirCachingGeneratorLocalizer(MirGeneratorLocalizer aMaster) {
+ master = aMaster;
+ }
+
+ public WriterEngine makeWriterEngine() throws MirLocalizerExc, MirLocalizerFailure {
+ if (writerEngine==null) {
+ writerEngine = master.makeWriterEngine();
+ }
+
+ return writerEngine;
+ };
+
+ public Generator.GeneratorLibrary makeProducerGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+ if (producerGeneratorLibrary==null) {
+ producerGeneratorLibrary = master.makeProducerGeneratorLibrary();
+ }
+
+ return producerGeneratorLibrary;
+ };
+
+ public Generator.GeneratorLibrary makeAdminGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+ if (adminGeneratorLibrary==null) {
+ adminGeneratorLibrary = master.makeAdminGeneratorLibrary();
+ }
+
+ return adminGeneratorLibrary;
+ };
+
+ public Generator.GeneratorLibrary makeOpenPostingGeneratorLibrary() throws MirLocalizerExc, MirLocalizerFailure {
+ if (openPostingGeneratorLibrary==null) {
+ openPostingGeneratorLibrary = master.makeOpenPostingGeneratorLibrary();
+ }
+
+ return openPostingGeneratorLibrary;
+ };
+ }
+
}
\ No newline at end of file
addSimpleCommentOperation(new ModifyCommentFieldOperation("hide", "is_published", "0"));
}
+ public String getAdminPageGenerator(String aPage, Map aTemplateData, EntityAdapter aUser, String aDefault) {
+ return aDefault;
+ }
+
public String makePasswordDigest(String aPassword) {
return aPassword;
}
protected abstract static class EntityModifyingOperation implements MirSimpleEntityOperation {
private String name;
+ private boolean logOperation;
- protected EntityModifyingOperation(String aName) {
+ protected EntityModifyingOperation(String aName, boolean aLogOperation) {
name = aName;
+ logOperation = aLogOperation;
}
public String getName() {
Entity entity = anEntity.getEntity();
try {
performModification(aUser, entity);
+
+ if (logOperation) {
+ try {
+ StringBuffer line = new StringBuffer();
+
+ line.append(DateTimeFunctions.advancedDateFormat(
+ MirGlobal.config().getString("Mir.DefaultDateTimeFormat"),
+ (new GregorianCalendar()).getTime(),
+ MirGlobal.config().getString("Mir.DefaultTimezone")));
+ line.append(" ");
+ if (aUser != null)
+ line.append(aUser.get("login"));
+ else
+ line.append("unknown");
+
+ line.append(" ");
+ line.append(getName());
+ entity.appendLineToField("comment", line.toString());
+ }
+ catch (Throwable t) {
+ logger.error("Error while trying to log an article operation: " + t.toString());
+ }
+ }
+
entity.update();
}
catch (Throwable t) {
}
public static abstract class CommentModifyingOperation extends EntityModifyingOperation {
+ public CommentModifyingOperation(String aName, boolean aLogOperation) {
+ super(aName, aLogOperation);
+ }
+
public CommentModifyingOperation(String aName) {
- super(aName);
+ this(aName, true);
}
protected boolean isAvailable(Entity anEntity) throws StorageObjectFailure {
}
public static abstract class ArticleModifyingOperation extends EntityModifyingOperation {
- private boolean logOperation;
-
public ArticleModifyingOperation(String aName, boolean aLogOperation) {
- super(aName);
-
- logOperation = aLogOperation;
+ super(aName, aLogOperation);
}
protected boolean isAvailable(Entity anEntity) throws StorageObjectFailure {
protected void performModification(EntityAdapter aUser, Entity anEntity) throws StorageObjectFailure {
performModification(aUser, (EntityContent) anEntity);
anEntity.setValueForProperty("is_produced", "0");
-
- if (logOperation) {
- try {
- StringBuffer line = new StringBuffer();
-
- line.append(DateTimeFunctions.advancedDateFormat(
- MirGlobal.config().getString("Mir.DefaultDateTimeFormat"),
- (new GregorianCalendar()).getTime(),
- MirGlobal.config().getString("Mir.DefaultTimezone")));
- line.append(" ");
- if (aUser != null)
- line.append(aUser.get("login"));
- else
- line.append("unknown");
-
- line.append(" ");
- line.append(getName());
- ( (EntityContent) anEntity).appendToComments(line.toString());
- }
- catch (Throwable t) {
- logger.error("Error while trying to log an article operation: " + t.toString());
- }
- }
};
protected abstract boolean isAvailable(EntityContent anArticle) throws StorageObjectFailure ;
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.localizer.basic;\r
-\r
-import mir.session.Request;\r
-import mir.session.Session;\r
-import mir.session.SessionExc;\r
-import mir.session.SessionFailure;\r
-import mircoders.entity.EntityContent;\r
-\r
-\r
-public class MirBasicChildArticlePostingHandler extends MirBasicArticlePostingHandler {\r
- public MirBasicChildArticlePostingHandler() {\r
- super();\r
-\r
- setNormalResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));\r
- }\r
-\r
- public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {\r
- super.finalizeArticle(aRequest, aSession, anArticle);\r
-\r
- anArticle.setValueForProperty("to_content", (String) aSession.getAttribute("to_content"));\r
- }\r
-\r
- protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
- super.initializeSession(aRequest, aSession);\r
-\r
- String parentId = aRequest.getParameter("to_content");\r
- if (parentId==null)\r
- throw new SessionExc("initializeSession: parent id not set!");\r
-\r
- aSession.setAttribute("to_content", parentId);\r
- };\r
+/*
+ * 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 mir.session.Request;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mircoders.entity.EntityContent;
+
+
+public class MirBasicChildArticlePostingHandler extends MirBasicArticlePostingHandler {
+ public MirBasicChildArticlePostingHandler() {
+ super();
+
+ setNormalResponseGenerator(configuration.getString("Localizer.OpenSession.article.EditTemplate"));
+ }
+
+ public void finalizeArticle(Request aRequest, Session aSession, EntityContent anArticle) throws SessionExc, SessionFailure {
+ super.finalizeArticle(aRequest, aSession, anArticle);
+
+ anArticle.setValueForProperty("to_content", (String) aSession.getAttribute("to_content"));
+ }
+
+ protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+ super.initializeSession(aRequest, aSession);
+
+ String parentId = aRequest.getParameter("to_content");
+ if (parentId==null)
+ throw new SessionExc("initializeSession: parent id not set!");
+
+ aSession.setAttribute("to_content", parentId);
+ };
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer.basic;\r
-\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.session.Request;\r
-import mir.session.Response;\r
-import mir.session.Session;\r
-import mir.session.SessionExc;\r
-import mir.session.SessionFailure;\r
-import mir.session.UploadedFile;\r
-import mir.session.ValidationHelper;\r
-import mircoders.entity.EntityComment;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.media.MediaUploadProcessor;\r
-import mircoders.module.ModuleComment;\r
-import mircoders.module.ModuleCommentStatus;\r
-import mircoders.module.ModuleMediafolder;\r
-import mircoders.storage.DatabaseComment;\r
-import mircoders.storage.DatabaseCommentStatus;\r
-import mircoders.storage.DatabaseCommentToMedia;\r
-import mircoders.storage.DatabaseContent;\r
-import mircoders.storage.DatabaseMediafolder;\r
-\r
-/**\r
- *\r
- * <p>Title: Experimental session handler for comment postings </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author Zapata\r
- * @version 1.0\r
- */\r
-\r
-public class MirBasicCommentPostingHandler extends MirBasicPostingSessionHandler {\r
- protected ModuleComment commentModule = new ModuleComment(DatabaseComment.getInstance());\r
- protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();\r
-\r
-\r
- public MirBasicCommentPostingHandler() {\r
- super();\r
-\r
- setResponseGenerators(\r
- configuration.getString("Localizer.OpenSession.comment.EditTemplate"),\r
- configuration.getString("Localizer.OpenSession.comment.DupeTemplate"),\r
- configuration.getString("Localizer.OpenSession.comment.UnsupportedMediaTemplate"),\r
- configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));\r
- }\r
-\r
- protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {\r
- super.initializeResponseData(aRequest, aSession, aResponse);\r
-\r
- Iterator i = DatabaseComment.getInstance().getFields().iterator();\r
- while (i.hasNext()) {\r
- String field = (String) i.next();\r
- aResponse.setResponseValue(field, aRequest.getParameter(field));\r
- }\r
- }\r
-\r
- public void validate(List aResults, Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
- super.validate(aResults, aRequest, aSession);\r
-\r
- ValidationHelper.testFieldEntered(aRequest, "title", "validationerror.missing", aResults);\r
- ValidationHelper.testFieldEntered(aRequest, "description", "validationerror.missing", aResults);\r
- ValidationHelper.testFieldEntered(aRequest, "creator", "validationerror.missing", aResults);\r
- }\r
-\r
- protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
- super.initializeSession(aRequest, aSession);\r
-\r
- String articleId = aRequest.getParameter("to_media");\r
- if (articleId==null)\r
- throw new SessionExc("initializeSession: article id not set!");\r
-\r
- aSession.setAttribute("to_media", articleId);\r
- };\r
-\r
- public void finalizeComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {\r
- try {\r
- aComment.setValueForProperty("is_published", "1");\r
- ModuleCommentStatus module = new ModuleCommentStatus(DatabaseCommentStatus.getInstance());\r
- aComment.setValueForProperty("to_comment_status", module.commentStatusIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultCommentStatus")));\r
- aComment.setValueForProperty("is_html", "0");\r
- aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));\r
- }\r
- catch (Throwable t) {\r
- throw new SessionFailure(t);\r
- }\r
- }\r
-\r
- public void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
- try {\r
- String id;\r
- Map values = getIntersectingValues(aRequest, DatabaseComment.getInstance());\r
-\r
- EntityComment comment = (EntityComment) commentModule.createNew();\r
- comment.setValues(values);\r
- finalizeComment(aRequest, aSession, comment);\r
- id = comment.insert();\r
- if (id == null) {\r
- logger.info("Duplicate comment rejected");\r
- throw new DuplicateCommentExc("Duplicate comment rejected");\r
- }\r
- aSession.setAttribute("comment", comment);\r
- }\r
- catch (Throwable t) {\r
- throw new SessionFailure(t);\r
- }\r
- }\r
-\r
- public void processUploadedFile(Request aRequest, Session aSession, UploadedFile aFile) throws SessionExc, SessionFailure {\r
- try {\r
- Map values = new HashMap();\r
- values.put("title", aRequest.getParameter(aFile.getFieldName()+"_title"));\r
- values.put("creator", aRequest.getParameter("creator"));\r
- values.put("to_publisher", "0");\r
- values.put("is_published", "1");\r
- ModuleMediafolder module = new ModuleMediafolder(DatabaseMediafolder.getInstance());\r
- values.put("to_media_folder", module.mediaFolderIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultMediaFolder")));\r
-\r
- Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, values);\r
- mediaItem.update();\r
- commentToMedia.addMedia(((EntityComment) aSession.getAttribute("comment")).getId(), mediaItem.getId());\r
- }\r
- catch (Throwable t) {\r
- throw new SessionFailure(t);\r
- }\r
- }\r
-\r
- public void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {\r
- EntityComment comment = (EntityComment) aSession.getAttribute("comment");\r
-\r
- MirGlobal.abuse().checkComment(comment, aRequest, null);\r
- try {\r
- MirGlobal.localizer().openPostings().afterCommentPosting(comment);\r
- }\r
- catch (Throwable t) {\r
- throw new SessionFailure(t);\r
- }\r
- DatabaseContent.getInstance().setUnproduced("id=" + comment.getValue("to_media"));\r
- logger.info("Comment posted");\r
- };\r
-\r
- protected static class DuplicateCommentExc extends SessionExc {\r
- public DuplicateCommentExc(String aMessage) {\r
- super(aMessage);\r
- }\r
- }\r
-}\r
+/*
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.session.Request;
+import mir.session.Response;
+import mir.session.Session;
+import mir.session.SessionExc;
+import mir.session.SessionFailure;
+import mir.session.UploadedFile;
+import mir.session.ValidationHelper;
+import mircoders.entity.EntityComment;
+import mircoders.global.MirGlobal;
+import mircoders.media.MediaUploadProcessor;
+import mircoders.module.ModuleComment;
+import mircoders.module.ModuleCommentStatus;
+import mircoders.module.ModuleMediafolder;
+import mircoders.storage.DatabaseComment;
+import mircoders.storage.DatabaseCommentStatus;
+import mircoders.storage.DatabaseCommentToMedia;
+import mircoders.storage.DatabaseContent;
+import mircoders.storage.DatabaseMediafolder;
+
+/**
+ *
+ * <p>Title: Experimental session handler for comment postings </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author Zapata
+ * @version 1.0
+ */
+
+public class MirBasicCommentPostingHandler extends MirBasicPostingSessionHandler {
+ protected ModuleComment commentModule = new ModuleComment(DatabaseComment.getInstance());
+ protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance();
+
+
+ public MirBasicCommentPostingHandler() {
+ super();
+
+ setResponseGenerators(
+ configuration.getString("Localizer.OpenSession.comment.EditTemplate"),
+ configuration.getString("Localizer.OpenSession.comment.DupeTemplate"),
+ configuration.getString("Localizer.OpenSession.comment.UnsupportedMediaTemplate"),
+ configuration.getString("Localizer.OpenSession.comment.DoneTemplate"));
+ }
+
+ protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure {
+ super.initializeResponseData(aRequest, aSession, aResponse);
+
+ Iterator i = DatabaseComment.getInstance().getFields().iterator();
+ while (i.hasNext()) {
+ String field = (String) i.next();
+ aResponse.setResponseValue(field, aRequest.getParameter(field));
+ }
+ }
+
+ public void validate(List aResults, Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+ super.validate(aResults, aRequest, aSession);
+
+ ValidationHelper.testFieldEntered(aRequest, "title", "validationerror.missing", aResults);
+ ValidationHelper.testFieldEntered(aRequest, "description", "validationerror.missing", aResults);
+ ValidationHelper.testFieldEntered(aRequest, "creator", "validationerror.missing", aResults);
+ }
+
+ protected void initializeSession(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+ super.initializeSession(aRequest, aSession);
+
+ String articleId = aRequest.getParameter("to_media");
+ if (articleId==null)
+ throw new SessionExc("initializeSession: article id not set!");
+
+ aSession.setAttribute("to_media", articleId);
+ };
+
+ public void finalizeComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure {
+ try {
+ aComment.setValueForProperty("is_published", "1");
+ ModuleCommentStatus module = new ModuleCommentStatus(DatabaseCommentStatus.getInstance());
+ aComment.setValueForProperty("to_comment_status", module.commentStatusIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultCommentStatus")));
+ aComment.setValueForProperty("is_html", "0");
+ aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media"));
+ }
+ catch (Throwable t) {
+ throw new SessionFailure(t);
+ }
+ }
+
+ public void preProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+ try {
+ String id;
+ Map values = getIntersectingValues(aRequest, DatabaseComment.getInstance());
+
+ EntityComment comment = (EntityComment) commentModule.createNew();
+ comment.setValues(values);
+ finalizeComment(aRequest, aSession, comment);
+ id = comment.insert();
+ if (id == null) {
+ logger.info("Duplicate comment rejected");
+ throw new DuplicateCommentExc("Duplicate comment rejected");
+ }
+ aSession.setAttribute("comment", comment);
+ }
+ catch (Throwable t) {
+ throw new SessionFailure(t);
+ }
+ }
+
+ public void processUploadedFile(Request aRequest, Session aSession, UploadedFile aFile) throws SessionExc, SessionFailure {
+ try {
+ Map values = new HashMap();
+ values.put("title", aRequest.getParameter(aFile.getFieldName()+"_title"));
+ values.put("creator", aRequest.getParameter("creator"));
+ values.put("to_publisher", "0");
+ values.put("is_published", "1");
+ ModuleMediafolder module = new ModuleMediafolder(DatabaseMediafolder.getInstance());
+ values.put("to_media_folder", module.mediaFolderIdForName(configuration.getString("Localizer.OpenSession.comment.DefaultMediaFolder")));
+
+ Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, values);
+ mediaItem.update();
+ commentToMedia.addMedia(((EntityComment) aSession.getAttribute("comment")).getId(), mediaItem.getId());
+ }
+ catch (Throwable t) {
+ throw new SessionFailure(t);
+ }
+ }
+
+ public void postProcessRequest(Request aRequest, Session aSession) throws SessionExc, SessionFailure {
+ EntityComment comment = (EntityComment) aSession.getAttribute("comment");
+
+ MirGlobal.abuse().checkComment(comment, aRequest, null);
+ try {
+ MirGlobal.localizer().openPostings().afterCommentPosting(comment);
+ }
+ catch (Throwable t) {
+ throw new SessionFailure(t);
+ }
+ DatabaseContent.getInstance().setUnproduced("id=" + comment.getValue("to_media"));
+ logger.info("Comment posted");
+ };
+
+ protected static class DuplicateCommentExc extends SessionExc {
+ public DuplicateCommentExc(String aMessage) {
+ super(aMessage);
+ }
+ }
+}
import mir.entity.adapter.EntityAdapterDefinition;\r
import mir.entity.adapter.EntityAdapterModel;\r
import mir.log.LoggerWrapper;\r
-import mircoders.media.MediaHelper;\r
-import mir.misc.NumberUtils;\r
import mir.media.MediaHandler;\r
+import mir.misc.NumberUtils;\r
import mir.util.ParameterExpander;\r
import mir.util.RewindableIterator;\r
import mir.util.StructuredContentParser;\r
import mircoders.localizer.MirDataModelLocalizer;\r
import mircoders.localizer.MirLocalizerExc;\r
import mircoders.localizer.MirLocalizerFailure;\r
+import mircoders.media.MediaHelper;\r
+import mircoders.module.ModuleContent;\r
import mircoders.storage.DatabaseArticleType;\r
import mircoders.storage.DatabaseAudio;\r
import mircoders.storage.DatabaseBreaking;\r
anEntityAdapterDefinition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
anEntityAdapterDefinition.addDBDateField("changedate", "webdb_lastchange", configuration.getString("Mir.DefaultTimezone"));\r
anEntityAdapterDefinition.addMirDateField("date", "date", configuration.getString("Mir.DefaultTimezone"));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("lockinguser", new ContentToUserField("to_locking_user"));\r
+ anEntityAdapterDefinition.addCalculatedField("is_locked", new ContentToIsLockedField());\r
+\r
anEntityAdapterDefinition.addCalculatedField("to_topics", new ContentToTopicsField());\r
anEntityAdapterDefinition.addCalculatedField("to_comments", new ContentToCommentsField());\r
anEntityAdapterDefinition.addCalculatedField("language", new ContentToLanguageField());\r
result.addMapping( "language", DatabaseLanguage.getInstance(), new EntityAdapterDefinition());\r
result.addMapping( "mediaType", DatabaseMediaType.getInstance(), new EntityAdapterDefinition());\r
result.addMapping( "topic", DatabaseTopics.getInstance(), new EntityAdapterDefinition());\r
- result.addMapping( "user", DatabaseUsers.getInstance(), new EntityAdapterDefinition());\r
+\r
+ definition = new EntityAdapterDefinition();\r
+ definition.addDBDateField("creationdate", "webdb_create", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addDBDateField("lastlogindate", "lastlogin", configuration.getString("Mir.DefaultTimezone"));\r
+ definition.addCalculatedField("structuredProfile", new StructuredContentField("profile"));\r
+ result.addMapping( "user", DatabaseUsers.getInstance(), definition);\r
+\r
result.addMapping( "otherMedia", DatabaseOther.getInstance(), new EntityAdapterDefinition());\r
\r
result.addMapping( "content_x_topic", DatabaseContentToTopics.getInstance(), new EntityAdapterDefinition());\r
}\r
}\r
}\r
-}\r
-\r
+ protected class ContentToUserField implements EntityAdapterDefinition.CalculatedField {\r
+ /**\r
+ *\r
+ * @param aFieldName the source field. will be mapped to the id field in the user\r
+ * table\r
+ */\r
+ private String fieldName;\r
\r
-/*\r
- public String getValue(String key) {\r
- String returnValue = null;\r
-\r
- if (key != null) {\r
- if (key.equals("big_icon"))\r
- returnValue = getBigIconName();\r
- else if (key.equals("descr") || key.equals("media_descr"))\r
- returnValue = getDescr();\r
- else if (key.equals("mediatype"))\r
- returnValue = getMediaTypeString();\r
- else if (key.equals("mimetype"))\r
- returnValue = getMimeType();\r
- else\r
- returnValue = super.getValue(key);\r
+ public ContentToUserField(String aFieldName) {\r
+ fieldName = aFieldName;\r
}\r
- return returnValue;\r
- }\r
-\r
- // @todo all these methods should be merged into 1\r
- // and the MediaHandler should be cached somehow.\r
- private String getMediaTypeString() {\r
- if (this instanceof EntityImages)\r
- return "image";\r
- if (this instanceof EntityAudio)\r
- return "audio";\r
- if (this instanceof EntityVideo)\r
- return "video";\r
- else\r
- return "other";\r
- }\r
-\r
-private String getBigIconName() {\r
- MediaHandler mediaHandler = null;\r
- Entity mediaType = null;\r
-\r
- try {\r
- mediaType = getMediaType();\r
- mediaHandler = MediaHelper.getHandler(mediaType);\r
- return mediaHandler.getBigIconName();\r
- }\r
- catch (Exception ex) {\r
- logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
- }\r
- return null;\r
-}\r
\r
-private List getUrl() {\r
- MediaHandler mediaHandler = null;\r
- Entity mediaType = null;\r
-\r
- try {\r
- mediaType = getMediaType();\r
- mediaHandler = MediaHelper.getHandler(mediaType);\r
- return mediaHandler.getURL(this, mediaType);\r
- }\r
- catch (Throwable t) {\r
- logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + t.toString());\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return anEntityAdapter.getToOneRelation(\r
+ "id=" + anEntityAdapter.get(fieldName),\r
+ "id",\r
+ "user");\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
}\r
- return null;\r
-}\r
\r
-private String getDescr() {\r
- MediaHandler mediaHandler = null;\r
- Entity mediaType = null;\r
+ protected class ContentToIsLockedField implements EntityAdapterDefinition.CalculatedField {\r
+ private ModuleContent contentModule;\r
\r
- try {\r
- mediaType = getMediaType();\r
- mediaHandler = MediaHelper.getHandler(mediaType);\r
- return mediaHandler.getDescr(mediaType);\r
- }\r
- catch (Exception ex) {\r
- logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());\r
- }\r
- return null;\r
-}\r
-private String getMimeType() {\r
- Entity mediaType = null;\r
+ public ContentToIsLockedField() {\r
+ contentModule = new ModuleContent(DatabaseContent.getInstance());\r
+ }\r
\r
- try {\r
- mediaType = getMediaType();\r
- return mediaType.getValue("mime_type");\r
- }\r
- catch (Exception ex) {\r
- logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());\r
+ public Object getValue(EntityAdapter anEntityAdapter) {\r
+ try {\r
+ return new Boolean(contentModule.queryArticleLock(anEntityAdapter.getEntity().getId())!=null);\r
+ }\r
+ catch (Throwable t) {\r
+ throw new RuntimeException(t.getMessage());\r
+ }\r
+ }\r
}\r
- return null;\r
}\r
-*/
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer.basic;\r
-\r
-import mircoders.localizer.MirAdminInterfaceLocalizer;\r
-import mircoders.localizer.MirDataModelLocalizer;\r
-import mircoders.localizer.MirGeneratorLocalizer;\r
-import mircoders.localizer.MirLocalizer;\r
-import mircoders.localizer.MirLocalizerExc;\r
-import mircoders.localizer.MirLocalizerFailure;\r
-import mircoders.localizer.MirOpenPostingLocalizer;\r
-import mircoders.localizer.MirProducerAssistantLocalizer;\r
-import mircoders.localizer.MirProducerLocalizer;\r
-import mircoders.localizer.MirMediaLocalizer;\r
-\r
-public class MirBasicLocalizer implements MirLocalizer {\r
-\r
- public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicProducerLocalizer();\r
- }\r
-\r
- public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicGeneratorLocalizer();\r
- }\r
-\r
- public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicOpenPostingLocalizer();\r
- }\r
-\r
- public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicProducerAssistantLocalizer();\r
- }\r
-\r
- public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicDataModelLocalizer();\r
- };\r
-\r
- public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicAdminInterfaceLocalizer();\r
- }\r
-\r
- public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {\r
- return new MirBasicMediaLocalizer();\r
- }\r
+/*
+ * 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 mircoders.localizer.MirAdminInterfaceLocalizer;
+import mircoders.localizer.MirDataModelLocalizer;
+import mircoders.localizer.MirGeneratorLocalizer;
+import mircoders.localizer.MirLocalizer;
+import mircoders.localizer.MirLocalizerExc;
+import mircoders.localizer.MirLocalizerFailure;
+import mircoders.localizer.MirOpenPostingLocalizer;
+import mircoders.localizer.MirProducerAssistantLocalizer;
+import mircoders.localizer.MirProducerLocalizer;
+import mircoders.localizer.MirMediaLocalizer;
+
+public class MirBasicLocalizer implements MirLocalizer {
+
+ public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicProducerLocalizer();
+ }
+
+ public MirGeneratorLocalizer generators() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicGeneratorLocalizer();
+ }
+
+ public MirOpenPostingLocalizer openPostings() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicOpenPostingLocalizer();
+ }
+
+ public MirProducerAssistantLocalizer producerAssistant() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicProducerAssistantLocalizer();
+ }
+
+ public MirDataModelLocalizer dataModel() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicDataModelLocalizer();
+ };
+
+ public MirAdminInterfaceLocalizer adminInterface() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicAdminInterfaceLocalizer();
+ }
+
+ public MirMediaLocalizer media() throws MirLocalizerFailure, MirLocalizerExc {
+ return new MirBasicMediaLocalizer();
+ }
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer.basic;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import mir.media.MediaHandler;\r
-import mir.config.*;\r
-import mircoders.localizer.MirLocalizerExc;\r
-import mircoders.localizer.MirLocalizerFailure;\r
-import mircoders.localizer.MirMediaLocalizer;\r
-import mircoders.media.*;\r
-\r
-/**\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class MirBasicMediaLocalizer implements MirMediaLocalizer {\r
- private Map mediaHandlers;\r
-\r
- /**\r
- *\r
- * @throws MirLocalizerExc\r
- * @throws MirLocalizerFailure\r
- */\r
- public MirBasicMediaLocalizer() throws MirLocalizerExc, MirLocalizerFailure {\r
- MirPropertiesConfiguration configuration;\r
-\r
- try {\r
- configuration = MirPropertiesConfiguration.instance();\r
- }\r
- catch (Throwable t) {\r
- throw new MirLocalizerFailure("Can't get configuration", t);\r
- }\r
-\r
- mediaHandlers = new HashMap();\r
-\r
-\r
- registerMediaHandler("Audio", new MediaHandlerAudio());\r
- registerMediaHandler("Generic", new MediaHandlerGeneric());\r
- registerMediaHandler("ImagesExtern", new MediaHandlerImagesExtern());\r
- registerMediaHandler("ImagesJpeg", new MediaHandlerImagesJpeg());\r
- registerMediaHandler("ImagesPng", new MediaHandlerImagesPng());\r
- registerMediaHandler("Mp3", new MediaHandlerMp3());\r
- registerMediaHandler("Ogg", new MediaHandlerOgg());\r
- registerMediaHandler("RealAudio", new MediaHandlerRealAudio());\r
- registerMediaHandler("RealVideo", new MediaHandlerRealVideo());\r
- registerMediaHandler("Video", new MediaHandlerVideo());\r
-\r
- registerMediaHandler("VideoUrl", new URLMediaHandler(\r
- configuration.getString("Producer.Icon.BigVideo"),\r
- configuration.getString("Producer.Icon.TinyVideo"),\r
- "Video Url"));\r
-\r
- registerMediaHandler("AudioUrl", new URLMediaHandler(\r
- configuration.getString("Producer.Icon.BigAudio"),\r
- configuration.getString("Producer.Icon.TinyAudio"),\r
- "Audio Url"));\r
-\r
- registerMediaHandler("ImageUrl", new URLMediaHandler(\r
- configuration.getString("Producer.Icon.BigImage"),\r
- configuration.getString("Producer.Icon.TinyImage"),\r
- "Image Url"));\r
-\r
- registerMediaHandler("OtherUrl", new URLMediaHandler(\r
- configuration.getString("Producer.Icon.BigAudio"),\r
- configuration.getString("Producer.Icon.TinyAudio"),\r
- "Url"));\r
- }\r
-\r
- /** returns the {@link MediaHandler} associated with name <code>aName</code> by way of\r
- * an internal <code>Map</code>. This <code>Map</code> can be manipulated by calling\r
- * <code>registerMediaHandler</code> and <code>unregisterMediaHandler</code>\r
- */\r
- public MediaHandler getHandler(String aName) {\r
- synchronized (mediaHandlers) {\r
- return (MediaHandler) mediaHandlers.get(aName);\r
- }\r
- }\r
-\r
- /** adds a media handler to the registry */\r
- public void registerMediaHandler(String aName, MediaHandler aHandler) {\r
- synchronized (mediaHandlers) {\r
- mediaHandlers.put(aName, aHandler);\r
- }\r
- }\r
-\r
- /** removes a media handler from the registry*/\r
- public void unregisterMediaHandler(String aName) {\r
- synchronized (mediaHandlers) {\r
- mediaHandlers.remove(aName);\r
- }\r
- }\r
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import mir.media.MediaHandler;
+import mir.config.*;
+import mircoders.localizer.MirLocalizerExc;
+import mircoders.localizer.MirLocalizerFailure;
+import mircoders.localizer.MirMediaLocalizer;
+import mircoders.media.*;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class MirBasicMediaLocalizer implements MirMediaLocalizer {
+ private Map mediaHandlers;
+
+ /**
+ *
+ * @throws MirLocalizerExc
+ * @throws MirLocalizerFailure
+ */
+ public MirBasicMediaLocalizer() throws MirLocalizerExc, MirLocalizerFailure {
+ MirPropertiesConfiguration configuration;
+
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+ }
+ catch (Throwable t) {
+ throw new MirLocalizerFailure("Can't get configuration", t);
+ }
+
+ mediaHandlers = new HashMap();
+
+
+ registerMediaHandler("Audio", new MediaHandlerAudio());
+ registerMediaHandler("Generic", new MediaHandlerGeneric());
+ registerMediaHandler("ImagesExtern", new MediaHandlerImagesExtern());
+ registerMediaHandler("ImagesJpeg", new MediaHandlerImagesJpeg());
+ registerMediaHandler("ImagesPng", new MediaHandlerImagesPng());
+ registerMediaHandler("Mp3", new MediaHandlerMp3());
+ registerMediaHandler("Ogg", new MediaHandlerOgg());
+ registerMediaHandler("RealAudio", new MediaHandlerRealAudio());
+ registerMediaHandler("RealVideo", new MediaHandlerRealVideo());
+ registerMediaHandler("Video", new MediaHandlerVideo());
+
+ registerMediaHandler("VideoUrl", new URLMediaHandler(
+ configuration.getString("Producer.Icon.BigVideo"),
+ configuration.getString("Producer.Icon.TinyVideo"),
+ "Video Url"));
+
+ registerMediaHandler("AudioUrl", new URLMediaHandler(
+ configuration.getString("Producer.Icon.BigAudio"),
+ configuration.getString("Producer.Icon.TinyAudio"),
+ "Audio Url"));
+
+ registerMediaHandler("ImageUrl", new URLMediaHandler(
+ configuration.getString("Producer.Icon.BigImage"),
+ configuration.getString("Producer.Icon.TinyImage"),
+ "Image Url"));
+
+ registerMediaHandler("OtherUrl", new URLMediaHandler(
+ configuration.getString("Producer.Icon.BigAudio"),
+ configuration.getString("Producer.Icon.TinyAudio"),
+ "Url"));
+ }
+
+ /** returns the {@link MediaHandler} associated with name <code>aName</code> by way of
+ * an internal <code>Map</code>. This <code>Map</code> can be manipulated by calling
+ * <code>registerMediaHandler</code> and <code>unregisterMediaHandler</code>
+ */
+ public MediaHandler getHandler(String aName) {
+ synchronized (mediaHandlers) {
+ return (MediaHandler) mediaHandlers.get(aName);
+ }
+ }
+
+ /** adds a media handler to the registry */
+ public void registerMediaHandler(String aName, MediaHandler aHandler) {
+ synchronized (mediaHandlers) {
+ mediaHandlers.put(aName, aHandler);
+ }
+ }
+
+ /** removes a media handler from the registry*/
+ public void unregisterMediaHandler(String aName) {
+ synchronized (mediaHandlers) {
+ mediaHandlers.remove(aName);
+ }
+ }
}
\ No newline at end of file
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.localizer.basic;\r
-\r
-import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.entity.adapter.EntityAdapter;\r
-import mir.entity.adapter.EntityIteratorAdapter;\r
-import mir.log.LoggerWrapper;\r
-import mir.misc.StringUtil;\r
-import mir.util.GeneratorDateTimeFunctions;\r
-import mir.util.GeneratorExpressionFunctions;\r
-import mir.util.GeneratorFormatAdapters;\r
-import mir.util.GeneratorHTMLFunctions;\r
-import mir.util.GeneratorIntegerFunctions;\r
-import mir.util.GeneratorListFunctions;\r
-import mir.util.GeneratorRegularExpressionFunctions;\r
-import mir.util.GeneratorStringFunctions;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.localizer.MirLocalizerExc;\r
-import mircoders.localizer.MirLocalizerFailure;\r
-import mircoders.localizer.MirProducerAssistantLocalizer;\r
-\r
-public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {\r
- protected LoggerWrapper logger;\r
-\r
- public void initializeGenerationValueSet(Map aValueSet) throws MirLocalizerExc, MirLocalizerFailure {\r
- try {\r
- Iterator i;\r
-\r
- Map configMap = new HashMap();\r
- Map utilityMap = new HashMap();\r
-\r
- logger = new LoggerWrapper("Localizer.ProducerAssistant");\r
-\r
-// obsolete:\r
- configMap.put("producerDocRoot", MirGlobal.config().getString("Producer.DocRoot"));\r
- configMap.put("storageRoot", MirGlobal.config().getString("Producer.StorageRoot"));\r
- configMap.put("productionHost", MirGlobal.config().getString("Producer.ProductionHost"));\r
- configMap.put("openAction", MirGlobal.config().getString("Producer.OpenAction"));\r
- configMap.put("docRoot", MirGlobal.config().getString("RootUri"));\r
- configMap.put("actionRoot", MirGlobal.config().getString("RootUri") + "/servlet/Mir");\r
- configMap.put("now", new GeneratorFormatAdapters.DateFormatAdapter(new GregorianCalendar().getTime(), MirGlobal.config().getString("Mir.DefaultTimezone")));\r
- configMap.put("videoHost", MirGlobal.config().getString("Producer.Video.Host"));\r
- configMap.put("audioHost", MirGlobal.config().getString("Producer.Audio.Host"));\r
- configMap.put("imageHost", MirGlobal.config().getString("Producer.Image.Host"));\r
- configMap.put("imagePath", MirGlobal.config().getString("Producer.Image.Path"));\r
- configMap.put("mirVersion", MirGlobal.config().getString("Mir.Version"));\r
- configMap.put("defEncoding", MirGlobal.config().getString("Mir.DefaultEncoding"));\r
-\r
-// "new":\r
- configMap.putAll(MirPropertiesConfiguration.instance().allSettings());\r
-\r
- utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace());\r
- utilityMap.put("encodeHTML", new GeneratorHTMLFunctions.encodeHTMLGeneratorFunction());\r
- utilityMap.put("prettyEncodeHTML", new GeneratorHTMLFunctions.prettyEncodeHTMLGeneratorFunction());\r
- utilityMap.put("encodeXML", new GeneratorHTMLFunctions.encodeXMLGeneratorFunction());\r
- utilityMap.put("encodeURI", new GeneratorHTMLFunctions.encodeURIGeneratorFunction());\r
- utilityMap.put("subString", new GeneratorStringFunctions.subStringFunction());\r
- utilityMap.put("subList", new GeneratorListFunctions.subListFunction());\r
- utilityMap.put("isOdd", new GeneratorIntegerFunctions.isOddFunction());\r
- utilityMap.put("increment", new GeneratorIntegerFunctions.incrementFunction());\r
- utilityMap.put("evaluate", new GeneratorExpressionFunctions.evaluateExpressionFunction());\r
- utilityMap.put("constructString", new GeneratorStringFunctions.constructStructuredStringFunction());\r
- utilityMap.put("parseStructuredString", new GeneratorStringFunctions.structuredStringParserFunction());\r
- utilityMap.put("escapeJDBCString", new GeneratorStringFunctions.jdbcStringEscapeFunction());\r
- utilityMap.put("regexpreplace", new GeneratorRegularExpressionFunctions.regularExpressionReplaceFunction());\r
- utilityMap.put("regexpmatch", new GeneratorRegularExpressionFunctions.regularExpressionMatchFunction());\r
- utilityMap.put("datetime", new GeneratorDateTimeFunctions.DateTimeFunctions(\r
- MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));\r
-\r
- aValueSet.put("config", configMap);\r
- aValueSet.put("utility", utilityMap);\r
-\r
- aValueSet.put("languages",\r
- new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "language"));\r
-\r
- aValueSet.put("topics",\r
- new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));\r
-\r
- Map articleTypeMap = new HashMap();\r
- articleTypeMap.put("openposting", "0");\r
- articleTypeMap.put("newswire", "1");\r
- articleTypeMap.put("feature", "2");\r
- articleTypeMap.put("topicspecial", "3");\r
- articleTypeMap.put("startspecial", "4");\r
-\r
- i = new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "articleType");\r
- while (i.hasNext()) {\r
- EntityAdapter articleType = (EntityAdapter) i.next();\r
-\r
- articleTypeMap.put(articleType.get("name"), articleType.get("id"));\r
- }\r
- aValueSet.put("articletype", articleTypeMap);\r
-\r
- Map commentStatusMap = new HashMap();\r
- i = new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "commentStatus");\r
- while (i.hasNext()) {\r
- EntityAdapter commentStatus = (EntityAdapter) i.next();\r
-\r
- commentStatusMap.put(commentStatus.get("name"), commentStatus.get("id"));\r
- }\r
- aValueSet.put("commentstatus", commentStatusMap);\r
- }\r
- catch (Throwable t) {\r
- logger.error("initializeGenerationValueSet: Exception while collecting comment statuses" + t.getMessage());\r
- throw new RuntimeException(t.getMessage());\r
- }\r
-\r
- };\r
-\r
- public String filterNonHTMLText(String aText) {\r
-\r
- logger.debug("about to filter non HTML Text of length " + aText.length());\r
- try {\r
- String result =\r
- StringUtil.createHTML(\r
- StringUtil.removeHTMLTags(aText),\r
- MirGlobal.config().getString("Producer.ImageRoot"),\r
- MirGlobal.config().getString("Producer.MailLinkName"),\r
- MirGlobal.config().getString("Producer.ExtLinkName"),\r
- MirGlobal.config().getString("Producer.IntLinkName")\r
- );\r
- logger.debug("done filtering non-HTML text ");\r
- return result;\r
- }\r
- catch (Throwable t) {\r
- logger.error("error while filtering non-HTML text: " + t.toString());\r
-\r
- throw new RuntimeException(t.toString());\r
- }\r
- }\r
-\r
- public String filterHTMLText(String aText) {\r
- return StringUtil.deleteForbiddenTags(aText);\r
- }\r
-}\r
+/*
+ * 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.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.adapter.EntityAdapter;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.log.LoggerWrapper;
+import mir.misc.StringUtil;
+import mir.util.GeneratorDateTimeFunctions;
+import mir.util.GeneratorExpressionFunctions;
+import mir.util.GeneratorFormatAdapters;
+import mir.util.GeneratorHTMLFunctions;
+import mir.util.GeneratorIntegerFunctions;
+import mir.util.GeneratorListFunctions;
+import mir.util.GeneratorRegularExpressionFunctions;
+import mir.util.GeneratorStringFunctions;
+import mircoders.global.MirGlobal;
+import mircoders.localizer.MirLocalizerExc;
+import mircoders.localizer.MirLocalizerFailure;
+import mircoders.localizer.MirProducerAssistantLocalizer;
+
+public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {
+ protected LoggerWrapper logger;
+
+ public void initializeGenerationValueSet(Map aValueSet) throws MirLocalizerExc, MirLocalizerFailure {
+ try {
+ Iterator i;
+
+ Map configMap = new HashMap();
+ Map utilityMap = new HashMap();
+
+ logger = new LoggerWrapper("Localizer.ProducerAssistant");
+
+// obsolete:
+ configMap.put("producerDocRoot", MirGlobal.config().getString("Producer.DocRoot"));
+ configMap.put("storageRoot", MirGlobal.config().getString("Producer.StorageRoot"));
+ configMap.put("productionHost", MirGlobal.config().getString("Producer.ProductionHost"));
+ configMap.put("openAction", MirGlobal.config().getString("Producer.OpenAction"));
+ configMap.put("docRoot", MirGlobal.config().getString("RootUri"));
+ configMap.put("actionRoot", MirGlobal.config().getString("RootUri") + "/servlet/Mir");
+ configMap.put("now", new GeneratorFormatAdapters.DateFormatAdapter(new GregorianCalendar().getTime(), MirGlobal.config().getString("Mir.DefaultTimezone")));
+ configMap.put("videoHost", MirGlobal.config().getString("Producer.Video.Host"));
+ configMap.put("audioHost", MirGlobal.config().getString("Producer.Audio.Host"));
+ configMap.put("imageHost", MirGlobal.config().getString("Producer.Image.Host"));
+ configMap.put("imagePath", MirGlobal.config().getString("Producer.Image.Path"));
+ configMap.put("mirVersion", MirGlobal.config().getString("Mir.Version"));
+ configMap.put("defEncoding", MirGlobal.config().getString("Mir.DefaultEncoding"));
+
+// "new":
+ configMap.putAll(MirPropertiesConfiguration.instance().allSettings());
+
+ utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace());
+ utilityMap.put("encodeHTML", new GeneratorHTMLFunctions.encodeHTMLGeneratorFunction());
+ utilityMap.put("prettyEncodeHTML", new GeneratorHTMLFunctions.prettyEncodeHTMLGeneratorFunction());
+ utilityMap.put("encodeXML", new GeneratorHTMLFunctions.encodeXMLGeneratorFunction());
+ utilityMap.put("encodeURI", new GeneratorHTMLFunctions.encodeURIGeneratorFunction());
+ utilityMap.put("subString", new GeneratorStringFunctions.subStringFunction());
+ utilityMap.put("subList", new GeneratorListFunctions.subListFunction());
+ utilityMap.put("isOdd", new GeneratorIntegerFunctions.isOddFunction());
+ utilityMap.put("increment", new GeneratorIntegerFunctions.incrementFunction());
+ utilityMap.put("evaluate", new GeneratorExpressionFunctions.evaluateExpressionFunction());
+ utilityMap.put("constructString", new GeneratorStringFunctions.constructStructuredStringFunction());
+ utilityMap.put("parseStructuredString", new GeneratorStringFunctions.structuredStringParserFunction());
+ utilityMap.put("escapeJDBCString", new GeneratorStringFunctions.jdbcStringEscapeFunction());
+ utilityMap.put("regexpreplace", new GeneratorRegularExpressionFunctions.regularExpressionReplaceFunction());
+ utilityMap.put("regexpmatch", new GeneratorRegularExpressionFunctions.regularExpressionMatchFunction());
+ utilityMap.put("datetime", new GeneratorDateTimeFunctions.DateTimeFunctions(
+ MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));
+
+ aValueSet.put("config", configMap);
+ aValueSet.put("utility", utilityMap);
+
+ aValueSet.put("languages",
+ new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "language"));
+
+ aValueSet.put("topics",
+ new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
+
+ Map articleTypeMap = new HashMap();
+ articleTypeMap.put("openposting", "0");
+ articleTypeMap.put("newswire", "1");
+ articleTypeMap.put("feature", "2");
+ articleTypeMap.put("topicspecial", "3");
+ articleTypeMap.put("startspecial", "4");
+
+ i = new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "articleType");
+ while (i.hasNext()) {
+ EntityAdapter articleType = (EntityAdapter) i.next();
+
+ articleTypeMap.put(articleType.get("name"), articleType.get("id"));
+ }
+ aValueSet.put("articletype", articleTypeMap);
+
+ Map commentStatusMap = new HashMap();
+ i = new EntityIteratorAdapter("", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "commentStatus");
+ while (i.hasNext()) {
+ EntityAdapter commentStatus = (EntityAdapter) i.next();
+
+ commentStatusMap.put(commentStatus.get("name"), commentStatus.get("id"));
+ }
+ aValueSet.put("commentstatus", commentStatusMap);
+ }
+ catch (Throwable t) {
+ logger.error("initializeGenerationValueSet: Exception while collecting comment statuses" + t.getMessage());
+ throw new RuntimeException(t.getMessage());
+ }
+
+ };
+
+ public String filterNonHTMLText(String aText) {
+
+ logger.debug("about to filter non HTML Text of length " + aText.length());
+ try {
+ String result =
+ StringUtil.createHTML(
+ StringUtil.removeHTMLTags(aText),
+ MirGlobal.config().getString("Producer.ImageRoot"),
+ MirGlobal.config().getString("Producer.MailLinkName"),
+ MirGlobal.config().getString("Producer.ExtLinkName"),
+ MirGlobal.config().getString("Producer.IntLinkName")
+ );
+ logger.debug("done filtering non-HTML text ");
+ return result;
+ }
+ catch (Throwable t) {
+ logger.error("error while filtering non-HTML text: " + t.toString());
+
+ throw new RuntimeException(t.toString());
+ }
+ }
+
+ public String filterHTMLText(String aText) {
+ return StringUtil.deleteForbiddenTags(aText);
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.media;\r
-\r
-import java.io.StringReader;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.media.MediaExc;\r
-import mir.media.MediaFailure;\r
-import mir.media.MediaHandler;\r
-import mir.misc.FileUtil;\r
-import mir.misc.StringUtil;\r
-\r
-\r
-\r
-/**\r
- * Handles realAudio .it manages the ram file.\r
- *\r
- * 03.2002 - reworked Realmedia handling. -mh\r
- *\r
- * @see mir.media.MediaHandlerGeneric\r
- * @see mir.media.MediaHandler\r
- * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>\r
- * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.2 2003/12/14 16:37:08 zapata Exp $\r
- */\r
-\r
-\r
-public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHandler\r
-{\r
- public MediaHandlerRealAudio() {\r
- logger = new LoggerWrapper("Media.Audio.Real");\r
- }\r
-\r
- public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {\r
-\r
- // first see if the file exists\r
- super.produce(ent, mediaTypeEnt);\r
-\r
- String baseName = ent.getId();\r
- String date = ent.getValue("date");\r
- String datePath = StringUtil.webdbDate2path(date);\r
- String rtspDir = configuration.getString("Producer.RealMedia.Path");\r
- String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");\r
-\r
- String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");\r
- String RealMediaFile = datePath+ent.getId()+".ram";\r
- try {\r
- //write an rm (ram?. -mh) file\r
- FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,\r
- new StringReader(RealMediaPointer), "US-ASCII");\r
- }\r
- catch (Throwable e) {\r
- logger.error("MediaHandlerRealAudio.produce: " + e.toString());\r
- throw new MediaFailure(e);\r
- }\r
- }\r
-\r
- public List getURL(Entity ent, Entity mediaTypeEnt)\r
- {\r
- List theList = new Vector();\r
-\r
- //String stringSize = ent.getValue("size");\r
- //int size = Integer.parseInt(stringSize, 10)/1024;\r
- theList.add(ent);\r
-\r
- String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),\r
- ".ra$","");\r
-\r
- // @todo the texts ("title") below urgently need to be sanely localizaeble\r
- // somehow\r
- Map ramHash = new HashMap();\r
- ramHash.put("publish_path", basePath+".ram");\r
- ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));\r
- ramHash.put("title", "stream URL");\r
- theList.add(ramHash);\r
-\r
- return theList;\r
- }\r
-\r
- public String getStoragePath()\r
- {\r
- return configuration.getString("Producer.RealMedia.Path");\r
- }\r
-\r
- public String getDescr(Entity mediaType)\r
- {\r
- return "RealMedia";\r
- }\r
-\r
- public String getPublishHost()\r
- {\r
- return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));\r
- }\r
-\r
-}\r
-\r
-\r
-\r
+/*
+ * 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.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.media.MediaExc;
+import mir.media.MediaFailure;
+import mir.media.MediaHandler;
+import mir.misc.FileUtil;
+import mir.misc.StringUtil;
+
+
+
+/**
+ * Handles realAudio .it manages the ram file.
+ *
+ * 03.2002 - reworked Realmedia handling. -mh
+ *
+ * @see mir.media.MediaHandlerGeneric
+ * @see mir.media.MediaHandler
+ * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
+ * @version $Id: MediaHandlerRealAudio.java,v 1.19.2.3 2003/12/21 13:32:05 zapata Exp $
+ */
+
+
+public class MediaHandlerRealAudio extends MediaHandlerAudio implements MediaHandler
+{
+ public MediaHandlerRealAudio() {
+ logger = new LoggerWrapper("Media.Audio.Real");
+ }
+
+ public void produce (Entity ent, Entity mediaTypeEnt ) throws MediaExc, MediaFailure {
+
+ // first see if the file exists
+ super.produce(ent, mediaTypeEnt);
+
+ String baseName = ent.getId();
+ String date = ent.getValue("date");
+ String datePath = StringUtil.webdbDate2path(date);
+ String rtspDir = configuration.getString("Producer.RealMedia.Path");
+ String rtspMediaHost = configuration.getString("Producer.RealMedia.Host");
+
+ String RealMediaPointer = rtspMediaHost+ent.getValue("publish_path");
+ String RealMediaFile = datePath+ent.getId()+".ram";
+ try {
+ //write an rm (ram?. -mh) file
+ FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
+ new StringReader(RealMediaPointer), "US-ASCII");
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerRealAudio.produce: " + e.toString());
+ throw new MediaFailure(e);
+ }
+ }
+
+ public List getURL(Entity ent, Entity mediaTypeEnt)
+ {
+ List theList = new Vector();
+
+ //String stringSize = ent.getValue("size");
+ //int size = Integer.parseInt(stringSize, 10)/1024;
+ theList.add(ent);
+
+ String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
+ ".ra$","");
+
+ // @todo the texts ("title") below urgently need to be sanely localizaeble
+ // somehow
+ Map ramHash = new HashMap();
+ ramHash.put("publish_path", basePath+".ram");
+ ramHash.put("publish_server", configuration.getString("Producer.Media.Host"));
+ ramHash.put("title", "stream URL");
+ theList.add(ramHash);
+
+ return theList;
+ }
+
+ public String getStoragePath()
+ {
+ return configuration.getString("Producer.RealMedia.Path");
+ }
+
+ public String getDescr(Entity mediaType)
+ {
+ return "RealMedia";
+ }
+
+ public String getPublishHost()
+ {
+ return StringUtil.removeSlash(configuration.getString("Producer.RealMedia.Host"));
+ }
+
+}
+
+
+
*/
package mircoders.module;
-import mir.log.LoggerWrapper;\r
-import mir.module.AbstractModule;\r
-import mir.module.ModuleExc;\r
-import mir.module.ModuleFailure;\r
-import mir.storage.StorageObject;\r
+import mir.log.LoggerWrapper;
+import mir.module.AbstractModule;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
+import mir.storage.StorageObject;
import mir.util.JDBCStringRoutines;
public class ModuleArticleType extends AbstractModule {
*/
package mircoders.module;
-import java.util.Map;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.module.AbstractModule;\r
-import mir.module.ModuleExc;\r
-import mir.module.ModuleFailure;\r
-import mir.storage.StorageObject;\r
+import java.util.Map;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.module.AbstractModule;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
+import mir.storage.StorageObject;
import mircoders.storage.DatabaseContent;
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.module;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.module.AbstractModule;\r
-import mir.module.ModuleExc;\r
-import mir.module.ModuleFailure;\r
-import mir.storage.StorageObject;\r
-import mir.util.JDBCStringRoutines;\r
-\r
-public class ModuleCommentStatus extends AbstractModule {\r
- static LoggerWrapper logger = new LoggerWrapper("Module.CommentStatus");\r
-\r
- public ModuleCommentStatus (StorageObject theStorage) {\r
- if (theStorage == null)\r
- logger.warn("ModuleCommentStatus -- StorageObject was null!");\r
-\r
- this.theStorage = theStorage;\r
- }\r
-\r
- public String commentStatusIdForName(String aName) throws ModuleExc, ModuleFailure {\r
- try {\r
- return theStorage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");\r
- }\r
- catch (Throwable t) {\r
- throw new ModuleFailure(t);\r
- }\r
- }\r
-}\r
+/*
+ * 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.module;
+
+import mir.log.LoggerWrapper;
+import mir.module.AbstractModule;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
+import mir.storage.StorageObject;
+import mir.util.JDBCStringRoutines;
+
+public class ModuleCommentStatus extends AbstractModule {
+ static LoggerWrapper logger = new LoggerWrapper("Module.CommentStatus");
+
+ public ModuleCommentStatus (StorageObject theStorage) {
+ if (theStorage == null)
+ logger.warn("ModuleCommentStatus -- StorageObject was null!");
+
+ this.theStorage = theStorage;
+ }
+
+ public String commentStatusIdForName(String aName) throws ModuleExc, ModuleFailure {
+ try {
+ return theStorage.executeFreeSingleValueSql("select id from comment_status where name = '" + JDBCStringRoutines.escapeStringLiteral(aName) + "'");
+ }
+ catch (Throwable t) {
+ throw new ModuleFailure(t);
+ }
+ }
+}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.module;
-import mir.entity.EntityList;
import mir.log.LoggerWrapper;
import mir.module.AbstractModule;
-import mir.module.ModuleExc;
-import mir.module.ModuleFailure;
import mir.storage.StorageObject;
+import mir.util.JDBCStringRoutines;
+import mircoders.global.*;
/**
*
super();
}
- public ModuleContent(StorageObject theStorage) {
- this.theStorage = theStorage;
+ public ModuleContent(StorageObject aStorage) {
+ theStorage = aStorage;
}
- public EntityList getContent(String whereClause, String orderBy,int offset, int limit) throws ModuleExc, ModuleFailure {
+ public void expireArticleLock(String anId, String aUserId) {
+ if (!MirGlobal.isUserLoggedIn(anId)) {
+ unlockArticle(anId, aUserId, false);
+ }
+ }
+
+ /**
+ * Locks an article. Forced (that is, without checking wether it's already locked)
+ * if necessary.
+ *
+ * @param anId The article number
+ * @param aUserId The locking user
+ * @param aForce Should it e forced?
+ * @return
+ */
+ public boolean lockArticle(String anId, String aUserId, boolean aForce) {
+ try {
+ String query =
+ "update content set to_locking_user=" + JDBCStringRoutines.escapeStringLiteral(aUserId) +
+ " where id = " + JDBCStringRoutines.escapeStringLiteral(anId);
+
+ if (!aForce)
+ query = query + " and to_locking_user is null";
+
+ return theStorage.executeUpdate(query) > 0;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ }
+
+ /**
+ * Unlocks an article. Forced (that is, without checking wether it's locked by
+ * the person that unlocks it) if necessary.
+ *
+ * @param anId The article number
+ * @param aUserId The user that unlocks
+ * @param aForce Should it e forced?
+ * @return <code>true</code> if successfull, <code>false</code> if not
+ */
+ public boolean unlockArticle(String anId, String aUserId, boolean aForce) {
try {
- return theStorage.selectByWhereClause(whereClause, orderBy, offset, limit);
+ String query =
+ "update content set to_locking_user=null" +
+ " where id = " + JDBCStringRoutines.escapeStringLiteral(anId);
+
+ if (!aForce)
+ query = query + " and to_locking_user = "+JDBCStringRoutines.escapeStringLiteral(aUserId);
+
+ return theStorage.executeUpdate(query) > 0;
+ }
+ catch (Throwable t) {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the id of the locking user of an article. <code>null</code> otherwise.
+ *
+ * @param anId
+ * @return
+ */
+ public String queryArticleLock(String anId) {
+ try {
+ String result = theStorage.executeFreeSingleValueSql("select to_locking_user from content where id = " + JDBCStringRoutines.escapeStringLiteral(anId));
+
+ if (result!=null && !MirGlobal.isUserLoggedIn(result)) {
+ expireArticleLock(anId, result);
+ result = null;
+ }
+
+ return result;
}
- catch (Throwable e){
- throw new ModuleFailure(e);
+ catch (Throwable t) {
+ return null;
}
}
}
* @version
*/
-import mir.log.LoggerWrapper;\r
-import mir.module.AbstractModule;\r
-import mir.module.ModuleExc;\r
-import mir.module.ModuleFailure;\r
-import mir.storage.StorageObject;\r
+import mir.log.LoggerWrapper;
+import mir.module.AbstractModule;
+import mir.module.ModuleExc;
+import mir.module.ModuleFailure;
+import mir.storage.StorageObject;
import mir.util.JDBCStringRoutines;
{
static LoggerWrapper logger = new LoggerWrapper("Module.Users");
- public ModuleUsers(StorageObject theStorage)
+ public ModuleUsers(StorageObject aStorage)
{
- if (theStorage == null)
+ if (aStorage == null)
logger.warn("ModuleUsers(): StorageObject was null!");
- this.theStorage = theStorage;
+ theStorage = aStorage;
}
/**
EntityList userList = getByWhereClause(whereString, -1);
- if (userList != null && userList.getCount() == 1)
- return (EntityUsers) userList.elementAt(0);
- else
- return null;
+ if (userList != null && userList.getCount() == 1) {
+ EntityUsers result = (EntityUsers) userList.elementAt(0);
+
+ if (result.getValue("is_disabled") == null ||
+ result.getValue("is_disabled").equals("0"))
+ return result;
+
+ }
+
+ return null;
}
catch (Throwable t) {
throw new ModuleFailure(t);
return result;
}
+ /**
+ *
+ * @param theValues
+ * @return
+ * @throws ModuleExc
+ * @throws ModuleFailure
+ */
+
public String add (Map theValues) throws ModuleExc, ModuleFailure {
try {
return super.add(digestPassword(theValues));
}
/**
- * Standardfunktion, um einen Datensatz via StorageObject zu aktualisieren
- * @param theValues Hash mit Spalte/Wert-Paaren
- * @return Id des eingef?gten Objekts
- * @exception ModuleException
+ *
+ * @param theValues
+ * @return
+ * @throws ModuleExc
+ * @throws ModuleFailure
*/
public String set (Map theValues) throws ModuleExc, ModuleFailure {
try {
throw new ModuleFailure(t);
}
}
+
+ public void recordLogin(EntityUsers aUser) throws ModuleExc, ModuleFailure {
+ try {
+ String sql = "update webdb_users set lastlogin=now() where id = " + aUser.getId();
+
+ theStorage.executeUpdate(sql);
+ }
+ catch (Throwable t) {
+ throw new ModuleFailure(t);
+ }
+ }
}
\ No newline at end of file
}
public void start(HttpServletRequest aRequest, HttpServletResponse aResponse) {
- String startTemplate = configuration.getString("Mir.StartTemplate");
+ String defaultStartTemplate = configuration.getString("Mir.StartTemplate");
String sessionUrl = aResponse.encodeURL("");
try {
mergeData.put("selectarticleurl", null);
mergeData.put("recipes", MirGlobal.localizer().producers().getRecipeNames());
+ String startTemplate = MirGlobal.localizer().adminInterface().getAdminPageGenerator(
+ "admin.start", mergeData,
+ ServletHelper.getUserAdapter(aRequest), defaultStartTemplate);
+
ServletHelper.generateResponse(aResponse.getWriter(), mergeData, startTemplate);
}
catch (Exception e) {
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.servlet;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.servlet.ServletModule;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.module.ModuleArticleType;\r
-import mircoders.storage.DatabaseArticleType;\r
-\r
-/**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-public class ServletModuleArticleType extends ServletModule\r
-{\r
- private static ServletModuleArticleType instance = new ServletModuleArticleType();\r
- public static ServletModule getInstance() { return instance; }\r
-\r
- private ServletModuleArticleType() {\r
- logger = new LoggerWrapper("ServletModule.ArticleType");\r
-\r
- try {\r
- model = MirGlobal.localizer().dataModel().adapterModel();\r
- definition = "articleType";\r
- mainModule = new ModuleArticleType(DatabaseArticleType.getInstance());\r
- }\r
- catch (Exception e) {\r
- logger.error("Initialization of ServletModuleArticleType failed!: " + e.getMessage());\r
- }\r
- }\r
-}\r
+/*
+ * 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 mir.log.LoggerWrapper;
+import mir.servlet.ServletModule;
+import mircoders.global.MirGlobal;
+import mircoders.module.ModuleArticleType;
+import mircoders.storage.DatabaseArticleType;
+
+/**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+public class ServletModuleArticleType extends ServletModule
+{
+ private static ServletModuleArticleType instance = new ServletModuleArticleType();
+ public static ServletModule getInstance() { return instance; }
+
+ private ServletModuleArticleType() {
+ logger = new LoggerWrapper("ServletModule.ArticleType");
+
+ try {
+ model = MirGlobal.localizer().dataModel().adapterModel();
+ definition = "articleType";
+ mainModule = new ModuleArticleType(DatabaseArticleType.getInstance());
+ }
+ catch (Exception e) {
+ logger.error("Initialization of ServletModuleArticleType failed!: " + e.getMessage());
+ }
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.servlet;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.servlet.ServletModule;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.module.ModuleBreaking;\r
-import mircoders.storage.DatabaseBreaking;\r
-\r
-/**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class ServletModuleBreaking extends ServletModule\r
-{\r
- private static ServletModuleBreaking instance = new ServletModuleBreaking();\r
- public static ServletModule getInstance() { return instance; }\r
-\r
- private ServletModuleBreaking() {\r
- logger = new LoggerWrapper("ServletModule.Breaking");\r
-\r
- try {\r
- model = MirGlobal.localizer().dataModel().adapterModel();\r
- definition = "breakingNews";\r
- mainModule = new ModuleBreaking(DatabaseBreaking.getInstance());\r
- }\r
- catch (Exception e) {\r
- logger.error("Initialisation of ServletModuleBreaking failed!: " + e.getMessage());\r
- }\r
- }\r
-}\r
+/*
+ * 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 mir.log.LoggerWrapper;
+import mir.servlet.ServletModule;
+import mircoders.global.MirGlobal;
+import mircoders.module.ModuleBreaking;
+import mircoders.storage.DatabaseBreaking;
+
+/**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class ServletModuleBreaking extends ServletModule
+{
+ private static ServletModuleBreaking instance = new ServletModuleBreaking();
+ public static ServletModule getInstance() { return instance; }
+
+ private ServletModuleBreaking() {
+ logger = new LoggerWrapper("ServletModule.Breaking");
+
+ try {
+ model = MirGlobal.localizer().dataModel().adapterModel();
+ definition = "breakingNews";
+ mainModule = new ModuleBreaking(DatabaseBreaking.getInstance());
+ }
+ catch (Exception e) {
+ logger.error("Initialisation of ServletModuleBreaking failed!: " + e.getMessage());
+ }
+ }
+}
import mir.util.SQLQueryBuilder;
import mir.util.StringRoutines;
import mir.util.URLBuilder;
-import mircoders.entity.EntityContent;
+import mircoders.entity.*;
import mircoders.global.MirGlobal;
import mircoders.module.ModuleContent;
import mircoders.storage.DatabaseContent;
* ServletModuleContent -
* deliver html for the article admin form.
*
- * @version $Id: ServletModuleContent.java,v 1.52.2.12 2003/10/23 14:55:25 rk Exp $
+ * @version $Id: ServletModuleContent.java,v 1.52.2.13 2003/12/21 13:32:06 zapata Exp $
* @author rk, mir-coders
*
*/
{
private static ServletModuleContent instance = new ServletModuleContent();
public static ServletModule getInstance() { return instance; }
+ private static ModuleContent contentModule;
private ServletModuleContent() {
super();
logger = new LoggerWrapper("ServletModule.Content");
try {
- mainModule = new ModuleContent(DatabaseContent.getInstance());
+ contentModule = new ModuleContent(DatabaseContent.getInstance());
+ mainModule = contentModule;
}
catch (Throwable e) {
logger.fatal("ServletModuleContent could not be initialized: " + e.toString());
editObject(aRequest, aResponse, null);
}
-
public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
-//theLog.printDebugInfo(":: content :: trying to insert");
try {
Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
editObject(aRequest, aResponse, idParam);
}
-// methods for attaching media file
+ /**
+ * Attaches media to an article
+ *
+ */
public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
String mediaIdParam = aRequest.getParameter("mid");
if (articleId == null || mediaIdParam==null)
throw new ServletModuleExc("smod content :: attach :: articleid/mid missing");
+ if (!MirGlobal.accessControl().article().mayEditArticle(ServletHelper.getUser(aRequest), articleId))
+ throw new ServletModuleExc("Article has been locked");
+
try {
EntityContent entContent = (EntityContent) mainModule.getById(articleId);
entContent.attach(mediaIdParam);
editObject(aRequest, aResponse, articleId);
}
+ /**
+ * Deattaches media from an article
+ */
public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
String articleId = aRequest.getParameter("articleid");
if (midParam == null)
throw new ServletModuleExc("smod content :: dettach :: mid missing");
+ if (!MirGlobal.accessControl().article().mayEditArticle(ServletHelper.getUser(aRequest), articleId))
+ throw new ServletModuleExc("Article has been locked");
+
try {
EntityContent entContent = (EntityContent)mainModule.getById(articleId);
entContent.dettach(articleId, midParam);
editObject(aRequest, aResponse, articleId);
}
+ /**
+ * Locks an article
+ */
+ public void lock(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String returnUrl = requestParser.getParameter("returnurl");
+
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Wrong call: (id) is missing");
+
+ EntityUsers user = ServletHelper.getUser(aRequest);
+
+ if (!MirGlobal.accessControl().article().mayLockArticle(user, idParam))
+ throw new ServletModuleExc("Unable to lock");
+
+ contentModule.lockArticle(idParam, user.getId(), false);
+
+ editObject(aRequest, aResponse, idParam);
+ }
+
+ /**
+ * Unlocks an article
+ */
+ public void unlock(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String returnUrl = requestParser.getParameter("returnurl");
+
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Wrong call: (id) is missing");
+
+ EntityUsers user = ServletHelper.getUser(aRequest);
+
+ if (!MirGlobal.accessControl().article().mayUnlockArticle(user, idParam))
+ throw new ServletModuleExc("Unable to unlock");
+
+ contentModule.unlockArticle(idParam, user.getId(), false);
+
+ editObject(aRequest, aResponse, idParam);
+ }
+
+ /**
+ * Forcelocks an article
+ */
+ public void forcelock(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ String returnUrl = requestParser.getParameter("returnurl");
+
+ String idParam = aRequest.getParameter("id");
+ if (idParam == null)
+ throw new ServletModuleExc("Wrong call: (id) is missing");
+
+ EntityUsers user = ServletHelper.getUser(aRequest);
+
+ if (!MirGlobal.accessControl().article().mayForceLockArticle(user, idParam))
+ throw new ServletModuleExc("Unable to force lock");
+
+ contentModule.lockArticle(idParam, user.getId(), true);
+
+ editObject(aRequest, aResponse, idParam);
+ }
+
+ /**
+ * Stores an article
+ */
public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
try {
if (idParam == null)
throw new ServletModuleExc("Wrong call: (id) is missing");
+ if (!MirGlobal.accessControl().article().mayEditArticle(ServletHelper.getUser(aRequest), idParam))
+ throw new ServletModuleExc("Article has been locked");
+
Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
String content_id = aRequest.getParameter("id");
DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"), aRequest.getParameterValues("to_topic"));
- if (returnUrl!=null && !returnUrl.equals("")){
- redirect(aResponse, returnUrl);
+ if (MirGlobal.accessControl().article().mayUnlockArticle(ServletHelper.getUser(aRequest), idParam) &&
+ (requestParser.getParameterWithDefault("unlock", "0").equals("1"))) {
+ contentModule.unlockArticle(id, ServletHelper.getUser(aRequest).getId(), false);
}
- else
- editObject(aRequest, aResponse, idParam);
+
+ editObject(aRequest, aResponse, idParam);
}
catch (Throwable e) {
throw new ServletModuleFailure(e);
/**
- * HelperMethod shows the basic article editing form.
- *
- * if the "id" parameter is null, it means show an empty form to add a new
- * article.
+ * Returns the basic article editing form.
*
- * @param id
- * @param aRequest
- * @param aResponse
- * @throws ServletModuleExc
+ * @param id identifier of the article. <code>null</code>, means show an
+ * empty form to add a new article.
*/
public void editObject(HttpServletRequest aRequest, HttpServletResponse aResponse, String id)
throws ServletModuleExc {
if (id!=null) {
responseData.put("new", Boolean.FALSE);
article = model.makeEntityAdapter("content", mainModule.getById(id));
+
+ EntityUsers user = ServletHelper.getUser(aRequest);
+
+ responseData.put("mayEdit", new Boolean(MirGlobal.accessControl().article().mayEditArticle(user, id)));
+ responseData.put("mayLock", new Boolean(MirGlobal.accessControl().article().mayLockArticle(user, id)));
+ responseData.put("mayForceLock", new Boolean(MirGlobal.accessControl().article().mayForceLockArticle(user, id)));
+ responseData.put("mayUnlock", new Boolean(MirGlobal.accessControl().article().mayUnlockArticle(user, id)));
}
else {
List fields = DatabaseContent.getInstance().getFields();
article.put("to_topics", null);
MirGlobal.localizer().adminInterface().initializeArticle(article);
+
+ responseData.put("mayEdit", Boolean.TRUE);
+ responseData.put("mayLock", Boolean.FALSE);
+ responseData.put("mayForceLock", Boolean.FALSE);
+ responseData.put("mayUnlock", Boolean.FALSE);
}
responseData.put("article", article);
String parentId = aRequest.getParameter("id");
String returnUrl = aRequest.getParameter("returnurl");
+ if (!MirGlobal.accessControl().article().mayEditArticle(ServletHelper.getUser(aRequest), articleId))
+ throw new ServletModuleExc("Article has been locked");
+
try {
EntityContent article = (EntityContent) mainModule.getById(articleId);
article.setValueForProperty("to_content", parentId);
catch (Exception e) {
logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage());
}
-
-
}
+ /**
+ * Performs a localizer operation on an article.
+ *
+ * See also
+ * {@link mircoders.localizer.MirAdminInterfaceLocalizer#simpleArticleOperations()}
+ * {@link mircoders.localizer.MirAdminInterfaceLocalizer$MirSimpleEntityOperation()}
+ *
+ * @param aRequest The originating request
+ * @param anId The id of the article
+ * @param anOperation The identifier of the operation to perform
+ */
public void performCommentOperation(HttpServletRequest aRequest, String anId, String anOperation) {
MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;
EntityAdapter comment;
if (entity != null) {
MirGlobal.performArticleOperation(ServletHelper.getUser(aRequest), entity, anOperation);
logger.info("Operation " + anOperation + " successfully performed on article " + anId);
- logAdminUsage(aRequest, "article."+anId, "operation " + anOperation + " performed");
+ logAdminUsage(aRequest, "article." + anId, "operation " + anOperation + " performed");
}
else {
logger.error("Error while performing " + anOperation + " on article " + anId + ": article is null");
{
if ( (aRequestParser.getParameter("newpassword") != null &&
aRequestParser.getParameter("newpassword").length() > 0) ||
- (aRequestParser.getParameter("newpassword2") != null &&
- aRequestParser.getParameter("newpassword2").length() > 0)
+ (aRequestParser.getParameter("newpassword2") != null &&
+ aRequestParser.getParameter("newpassword2").length() > 0)
) {
String newPassword = aRequestParser.getParameterWithDefault("newpassword", "");
String newPassword2 = aRequestParser.getParameterWithDefault("newpassword2", "");
Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());
if (!withValues.containsKey("is_admin"))
withValues.put("is_admin","0");
+ if (!withValues.containsKey("is_disabled"))
+ withValues.put("is_disabled","0");
String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
if (newPassword!=null)
* @version 1.0
*/
-import java.util.List;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import java.util.List;
+
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
public class DatabaseArticleType extends Database implements StorageObject{
package mircoders.storage;
-import java.sql.Connection;\r
-import java.sql.SQLException;\r
-import java.sql.Statement;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
/**
* @version 1.0
*/
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
package mircoders.storage;
-import java.sql.Connection;\r
-import java.sql.Statement;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import java.sql.Connection;
+import java.sql.Statement;
+
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
/**
package mircoders.storage;
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
import mir.storage.StorageObject;
/**
package mircoders.storage;
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
import mir.storage.StorageObject;
/**
package mircoders.storage;
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
import mir.storage.StorageObject;
/**
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.storage;\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-\r
-/**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class DatabaseImageType extends Database implements StorageObject{\r
- private static DatabaseImageType instance;\r
-\r
- public synchronized static DatabaseImageType getInstance() {\r
- if (instance == null) {\r
- instance = new DatabaseImageType();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseImageType() {\r
- super();\r
- logger = new LoggerWrapper("Database.ImageType");\r
-\r
- hasTimestamp = false;\r
- theTable = "img_type";\r
- }\r
-}\r
+/*
+ * 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.StorageObject;
+
+/**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class DatabaseImageType extends Database implements StorageObject{
+ private static DatabaseImageType instance;
+
+ public synchronized static DatabaseImageType getInstance() {
+ if (instance == null) {
+ instance = new DatabaseImageType();
+ }
+ return instance;
+ }
+
+ private DatabaseImageType() {
+ super();
+ logger = new LoggerWrapper("Database.ImageType");
+
+ hasTimestamp = false;
+ theTable = "img_type";
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.storage;\r
-\r
-/**\r
- * Title: DatabaseLanguage\r
- * Description:\r
- * Copyright: Copyright (c) 2001\r
- * Company: Indymedia\r
- * @author\r
- * @version 1.0\r
- */\r
-\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.entity.EntityBrowser;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-\r
-\r
-public class DatabaseLanguage extends Database implements StorageObject{\r
- private static DatabaseLanguage instance;\r
-\r
- // the following *has* to be sychronized cause this static method\r
- // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
- // see the "Singletons with needles and thread" article at JavaWorld -mh\r
- public synchronized static DatabaseLanguage getInstance() throws\r
- StorageObjectFailure {\r
- if (instance == null) {\r
- instance = new DatabaseLanguage();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseLanguage() throws StorageObjectFailure {\r
- super();\r
- logger = new LoggerWrapper("Database.Language");\r
-\r
- this.hasTimestamp = false;\r
- this.theTable = "language";\r
- }\r
-\r
- public List getPopupData() throws StorageObjectFailure {\r
- List result = new Vector();\r
- Iterator i = new EntityBrowser(this, "", "name", 100, -1, 0);\r
-\r
- while (i.hasNext()) {\r
- Entity e = (Entity) i.next();\r
- Map entry = new HashMap();\r
- entry.put("key", e.getId());\r
- entry.put("value", e.getValue("name"));\r
-\r
- result.add(entry);\r
- }\r
-\r
- return result;\r
- }\r
-}\r
+/*
+ * 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;
+
+/**
+ * Title: DatabaseLanguage
+ * Description:
+ * Copyright: Copyright (c) 2001
+ * Company: Indymedia
+ * @author
+ * @version 1.0
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.entity.EntityBrowser;
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+
+
+public class DatabaseLanguage extends Database implements StorageObject{
+ private static DatabaseLanguage instance;
+
+ // the following *has* to be sychronized cause this static method
+ // could get preemted and we could end up with 2 instances of DatabaseFoo..
+ // see the "Singletons with needles and thread" article at JavaWorld -mh
+ public synchronized static DatabaseLanguage getInstance() throws
+ StorageObjectFailure {
+ if (instance == null) {
+ instance = new DatabaseLanguage();
+ }
+ return instance;
+ }
+
+ private DatabaseLanguage() throws StorageObjectFailure {
+ super();
+ logger = new LoggerWrapper("Database.Language");
+
+ this.hasTimestamp = false;
+ this.theTable = "language";
+ }
+
+ public List getPopupData() throws StorageObjectFailure {
+ List result = new Vector();
+ Iterator i = new EntityBrowser(this, "", "name", 100, -1, 0);
+
+ while (i.hasNext()) {
+ Entity e = (Entity) i.next();
+ Map entry = new HashMap();
+ entry.put("key", e.getId());
+ entry.put("value", e.getValue("name"));
+
+ result.add(entry);
+ }
+
+ return result;
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.storage;\r
-\r
-/**\r
- *\r
- */\r
-\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-\r
-public class DatabaseMediafolder extends Database implements StorageObject{\r
- private static DatabaseMediafolder instance;\r
-\r
- public synchronized static DatabaseMediafolder getInstance() {\r
- if (instance == null) {\r
- instance = new DatabaseMediafolder();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseMediafolder() {\r
- super();\r
-\r
- logger = new LoggerWrapper("Database.Mediafolder");\r
-\r
- hasTimestamp = false;\r
- theTable="media_folder";\r
- }\r
-}\r
+/*
+ * 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.StorageObject;
+
+public class DatabaseMediafolder extends Database implements StorageObject{
+ private static DatabaseMediafolder instance;
+
+ public synchronized static DatabaseMediafolder getInstance() {
+ if (instance == null) {
+ instance = new DatabaseMediafolder();
+ }
+ return instance;
+ }
+
+ private DatabaseMediafolder() {
+ super();
+
+ logger = new LoggerWrapper("Database.Mediafolder");
+
+ hasTimestamp = false;
+ theTable="media_folder";
+ }
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-package mircoders.storage;\r
-\r
-\r
-import java.util.GregorianCalendar;\r
-\r
-import mir.entity.Entity;\r
-import mir.log.LoggerWrapper;\r
-import mir.misc.StringUtil;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-\r
-/**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class DatabaseOther extends Database implements StorageObject{\r
- private static DatabaseOther instance;\r
-\r
- // the following *has* to be sychronized cause this static method\r
- // could get preemted and we could end up with 2 instances of DatabaseFoo..\r
- // see the "Singletons with needles and thread" article at JavaWorld -mh\r
- public synchronized static DatabaseOther getInstance() {\r
- if (instance == null) {\r
- instance = new DatabaseOther();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseOther() {\r
- super();\r
-\r
- logger = new LoggerWrapper("Database.OtherMedia");\r
-\r
- hasTimestamp = true;\r
- theTable = "other_media";\r
- theCoreTable = "media";\r
- theEntityClass = mircoders.entity.EntityOther.class;\r
- }\r
-\r
- public void update(Entity theEntity) throws StorageObjectFailure {\r
- String date = theEntity.getValue("date");\r
- if (date == null) {\r
- date = StringUtil.date2webdbDate(new GregorianCalendar());\r
- theEntity.setValueForProperty("date", date);\r
- }\r
-\r
- super.update(theEntity);\r
- }\r
-\r
- public String insert(Entity theEntity) throws StorageObjectFailure {\r
- String date = theEntity.getValue("date");\r
- if (date == null) {\r
- date = StringUtil.date2webdbDate(new GregorianCalendar());\r
- theEntity.setValueForProperty("date", date);\r
- }\r
- return super.insert(theEntity);\r
- }\r
-\r
- // initialisierungen aus den statischen Tabellen\r
-\r
-}\r
+/*
+ * 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 java.util.GregorianCalendar;
+
+import mir.entity.Entity;
+import mir.log.LoggerWrapper;
+import mir.misc.StringUtil;
+import mir.storage.Database;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+
+/**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class DatabaseOther extends Database implements StorageObject{
+ private static DatabaseOther instance;
+
+ // the following *has* to be sychronized cause this static method
+ // could get preemted and we could end up with 2 instances of DatabaseFoo..
+ // see the "Singletons with needles and thread" article at JavaWorld -mh
+ public synchronized static DatabaseOther getInstance() {
+ if (instance == null) {
+ instance = new DatabaseOther();
+ }
+ return instance;
+ }
+
+ private DatabaseOther() {
+ super();
+
+ logger = new LoggerWrapper("Database.OtherMedia");
+
+ hasTimestamp = true;
+ theTable = "other_media";
+ theCoreTable = "media";
+ theEntityClass = mircoders.entity.EntityOther.class;
+ }
+
+ public void update(Entity theEntity) throws StorageObjectFailure {
+ String date = theEntity.getValue("date");
+ if (date == null) {
+ date = StringUtil.date2webdbDate(new GregorianCalendar());
+ theEntity.setValueForProperty("date", date);
+ }
+
+ super.update(theEntity);
+ }
+
+ public String insert(Entity theEntity) throws StorageObjectFailure {
+ String date = theEntity.getValue("date");
+ if (date == null) {
+ date = StringUtil.date2webdbDate(new GregorianCalendar());
+ theEntity.setValueForProperty("date", date);
+ }
+ return super.insert(theEntity);
+ }
+
+ // initialisierungen aus den statischen Tabellen
+
+}
-/*\r
- * Copyright (C) 2001, 2002 The Mir-coders group\r
- *\r
- * This file is part of Mir.\r
- *\r
- * Mir is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Mir is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with Mir; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * In addition, as a special exception, The Mir-coders gives permission to link\r
- * the code of this program with any library licensed under the Apache Software License,\r
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
- * (or with modified versions of the above that use the same license as the above),\r
- * and distribute linked combinations including the two. You must obey the\r
- * GNU General Public License in all respects for all of the code used other than\r
- * the above mentioned libraries. If you modify this file, you may extend this\r
- * exception to your version of the file, but you are not obligated to do so.\r
- * If you do not wish to do so, delete this exception statement from your version.\r
- */\r
-\r
-package mircoders.storage;\r
-\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import mir.entity.Entity;\r
-import mir.entity.EntityBrowser;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
-import mir.storage.StorageObjectFailure;\r
-\r
-/**\r
- *\r
- * <p>Title: </p>\r
- * <p>Description: </p>\r
- * <p>Copyright: Copyright (c) 2003</p>\r
- * <p>Company: </p>\r
- * @author not attributable\r
- * @version 1.0\r
- */\r
-\r
-public class DatabaseTopics extends Database implements StorageObject{\r
- private static DatabaseTopics instance;\r
-\r
- public synchronized static DatabaseTopics getInstance() {\r
- if (instance == null) {\r
- instance = new DatabaseTopics();\r
- }\r
- return instance;\r
- }\r
-\r
- private DatabaseTopics() throws StorageObjectFailure {\r
- super();\r
-\r
- logger = new LoggerWrapper("Database.Topics");\r
-\r
- hasTimestamp = false;\r
- theTable = "topic";\r
- theEntityClass = mircoders.entity.EntityTopics.class;\r
- }\r
-\r
- public List getPopupData() throws StorageObjectFailure {\r
- List result = new Vector();\r
- Iterator i = new EntityBrowser(this, "", "title", 100, -1, 0);\r
-\r
- while (i.hasNext()) {\r
- Entity e = (Entity) i.next();\r
- Map entry = new HashMap();\r
- entry.put("key", e.getId());\r
- entry.put("value", e.getValue("title"));\r
-\r
- result.add(entry);\r
- }\r
-\r
- return result;\r
- }\r
-}\r
+/*
+ * 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 java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import mir.entity.Entity;
+import mir.entity.EntityBrowser;
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
+import mir.storage.StorageObjectFailure;
+
+/**
+ *
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2003</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+public class DatabaseTopics extends Database implements StorageObject{
+ private static DatabaseTopics instance;
+
+ public synchronized static DatabaseTopics getInstance() {
+ if (instance == null) {
+ instance = new DatabaseTopics();
+ }
+ return instance;
+ }
+
+ private DatabaseTopics() throws StorageObjectFailure {
+ super();
+
+ logger = new LoggerWrapper("Database.Topics");
+
+ hasTimestamp = false;
+ theTable = "topic";
+ theEntityClass = mircoders.entity.EntityTopics.class;
+ }
+
+ public List getPopupData() throws StorageObjectFailure {
+ List result = new Vector();
+ Iterator i = new EntityBrowser(this, "", "title", 100, -1, 0);
+
+ while (i.hasNext()) {
+ Entity e = (Entity) i.next();
+ Map entry = new HashMap();
+ entry.put("key", e.getId());
+ entry.put("value", e.getValue("title"));
+
+ result.add(entry);
+ }
+
+ return result;
+ }
+}
package mircoders.storage;
-import java.util.Iterator;\r
-\r
-import mir.entity.Entity;\r
-import mir.entity.EntityBrowser;\r
-import mir.log.LoggerWrapper;\r
-import mir.storage.Database;\r
-import mir.storage.StorageObject;\r
+import java.util.Iterator;
+
+import mir.entity.Entity;
+import mir.entity.EntityBrowser;
+import mir.log.LoggerWrapper;
+import mir.storage.Database;
+import mir.storage.StorageObject;
import mir.storage.StorageObjectFailure;
public class DatabaseUploadedMedia extends Database implements StorageObject {
<input type="checkbox" name="${fieldname}" value="1"<if fieldcontent=="1"> checked</if>>
<call EditFieldEnd()>
</function> \r
+
+<function ReadOnlyCheckbox(label, fieldcontent, aLabelClass, aValueClass)>
+ <call EditFieldStart(label, "", aLabelClass, aValueClass)>
+ <if fieldcontent=="1">${lang("yes")}<else>${lang("no")}</if>
+ <call EditFieldEnd()>
+</function> \r
\r
+<function ReadOnlyCheckboxNormal(label, fieldcontent)>\r
+ <call ReadOnlyCheckbox(label, fieldcontent, "table-left", "listrow2")>\r
+</function>
<function EditCheckboxNormal(label, fieldname, fieldcontent)>\r
<call EditCheckbox(label, fieldname, fieldcontent, "table-left", "listrow2")>\r
</function>
<p><a class="link-box" href="${config.actionRoot}?${aBackUrl}">[<] ${lang("back")} </a> </p>
</function>
+<function _PulldownTableRow (label, fieldname, entrieslist, keyfield, valuefield, value, langprefix, aCanEdit)>
+ <if aCanEdit=="1">
+ <call PulldownTableRow (label, fieldname, entrieslist, keyfield, valuefield, value, langprefix)>
+ <else>
+ <call ReadOnlyPulldownTableRow (label, entrieslist, keyfield, valuefield, value, langprefix)>
+ </if>
+</function>
+
+<function ReadOnlyPulldownTableRow (label, entrieslist, keyfield, valuefield, value, langprefix)>
+ <tr>
+ <td align="right" class="table-left">
+ <b>${label}:</b>
+ </td>
+ <td class="listrow2">
+ <list entrieslist as a>
+ <if (a[keyfield] == value)><if langprefix>${lang(langprefix+a[valuefield])}<else>${a[valuefield]}</if></if>
+ </list>
+ </td>
+ </tr>
+</function>
+
<function PulldownTableRow (label, fieldname, entrieslist, keyfield, valuefield, value, langprefix)>
<tr>
<td align="right" class="table-left">
</tr>
</function>
+<function ReadonlyTextTableRowNormal (label, fieldcontent)>
+ <call ReadonlyTextTableRow(label, fieldcontent, "listrow2")>
+</function>
+<function _TextInputTableRow(label, size, maxlength, fieldname, fieldcontent, aCanEdit)>
+ <if aCanEdit=="1">
+ <call TextInputTableRow(label, size, maxlength, fieldname, fieldcontent)>
+ <else>
+ <call ReadonlyTextTableRow(label, fieldcontent, "listrow2")>
+ </if>
+</function>
-
-
-
-
+<function _TextInputTableRowLight(label, size, maxlength, fieldname, fieldcontent, aCanEdit)>
+ <if aCanEdit=="1">
+ <call TextInputTableRowLight(label, size, maxlength, fieldname, fieldcontent)>
+ <else>
+ <call ReadonlyTextTableRow(label, fieldcontent, "listrow1")>
+ </if>
+</function>
<function TextInputTableRow (label, size, maxlength, fieldname, fieldcontent)>
<tr>
</tr>
</function>
-<function ReadonlyTextTableRow (label, fieldcontent)>
+<function ReadonlyTextTableRow (label, fieldcontent, class)>
<tr>
<td align="right" class="table-left">
<b>${label}:</b>
</td>
- <td class="listrow2">
+ <td class="${class}">
${utility.encodeHTML(fieldcontent)}
</td>
</tr>
<function CheckboxTableRow (label, fieldname, fieldcontent )>
<call EditCheckboxNormal(label, fieldname, fieldcontent)>
-<comment>
+</function>
+
+<function _CheckboxTableRow (label, fieldname, fieldcontent, aCanEdit)>
+ <if aCanEdit=="1">
+ <call EditCheckboxNormal(label, fieldname, fieldcontent)>
+ <else>
+ <call ReadOnlyCheckboxNormal(label, fieldcontent)>
+ </if>
+</function>
+
+<function _TextAreaTableRow (label, hint, cols, rows, fieldname, fieldcontent, aCanEdit)>
+ <if aCanEdit=="1">
+ <call TextAreaTableRow (label, hint, cols, rows, fieldname, fieldcontent)>
+ <else>
+ <call ReadOnlyTextAreaTableRow (label, hint, fieldcontent)>
+ </if>
+</function>
+<function ReadOnlyTextAreaTableRow (label, hint, fieldcontent )>
<tr>
<td align="right" valign="top" class="table-left">
<b>${label}:</b>
+ <if hint>
+ <br>
+ <span class="small">${hint}</span>
+ </if>
</td>
<td class="listrow2">
- <input type="checkbox" name="${fieldname}" value="1"<if fieldcontent=="1"> checked</if>>
+ ${utility.prettyEncodeHTML(fieldcontent)}
</td>
</tr>
-</comment>
-</function>
-
+</function>
<function TextAreaTableRow (label, hint, cols, rows, fieldname, fieldcontent )>
<tr>
<td align="right" valign="top" class="table-left">
<comment>functions to show media for an article/comment edit page</comment>
-<function showArticleAttachments(anArticle)>
- <call showAttachments(1, anArticle)>
+<function showArticleAttachments(anArticle, aCanEdit)>
+ <call showAttachments(1, anArticle, aCanEdit)>
</function>
<function showCommentAttachments(aComment)>
- <call showAttachments(0, aComment)>
+ <call showAttachments(0, aComment, "1")>
</function>
-<function showAttachments(anIsArticle, anObject)>
+<function showAttachments(anIsArticle, anObject, aCanEdit)>
<if anIsArticle=="1">
<assign objectKey="articleid">
<assign objectModule="Content">
<td align=right valign=top class="table-left">
${lang("content.images")}:
</td>
- <td align="left" valign="top" class="listrow2">
- <a href="${config.actionRoot}?module=Images&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addimage")}</a> |
- <a href="${config.actionRoot}?module=Images&do=add&${objectKey}=${anObject.id}">${lang("content.uploadimage")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top" class="listrow2">
+ <a href="${config.actionRoot}?module=Images&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addimage")}</a> |
+ <a href="${config.actionRoot}?module=Images&do=add&${objectKey}=${anObject.id}">${lang("content.uploadimage")}</a>
+ </td>
+ </if>
</tr>
<list anObject.to_all_media_images as m>
<tr>
<td align=right valign=top>
<a href="${config.actionRoot}?module=Images&do=edit&id=${m["id"]}"><img src="${config.actionRoot}?module=Images&do=getIcon&id=${m["id"]}" alt="edit" border="0"></a>
</td>
- <td align="left" valign="top">
- <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top">
+ <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
+ </td>
+ </if>
</tr>
</list>
-
<tr>
<td align=right valign=top class="table-left">
${lang("content.audio")}:
</td>
- <td align="left" valign="top" class="listrow2">
- <a href="${config.actionRoot}?module=Audio&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addaudio")}</a> |
- <a href="${config.actionRoot}?module=Audio&do=add&${objectKey}=${anObject.id}">${lang("content.uploadaudio")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top" class="listrow2">
+ <a href="${config.actionRoot}?module=Audio&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addaudio")}</a> |
+ <a href="${config.actionRoot}?module=Audio&do=add&${objectKey}=${anObject.id}">${lang("content.uploadaudio")}</a>
+ </td>
+ </if>
</tr>
<list anObject.to_all_media_audio as m>
<tr>
<td align=right valign=top>
<a href="${config.actionRoot}?module=Audio&do=edit&id=${m["id"]}"><img src="${config.docRoot}/img/${m["big_icon"]}" alt="edit" border="0"></a>
</td>
- <td align="left" valign="top">
- <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top">
+ <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
+ </td>
+ </if>
</tr>
</list>
<td align=right valign=top class="table-left">
${lang("content.video")}:
</td>
- <td align="left" valign="top" class="listrow2">
- <a href="${config.actionRoot}?module=Video&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addvideo")}</a> |
- <a href="${config.actionRoot}?module=Video&do=add&${objectKey}=${anObject.id}">${lang("content.uploadvideo")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top" class="listrow2">
+ <a href="${config.actionRoot}?module=Video&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addvideo")}</a> |
+ <a href="${config.actionRoot}?module=Video&do=add&${objectKey}=${anObject.id}">${lang("content.uploadvideo")}</a>
+ </td>
+ </if>
</tr>
<list anObject.to_all_media_video as m>
<tr>
<td align=right valign=top>
<a href="${config.actionRoot}?module=Video&do=edit&id=${m["id"]}"><img src="${config.docRoot}/img/${m["big_icon"]}" alt="edit" border="0"></a>
</td>
- <td align="left" valign="top">
- <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top">
+ <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
+ </td>
+ </if>
</tr>
</list>
+
<tr>
<td align=right valign=top class="table-left">
${lang("content.other")}:
</td>
- <td align="left" valign="top" class="listrow2">
- <a href="${config.actionRoot}?module=OtherMedia&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addother")}</a> |
- <a href="${config.actionRoot}?module=OtherMedia&do=add&${objectKey}=${anObject.id}">${lang("content.uploadother")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top" class="listrow2">
+ <a href="${config.actionRoot}?module=OtherMedia&do=list&${objectKey}=${anObject.id}">[+] ${lang("content.addother")}</a> |
+ <a href="${config.actionRoot}?module=OtherMedia&do=add&${objectKey}=${anObject.id}">${lang("content.uploadother")}</a>
+ </td>
+ </if>
</tr>
<list anObject.to_all_media_other as m>
<tr>
<td align=right valign=top">
<a href="${config.actionRoot}?module=OtherMedia&do=edit&id=${m["id"]}"><img src="${config.docRoot}/img/${m["big_icon"]}" alt="edit" border="0"></a>
</td>
- <td align="left" valign="top">
- <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
- </td>
+ <if aCanEdit=="1">
+ <td align="left" valign="top">
+ <a href="${config.actionRoot}?module=${objectModule}&do=dettach&${objectKey}=${anObject.id}&mid=${m["id"]}">[-] ${lang("delete")}</a>
+ </td>
+ </if>
</tr>
</list>
</table>
<function MediaSearch (module)>
-<form method="GET" action="${config.actionRoot}">
-
-<input type="hidden" name="module" value="${module}">
-<input type="hidden" name="do" value="search">
-<input type="hidden" name="articleid" value="${articleid}">
-<input type="hidden" name="commentid" value="${commentid}">
-
-<table border="0" cellspacing="2" cellpadding="2">
- <tr>
- <td class="table-head">${lang("search")}:</td>
- <td class="table-head">${lang("medialist.search_text_in")}:</td>
- <td class="table-head">${lang("media.published")}:</td>
- <td class="table-head">${lang("media.mediafolder")}:</td>
- <td class="table-head"> </td>
- <td><a class="link-box" href="${config.actionRoot}?module=${module}&do=add">[+] ${lang("add")} </a></td>
- </tr>
-
- <tr>
- <td class="listrow2">
- <input type="text" size="20" maxlength="30" name="searchtext" value="${searchtext}">
- </td>
- <td class="listrow2">
- <select name="searchfield">
- <option value="title"<if searchfield=="title"> selected</if>>${lang("media.title")}</option>
- <option value="creator"<if searchfield=="creator"> selected</if>>${lang("media.creator")}</option>
- <option value="place"<if searchfield=="place"> selected</if>>${lang("media.location")}</option>
- </select>
- </td>
-
- <td class="listrow2">
- <select name="searchispublished">
- <option value="">${lang("dontcare")}</option>
- <option value="0" <if searchispublished=="0"> selected</if>>${lang("no")}</option>
- <option value="1" <if searchispublished=="1"> selected</if>>${lang("yes")}</option>
+ <form method="GET" action="${config.actionRoot}">
+
+ <input type="hidden" name="module" value="${module}">
+ <input type="hidden" name="do" value="search">
+ <input type="hidden" name="articleid" value="${articleid}">
+ <input type="hidden" name="commentid" value="${commentid}">
+
+ <table border="0" cellspacing="2" cellpadding="2">
+ <tr>
+ <td class="table-head">${lang("search")}:</td>
+ <td class="table-head">${lang("medialist.search_text_in")}:</td>
+ <td class="table-head">${lang("media.published")}:</td>
+ <td class="table-head">${lang("media.mediafolder")}:</td>
+ <td class="table-head"> </td>
+ <td><a class="link-box" href="${config.actionRoot}?module=${module}&do=add">[+] ${lang("add")} </a></td>
+ </tr>
+
+ <tr>
+ <td class="listrow2">
+ <input type="text" size="20" maxlength="30" name="searchtext" value="${searchtext}">
+ </td>
+ <td class="listrow2">
+ <select name="searchfield">
+ <option value="title"<if searchfield=="title"> selected</if>>${lang("media.title")}</option>
+ <option value="creator"<if searchfield=="creator"> selected</if>>${lang("media.creator")}</option>
+ <option value="place"<if searchfield=="place"> selected</if>>${lang("media.location")}</option>
+ </select>
+ </td>
+
+ <td class="listrow2">
+ <select name="searchispublished">
+ <option value="">${lang("dontcare")}</option>
+ <option value="0" <if searchispublished=="0"> selected</if>>${lang("no")}</option>
+ <option value="1" <if searchispublished=="1"> selected</if>>${lang("yes")}</option>
+ </select>
+ </td>
+
+ <td class="listrow2">
+ <select name="searchmediafolder">
+ <option value="">-</option>
+ <list mediafolders as m>
+ <option value="${m.id}" <if m.id == searchmediafolder>selected</if>>${m.name}</option>
+ </list>
</select>
- </td>
-
- <td class="listrow2">
- <select name="searchmediafolder">
- <option value="">-</option>
- <list mediafolders as m>
- <option value="${m.id}" <if m.id == searchmediafolder>selected</if>>${m.name}</option>
- </list>
- </select>
- </td>
-
- <td class="listrow2">
- <input type="submit" class="majorbutton" name="search" value="${lang("filter")}">
- </td>
-
- <td>
-
- </td>
- </tr>
-</table>
-
-</form>
-
+ </td>
+
+ <td class="listrow2">
+ <input type="submit" class="majorbutton" name="search" value="${lang("filter")}">
+ </td>
+
+ <td>
+
+ </td>
+ </tr>
+ </table>
+
+ </form>
+
</function>
<function MediaList (module)>
<call PulldownTableRow (lang("comment.language"), "to_language", languages, "id", "name", comment.to_language, "")>
<call CheckboxTableRow (lang("comment.html"), "is_html", comment.is_html )>
<call TextAreaTableRow (lang("comment.text"), "", 70, 15, "description", comment.description)>
+ <call TextAreaTableRow (lang("comment.comment"), lang("comment.comment.info"), 70, 6, "comment", comment.comment)>
<tr>
<td colspan="2" align="right" class="table-foot" >
${lang("comment.article")} / ${lang("comment.title")} / ${lang("comment.creator")} / ${lang("comment.text")}
</td>
<td>
+ ${lang("comment.comment")}
+ </td>
+ <td>
</td>
</tr>
${lang("by")}: ${entry.creator}
</if>
<br>
- ${utility.encodeHTML(entry.description)}
+ ${utility.prettyEncodeHTML(entry.description)}
<if entry.main_url><br>URL: ${entry.main_url}</if>
<br>
</td>
<td valign="top">
+ ${utility.prettyEncodeHTML(entry.comment)}
+ </td>
+ <td valign="top">
<if config["Mir.Localizer.Admin.AllowDeleteComment"]=="1">
<a class="small" href="${config.actionRoot}?module=Comment&do=delete&id=${entry.id}&okurl=${utility.encodeURI(thisurl)}&cancelurl=${utility.encodeURI(thisurl)}">[${lang("delete")}]</a>
<include "FUNCTIONS.template">
<include "head.template">
+<if new=="0">
+ <table width="100%" cellspacing="0" cellpadding="5">
+ <tr>
+ <td align="left" valign="top">
+ <call showGETButton(
+ "module=Comment&do=articlecomments&articleid="+article.id+"&returnurl="+utility.encodeURI(thisurl),
+ lang("content.comments"))>
+ </td>
+ <td align="right" valign="top">
+ <if article.is_locked=="1" && article.lockinguser>
+ ${lang("content.lockedby", article.lockinguser.login)}
+ </if>
+
+ <if mayLock=="1">
+ <form method="post" action="${config.actionRoot}">
+ <input type="hidden" name="module" value="Content">
+ <input type="hidden" name="id" value="${utility.encodeHTML(article.id)}">
+ <input type="hidden" name="returnurl" value="${utility.encodeURI(thisurl)}">
+ <input type="hidden" name="do" value="lock">
+ <input type="submit" class="majorbutton" name="lock" value="${lang("content.lock")}">
+ </form>
+ </if>
+ <if mayUnlock=="1">
+ <form method="post" action="${config.actionRoot}">
+ <input type="hidden" name="module" value="Content">
+ <input type="hidden" name="id" value="${utility.encodeHTML(article.id)}">
+ <input type="hidden" name="returnurl" value="${utility.encodeURI(thisurl)}">
+ <input type="hidden" name="do" value="unlock">
+ <input type="submit" class="majorbutton" name="unlock" value="${lang("content.unlock")}">
+ </form>
+ </if>
+ <if mayForceLock=="1">
+ <form method="post" action="${config.actionRoot}">
+ <input type="hidden" name="module" value="Content">
+ <input type="hidden" name="id" value="${utility.encodeHTML(article.id)}">
+ <input type="hidden" name="returnurl" value="${utility.encodeURI(thisurl)}">
+ <input type="hidden" name="do" value="forcelock">
+ <input type="submit" class="majorbutton" name="fotcelock" value="${lang("content.forcelock")}">
+ </form>
+ </if>
+ </td>
+ </tr>
+ </table>
+</if>
+
+<if mayEdit=="1">
<form method="post" action="${config.actionRoot}">
<input type="hidden" name="module" value="Content">
<input type="hidden" name="id" value="${utility.encodeHTML(article.id)}">
<else>
<input type="hidden" name="do" value="update">
</if>
+</if>
<table width="100%" cellspacing="0" cellpadding="5">
<tr>
<td align="left" valign="top">
<if new=="0">
- <call showGETButton(
- "module=Comment&do=articlecomments&articleid="+article.id+"&returnurl="+utility.encodeURI(thisurl),
- lang("content.comments"))>
- <call showAbsoluteLinkButton(
- article.publicurl,
- lang("preview"))>
<list article.operations as op>
<call showPOSTButton(
"module=Localizer&do=articleoperation&operation="+op+"&articleid="+article.id+"&returnurl="+utility.encodeURI(thisurl),
lang("content.operation."+op))>
</list>
</if>
-
</td>
<td align="right" valign="top">
${lang("content.published")} :
- <input type="checkbox" name="is_published" value="1"<if article.is_published!="0" && article.is_published!=""> checked</if>>
- <if new=="1">
- <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
+ <if mayEdit=="1">
+ <input type="checkbox" name="is_published" value="1"<if article.is_published!="0" && article.is_published!=""> checked</if>>
+ <if new=="1">
+ <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
+ <else>
+ <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
+ </if>
<else>
- <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
+ <if article.is_published!="0" && article.is_published!="">${lang("yes")}<else>${lang("no")}</if>
</if>
</td>
</tr>
</table>
<table width="100%" cellspacing="3" cellpadding="2">
<tr>
- <td align="right" class="table-left">
+ <td align="right" class="table-left" width="30%">
id # :
</td>
<td class="listrow2">
${lang("content.create_date")}:
</td>
<td class="listrow2">
- ${utility.encodeHTML(article.creationdate.format(config["Mir.DefaultDateTimeFormat"]))}<br>${lang("edit")}:
- <input type="text" size="10" maxlength="16" name="webdb_create" value=""> <span class="small">(yyyy-mm-dd [HH:mm])</span>
+ ${utility.encodeHTML(article.creationdate.format(config["Mir.DefaultDateTimeFormat"]))}
+ <if mayEdit=="1">
+ <br>${lang("edit")}:
+ <input type="text" size="10" maxlength="16" name="webdb_create" value=""> <span class="small">(yyyy-mm-dd [HH:mm])</span>
+ </if>
</td>
</tr>
- <call PulldownTableRow (lang("content.articletype"), "to_article_type", articletypes, "id", "name", article.to_article_type, "articletypes.")>
- <call PulldownTableRow (lang("content.language"), "to_language", languages, "id", "name", article.to_language, "")>
-
+ <call _PulldownTableRow (lang("content.articletype"), "to_article_type", articletypes, "id", "name", article.to_article_type, "articletypes.", mayEdit)>
+ <call _PulldownTableRow (lang("content.language"), "to_language", languages, "id", "name", article.to_language, "", mayEdit)>
<list topics as r>
- <tr>
- <td align="right" valign="top" class="table-left">
- ${lang(r.key)}:
- </td>
- <td class="listrow2">
- <if r.listtype=="1">
- <table border=0 cellpadding="2" cellspacing="0">
- <tr>
- <assign col=r.listparameter>
- <list r.items as t>
- <if col=="0">
- </tr>
- <tr>
- <assign col=r.listparameter>
- </if>
- <td title="${utility.encodeHTML(t.description)}">
- <input type="checkbox" name="to_topic" value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>checked</if></list>>
- <span class="small"> ${t.title}</span>
- </td>
- <assign col=utility.increment(col, "-1")>
- </list>
- <if col!="0">
- <td colspan="${col}">
-
- </td>
+ <tr>
+ <td align="right" valign="top" class="table-left">
+ ${lang(r.key)}:
+ </td>
+ <td class="listrow2">
+ <if mayEdit=="1">
+ <if r.listtype=="1">
+ <table border=0 cellpadding="2" cellspacing="0">
+ <tr>
+ <assign col=r.listparameter>
+ <list r.items as t>
+ <if col=="0">
+ </tr>
+ <tr>
+ <assign col=r.listparameter>
+ </if>
+ <td title="${utility.encodeHTML(t.description)}">
+ <input type="checkbox" name="to_topic" value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>checked</if></list>>
+ <span class="small"> ${t.title}</span>
+ </td>
+ <assign col=utility.increment(col, "-1")>
+ </list>
+ <if col!="0">
+ <td colspan="${col}">
+
+ </td>
+ </if>
+ </tr>
+ </table>
+ <else>
+ <if r.listtype=="0">
+ <select name="to_topic" size="r.listparameter" multiple>
+ <list r.items as t>
+ <option value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>selected</if></list>>${t.title}</option>
+ </list>
+ </select>
+ <else>
+ <select name="to_topic" size="1">
+ <list r.items as t>
+ <option value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>selected</if></list>>${t.title}</option>
+ </list>
+ </select>
</if>
- </tr>
- </table>
- <else>
- <if r.listtype=="0">
- <select name="to_topic" size="r.listparameter" multiple>
- <list r.items as t>
- <option value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>selected</if></list>>${t.title}</option>
- </list>
- </select>
+ </if>
<else>
- <select name="to_topic" size="1">
- <list r.items as t>
- <option value="${t.id}" <list article.to_topics as to><if (t.id == to["id"])>selected</if></list>>${t.title}</option>
- </list>
- </select>
+ <list r.items as t>
+ <list article.to_topics as to><if (t.id == to["id"])>${t.title} <br/> </if></list>
+ </list>
</if>
- </if>
- </td>
- </tr>
+ </td>
+ </tr>
</list>
- <call TextInputTableRow (lang("content.title"), 40, 255, "title", article.title)>
- <call TextInputTableRowLight (lang("content.subtitle"), 40, 255, "subtitle", article.subtitle)>
- <call TextInputTableRowLight (lang("content.edittitle"), 40, 255, "edittitle", article.edittitle)>
- <comment>
- <call TextInputTableRowLight ("", 20, 20, "subtitle", article.edittitle)>
- </comment>
- <call TextInputTableRowLight (lang("content.location"), 40, 255, "source", article.source)>
- <call TextInputTableRow (lang("content.creator"), 40, 80, "creator", article.creator)>
- <call TextInputTableRowLight (lang("content.creator.email"), 40, 80, "creator_email", article.creator_email)>
- <call TextInputTableRowLight (lang("content.creator.url"), 40, 255, "creator_main_url", article.creator_main_url)>
- <call TextInputTableRowLight (lang("content.creator.address"), 20, 80, "creator_address", article.creator_address)>
- <call TextInputTableRowLight (lang("content.creator.telephone"), 20, 20, "creator_phone", article.creator_phone)>
- <call CheckboxTableRow (lang("content.html"), "is_html", article.is_html )>
- <call TextAreaTableRow (lang("content.abstract"), "", 70, 15, "description", article.description)>
- <call TextAreaTableRow (lang("content.content"), "", 70, 20, "content_data", article.content_data)>
- <call TextAreaTableRow (lang("content.comment"), lang("content.internal"), 70, 6, "comment", article.comment)>
+ <call _TextInputTableRow (lang("content.title"), 40, 255, "title", article.title, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.subtitle"), 40, 255, "subtitle", article.subtitle, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.edittitle"), 40, 255, "edittitle", article.edittitle, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.location"), 40, 255, "source", article.source, mayEdit)>
+ <call _TextInputTableRow (lang("content.creator"), 40, 80, "creator", article.creator, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.creator.email"), 40, 80, "creator_email", article.creator_email, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.creator.url"), 40, 255, "creator_main_url", article.creator_main_url, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.creator.address"), 20, 80, "creator_address", article.creator_address, mayEdit)>
+ <call _TextInputTableRowLight (lang("content.creator.telephone"), 20, 20, "creator_phone", article.creator_phone, mayEdit)>
+ <call _CheckboxTableRow (lang("content.html"), "is_html", article.is_html, mayEdit)>
+ <call _TextAreaTableRow (lang("content.abstract"), "", 70, 15, "description", article.description, mayEdit)>
+ <call _TextAreaTableRow (lang("content.content"), "", 70, 20, "content_data", article.content_data, mayEdit)>
+ <call _TextAreaTableRow (lang("content.comment"), lang("content.internal"), 70, 6, "comment", article.comment, mayEdit)>
+ <call _TextAreaTableRow (lang("content.keywords"), "", 70, 4, "keywords", article.keywords, mayEdit)>
- <tr>
- <td colspan="2" align="right" valign="top">
- <if new=="1">
- <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
- <else>
- <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
- </if>
- </td>
- </tr>
+ <if mayEdit=="1">
+ <tr>
+ <td colspan="2" align="right" valign="top">
+ <if new=="1">
+ <input type="submit" class="majorbutton" name="save" value="${lang("insert")}">
+ <else>
+ <input type="submit" class="majorbutton" name="save" value="${lang("save")}">
+ </if>
+ </td>
+ </tr>
+ </if>
</table>
<if new=="0">
-
-<table width="90%" cellspacing="0" cellpadding="0">
-
-<tr>
-<td align="left" valign="top">
-
-<table cellspacing="3" cellpadding="2">
- <tr>
- <td class="table-head" colspan="2">
- ${lang("content.family")}
- </td>
- </tr>
-
+ <table width="90%" cellspacing="0" cellpadding="0">
+
<tr>
- <td align=right valign=top class="table-left">
- ${lang("content.parent")}:
- </td>
- <td align="left" valign="top" class="listrow2">
- <if article.parent>
- <b>${utility.encodeHTML(article.parent.title)}</b><br>
- <a href="${config.actionRoot}?module=Content&do=edit&id=${article.parent.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.viewparent")}</a> |
- <a href="${config.actionRoot}?module=Content&do=clearparent&id=${article.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.clearparent")}</a> |
- </if>
- <a href="${config.actionRoot}?module=Content&do=selectparent&id=${article.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.selectparent")}</a>
- </td>
- </tr>
+ <td align="left" valign="top">
- <tr>
- <td align=right valign=top class="table-left">
- ${lang("content.children")}:
- </td>
- <td align="left" valign="top" class="listrow2">
- <a href="${config.actionRoot}?module=Content&do=listchildren&article_id=${article.id}">${lang("content.viewchildren")}</a>
+ <table cellspacing="3" cellpadding="2">
+ <tr>
+ <td class="table-head" colspan="2">
+ ${lang("content.family")}
+ </td>
+ </tr>
+
+ <tr>
+ <td align=right valign=top class="table-left">
+ ${lang("content.parent")}:
+ </td>
+ <td align="left" valign="top" class="listrow2">
+ <if article.parent>
+ <b>${utility.encodeHTML(article.parent.title)}</b><br>
+ <a href="${config.actionRoot}?module=Content&do=edit&id=${article.parent.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.viewparent")}</a> |
+ <a href="${config.actionRoot}?module=Content&do=clearparent&id=${article.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.clearparent")}</a> |
+ </if>
+ <if mayEdit=="1">
+ <a href="${config.actionRoot}?module=Content&do=selectparent&id=${article.id}&returnurl=${utility.encodeURI(thisurl)}">${lang("content.selectparent")}</a>
+ </if>
+ </td>
+ </tr>
+
+ <tr>
+ <td align=right valign=top class="table-left">
+ ${lang("content.children")}:
+ </td>
+ <td align="left" valign="top" class="listrow2">
+ <a href="${config.actionRoot}?module=Content&do=listchildren&article_id=${article.id}">${lang("content.viewchildren")}</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td align="right" valign="top">
+ <call showArticleAttachments(article, mayEdit)>
</td>
</tr>
</table>
-</td>
-<td align="right" valign="top">
-<call showArticleAttachments(article)>
-</td>
-</tr>
-</table>
-
</if>
-
-</form>
+<if mayEdit=="1">
+ </form>
+</if>
<include "foot.template">
</body>
<table border="0" width="100%">
<tr>
- <td valign="top" width="40%">
+ <td valign="top" >
<!-- ###### left column ###### -->
<p class="box-head"><b>${lang("start.administer.title")}</b></p>
<p class="box">
<comment> Middle column </comment>
- <td valign="top" width="30%">
+ <td valign="top" >
<p class="box-head"><b>${lang("start.addandedit.title")}</b></p>
<div class="box">
<comment> RIGHT COLUMN </comment>
- <td valign="top" width="26%" rowspan="2">
+ <td valign="top" rowspan="2">
<comment>internal messageboard</comment>
<include "FUNCTIONS.template">
<include "head.template">
-<form action="${config.actionRoot}" method="post">
- <input type="hidden" name="module" value="Users">
- <input type="hidden" name="id" value="${user.id}">
- <if passwordonly=="1">
- <input type="hidden" name="do" value="updatepassword">
- <else>
- <if new=="1">
- <input type="hidden" name="do" value="insert">
- <else>
- <input type="hidden" name="do" value="update">
- </if>
- </if>
+ <if passwordonly=="1">
+ <assign method="updatepassword">
+ <else>
+ <if new=="1">
+ <assign method="insert">
+ <else>
+ <assign method="update">
+ </if>
+ </if>
+
+ <call EditStart(
+ ["module", "id", "do"],
+ ["Users", user.id, method])>
+
- <table border="0">
<if passwordonly=="1">
- <call ReadonlyTextTableRow(lang("user.login"), user.login)>
- <call PasswordTextInputTableRow (lang("user.oldpassword"), 40, 40, "oldpassword", "")>
+ <call EditReadonlyTextNormal(lang("user.login"), user.login)>
+ <call EditPasswordNormal(lang("user.oldpassword"), 40, 40, "oldpassword", "")>
<else>
- <call TextInputTableRow (lang("user.login"), 40, 40, "login", user.login)>
- <call PasswordTextInputTableRow (lang("user.ownpassword"), 40, 40, "oldpassword", "")>
+ <if new!="1">
+ <call EditReadonlyTextNormal(lang("user.creationdate"), user.creationdate.formatted[config["Mir.DefaultDateTimeFormat"]])>
+ <call EditReadonlyTextNormal(lang("user.lastlogindate"), user.lastlogindate.formatted[config["Mir.DefaultDateTimeFormat"]])>
+ </if>
+ <call EditTextNormal (lang("user.login"), 40, 16, "login", user.login)>
+ <call EditPasswordNormal (lang("user.ownpassword"), 40, 40, "oldpassword", "")>
</if>
- <call PasswordTextInputTableRow (lang("user.password"), 40, 40, "newpassword", "")>
- <call PasswordTextInputTableRow (lang("user.password2"), 40, 40, "newpassword2", "")>
+ <call EditPasswordNormal(lang("user.password"), 40, 40, "newpassword", "")>
+ <call EditPasswordNormal(lang("user.password2"), 40, 40, "newpassword2", "")>
+
<if passwordonly=="1">
- <call ReadonlyTextTableRow(lang("user.admin"), user.is_admin)>
+ <call EditReadonlyTextNormal(lang("user.admin"), user.is_admin)>
<else>
- <call CheckboxTableRow(lang("user.admin"), "is_admin", user.is_admin)>
+ <call EditCheckboxNormal(lang("user.admin"), "is_admin", user.is_admin)>
+ <call EditCheckboxNormal(lang("user.is_disabled"), "is_disabled", user.is_disabled)>
+ <call EditTextNormal (lang("user.email"), 40, 255, "email", user.email)>
+ <call EditTextAreaNormal(lang("user.comment"), "", 40, 10, "comment", user.comment)>
+ <call EditTextAreaNormal(lang("user.profile"), "", 40, 10, "profile", user.profile)>
</if>
- <tr>
- <td colspan="2" align="right" class="table-foot">
- <span class="witetext">
- <if new=="1">
- <input type="submit" name="save" value="${lang("insert")}">
- <else>
- <input type="submit" name="save" value="${lang("save")}">
- </if>
- </span>
- </td>
- </tr>
- </table>
-</form>
- <if passwordonly>
- <call showBack("")>
+
+ <if new=="1">
+ <call EditSubmitButtonNormal(lang("insert"), "save")>
+ <else>
+ <call EditSubmitButtonNormal(lang("save"), "save")>
+ </if>
+
+ <call EditEnd()>
+
+ <if returnurl>
+ <call showBack(returnurl)>
<else>
- <call showBack("module=Users&do=list")>
+ <if passwordonly>
+ <call showBack("")>
+ <else>
+ <call showBack("module=Users&do=list")>
+ </if>
</if>
<include "foot.template">
<html>
-<head>
-<title>${lang("usererror.htmltitle")}</title>
-</head>
-<body>
-<include "templates/admin/head_nonavi.template">
-<table width="100%" border="0" align="center">
- <tr bgcolor="#006600">
- <td>
- <div align="center"><h2><font color="Pink">${lang("usererror.title")}</font></h2>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <p>${lang("usererror.text")}
- </td>
- </tr>
- <tr>
- <td>
- <p>
- <p align="center"><font size="5" color="Red"><b> ${data.errorstring}</b></font>
- <p>
- <p>
- </td>
- </tr>
- <tr>
- <td>
- <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">${lang("usererror.what_to_do")}
- </a></font>
- <p>
- </td>
- </tr>
-</table>
-<include "foot.template">
-</body>
+ <head>
+ <title>${config["Mir.Name"]} | ${lang("error.htmltitle")}</title>
+ <link rel="stylesheet" type="text/css" href="${config.docRoot}/style/admin.css">
+ </head>
+ <body>
+ <include "head.template">
+
+ <table width="70%" align="center"><tr><td>
+
+ <p class="box-head" align="center"><font size="+2"><b>${lang("usererror.title")}</b></font></p>
+ <p align="center" class="bg-neutral"><br><font color="red">${date.format(config["Mir.DefaultDateTimeFormat"])} -- ${errorstring}</font><br><br></p>
+ <p align="center">${lang("usererror.what_to_do")}</p>
+
+ </td></tr></table>
+
+ <include "foot.template">
+ </body>
</html>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<include "FUNCTIONS.template">
+ <include "LISTFUNCTIONS.template">
<include "head.template">
- <call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
-
- <if users>
- <call showPrevNextLinks(prevurl, nexturl, "left")>
- <call EntityTable(users, ["login","is_admin"], [lang("user.login"), lang("user.admin")], from, to, count, mayDeleteUsers, mayEditUsers, "Users")>
- <call showPrevNextLinks(prevurl, nexturl, "left")>
+ <if mayEditUsers=="1">
<call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
+
+ <if users>
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+
+
+
+
+ <call ListStart()>
+ <call ListHead([
+ lang("user.login"),
+ lang("user.admin"),
+ lang("user.is_disabled"),
+ lang("user.creationdate"),
+ lang("user.lastlogindate"),
+ lang("user.comment"),
+ lang("user.email")])>\r
+ <list users as u>
+ <call ListEntry([
+ u.login,
+ u.is_admin,
+ u.is_disabled,
+ u.creationdate.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"]),
+ u.lastlogindate.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"]),
+ utility.prettyEncodeHTML(u.comment),
+ u.email],
+ "module=Users&id="+u.id,
+ ["&do=delete", "&do=edit"],
+ [lang("delete"), lang("edit")])>
+ </list>\r
+ <call ListEnd()>\r
+
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+ <call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
+ <else>
+ <P align="center">${lang("no_matches_found")}</p>
+ </if>
<else>
- <P align="center">${lang("no_matches_found")}</p>
+ <if users>
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+
+ <call EntityTable(users,
+ ["login"],
+ [lang("user.login")],
+ from, to, count, mayDeleteUsers, mayEditUsers, "Users")>
+
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+ <call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
+ <else>
+ <P align="center">${lang("no_matches_found")}</p>
+ </if>
</if>
<include "foot.template">