length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >\r
- \r
-<hibernate-mapping>\r
-\r
-<!-- \r
- Created by Middlegen Hibernate plugin\r
-\r
- http://boss.bekk.no/boss/middlegen/\r
- http://hibernate.sourceforge.net/\r
--->\r
-\r
-<class \r
- name="mir.core.model.Comment" \r
- table="comment"\r
->\r
- <id\r
- name="id"\r
- type="int"\r
- column="id"\r
- >\r
- <generator class="assigned" />\r
- </id>\r
- <property\r
- name="title"\r
- type="java.lang.String"\r
- column="title"\r
- not-null="true"\r
- length="80"\r
- />\r
- <property\r
- name="creator"\r
- type="java.lang.String"\r
- column="creator"\r
- not-null="true"\r
- length="80"\r
- />\r
- <property\r
- name="description"\r
- type="java.lang.String"\r
- column="description"\r
- not-null="true"\r
- length="-1"\r
- />\r
- <property\r
- name="mainUrl"\r
- type="java.lang.String"\r
- column="main_url"\r
- length="255"\r
- />\r
- <property\r
- name="email"\r
- type="java.lang.String"\r
- column="email"\r
- length="80"\r
- />\r
- <property\r
- name="address"\r
- type="java.lang.String"\r
- column="address"\r
- length="80"\r
- />\r
- <property\r
- name="phone"\r
- type="java.lang.String"\r
- column="phone"\r
- length="20"\r
- />\r
- <property\r
- name="webdbCreate"\r
- type="java.sql.Timestamp"\r
- column="webdb_create"\r
- not-null="true"\r
- length="8"\r
- />\r
- <property\r
- name="isPublished"\r
- type="boolean"\r
- column="is_published"\r
- not-null="true"\r
- length="1"\r
- />\r
- <property\r
- name="toLanguage"\r
- type="int"\r
- column="to_language"\r
- not-null="true"\r
- length="4"\r
- />\r
- <property\r
- name="toMedia"\r
- type="int"\r
- column="to_media"\r
- not-null="true"\r
- length="4"\r
- />\r
- <property\r
- name="toCommentStatus"\r
- type="short"\r
- column="to_comment_status"\r
- length="2"\r
- />\r
- <property\r
- name="checksum"\r
- type="int"\r
- column="checksum"\r
- length="4"\r
- />\r
- <property\r
- name="isHtml"\r
- type="boolean"\r
- column="is_html"\r
- not-null="true"\r
- length="1"\r
- />\r
-\r
- <!-- associations -->\r
-\r
-</class>\r
-</hibernate-mapping>\r
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
+
+<hibernate-mapping>
+
+<!--
+ Created by Middlegen Hibernate plugin
+
+ http://boss.bekk.no/boss/middlegen/
+ http://hibernate.sourceforge.net/
+-->
+
+<class
+ name="mir.core.model.Comment"
+ table="comment"
+>
+ <id
+ name="id"
+ type="int"
+ column="id"
+ >
+ <generator class="assigned" />
+ </id>
+ <property
+ name="title"
+ type="java.lang.String"
+ column="title"
+ not-null="true"
+ length="80"
+ />
+ <property
+ name="creator"
+ type="java.lang.String"
+ column="creator"
+ not-null="true"
+ length="80"
+ />
+ <property
+ name="description"
+ type="java.lang.String"
+ column="description"
+ not-null="true"
+ length="-1"
+ />
+ <property
+ name="mainUrl"
+ type="java.lang.String"
+ column="main_url"
+ length="255"
+ />
+ <property
+ name="email"
+ type="java.lang.String"
+ column="email"
+ length="80"
+ />
+ <property
+ name="address"
+ type="java.lang.String"
+ column="address"
+ length="80"
+ />
+ <property
+ name="phone"
+ type="java.lang.String"
+ column="phone"
+ length="20"
+ />
+ <property
+ name="webdbCreate"
+ type="java.sql.Timestamp"
+ column="webdb_create"
+ not-null="true"
+ length="8"
+ />
+ <property
+ name="published"
+ type="boolean"
+ column="is_published"
+ not-null="true"
+ length="1"
+ />
+ <property
+ name="toLanguage"
+ type="int"
+ column="to_language"
+ not-null="true"
+ length="4"
+ />
+ <property
+ name="toMedia"
+ type="int"
+ column="to_media"
+ not-null="true"
+ length="4"
+ />
+ <property
+ name="toCommentStatus"
+ type="short"
+ column="to_comment_status"
+ length="2"
+ />
+ <property
+ name="checksum"
+ type="int"
+ column="checksum"
+ length="4"
+ />
+ <property
+ name="html"
+ type="boolean"
+ column="is_html"
+ not-null="true"
+ length="1"
+ />
+
+ <!-- associations -->
+
+</class>
+</hibernate-mapping>
*
* Comment
* @author idefix
- * @version $Id: Comment.java,v 1.2 2003/08/17 19:13:19 idfx Exp $
+ * @version $Id: Comment.java,v 1.3 2003/09/05 20:23:59 idfx Exp $
*/
public class Comment implements Serializable {
this.webdbCreate = webdbCreate;
}
- public boolean isIsPublished() {
+ public boolean isPublished() {
return this.isPublished;
}
- public void setIsPublished(boolean isPublished) {
+ public void setPublished(boolean isPublished) {
this.isPublished = isPublished;
}
this.checksum = checksum;
}
- public boolean isIsHtml() {
+ public boolean isHtml() {
return this.isHtml;
}
- public void setIsHtml(boolean isHtml) {
+ public void setHtml(boolean isHtml) {
this.isHtml = isHtml;
}
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
length="8"
/>
<property
- name="isHtml"
+ name="html"
type="boolean"
column="is_html"
not-null="true"
*
* Content
* @author idefix
- * @version $Id: Content.java,v 1.3 2003/08/19 00:41:54 idfx Exp $
+ * @version $Id: Content.java,v 1.4 2003/09/05 20:23:59 idfx Exp $
*/
public class Content extends Media implements Serializable, IContent {
public Content() {
}
- public boolean isIsHtml() {
+ public boolean isHtml() {
return this.isHtml;
}
- public void setIsHtml(boolean isHtml) {
+ public void setHtml(boolean isHtml) {
this.isHtml = isHtml;
}
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >\r
- \r
-<hibernate-mapping>\r
-\r
-<!-- \r
- Created by Middlegen Hibernate plugin\r
-\r
- http://boss.bekk.no/boss/middlegen/\r
- http://hibernate.sourceforge.net/\r
--->\r
-\r
-<class \r
- name="mir.core.model.Feature" \r
- table="feature"\r
->\r
- <id\r
- name="id"\r
- type="int"\r
- column="id"\r
- >\r
- <generator class="sequence" />\r
- </id>\r
- <property\r
- name="title"\r
- type="java.lang.String"\r
- column="title"\r
- not-null="true"\r
- length="80"\r
- />\r
- <property\r
- name="description"\r
- type="java.lang.String"\r
- column="description"\r
- length="-1"\r
- />\r
- <property\r
- name="filename"\r
- type="java.lang.String"\r
- column="filename"\r
- not-null="true"\r
- length="20"\r
- />\r
- <property\r
- name="mainUrl"\r
- type="java.lang.String"\r
- column="main_url"\r
- length="255"\r
- />\r
- <property\r
- name="isPublished"\r
- type="boolean"\r
- column="is_published"\r
- not-null="true"\r
- length="1"\r
- />\r
-\r
- <!-- associations -->\r
-\r
-</class>\r
-</hibernate-mapping>\r
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
+
+<hibernate-mapping>
+
+<!--
+ Created by Middlegen Hibernate plugin
+
+ http://boss.bekk.no/boss/middlegen/
+ http://hibernate.sourceforge.net/
+-->
+
+<class
+ name="mir.core.model.Feature"
+ table="feature"
+>
+ <id
+ name="id"
+ type="int"
+ column="id"
+ >
+ <generator class="sequence" />
+ </id>
+ <property
+ name="title"
+ type="java.lang.String"
+ column="title"
+ not-null="true"
+ length="80"
+ />
+ <property
+ name="description"
+ type="java.lang.String"
+ column="description"
+ length="-1"
+ />
+ <property
+ name="filename"
+ type="java.lang.String"
+ column="filename"
+ not-null="true"
+ length="20"
+ />
+ <property
+ name="mainUrl"
+ type="java.lang.String"
+ column="main_url"
+ length="255"
+ />
+ <property
+ name="published"
+ type="boolean"
+ column="is_published"
+ not-null="true"
+ length="1"
+ />
+
+ <!-- associations -->
+
+</class>
+</hibernate-mapping>
*
* Feature
* @author idefix
- * @version $Id: Feature.java,v 1.2 2003/08/17 19:13:19 idfx Exp $
+ * @version $Id: Feature.java,v 1.3 2003/09/05 20:23:59 idfx Exp $
*/
public class Feature implements Serializable {
this.mainUrl = mainUrl;
}
- public boolean isIsPublished() {
+ public boolean isPublished() {
return this.isPublished;
}
- public void setIsPublished(boolean isPublished) {
+ public void setPublished(boolean isPublished) {
this.isPublished = isPublished;
}
/**
* IContent
* @author idefix
- * @version $Id: IContent.java,v 1.1 2003/08/19 00:41:54 idfx Exp $
+ * @version $Id: IContent.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public interface IContent extends IMedia {
- public abstract boolean isIsHtml();
- public abstract void setIsHtml(boolean isHtml);
+ public abstract boolean isHtml();
+ public abstract void setHtml(boolean isHtml);
public abstract java.lang.String getContentData();
public abstract void setContentData(java.lang.String contentData);
public abstract ArticleType getArticleType();
/**
* IMedia
* @author idefix
- * @version $Id: IMedia.java,v 1.1 2003/08/19 00:41:54 idfx Exp $
+ * @version $Id: IMedia.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public interface IMedia {
public abstract java.lang.Integer getId();
public abstract void setPublishServer(java.lang.String publishServer);
public abstract java.lang.String getPublishPath();
public abstract void setPublishPath(java.lang.String publishPath);
- public abstract boolean isIsPublished();
- public abstract void setIsPublished(boolean isPublished);
- public abstract boolean isIsProduced();
- public abstract void setIsProduced(boolean isProduced);
public abstract java.util.Date getWebdbCreate();
public abstract void setWebdbCreate(java.util.Date webdbCreate);
public abstract java.util.Date getWebdbLastchange();
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
*
* Media
* @author idefix
- * @version $Id: Media.java,v 1.4 2003/08/19 00:41:54 idfx Exp $
+ * @version $Id: Media.java,v 1.5 2003/09/05 20:23:59 idfx Exp $
*/
public class Media implements Serializable, IMedia {
this.publishPath = publishPath;
}
- public boolean isIsPublished() {
- return this.isPublished;
- }
-
- public void setIsPublished(boolean isPublished) {
- this.isPublished = isPublished;
- }
-
- public boolean isIsProduced() {
- return this.isProduced;
- }
-
- public void setIsProduced(boolean isProduced) {
- this.isProduced = isProduced;
- }
-
public java.util.Date getWebdbCreate() {
return this.webdbCreate;
}
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
*
* Topic
* @author idefix
- * @version $Id: Topic.java,v 1.2 2003/08/17 19:13:19 idfx Exp $
+ * @version $Id: Topic.java,v 1.3 2003/09/05 20:23:59 idfx Exp $
*/
-public class Topic implements Serializable {
-
- /** identifier field */
- private Integer id;
-
- /** persistent field */
- private String title;
-
- /** nullable persistent field */
- private String description;
-
- /** persistent field */
- private String filename;
-
- /** nullable persistent field */
- private String mainUrl;
-
- /** nullable persistent field */
- private String archivUrl;
-
- /** nullable persistent field */
- private mir.core.model.Topic parentTopic;
+public class Topic extends TopicStub implements Serializable {
private Set content;
/** default constructor */
public Topic() {
+ super();
}
-
- public java.lang.Integer getId() {
- return this.id;
- }
-
- public void setId(java.lang.Integer id) {
- this.id = id;
- }
-
- public java.lang.String getTitle() {
- return this.title;
- }
-
- public void setTitle(java.lang.String title) {
- this.title = title;
- }
-
- public java.lang.String getDescription() {
- return this.description;
- }
-
- public void setDescription(java.lang.String description) {
- this.description = description;
- }
-
- public java.lang.String getFilename() {
- return this.filename;
- }
-
- public void setFilename(java.lang.String filename) {
- this.filename = filename;
- }
-
- public java.lang.String getMainUrl() {
- return this.mainUrl;
- }
-
- public void setMainUrl(java.lang.String mainUrl) {
- this.mainUrl = mainUrl;
- }
-
- public java.lang.String getArchivUrl() {
- return this.archivUrl;
- }
-
- public void setArchivUrl(java.lang.String archivUrl) {
- this.archivUrl = archivUrl;
- }
-
- public mir.core.model.Topic getParentTopic() {
- return this.parentTopic;
- }
-
- public void setParentTopic(mir.core.model.Topic parentTopic) {
- this.parentTopic = parentTopic;
- }
-
/**
* @return
*/
--- /dev/null
+/*
+ * TopicStub.java created on 30.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.model;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/**
+ * TopicStub
+ * @author idefix
+ * @version $Id: TopicStub.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ */
+public class TopicStub implements Serializable {
+
+ /** identifier field */
+ private Integer id;
+
+ /** persistent field */
+ private String title;
+
+ /** nullable persistent field */
+ private String description;
+
+ /** persistent field */
+ private String filename;
+
+ /** nullable persistent field */
+ private String mainUrl;
+
+ /** nullable persistent field */
+ private String archivUrl;
+
+ /** nullable persistent field */
+ private mir.core.model.Topic parentTopic;
+
+ /**
+ *
+ */
+ public TopicStub() {
+ super();
+ }
+
+ public java.lang.Integer getId() {
+ return this.id;
+ }
+
+ public void setId(java.lang.Integer id) {
+ this.id = id;
+ }
+
+ public java.lang.String getTitle() {
+ return this.title;
+ }
+
+ public void setTitle(java.lang.String title) {
+ this.title = title;
+ }
+
+ public java.lang.String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(java.lang.String description) {
+ this.description = description;
+ }
+
+ public java.lang.String getFilename() {
+ return this.filename;
+ }
+
+ public void setFilename(java.lang.String filename) {
+ this.filename = filename;
+ }
+
+ public java.lang.String getMainUrl() {
+ return this.mainUrl;
+ }
+
+ public void setMainUrl(java.lang.String mainUrl) {
+ this.mainUrl = mainUrl;
+ }
+
+ public java.lang.String getArchivUrl() {
+ return this.archivUrl;
+ }
+
+ public void setArchivUrl(java.lang.String archivUrl) {
+ this.archivUrl = archivUrl;
+ }
+
+ public mir.core.model.Topic getParentTopic() {
+ return this.parentTopic;
+ }
+
+ public void setParentTopic(mir.core.model.Topic parentTopic) {
+ this.parentTopic = parentTopic;
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("id", getId())
+ .toString();
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof Topic) ) return false;
+ Topic castOther = (Topic) other;
+ return new EqualsBuilder()
+ .append(this.getId(), castOther.getId())
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder()
+ .append(getId())
+ .toHashCode();
+ }
+
+
+}
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
length="255"
/>
<property
- name="isPublished"
+ name="published"
type="boolean"
column="is_published"
not-null="true"
length="1"
/>
<property
- name="isProduced"
+ name="produced"
type="boolean"
column="is_produced"
not-null="true"
/**
* ArticleTypeService
* @author idefix
- * @version $Id: ArticleTypeService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: ArticleTypeService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class ArticleTypeService extends StorageService {
super(ArticleType.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) {
+ // doonothing;
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Audio;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* AudioService
* @author idefix
- * @version $Id: AudioService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: AudioService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class AudioService extends StorageService {
super(Audio.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject)
+ throws HibernateException {
+ if(returnObject instanceof Audio){
+ Audio audio = (Audio)returnObject;
+ Hibernate.initialize(audio.getContent());
+
+ }
+ }
+
}
package mir.core.service.storage;
import mir.core.model.BreakingNewsItem;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* BreakingService
* @author idefix
- * @version $Id: BreakingService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: BreakingService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class BreakingService extends StorageService {
super(BreakingNewsItem.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ //do nothing
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Comment;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* CommentService
* @author idefix
- * @version $Id: CommentService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: CommentService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class CommentService extends StorageService {
super(Comment.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof Comment){
+ Comment comment = (Comment)returnObject;
+ }
+ }
+
}
package mir.core.service.storage;
import mir.core.model.CommentStatus;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* CommentStatusService
* @author idefix
- * @version $Id: CommentStatusService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: CommentStatusService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class CommentStatusService extends StorageService {
super(CommentStatus.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ //do nothing
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Content;
+import mir.core.model.IContent;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* ContentService
* @author idefix
- * @version $Id: ContentService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: ContentService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class ContentService extends StorageService {
super(Content.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof IContent){
+ IContent content = (IContent)returnObject;
+ Hibernate.initialize(content.getAttachedMedias());
+ Hibernate.initialize(content.getChildContent());
+ Hibernate.initialize(content.getContent());
+ Hibernate.initialize(content.getTopics());
+ }
+ }
+
}
*/
package mir.core.service.storage;
+import mir.core.model.IImage;
import mir.core.model.Image;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* ImageService
* @author idefix
- * @version $Id: ImageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: ImageService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class ImageService extends StorageService {
super(Image.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof IImage){
+ IImage image = (IImage)returnObject;
+ Hibernate.initialize(image.getContent());
+ }
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Language;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* LanguageService
* @author idefix
- * @version $Id: LanguageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: LanguageService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class LanguageService extends StorageService {
super(Language.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ // do nothing
+ }
+
}
package mir.core.service.storage;
import mir.core.model.MediaFolder;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* MediaFolderService
* @author idefix
- * @version $Id: MediaFolderService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: MediaFolderService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class MediaFolderService extends StorageService {
super(MediaFolder.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ // do nothing
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Message;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* MessageService
* @author idefix
- * @version $Id: MessageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: MessageService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class MessageService extends StorageService {
super(Message.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ // do nothing
+ }
+
}
*/
package mir.core.service.storage;
+import mir.core.model.IUploadedMedia;
import mir.core.model.OtherMedia;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* OtherMediaService
* @author idefix
- * @version $Id: OtherMediaService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: OtherMediaService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class OtherMediaService extends StorageService {
public OtherMediaService(SessionFactory factory) {
super(OtherMedia.class, factory);
}
+
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof IUploadedMedia){
+ IUploadedMedia media = (IUploadedMedia)returnObject;
+ Hibernate.initialize(media.getContent());
+ }
+ }
}
/**
* SessionHolder
* @author idefix
- * @version $Id: SessionHolder.java,v 1.1 2003/08/19 00:42:38 idfx Exp $
+ * @version $Id: SessionHolder.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class SessionHolder {
private ThreadLocal threadLocalSession;
public void closeSession() throws HibernateException {
Session session = (Session) threadLocalSession.get();
- threadLocalSession.set(null);
if (session != null) {
+ session.flush();
session.close();
}
+ threadLocalSession.set(null);
}
}
import java.util.List;
+import mir.core.model.IImage;
import net.sf.hibernate.Criteria;
+import net.sf.hibernate.Hibernate;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
*
* StorageService
* @author idefix
- * @version $Id: StorageService.java,v 1.2 2003/08/19 00:42:38 idfx Exp $
+ * @version $Id: StorageService.java,v 1.3 2003/09/05 20:23:59 idfx Exp $
*/
public abstract class StorageService {
private Class objectClass;
.setMaxResults(limit);
List returnList = criteria.list();
transaction.commit();
+ sessionHolder.closeSession();
return returnList;
} catch (HibernateException e) {
throw new StorageServiceFailure(e);
Session session = sessionHolder.currentSession();
Transaction transaction = session.beginTransaction();
Object returnObject = session.load(objectClass, id);
+ initializeLazyCollections(returnObject);
transaction.commit();
+ sessionHolder.closeSession();
return returnObject;
} catch (HibernateException e) {
throw new StorageServiceFailure(e);
}
}
+ /**
+ * @param returnObject
+ */
+ protected abstract void initializeLazyCollections(Object returnObject)
+ throws HibernateException;
+
public Integer add(Object newObject){
try {
Session session = sessionHolder.currentSession();
package mir.core.service.storage;
import mir.core.model.Topic;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* TopicService
* @author idefix
- * @version $Id: TopicService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: TopicService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class TopicService extends StorageService {
super(Topic.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof Topic){
+ Topic topic = (Topic)returnObject;
+ Hibernate.initialize(topic.getContent());
+ }
+ }
+
}
*/
package mir.core.service.storage;
+import mir.core.model.IUploadedMedia;
import mir.core.model.UploadedMedia;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* UploadedMediaService
* @author idefix
- * @version $Id: UploadedMediaService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: UploadedMediaService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class UploadedMediaService extends StorageService {
super(UploadedMedia.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof IUploadedMedia){
+ IUploadedMedia media = (IUploadedMedia)returnObject;
+ Hibernate.initialize(media.getContent());
+ }
+ }
+
}
import java.util.List;
import mir.core.model.MirUser;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.expression.Expression;
/**
* UserService
* @author idefix
- * @version $Id: UserService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: UserService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class UserService extends StorageService {
return (MirUser)list.get(0);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ //do nothing
+ }
+
}
package mir.core.service.storage;
import mir.core.model.Video;
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
import net.sf.hibernate.SessionFactory;
/**
* VideoService
* @author idefix
- * @version $Id: VideoService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ * @version $Id: VideoService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
*/
public class VideoService extends StorageService {
super(Video.class, factory);
}
+ /**
+ * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
+ */
+ protected void initializeLazyCollections(Object returnObject) throws HibernateException {
+ if(returnObject instanceof Video){
+ Video video = (Video)returnObject;
+ Hibernate.initialize(video.getContent());
+ }
+ }
+
}
/**
* Test
- * @version $Id: Test.java,v 1.5 2003/08/19 00:43:02 idfx Exp $
+ * @version $Id: Test.java,v 1.6 2003/09/05 20:23:59 idfx Exp $
* @author idefix
*/
public class Test {
transaction.commit();
session.close();
ImageService imageService = new ImageService(factory);
- list = imageService.list(0,10);
+ //list = imageService.list(0,10);
System.out.println("****** image media");
- for(Iterator iterator = list.iterator(); iterator.hasNext();){
- Image media = (Image)iterator.next();
- System.out.println(media.toString() + media.getIconPath());
- }
+ //for(Iterator iterator = list.iterator(); iterator.hasNext();){
+ // Image media = (Image)iterator.next();
+ // System.out.println(media.toString() + media.getIconPath());
+ //}
IImage image = (IImage)imageService.load(new Integer(18));
System.out.println(image);
session = factory.openSession();
--- /dev/null
+/*
+ * AuthenticationAction.java created on 05.09.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.ui.action;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+/**
+ * AuthenticationAction
+ * @author idefix
+ * @version $Id: AuthenticationAction.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ */
+public class AuthenticationAction extends Action {
+
+
+ /**
+ * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm,
+ HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
+ // TODO Auto-generated method stub
+ return actionMapping.findForward("success");
+ }
+
+}
--- /dev/null
+/*
+ * AuthenticationFilter.java created on 04.09.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.ui.filter;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import mir.core.model.MirUser;
+import mir.core.ui.servlet.*;
+
+/**
+ * AuthenticationFilter
+ * @author idefix
+ * @version $Id: AuthenticationFilter.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ */
+public class AuthenticationFilter implements Filter {
+ private FilterConfig _filterConfig;
+ /**
+ *
+ */
+ public AuthenticationFilter() {
+ super();
+ }
+
+ /**
+ * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+ */
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ _filterConfig = filterConfig;
+ }
+
+ /**
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
+ HttpServletRequest request = (HttpServletRequest)servletRequest;
+ String requestUri = request.getRequestURI();
+ System.out.println(requestUri);
+ System.out.println(request.getContextPath());
+ if(requestUri != null && requestUri.startsWith(request.getContextPath() + "/admin")){
+ //check if authenticated, only if in admin-module
+ HttpSession httpSession = request.getSession();
+ MirUser mirUser = (MirUser)httpSession.getAttribute(ServletConstants.USER);
+ if(mirUser == null){
+ servletRequest.getRequestDispatcher("/admin/login.shtml").forward(servletRequest, servletResponse);
+ }
+ }
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+
+ /**
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy() {
+ }
+
+}
--- /dev/null
+/*
+ * HibernatePlugin.java
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.ui.plugin;
+
+import javax.servlet.ServletException;
+
+import mir.core.ui.servlet.ServletConstants;
+import net.sf.hibernate.HibernateException;
+import net.sf.hibernate.SessionFactory;
+import net.sf.hibernate.cfg.Configuration;
+
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.action.PlugIn;
+import org.apache.struts.config.ModuleConfig;
+
+/**
+ * HibernatePlugin
+ * @version $Id: HibernatePlugin.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ * @author idefix
+ */
+public class HibernatePlugin implements PlugIn {
+
+ /**
+ * @see org.apache.struts.action.PlugIn#destroy()
+ */
+ public void destroy() {
+ }
+
+ /**
+ * @see org.apache.struts.action.PlugIn#init(org.apache.struts.action.ActionServlet, org.apache.struts.config.ModuleConfig)
+ */
+ public void init(ActionServlet actionServlet, ModuleConfig config)
+ throws ServletException {
+ try {
+ SessionFactory factory =
+ new Configuration().configure().buildSessionFactory();
+ actionServlet.getServletContext()
+ .setAttribute(ServletConstants.SESSION_FACTORY, factory);
+ } catch (HibernateException e) {
+ throw new ServletException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * ServletConstants.java created on 05.09.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.ui.servlet;
+
+/**
+ * ServletConstants<br>
+ * Some constant string values needed as keys to store values in the servlet context.
+ * @author idefix
+ * @version $Id: ServletConstants.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ */
+public interface ServletConstants {
+ public static final String SESSION_FACTORY = "session factory";
+
+ public static final String USER = "user";
+
+}
--- /dev/null
+/*
+ * TemplateServlet.java created on 01.09.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 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.core.ui.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.servlet.ServletModuleExc;
+import mir.util.ResourceBundleGeneratorFunction;
+import mircoders.servlet.ServletHelper;
+
+import org.apache.struts.util.MessageResources;
+
+/**
+ * TemplateServlet
+ * @author idefix
+ * @version $Id: TemplateServlet.java,v 1.1 2003/09/05 20:23:59 idfx Exp $
+ */
+public class TemplateServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ public TemplateServlet() {
+ super();
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected final void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ process(request, response);
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected final void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ process(request, response);
+ }
+
+ /**
+ * Processes the request and invokes the presentation
+ * @param request
+ * @param response
+ */
+ protected void process(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ PrintWriter printWriter = response.getWriter();
+ Map requestData = new HashMap();
+ Enumeration keys = request.getAttributeNames();
+ while(keys.hasMoreElements()){
+ final String key = (String)keys.nextElement();
+ requestData.put(key, request.getAttribute(key));
+ }
+ Map sessionData = new HashMap();
+ HttpSession httpSession = request.getSession();
+ keys = httpSession.getAttributeNames();
+ while(keys.hasMoreElements()){
+ final String key = (String)keys.nextElement();
+ sessionData.put(key, httpSession.getAttribute(key));
+ }
+ Map applicationData = new HashMap();
+ ServletContext servletContext = getServletContext();
+ keys = servletContext.getAttributeNames();
+ while(keys.hasMoreElements()){
+ final String key = (String)keys.nextElement();
+ applicationData.put(key, servletContext.getAttribute(key));
+ }
+ Map templateData = new HashMap();
+ templateData.put("request", requestData);
+ templateData.put("session", sessionData);
+ templateData.put("application", applicationData);
+ try {
+ templateData.put("config", MirPropertiesConfiguration.instance().allSettings());
+ } catch (PropertiesConfigExc e) {
+ throw new ServletException(e);
+ }
+
+ String templateName = generateTemplateString(request);
+
+ Locale[] locales = new Locale[2];
+ locales[0] = request.getLocale();
+ locales[1] = request.getLocale();
+
+ try {
+ //write the servlet
+ generateResponse(printWriter, templateData, templateName, locales);
+ } catch (ServletModuleExc e) {
+ throw new ServletException(e);
+ }
+ }
+
+ private String generateTemplateString(HttpServletRequest request){
+ String returnString = request.getServletPath();
+ returnString = returnString.substring(0, returnString.indexOf("."));
+ return returnString + ".template";
+ }
+
+ private void generateResponse(PrintWriter printWriter, Map map,
+ String templateString, Locale[] locales)
+ throws ServletModuleExc{
+ if(templateString.startsWith("/admin")){
+ map.put( "lang",
+ new ResourceBundleGeneratorFunction( locales,
+ new MessageResources[] { MessageResources.getMessageResources("bundles.admin"),
+ MessageResources.getMessageResources("bundles.adminlocal")}));
+
+ templateString = templateString.substring(6);
+ ServletHelper.generateResponse(printWriter, map, templateString);
+ }
+ if(templateString.startsWith("/open")){
+ map.put( "lang",
+ new ResourceBundleGeneratorFunction( locales,
+ new MessageResources[] { MessageResources.getMessageResources("bundles.open"),
+ MessageResources.getMessageResources("bundles.open")}));
+
+ templateString = templateString.substring(5);
+ ServletHelper.generateOpenPostingResponse(printWriter, map, templateString);
+ }
+ }
+
+ /**
+ * @see javax.servlet.Servlet#destroy()
+ */
+ public void destroy() {
+ super.destroy();
+ }
+
+ /**
+ * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
+ */
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ }
+}