aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075106 [15/18] - in /aries/tags/samples-0.1-incubating: ./ ariestrader/ ariestrader/assemblies/ ariestrader/assemblies/ariestrader-all-eba/ ariestrader/assemblies/ariestrader-jdbc-eba/ ariestrader/assemblies/equinox-test-harness/ ariestra...
Date Sun, 27 Feb 2011 18:28:41 GMT
Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/AuthorImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/AuthorImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/AuthorImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/AuthorImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,143 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.persistence.jpa.entity;
+
+
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+
+import org.apache.aries.samples.blog.api.persistence.Author;
+
+/**
+ * This class represents a blog post Author
+ */
+
+@Entity(name = "AUTHOR")
+@Table(name = "AUTHOR")
+public class AuthorImpl implements Author
+{
+  /** The author's email address */
+  @Id
+  @Column(nullable = false, unique = true)
+  private String email;
+  
+  /** The author's full name */
+  private String name;
+  /** The display name for this author */
+  private String displayName;
+  /** A short bio for this author */
+  private String bio;  
+  /** The Author's date of birth */
+  private Date dob;
+
+  /** The blog entries posted by this user */
+  @OneToMany(cascade = {CascadeType.REMOVE}, fetch = FetchType.EAGER)
+  @OrderBy("publishDate DESC")
+  private List<EntryImpl> posts;
+
+  /** Get the author's email address */
+  public String getEmail()
+  {
+    return email;
+  }
+
+  /** Get the author's full name */
+  public String getName()
+  {
+    return name;
+  } 
+  
+  /** Get the author's displayed name */
+  public String getDisplayName()
+  {
+    return displayName;
+  }
+
+  /** Get the author's biographical information */
+  public String getBio()
+  {
+    return bio;
+  }
+
+  /** Get the author's date of birth */
+  public Date getDob()
+  {
+    return dob;
+  } 
+
+  /** Get the author's blog posts */
+  public List<EntryImpl> getEntries()
+  {
+    return posts;
+  }
+  
+  // Set methods are not defined in the interface
+  
+  /** Set the author's email address */
+  public void setEmail(String email)
+  {
+    this.email = email;
+  }
+  
+  /** Set the author's full name */
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+  
+  /** Set the author's displayed name */
+  public void setDisplayName(String displayName)
+  {
+    this.displayName = displayName;
+  }
+  
+  /** Set the author's biographical information */
+  public void setBio(String bio)
+  {
+    this.bio = bio;
+  }
+  
+  /** Set the author's date of birth */
+  public void setDob(Date dob)
+  {
+    this.dob = dob;
+  }
+
+  /** Update  the author's blog posts */
+  public void updateEntries(EntryImpl b)
+  {
+    this.posts.add(b);
+  }
+  
+  /** set  the author's blog posts */
+  public void setEntries(List<EntryImpl> lb)
+  {
+    this.posts = lb;
+  }
+  
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/EntryImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/EntryImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/EntryImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/entity/EntryImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.persistence.jpa.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.persistence.Column;
+
+import org.apache.aries.samples.blog.api.persistence.Entry;
+
+
+
+/**
+ * This class represents a blog entry
+ */
+@Entity(name = "BLOGENTRY")
+@Table(name = "BLOGENTRY")
+public class EntryImpl implements Entry
+{
+  /** An auto-generated primary key */
+	@Id
+	@GeneratedValue
+  private Long id;
+
+  /** The author of the blog post */
+	@ManyToOne(fetch=FetchType.EAGER)
+  private AuthorImpl author;
+
+  /** The date the post was published */
+  private Date publishDate;
+  /** The date the post was last updated */
+  private Date updatedDate;
+  /** The title of the post */
+  private String title;
+  /** Tags associated with the post */
+  private List<String> tags;
+  /** The text of the blog */
+	@Column(length=10000)
+  private String blogText;
+
+  /** Get the author of this blog post */
+  public AuthorImpl getAuthor()
+  {
+    return author;
+  }
+
+  /** Set the author of this blog post */
+  public void setAuthor(AuthorImpl author)
+  {
+    this.author = author;
+  }
+
+  /** Get the publish date of this blog post */
+  public Date getPublishDate()
+  {
+    return publishDate;
+  }
+
+  /** Set the publish date of this blog post */
+  public void setPublishDate(Date publishDate)
+  {
+    this.publishDate = publishDate;
+  }
+
+  /** Get the title of this blog post */
+  public String getTitle()
+  {
+    return title;
+  }
+
+  /** Set the title of this blog post */ 
+  public void setTitle(String title)
+  {
+    this.title = title;
+  }
+
+
+  /** Get the tags for this blog post */
+  public List<String> getTags()
+  {
+    return tags;
+  }
+
+  /** Set the tags for this blog post */
+  public void setTags(List<String> tags)
+  {
+    this.tags = tags;
+  }
+
+  /** Get the text for this blog post */
+  public String getBlogText()
+  {
+    return blogText;
+  }
+
+  /** Set the text for this blog post */
+  public void setBlogText(String blogText)
+  {
+    this.blogText = blogText;
+  }
+
+  /** get the Blog post id */
+  public long getId()
+  {
+    return id;
+  }
+
+  /** Set the id */
+  public void setId(Long id)
+  {
+    this.id = id;
+  }
+
+  /**
+   * @return The date of the last update to this blog
+   *         or null if it has never been modified
+   */
+  public Date getUpdatedDate()
+  {
+    return updatedDate;
+  }
+
+  /**
+   * Set the date that the blog post was last updated
+   * 
+   * @param updatedDate
+   */
+  public void setUpdatedDate(Date updatedDate)
+  {
+    this.updatedDate = updatedDate;
+  }
+
+
+}
+

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/META-INF/persistence.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/META-INF/persistence.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/META-INF/persistence.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,39 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+   version="1.0">
+
+  <persistence-unit name="blogExample" transaction-type="JTA">
+    <description>Persistence unit for the example blogging application</description>
+
+    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+
+    <jta-data-source>aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdb)</jta-data-source>
+    <non-jta-data-source>aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdbnojta)</non-jta-data-source>
+
+    <class>org.apache.aries.samples.blog.persistence.jpa.entity.AuthorImpl</class>
+    <class>org.apache.aries.samples.blog.persistence.jpa.entity.EntryImpl</class>
+    <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    
+    
+     <properties>
+    </properties>
+   
+  </persistence-unit>
+</persistence>

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+	<!--
+		Licensed to the Apache Software Foundation (ASF) under one or more
+		contributor license agreements. See the NOTICE file distributed with
+		this work for additional information regarding copyright ownership.
+		The ASF licenses this file to You under the Apache License, Version
+		2.0 (the "License"); you may not use this file except in compliance
+		with the License. You may obtain a copy of the License at
+
+		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+		applicable law or agreed to in writing, software distributed under the
+		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+		CONDITIONS OF ANY KIND, either express or implied. See the License for
+		the specific language governing permissions and limitations under the
+		License.
+	-->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0" xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
+	default-activation="lazy">
+
+	<bean id="persistenceImpl"
+		class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl">
+		<tx:transaction method="*" value="Required" />
+		<jpa:context property="entityManager" unitname="blogExample" />
+	</bean>
+
+	<service ref="persistenceImpl"
+		interface="org.apache.aries.samples.blog.api.persistence.BlogPersistenceService">
+	</service>
+
+</blueprint>

Added: aries/tags/samples-0.1-incubating/blog/blog-web/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.samples.blog</groupId>
+        <artifactId>blog</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+
+    <groupId>org.apache.aries.samples.blog</groupId>
+    <artifactId>org.apache.aries.samples.blog.web</artifactId>
+    <name>Apache Aries blog sample web component</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Web-ContextPath>/blog</Web-ContextPath>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Private-Package>org.apache.aries.samples.blog.web.*</Private-Package>
+                        <Export-Package>!org.apache.aries.samples.blog.web.*</Export-Package>
+                        <Import-Package>
+                            javax.servlet*;version=2.5,
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+	

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddComment.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddComment.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddComment.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddComment.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+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 org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+public class AddComment extends HttpServlet {
+	private static final long serialVersionUID = -920234218060948564L;
+	public static final String ERROR_MESSAGES_ID = "commentErrorMessages";
+
+	@Override
+	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+
+		// email address of the comment's author
+		String email = req.getParameter("email");
+		// the id of the blog entry to which this comment is associated
+		long postId = Long.parseLong(req.getParameter("postId"));
+		// the text of the comment
+		String text = req.getParameter("text");
+
+		BloggingService service = JNDIHelper.getBloggingService();
+
+		// retrieve the blog entry and create the associated comment
+
+		if (service.getBlogAuthor(email) != null) {
+			service.createBlogComment(text, email, postId);
+			resp.sendRedirect("ViewBlog");
+		} else {
+
+			if (email.equals(""))
+				addError(req, "The email field is required.");
+			else
+				addError(req, "The email filed is not valid.");
+			resp.sendRedirect("AddCommentForm?postId=" + postId);
+		}
+	}
+
+	public static void addError(HttpServletRequest req, String error) {
+		HttpSession session = req.getSession();
+		if (session != null) {
+			@SuppressWarnings("unchecked")
+			List<String> errors = (List<String>) session
+					.getAttribute(ERROR_MESSAGES_ID);
+
+			if (errors == null) {
+				errors = new ArrayList<String>();
+				session.setAttribute(ERROR_MESSAGES_ID, errors);
+			}
+
+			errors.add(error);
+		}
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddCommentForm.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddCommentForm.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddCommentForm.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/AddCommentForm.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.samples.blog.web.util.HTMLOutput;
+
+public class AddCommentForm extends HttpServlet{
+	private static final long serialVersionUID = 4989805137759774598L;
+	public static final String ERROR_MESSAGES_ID = "commentErrorMessages";
+	public static final String ID = "comment";
+
+
+	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+		PrintWriter out = resp.getWriter();
+		
+		String postId = checkPostId(req.getParameter("postId"));
+
+		// if we have a valid postId, display the add comment page
+		if (postId != null) {
+			HTMLOutput.writeHTMLHeaderPartOne(out, "Add Comment");
+			HTMLOutput.writeDojoUses(out, "dojo.parser", "dijit.dijit",
+					"dijit.Editor", "dijit.form.TextBox");
+
+			out.println("<script type=\"text/javascript\">");
+			out.println("function storeCommentContent() {");
+			out.println("var textBox = dijit.byId('textArea');");
+			out.println("var textArea = dojo.byId('text');");
+			out.println("textArea.value = textBox.getValue();");
+			out.println("}");
+			out.println("</script>");
+
+			HTMLOutput.writeHTMLHeaderPartTwo(out);
+			
+			List<String> errors = null;
+			if (req.getSession() != null)
+				errors = (List<String>) req.getSession().getAttribute(
+						ERROR_MESSAGES_ID);
+
+			if (errors != null) {
+				out.println("\t\t\t<div id=\"errorMessages\">");
+				for (String msg : errors) {
+					out.println("\t\t\t\t<div class=\"errorMessage\">" + msg
+							+ "</div>");
+				}
+
+				out.println("\t\t\t</div>");
+				req.getSession().removeAttribute("commentErrorMessages");
+			}
+
+			out
+					.println("<form name=\"createComment\" method=\"get\" action=\"AddComment\">");
+			out
+					.println("<div class=\"textEntry\"><textarea dojoType=\"dijit.Editor\" id=\"textArea\" name=\"textArea\"></textarea></div>");
+			out
+					.println("<div class=\"textEntry\"><label>Email <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"email\" /></label></div>");
+			out
+					.println("<input type=\"hidden\" name=\"text\" id=\"text\" value=\"\"/>");
+			out.print("<input type=\"hidden\" name=\"postId\" value=\"");
+			out.print(postId);
+			out.println("\"/>");
+			out
+					.println("<input class=\"submit\" type=\"submit\" value=\"Submit\" name=\"Submit\" onclick=\"storeCommentContent()\"/>");
+			out.println("</form>");
+
+			HTMLOutput.writeHTMLFooter(out);
+			
+		} else {
+			// otherwise show the blog
+			RequestDispatcher dispatch = getServletContext()
+					.getRequestDispatcher("ViewBlog");
+			dispatch.forward(req, resp);
+		}
+	}
+
+	private String checkPostId(String parameter) {
+		if (parameter != null && parameter.matches("^\\d*$"))
+			return parameter;
+		return null;
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntry.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntry.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntry.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntry.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.FormServlet;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+public class CreateBlogEntry extends HttpServlet
+{
+  private static final long serialVersionUID = -6484228320837122235L;
+
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException{
+        doPost(req,resp);
+  }
+  
+  @Override
+  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException
+  {
+    // new blog entry values
+    String email = req.getParameter("email");
+    String title = req.getParameter("title");
+    String text = req.getParameter("text");
+    String tags = req.getParameter("tags");
+    
+    BloggingService service = JNDIHelper.getBloggingService();
+    
+    if (service.getBlogAuthor(email) != null) {
+      service.createBlogEntry(email, title, text, tags);
+      resp.sendRedirect("ViewBlog");
+    } else {
+      storeParam(req, "email", email);
+      storeParam(req, "title", title);
+      storeParam(req, "text", text);
+      storeParam(req, "tags", tags);
+      
+      if (email.equals(""))
+        FormServlet.addError(req, "The email field is required.");
+      else
+        FormServlet.addError(req, "The author's email is not valid.");
+      
+      resp.sendRedirect("CreateBlogEntryForm");
+    }
+  }
+  
+  private void storeParam(HttpServletRequest req, String param, String value) 
+  {
+    FormServlet.storeParam(req, CreateBlogEntryForm.ID, param, value);
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntryForm.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntryForm.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntryForm.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/CreateBlogEntryForm.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.PrintWriter;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.aries.samples.blog.web.util.FormServlet;
+import org.apache.aries.samples.blog.web.util.HTMLOutput;
+
+
+public class CreateBlogEntryForm extends FormServlet
+{
+  private static final long serialVersionUID = -6484228320837122235L;
+  public static final String ID = "post";
+  
+  public CreateBlogEntryForm()
+  {
+    super(ID);
+  }
+  
+  @Override
+  protected String getPageTitle(HttpServletRequest req)
+  { 
+    return "Create Blog Post";
+  }
+
+  @Override
+  protected void writeForm(HttpServletRequest req, PrintWriter out)
+  {
+    String email = retrieveOrEmpty(req, "email");
+    String title = retrieveOrEmpty(req, "title");
+    String text = retrieveOrEmpty(req, "text");
+    String tags = retrieveOrEmpty(req, "tags");
+    
+    out.println("<form name=\"createPost\" method=\"post\" action=\"CreateBlogEntry\">");
+
+    out.println("<div class=\"textEntry\"><label>Title <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"title\" value=\"" + title + "\"/></label></div>");
+    out.println("<div class=\"textEntry\"><textarea dojoType=\"dijit.Editor\" id=\"text\" name=\"text\">" + text + "</textarea></div>");
+    out.println("<div class=\"textEntry\"><label>Email <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"email\" value=\"" + email + "\"/></label></div>");
+    out.println("<div class=\"textEntry\"><label>Tags &nbsp;<input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"tags\" value=\"" + tags + "\"/></label></div>");
+    
+    out.println("<input type=\"hidden\" name=\"text\" id=\"text\" value=\"\"/>");
+    out.println("<input class=\"submit\" type=\"submit\" value=\"Submit\" name=\"Submit\" onclick=\"storeBlogContent();return true;\"/>");
+    out.println("</form>");
+  }
+  
+  @Override
+  protected void writeCustomHeaderContent(HttpServletRequest req, PrintWriter out)
+  {
+    HTMLOutput.writeDojoUses(out, "dojo.parser", "dijit.dijit", "dijit.Editor", "dijit.form.TextBox"); 
+    
+    
+    out.println("<script type=\"text/javascript\">");
+    out.println("  function storeBlogContent() {");
+    out.println("    var textBox = dijit.byId('textArea');");
+    out.println("    var textArea = dojo.byId('text');");
+    out.println("    textArea.value = textBox.getValue();");
+    out.println("  }");
+    out.println("</script>");
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthor.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.FormServlet;
+import org.apache.aries.samples.blog.web.util.FormatChecker;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+public class EditAuthor extends HttpServlet
+{
+  private static final long serialVersionUID = -8881545878284864977L;
+
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+  {
+    doPost(req, resp);
+  }
+  
+  @Override
+  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException
+  {
+    // This method will update or create an author depending on the
+    // existence of the author in the database.
+    
+    // The authors email address is the key in the database, thus if
+    // the email address is not in the database we create this as a 
+    // new author.
+    
+    String email = req.getParameter("email");
+    String nickName = req.getParameter("nickName");
+    String name = req.getParameter("name");
+    String bio = req.getParameter("bio");
+    String dob = req.getParameter("dob");
+    
+    if (email == null || email.equals("")) {
+      storeParam(req, "email", email);
+      storeParam(req, "nickName", nickName);
+      storeParam(req, "name", name);
+      storeParam(req, "bio", bio);
+      storeParam(req, "dob", dob);
+      
+      FormServlet.addError(req, "The email field is required.");
+      resp.sendRedirect("EditAuthorForm");
+      
+    }else if (!FormatChecker.isValidEmail(email)) {
+    	storeParam(req, "email", email);
+        storeParam(req, "nickName", nickName);
+        storeParam(req, "name", name);
+        storeParam(req, "bio", bio);
+        storeParam(req, "dob", dob);
+        
+    	FormServlet.addError(req, "The email field is not properly formatted");
+        resp.sendRedirect("EditAuthorForm");	
+    } else {
+      BloggingService service = JNDIHelper.getBloggingService();
+
+      if (service.getBlogAuthor(email) != null) {
+        // do an update
+        service.updateBlogAuthor(email, nickName, name, bio, dob);
+      } else {
+        // do a create
+        service.createBlogAuthor(email, nickName, name, bio, dob);
+      } 
+      RequestDispatcher dispatch = getServletContext().getRequestDispatcher("/ViewAuthor");
+      dispatch.forward(req, resp);
+    }
+  }
+  
+    private void storeParam(HttpServletRequest req, String param, String value) 
+  {
+    FormServlet.storeParam(req, EditAuthorForm.ID, param, value);
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthorForm.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthorForm.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthorForm.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/EditAuthorForm.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.aries.samples.blog.api.BlogAuthor;
+import org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.FormServlet;
+import org.apache.aries.samples.blog.web.util.FormatChecker;
+import org.apache.aries.samples.blog.web.util.HTMLOutput;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+
+public class EditAuthorForm extends FormServlet
+{
+  private static final long serialVersionUID = 4996935653835900015L;
+  public static final String ID = "author";
+
+  public EditAuthorForm()
+  {
+    super(ID);
+  }
+  
+  @Override
+  protected void writeCustomHeaderContent(HttpServletRequest req, PrintWriter out)
+  {
+    HTMLOutput.writeDojoUses(out, "dijit.form.TextBox", "dijit.form.DateTextBox", "dijit.form.Textarea");
+  }
+
+  @Override
+  protected String getPageTitle(HttpServletRequest req) throws IOException
+  {
+    String pageTitle = "Create Author";
+    
+    BloggingService service = JNDIHelper.getBloggingService();
+    String email = getEmail(req);
+    
+    if (email != null && !!!"".equals(email)) {
+      BlogAuthor author = service.getBlogAuthor(email);
+      if (author != null) {
+        pageTitle = "Update " + author.getName() + "'s profile";
+      }
+    }
+    
+    return pageTitle;
+  }
+
+  private String getEmail(HttpServletRequest req)
+  {
+    String email = retrieveOrEmpty(req, "email");
+    
+    if ("".equals(email)) {
+      email = req.getParameter("email");
+    }
+    if(FormatChecker.isValidEmail(email))
+    	return email;
+    else 
+    	return null;
+  }
+  
+  @Override
+  protected void writeForm(HttpServletRequest req, PrintWriter out) throws IOException
+  {
+    String name = retrieveOrEmpty(req, "name");
+    String nickName = retrieveOrEmpty(req, "nickName");
+    String bio = retrieveOrEmpty(req, "bio");
+    String dob = retrieveOrEmpty(req, "dob");
+    String email = getEmail(req);
+    
+    BloggingService service = JNDIHelper.getBloggingService();
+    
+    if (email != null && !!!"".equals(email)) {
+      BlogAuthor author = service.getBlogAuthor(email);
+      
+      if ("".equals(name))
+        name = author.getFullName();
+      if ("".equals(nickName))
+        nickName = author.getName();
+      if ("".equals(bio))
+        bio = author.getBio();
+      if ("".equals(dob))
+        dob = author.getDateOfBirth();
+    } else {
+      email = "";
+    }
+    
+    out.println("<form method=\"get\" action=\"EditAuthor\">");
+    
+    out.print("<div class=\"textEntry\"><label>Name <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"name\" value=\"");
+    out.print(name);
+    out.println("\"/></label></div>");
+    out.print("<div class=\"textEntry\"><label>Nickname <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"nickName\" value=\"");
+    out.print(nickName);
+    out.println("\"/></label></div>");
+    out.print("<div class=\"textEntry\"><label>Email <input dojoType=\"dijit.form.TextBox\" type=\"text\" name=\"email\" value=\"");
+    out.print(email);
+    out.println("\"/></label></div>");
+    out.print("<div class=\"textEntry\"><label>Date of Birth <input dojoType=\"dijit.form.DateTextBox\" type=\"text\" name=\"dob\" required=\"true\" value=\"");
+    out.print(dob);
+    out.println("\"/></label></div>");
+    out.print("<div class=\"textEntry\"><label>Bio <textarea dojoType=\"dijit.form.Textarea\" style=\"width:300px\" name=\"bio\">");
+    out.print(bio);
+    out.println("</textarea></label></div>");
+
+    out.println("<input class=\"submit\" type=\"submit\" value=\"Submit\" name=\"Submit\"/>");
+    
+    out.println("</form>");
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewAuthor.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewAuthor.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewAuthor.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewAuthor.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.samples.blog.api.BlogAuthor;
+import org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.HTMLOutput;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+
+
+public class ViewAuthor extends HttpServlet
+{
+  private static final long serialVersionUID = 3020369464892668248L;
+
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException
+  {
+    String email = req.getParameter("email");
+    
+    if (email == null || "".equals(email)) {
+      // TODO dispatch to another page
+    } else {
+      PrintWriter out = resp.getWriter();
+      
+      BloggingService service = JNDIHelper.getBloggingService();
+      
+      BlogAuthor author = service.getBlogAuthor(email);
+      
+      HTMLOutput.writeHTMLHeaderPartOne(out, author.getName());
+      
+      HTMLOutput.writeHTMLHeaderPartTwo(out);
+
+      out.println("<h3>Name</h3>");
+      out.print("<div class=\"text\">");
+      out.print(author.getFullName());
+      out.println("</div>");
+      out.println("<h3>Nick Name</h3>");
+      out.print("<div class=\"text\">");
+      out.print(author.getName());
+      out.println("</div>");
+      out.println("<h3>Email</h3>");
+      out.print("<div class=\"text\">");
+      out.print(author.getEmailAddress());
+      out.println("</div>");
+      out.println("<h3>DOB</h3>");
+      out.print("<div class=\"text\">");
+      out.print(author.getDateOfBirth());
+      out.println("</div>");
+      out.println("<h3>Bio</h3>");
+      out.print("<div class=\"text\">");
+      out.print(author.getBio());
+      out.println("</div>");
+      
+      out.print("<a href=\"EditAuthorForm?email=");
+      out.print(author.getEmailAddress());
+      out.println("\">Edit Author Information</a>");
+      
+      HTMLOutput.writeHTMLFooter(out);
+    }
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewBlog.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewBlog.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewBlog.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/ViewBlog.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,225 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.samples.blog.api.BlogComment;
+import org.apache.aries.samples.blog.api.BlogEntry;
+import org.apache.aries.samples.blog.api.BloggingService;
+import org.apache.aries.samples.blog.web.util.HTMLOutput;
+import org.apache.aries.samples.blog.web.util.JNDIHelper;
+
+
+
+public class ViewBlog extends HttpServlet
+{
+  private static final long serialVersionUID = -1854915218416871420L;
+  private static final int POSTS_PER_PAGE = 10;
+  
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+      IOException
+  {
+    PrintWriter out = resp.getWriter();
+
+    BloggingService service = JNDIHelper.getBloggingService();
+    
+    String blogTitle = service.getBlogTitle();
+
+    // TODO cope with the service being null, redirect elsewhere.
+
+    HTMLOutput.writeHTMLHeaderPartOne(out, blogTitle);
+    HTMLOutput.writeDojoUses(out, "dojo.parser");
+    
+    
+
+		HTMLOutput.writeHTMLHeaderPartTwo(out);
+
+    int maxPage = (service.getNoOfEntries()-1) / POSTS_PER_PAGE;
+    int pageNoInt = 0;
+    
+    String pageNo = req.getParameter("page");
+    if (pageNo != null) {
+      try {
+        pageNoInt = Integer.parseInt(pageNo)-1;
+
+        if (pageNoInt > maxPage)
+          pageNoInt = maxPage;
+        else if (pageNoInt < 0)
+          pageNoInt = 0;
+        
+      } catch (NumberFormatException e) {
+        e.printStackTrace();
+      }
+    }
+  
+    Iterator<? extends BlogEntry> posts = service.getBlogEntries(pageNoInt * POSTS_PER_PAGE, POSTS_PER_PAGE).iterator();
+    
+    out.println("<div class=\"links\"><a href=\"CreateBlogEntryForm\">Create New Post</a> <a href=\"EditAuthorForm\">Create Author</a></div>");
+    
+    Date currentDate = null;
+
+    for (int i = 0; posts.hasNext(); i++) {
+      BlogEntry post = posts.next();
+      
+      if (doesNotMatch(post.getPublishDate(), currentDate)) {
+        currentDate = post.getPublishDate();
+        out.print("<div class=\"postDate\">");
+        //out.print(DateFormat.getDateInstance(DateFormat.FULL).format(currentDate));
+        if (currentDate != null) {
+        	 out.print(DateFormat.getDateInstance(DateFormat.FULL).format(currentDate));          
+        }
+
+        out.println("</div>");
+      }
+      
+      out.print("\t\t<div class=\"post\" id=\"");
+      out.print(i);
+      out.println("\">");
+
+      out.print("\t\t\t<div class=\"postTitle\">");
+      out.print(post.getTitle());
+      out.print("</div>");
+      out.print("\t\t\t<div class=\"postBody\">");
+      out.print(post.getBody());
+      out.println("</div>");
+      out.print("\t\t\t<div class=\"postAuthor\"><a href=\"ViewAuthor?email=");
+      out.print(post.getAuthorEmail());
+      out.print("\">");
+      out.print(post.getAuthor().getFullName());
+      out.println("</a></div>");
+      
+      if (service.isCommentingAvailable()) {
+
+			out.print("<div class=\"links\"><a href=\"AddCommentForm?postId=");
+			out.print(post.getId());
+			out.print("\">Add Comment</a></div>");
+
+			List<? extends BlogComment> comments = service
+					.getCommentsForEntry(post);
+			int size = comments.size();
+			out.print("<div class=\"commentTitle\"");
+			if (size > 0) {
+				out.print("onclick=\"expand(");
+				out.print(post.getId());
+				out.print(")\"");
+			}
+			out.print(" style=\"cursor: pointer;\">Comments (");
+			out.print(size);
+			out.println(")</div>");
+
+			if (size > 0) {
+
+				out.print("<div id=\"comments");
+				out.print(post.getId());
+				out.println("\">");
+
+				for (BlogComment comment : comments) {
+					out.println("<div class=\"comment\">");
+
+					out.println(comment.getComment());
+
+					out.println("</div>");
+					out
+							.print("\t\t\t<div class=\"commentAuthor\"><a href=\"ViewAuthor?email=");
+					out.print(comment.getAuthor().getEmailAddress());
+					out.print("\">");
+					out.print(
+						comment.getAuthor().getName());
+					out.println("</a></div>");
+				}
+
+				out.println("</div>");
+			}
+		}
+
+     
+      out.println("\t\t</div>");
+    }
+    
+    /*
+     * Translate indices from 0-indexed to 1-indexed
+     */
+    writePager(out, pageNoInt+1, maxPage+1);
+
+    HTMLOutput.writeHTMLFooter(out);
+  }
+  
+  /**
+   * Write a paging bar (if there is more than a single page)
+   * 
+   * @param out
+   * @param currentPage Page number (indices starting from 1)
+   * @param maxPage (indices starting from 1)
+   */
+  private void writePager(PrintWriter out, int currentPage, int maxPage)
+  {
+    /*
+     * No paging is needed if we only have a single page
+     */
+    if (maxPage > 1) {
+      out.println("<div id=\"pagination\">");
+      
+      if (currentPage > 1) {
+        out.println("<a href=\"ViewBlog?page=1\">&lt;&lt;</a>");
+        out.println("<a href=\"ViewBlog?page="+(currentPage-1)+"\">&lt;</a>");
+      } else {
+        out.println("<span>&lt;&lt;</span>");
+        out.println("<span>&lt;</span>");
+      }
+      
+      out.println(currentPage + " of " + maxPage);
+  
+      if (currentPage < maxPage) {
+        out.println("<a href=\"ViewBlog?page="+(currentPage+1)+"\">&gt;</a>");
+        out.println("<a href=\"ViewBlog?page=" + maxPage + "\">&gt;&gt;</a>");
+      } else {
+        out.println("<span>&gt;&gt;</span>");
+        out.println("<span>&gt;</span>");        
+      }
+      
+      out.println("</div>");
+    }
+  }
+
+  private boolean doesNotMatch(Date publishDate, Date currentDate)
+  {
+    if (currentDate == null) return true;
+    Calendar publish = Calendar.getInstance();
+    Calendar current = Calendar.getInstance();
+    publish.setTime(publishDate);
+    current.setTime(currentDate);
+    boolean differentYear = publish.get(Calendar.YEAR) != current.get(Calendar.YEAR);
+    boolean differentMonth = publish.get(Calendar.MONTH) != current.get(Calendar.MONTH);
+    boolean differentDayOfMonth = publish.get(Calendar.DAY_OF_MONTH) != current.get(Calendar.DAY_OF_MONTH);
+    return differentYear || differentMonth || differentDayOfMonth;
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormServlet.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormServlet.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormServlet.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormServlet.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+
+
+public abstract class FormServlet extends HttpServlet
+{
+  private static final long serialVersionUID = -1019904995493434571L;
+  public static final String ERROR_MESSAGES_ID = "errorMessages";
+  private String id;
+  
+  public static void addError(HttpServletRequest req, String error)
+  {
+    HttpSession session = req.getSession();
+    if (session != null) {
+      @SuppressWarnings("unchecked")
+      List<String> errors = (List<String>) session.getAttribute(ERROR_MESSAGES_ID); 
+  
+      if (errors == null) {
+        errors = new ArrayList<String>();
+        session.setAttribute(ERROR_MESSAGES_ID, errors);
+      }
+      
+      errors.add(error);
+    }
+  }
+  
+  public static void storeParam(HttpServletRequest req, String id, String param, String value)
+  {
+    HttpSession session = req.getSession();
+    if (session != null)
+      session.setAttribute(id + ":" + param, value);
+  }
+  
+  protected FormServlet(String id)
+  {
+    this.id = id;
+  }
+  
+  protected abstract void writeCustomHeaderContent(HttpServletRequest req, PrintWriter out);
+  protected abstract void writeForm(HttpServletRequest req, PrintWriter out) throws IOException;
+  protected abstract String getPageTitle(HttpServletRequest req) throws IOException;
+  
+  protected String retrieveOrEmpty(HttpServletRequest req, String param)
+  {
+    HttpSession session = req.getSession();
+    String value = "";
+    if (session != null) { 
+      value = (String) session.getAttribute(id+":"+param);
+      if (value == null) {
+        value = "";
+      }
+    }
+    
+    return value;
+  }
+  
+  @Override
+  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException
+  {
+    PrintWriter out = resp.getWriter();
+
+    HTMLOutput.writeHTMLHeaderPartOne(out, getPageTitle(req));
+    writeCustomHeaderContent(req, out);
+    
+    List<String> errors = null;
+    if (req.getSession() != null)
+      errors = (List<String>) req.getSession().getAttribute(ERROR_MESSAGES_ID);
+    
+    if (errors == null) {    
+      try {
+		HTMLOutput.writeHTMLHeaderPartTwo(out);
+	} catch (Exception e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	}
+    } else {
+      try {
+		HTMLOutput.writeHTMLHeaderPartTwo(out, errors);
+	} catch (Exception e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	}
+    }
+    
+    writeForm(req, out);
+    
+    HTMLOutput.writeHTMLFooter(out);
+    cleanupSession(req);
+  }
+  
+  private void cleanupSession(HttpServletRequest req) 
+  {
+    HttpSession session = req.getSession();
+
+    if (session != null) {
+      @SuppressWarnings("unchecked")
+      Enumeration<String> names = session.getAttributeNames();
+      
+      while (names.hasMoreElements()) {
+        String name = names.nextElement();
+        if (name.startsWith(id+":"))
+          session.removeAttribute(name);
+      }
+      
+      session.removeAttribute("errorMessages");
+    }
+  }  
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormatChecker.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormatChecker.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormatChecker.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/FormatChecker.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web.util;
+
+
+public class FormatChecker {
+	public static boolean isValidEmail(String email) {
+		if (email != null && email.matches("^(?:[a-zA-Z0-9_'^&amp;/+-])+(?:\\.(?:[a-zA-Z0-9_'^&amp;/+-])+)*@(?:(?:\\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\]?)|(?:[a-zA-Z0-9-]+\\.)+(?:[a-zA-Z]){2,}\\.?)$")) return true;
+		return false;
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/HTMLOutput.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/HTMLOutput.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/HTMLOutput.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/HTMLOutput.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web.util;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Utility class to provide html headers, footers, dojo use and blogging
+ * service.
+ */
+public class HTMLOutput {
+
+	public static final void writeHTMLHeaderPartOne(PrintWriter out,
+			String pageTitle) {
+		out.println("<html>");
+		out.println(" <head>");
+
+		out
+				.println("  <link type=\"text/css\" rel=\"stylesheet\" href=\"style/blog.css\"></link>");
+		out.println("  <meta name=\"keywords\" content=\"...\">");
+		out.println("  <meta name=\"description\" content=\"...\">");
+
+		out.print("  <title>");
+		out.print(pageTitle);
+		out.println("  </title>");
+
+		out
+				.println("  <META http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">");
+		out.println(" </head>");
+		
+	}
+
+	public static final void writeDojoUses(PrintWriter out, String... modules) {
+		out
+				.println("<link rel=\"Stylesheet\" href=\"http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dijit/themes/tundra/tundra.css\" type=\"text/css\" media=\"screen\"/>");
+		out
+				.println("<link rel=\"Stylesheet\" href=\"http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dijit/themes/nihilo/nihilo.css\" type=\"text/css\" media=\"screen\"/>");
+		out
+				.println("<link rel=\"Stylesheet\" href=\"http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dijit/themes/soria/soria.css\" type=\"text/css\" media=\"screen\"/>");
+	
+		out
+				.println("<script type=\"text/javascript\"  src=\"http://ajax.googleapis.com/ajax/libs/dojo/1.4.0/dojo/dojo.xd.js\" djConfig=\"parseOnLoad: true\"></script>");
+		out.println("<script type=\"text/javascript\">");
+		out.println("dojo.require(\"dojo.parser\");");
+
+		for (String module : modules) {
+			out.print("dojo.require(\"");
+			out.print(module);
+			out.println("\");");
+		}
+
+		out.println("</script>");
+	}
+
+	public static final void writeHTMLHeaderPartTwo(PrintWriter out) {
+		writeHTMLHeaderPartTwo(out, new ArrayList<String>());
+	}
+
+	public static final void writeHTMLHeaderPartTwo(PrintWriter out,
+			Collection<String> errorMessages) {
+
+		out.println(" <body class=\"soria\">");
+
+		out
+				.println("  <TABLE width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">");
+		out.println("   <TR width=\"100%\">");
+		out.println("    <TD id=\"cell-0-0\" colspan=\"2\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-0-1\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-0-2\" colspan=\"2\">&nbsp;</TD>");
+		out.println("   </TR>");
+
+		out.println("   <TR width=\"100%\">");
+		out.println("    <TD id=\"cell-1-0\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-1-1\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-1-2\">");
+
+		out.println("     <DIV style=\"padding: 5px;\">");
+		out.println("      <DIV id=\"banner\">");
+
+		out
+				.println("       <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
+		out.println("        <TR>");
+		out.println("         <TD align=\"left\" class=\"topbardiv\" nowrap=\"\">");
+		out
+				.println("          <A href=\"http://incubator.apache.org/aries/\" title=\"Apache Aries (incubating)\">");
+		out
+				.println("          <IMG border=\"0\" src=\"http://incubator.apache.org/aries/images/Arieslogo_Horizontal.gif\">");
+		out.println("          </A>");
+		out.println("         </TD>");
+		out.println("         <TD align=\"right\" nowrap=\"\">");
+		out
+				.println("          <A href=\"http://www.apache.org/\" title=\"The Apache Software Foundation\">");
+		out
+				.println("          <IMG border=\"0\" src=\"http://incubator.apache.org/aries/images/apache-incubator-logo.png\">");
+		out.println("          </A>");
+		out.println("         </TD>");
+		out.println("        </TR> ");
+		out.println("       </TABLE>");
+		out.println("      </DIV>");
+		out.println("     </DIV>");
+
+		out.println("     <DIV id=\"top-menu\">");
+		out
+				.println("      <TABLE border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">");
+		out.println("       <TR>");
+		out.println("        <TD>");
+		out.println("         <DIV align=\"left\">");
+		out.println("          <!-- Breadcrumbs -->");
+		out.println("          <!-- Breadcrumbs -->");
+		out.println("         </DIV>");
+		out.println("        </TD>");
+		out.println("        <TD>");
+		out.println("         <DIV align=\"right\">");
+		out.println("          <!-- Quicklinks -->");
+		out.println("           <p><a href=\"ViewBlog\" style=\"text-decoration: none; color: white\">Blog home</a></p>");
+		out.println("          <!-- Quicklinks -->");
+		out.println("         </DIV>");
+		out.println("        </TD>");
+		out.println("       </TR>");
+		out.println("      </TABLE>");
+		out.println("     </DIV>");
+		out.println("    </TD>");
+		out.println("    <TD id=\"cell-1-3\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-1-4\">&nbsp;</TD>");
+		out.println("   </TR>");
+
+		out.println("   <TR width=\"100%\">");
+		out.println("    <TD id=\"cell-2-0\" colspan=\"2\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-2-1\">");
+		out.println("     <TABLE>");
+		out.println("      <TR height=\"100%\" valign=\"top\">");
+		out.println("       <TD height=\"100%\"></td>");
+		out.println("       <TD height=\"100%\" width=\"100%\">");
+		out.println("        <H1>Apache Aries Sample Blog</H1><br>");
+
+		if (!!!errorMessages.isEmpty()) {
+			out.println("\t\t\t<div id=\"errorMessages\">");
+			for (String msg : errorMessages) {
+				out.println("\t\t\t\t<div class=\"errorMessage\">" + msg
+						+ "</div>");
+			}
+			out.println("\t\t\t</div>");
+		}
+
+		out.println("        <div id=\"mainContent\" class=\"mainContent\">");
+	}
+
+	public static final void writeHTMLFooter(PrintWriter out) {
+		out.println("         <BR>");
+		out.println("        </DIV>");
+		out.println("       </TD>");
+		out.println("      </TR>");
+		out.println("     </TABLE>");
+		out.println("    </TD>");
+		out.println("    <TD id=\"cell-2-2\" colspan=\"2\">&nbsp;</TD>");
+		out.println("   </TR>");
+		out.println("   <TR width=\"100%\">");
+
+		out.println("    <TD id=\"cell-3-0\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-3-1\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-3-2\">");
+		out.println("     <DIV id=\"footer\">");
+		out.println("     <!-- Footer -->");
+		out.println("     </DIV>");
+		
+		out.println("    </TD>");
+		out.println("    <TD id=\"cell-3-3\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-3-4\">&nbsp;</TD>");
+		out.println("   </TR>");
+		out.println("   <TR width=\"100%\">");
+		out.println("    <TD id=\"cell-4-0\" colspan=\"2\">&nbsp;</TD>");
+		out.println("    <TD id=\"cell-4-1\">&nbsp;</TD>");
+
+		out.println("    <TD id=\"cell-4-2\" colspan=\"2\">&nbsp;</TD>");
+		out.println("   </TR>");
+		out.println("  </TABLE>");
+		out.println(" </BODY>");
+		out.println("</HTML> ");
+
+	}
+
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/JNDIHelper.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/JNDIHelper.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/JNDIHelper.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/java/org/apache/aries/samples/blog/web/util/JNDIHelper.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.web.util;
+
+import java.io.IOException;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.aries.samples.blog.api.BloggingService;
+
+public class JNDIHelper {
+	public static final BloggingService getBloggingService() throws IOException {
+		try {
+			InitialContext ic = new InitialContext();
+
+			return (BloggingService) ic.lookup("aries:services/"
+					+ BloggingService.class.getName());
+		} catch (NamingException e) {
+			e.printStackTrace();
+			IOException ioe = new IOException(
+					"Blogging service resolution failed");
+			ioe.initCause(e);
+			throw ioe;
+		}
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/WEB-INF/web.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/WEB-INF/web.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/WEB-INF/web.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+   <web-app id="Blog">   
+      <display-name>Blog Application</display-name>
+      <description>This is the Blog Sample Application.</description>
+      <servlet id="Servlet_1">
+         <servlet-name>View Blog Author</servlet-name>
+         <display-name>View Blog Author</display-name>
+         <description>This Servlet loads and displays the details of a blog author.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.ViewAuthor</servlet-class>
+      </servlet>
+      <servlet id="Servlet_2">
+         <servlet-name>Edit Blog Author</servlet-name>
+         <display-name>Edit Blog Author</display-name>
+         <description>This Servlet edits or creates the details of a blog author.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.EditAuthor</servlet-class>
+      </servlet>
+      <servlet id="Servlet_3">
+         <servlet-name>Edit Blog Author Form</servlet-name>
+         <display-name>Edit Blog Author Form</display-name>
+         <description>This Servlet that displays the form for creating or updating the details of a blog author.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.EditAuthorForm</servlet-class>
+      </servlet>
+      <servlet id="Servlet_4">
+         <servlet-name>Add Comment Form Servlet</servlet-name>
+         <display-name>Add Comment Form Servlet</display-name>
+         <description>This Servlet shows a form for adding comments.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.AddCommentForm</servlet-class>
+      </servlet>
+      <servlet id="Servlet_5">
+         <servlet-name>Create Blog Entry</servlet-name>
+         <display-name>Create Blog Entry</display-name>
+         <description>This Servlet that creates a blog entry.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.CreateBlogEntry</servlet-class>
+      </servlet>
+      <servlet id="Servlet_6">
+         <servlet-name>View Blog</servlet-name>
+         <display-name>View Blog</display-name>
+         <description>This Servlet that views the blog posts.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.ViewBlog</servlet-class>
+      </servlet>
+      <servlet id="Servlet_7">
+         <servlet-name>Add Comment Servlet</servlet-name>
+         <display-name>Add Comment Servlet</display-name>
+         <description>This Servlet adds a comments.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.AddComment</servlet-class>
+      </servlet>
+      <servlet id="Servlet_8">
+         <servlet-name>Create Blog Entry Form</servlet-name>
+         <display-name>Create Blog Entry Form</display-name>
+         <description>This Servlet that displays the form for creating a blog post.</description>
+         <servlet-class>org.apache.aries.samples.blog.web.CreateBlogEntryForm</servlet-class>
+      </servlet>      
+      <servlet-mapping id="ServletMapping_1">
+         <servlet-name>View Blog Author</servlet-name>
+         <url-pattern>/ViewAuthor</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_2">
+         <servlet-name>Edit Blog Author</servlet-name>
+         <url-pattern>/EditAuthor</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_3">
+         <servlet-name>Edit Blog Author Form</servlet-name>
+         <url-pattern>/EditAuthorForm</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_4">
+         <servlet-name>Add Comment Form Servlet</servlet-name>
+         <url-pattern>/AddCommentForm</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_5">
+         <servlet-name>Create Blog Entry</servlet-name>
+         <url-pattern>/CreateBlogEntry</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_7">
+         <servlet-name>Add Comment Servlet</servlet-name>
+         <url-pattern>/AddComment</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_6">
+         <servlet-name>View Blog</servlet-name>
+         <url-pattern>/ViewBlog</url-pattern>
+      </servlet-mapping>
+      <servlet-mapping id="ServletMapping_8">
+         <servlet-name>Create Blog Entry Form</servlet-name>
+         <url-pattern>/CreateBlogEntryForm</url-pattern>      	
+      </servlet-mapping>
+	  <welcome-file-list>
+	    <welcome-file>index.html</welcome-file>
+	  </welcome-file-list>
+   </web-app>
+

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/Arieslogo_Horizontal.gif
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/Arieslogo_Horizontal.gif?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/Arieslogo_Horizontal.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/BigBullet.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/BigBullet.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/BigBullet.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/apache-incubator-logo.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/apache-incubator-logo.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/apache-incubator-logo.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-left.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-left.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-left.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-right.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-right.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-purple-right.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-left-nogr.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-left-nogr.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-left-nogr.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-right-nogr.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-right-nogr.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/bg02-white-right-nogr.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-bottom.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-bottom.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-bottom.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-right.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-right.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-right.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-top.png
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-top.png?rev=1075106&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/images/left-box-top.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/index.html
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/index.html?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/index.html (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-web/src/main/resources/index.html Sun Feb 27 18:28:26 2011
@@ -0,0 +1,23 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<head>
+	<title>Your Page Title</title>
+	<meta http-equiv="REFRESH" content="0;url=ViewBlog">
+</head>
+<body />
+</html>
+



Mime
View raw message