Inital commit

This commit is contained in:
Tilman
2011-10-26 09:44:02 +02:00
commit 5971f4b417
1813 changed files with 737837 additions and 0 deletions
@@ -0,0 +1,3 @@
<div class="demolabel">
This recipe book is a demo of the Google Base Data API. <br/><a href="http://code.google.com/apis/base">Learn more and download API tools</a>.
</div>
@@ -0,0 +1,7 @@
<div id="footer">
<a href="http://code.google.com/apis/base">Google Base Data API</a> -
<a href="http://code.google.com/apis/base/terms.html">Terms and Conditions</a> -
<a href="http://base.google.com">Google Base</a> -
<a href="http://www.google.com">Google home</a>
<p id="copyright">&copy; Google 2006</p>
</div>
@@ -0,0 +1,68 @@
<%--
Copyright (c) 2006 Google Inc.
Licensed 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.
--%>
<%@ page import="sample.gbase.recipe.DisplayUtils"%>
<%@ page import="sample.gbase.recipe.Recipe"%>
<%@ page import="sample.gbase.recipe.RecipeSearch"%>
<%@ page import="sample.gbase.recipe.RecipeUtil"%>
<%RecipeSearch searchResults = RecipeUtil.getRecipeSearch(request);%>
<div id="leftnav">
<div id="search">
<form name="searchForm" action="recipe<%= searchResults.isOwnItems() ? "List" : "Search" %>" method="GET"><h2>Find a recipe</h2>
<table border="0" cellpadding="0" cellspacing="0" id="advancedsearch">
<tr><th colspan="2">With the word or phrase</th></tr>
<tr>
<td><input type="text" name="query" size="25" class="txt"
value='<%=DisplayUtils.escape(searchResults.getQuery()) %>'>
</td>
</tr>
<tr>
<th>Cuisine type</th>
</tr>
<tr>
<td><%DisplayUtils.printCheckboxes(out,
RecipeUtil.CUISINE_PARAMETER,
RecipeUtil.getMostUsedValues(pageContext.getServletContext()).getMostUsedValuesForAttribute(Recipe.CUISINE_ATTRIBUTE),
searchResults.getCuisineValues()); %></td>
</tr>
<tr>
<th>Main ingredient</th>
</tr>
<tr>
<td><%DisplayUtils.printCheckboxes(out,
RecipeUtil.MAIN_INGREDIENT_PARAMETER,
RecipeUtil.getMostUsedValues(pageContext.getServletContext()).getMostUsedValuesForAttribute(Recipe.MAIN_INGREDIENT_ATTRIBUTE),
searchResults.getMainIngredientValues()); %></td>
</tr>
<tr>
<th>Cooking time</th>
</tr>
<tr>
<td><input name="cookingTime" type="text" size="4"
value='<%=DisplayUtils.escape(searchResults.getCookingTime()) %>'
> <%=RecipeUtil.COOKING_TIME_UNIT %></td>
</tr>
</table>
<br/>
<button onclick="document.searchForm.startIndex.value='0'; document.searchForm.submit();"
style="font-weight:bold; -moz-border-radius:3px;border: 2px outset #bbbbbb;font-size:124%; padding:2px 1em;">Search</button>
<input type="hidden" name="startIndex" value="0"></form>
</div>
<p id="poweredby">
&nbsp;Powered by<br>
<a href="http://base.google.com/"><img src="googleBase.gif" border="0" alt="Google Base" vspace="2"></a>
</p>
</div>
@@ -0,0 +1,71 @@
<%--
Copyright (c) 2006 Google Inc.
Licensed 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.
--%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="sample.gbase.recipe.DisplayUtils"%>
<%@ page import="sample.gbase.recipe.Recipe"%>
<%@ page import="sample.gbase.recipe.RecipeUtil"%>
<html>
<head>
<title>Google Base API Demo: Recipe Book</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<div id="content">
<%@ include file="demoLabel.inc" %>
<%Recipe recipe = (Recipe) request.getAttribute(RecipeUtil.RECIPE_ATTRIBUTE); %>
<h1><a href="recipeSearch" class="on">All Recipes</a> &gt; <%=DisplayUtils.escape(recipe.getTitle()) %></h1>
<%@ include file="leftNav.jsp" %>
<div id="body" class="main">
<div id="singleitem">
<h3 class="itemtitle"><%=DisplayUtils.escape(recipe.getTitle()) %></h3>
<h4 class="postdate"><%=recipe.getPostedOnAsString(true) %></h4>
<%if (recipe.hasCuisine()) { %>
<h5>Cuisine: <%=DisplayUtils.printList(recipe.getCuisine()) %></h5><br/>
<%} %>
<%if (recipe.hasCookingTime()) { %>
<h5>Cooking time: <%=recipe.getCookingTime().getValue() %> <%=DisplayUtils.escape(recipe.getCookingTime().getUnit()) %></h5>
<%} %>
<%if (recipe.hasMainIngredient()) { %>
<div class="ingredients">
<ul>
<%for (String ingredient : recipe.getMainIngredient()) { %>
<li><%=DisplayUtils.escape(ingredient) %></li>
<%} %>
</ul>
</div>
<%} %>
<br/>
<div class="preparation">
<%=DisplayUtils.escape(recipe.getDescription()) %>
</div>
</div>
</div>
<br clear="all">
<%@ include file="demoLabel.inc" %>
</div>
<%@ include file="footer.inc" %>
</body>
</html>
@@ -0,0 +1,112 @@
<%--
Copyright (c) 2006 Google Inc.
Licensed 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.
--%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="sample.gbase.recipe.DisplayUtils"%>
<%@ page import="sample.gbase.recipe.Recipe"%>
<%@ page import="sample.gbase.recipe.RecipeUtil"%>
<html>
<head>
<title>Google Base API Demo: Recipe Book</title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
.main {
margin-left: 0;
}
</style>
</head>
<body>
<div id="content">
<%@ include file="demoLabel.inc" %>
<%Recipe recipe = (Recipe) request.getAttribute(RecipeUtil.RECIPE_ATTRIBUTE); %>
<%String message = (String) request.getAttribute(RecipeUtil.MESSAGE_ATTRIBUTE); %>
<h1><a href="recipeList" class="on">My Recipes</a> &gt; <%=recipe.isNew() ? "Add" : "Update" %> a recipe</h1>
<div id="body" class="main">
<div id="newitem">
<%=message %>
<form name="newitem" method="POST" action="recipe<%=recipe.isNew() ? "Add" : "Update?" + RecipeUtil.ID_PARAMETER + "=" + DisplayUtils.escape(recipe.getId()) %>"/>
<table cellpadding="0" cellspacing="0" border="0" id="createrecipe">
<tr>
<th>Recipe title *</th>
<td><input type="text" name="<%=RecipeUtil.TITLE_PARAMETER %>"
value="<%=DisplayUtils.escape(recipe.getTitle()) %>"
class="txt" size="35"></td>
</tr>
<tr>
<th>Cuisine type *</th>
<td>
<%DisplayUtils.printCheckboxes(out,
RecipeUtil.CUISINE_PARAMETER,
RecipeUtil.getMostUsedValues(pageContext.getServletContext()).getMostUsedValuesForAttribute(Recipe.CUISINE_ATTRIBUTE),
recipe.getCuisine()); %>
</td>
</tr>
<tr>
<th>Instructions *</th>
<td><textarea name="<%=RecipeUtil.DESCRIPTION_PARAMETER %>"
cols="40" rows="8"
><%=DisplayUtils.escape(recipe.getDescription()) %></textarea>
</td>
</tr>
<tr>
<th>Main ingredients *</th>
<td>
<%DisplayUtils.printCheckboxes(out,
RecipeUtil.MAIN_INGREDIENT_PARAMETER,
RecipeUtil.getMostUsedValues(pageContext.getServletContext()).getMostUsedValuesForAttribute(Recipe.MAIN_INGREDIENT_ATTRIBUTE),
recipe.getMainIngredient()); %>
</td>
</tr>
<tr>
<th>URL</th>
<td><input type="text" name="<%=RecipeUtil.URL_PARAMETER %>"
value="<%=DisplayUtils.escape(recipe.getUrl()) %>"
class="txt" size="40"></td>
</tr>
<tr>
<th>Cooking time</th>
<td><input type="text" name="<%=RecipeUtil.COOKING_TIME_PARAMETER %>"
value="<%=recipe.hasCookingTime() ? recipe.getCookingTime().getValue() : "" %>"
class="txt" size="4"> <%=RecipeUtil.COOKING_TIME_UNIT %></td>
</tr>
</table>
<p>
This recipe will be publicly viewable on the internet once you click "Publish". <br> <br>
<input type="submit" value="Publish this recipe" style="font-weight:bold;"> &nbsp;
<button onclick="history.go(-1); return false;">Cancel</button>
</p>
<p>* Mandatory attributes</p>
</form>
</div>
</div>
<br clear="all">
<%@ include file="demoLabel.inc" %>
</div>
<%@ include file="footer.inc" %>
</body>
</html>
@@ -0,0 +1,78 @@
<%--
Copyright (c) 2007 Google Inc.
Licensed 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.
--%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.google.api.gbase.client.ServiceErrors"%>
<%@ page import="sample.gbase.recipe.RecipeUtil"%>
<%@page import="sample.gbase.recipe.DisplayUtils"%>
<%@page import="com.google.api.gbase.client.ServiceError"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Google Base API demo: Recipe Book</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="content">
<%@ include file="demoLabel.inc" %>
<%
String error = RecipeUtil.getRecipeError(request);
String description = RecipeUtil.getRecipeErrorDescription(request);
ServiceErrors serviceErrors = RecipeUtil.getRecipeErrorObject(request);
%>
<div style="height:70%; padding-top: 20px;">
An error has occured. Hit the browser's Back button for continuing to use
the Recipe Demo Application. <br/>
<%if (error != null) { %>
<div class="errordiv">
<span class="errormessage"><%= DisplayUtils.escape(error) %></span>
<br/>
</div>
<%} // has error %>
<%if (description != null) { %>
<div class="errordiv">
Detailed information about the error: <br/>
<pre><%= DisplayUtils.escape(description) %></pre>
</div>
<%} // has description %>
<%if (serviceErrors != null) { %>
<div class="errordiv">
Detailed information about the Google Base service error: <br/>
<ul>
<%for (ServiceError serviceError : serviceErrors.getAllErrors()) { %>
<li> <%= DisplayUtils.escape(serviceError.getType()) %> : <%= DisplayUtils.escape(serviceError.getReason()) %>
<%} // for each service error %>
</ul>
<%if (serviceErrors.getAllErrors().size() == 0) { %>
<i>No service errors could be parsed</i>
<%} // if no service errors registered %>
</div>
<%} // has errors object %>
</div>
<br clear="all">
<%@ include file="demoLabel.inc" %>
</div>
<%@ include file="footer.inc" %>
</body>
</html>
@@ -0,0 +1,138 @@
<%--
Copyright (c) 2006 Google Inc.
Licensed 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.
--%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="sample.gbase.recipe.DisplayUtils"%>
<%@ page import="sample.gbase.recipe.Recipe"%>
<%@ page import="sample.gbase.recipe.RecipeSearch"%>
<%@ page import="sample.gbase.recipe.RecipeUtil"%>
<%@ page import="java.util.Iterator"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Google Base API demo: Recipe Book</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="content">
<%@ include file="demoLabel.inc" %>
<%RecipeSearch recipeSearch = RecipeUtil.getRecipeSearch(request); %>
<%if (recipeSearch.isOwnItems()) { %>
<a href="recipeSearch" class="toplink">All recipes</a>
<%} else { %>
<a href="recipeList" class="toplink">My recipes</a>
<%} %>
<%if (recipeSearch.isOwnItems()) { %>
<a href="recipeAdd" class="toplink">Add a recipe</a>
<%} %>
<h1>
<%if (recipeSearch.isOwnItems()) { %>
<a href="recipeList" class="on">My Recipes</a>
<%} else { %>
<a href="recipeSearch" class="on">All Recipes</a>
<%} %>
&gt; Search
<%if (recipeSearch.getTotal() > 0) { %>
results
<%} %>
</h1>
<%@ include file="leftNav.jsp" %>
<div id="body" class="main">
<div id="searchresults">
<script language="JavaScript">
function gotoPage(index) {
document.searchForm.reset();
document.searchForm.startIndex.value =
index*<%=recipeSearch.getMaxResults()%>;
document.searchForm.submit();
}
function narrowSearchByIngredient(ingredient) {
document.searchForm.reset();
document.searchForm.othermainIngredient.value = ingredient;
document.searchForm.submit();
}
function confirmDelete(oid) {
if (confirm("Do you really want to delete this recipe?")) {
window.location = "recipeDelete?oid=" + oid;
}
}
</script>
<%if (recipeSearch.getTotal() >= 0) {%>
<%if (recipeSearch.getTotal() == 0) {%>
<h4>Your search for recipes
<%=recipeSearch.getFilterDescription() %>
did not match any recipes.</h4>
<%} %>
<%if (recipeSearch.hasResults()) {%>
<h4><%=recipeSearch.getTotal()%> recipes
<%=recipeSearch.getFilterDescription() %>
- showing <%=recipeSearch.getCurrentPageInterval()%></h4>
<%for (Iterator iter = recipeSearch.getRecipes().iterator(); iter.hasNext(); ) {%>
<%Recipe recipe = (Recipe)iter.next();%>
<p>
<a href="recipeDisplay?oid=<%=recipe.getId()%>" class="m"><%=DisplayUtils.escape(recipe.getTitle()).toUpperCase() %></a>
Main ingredient:
<%for (Iterator<String> ingredientIter = recipe.getMainIngredient().iterator(); ingredientIter.hasNext(); ) { %>
<%String ingredient = ingredientIter.next(); %>
<a href="javascript:narrowSearchByIngredient('<%=ingredient%>')" class="r"><%=ingredient%></a><%=ingredientIter.hasNext() ? ", " : "" %>
<%} %>
<br>
posted on <%=recipe.getPostedOnAsString(false)%>
by <%=DisplayUtils.escape(recipe.getPostedBy())%><br>
<%if (recipeSearch.isOwnItems()) { %>
<a href="recipeUpdate?oid=<%=recipe.getId() %>">Update</a> |
<a href="javascript:confirmDelete('<%=recipe.getId() %>')">Delete</a>
<%} %>
</p>
<%} // for recipe in recipeSearch.getRecipes()%>
<%} // if recipeSearch.hasResults%>
<%if (recipeSearch.getTotal() > recipeSearch.getMaxResults()) { //results don't fit on one page?%>
<p class="pagination">
Results <%=recipeSearch.getCurrentPageInterval() %> of <%=recipeSearch.getTotal() %><br/>
<%if (recipeSearch.hasPreviousPage()) {%>
<a href="javascript:gotoPage(<%=recipeSearch.getCurrentPage() - 1 %>)"
style="margin-right:1em;"
class="next">&laquo; Previous <%=recipeSearch.getMaxResults() %></a>
<%} %>
<%if (recipeSearch.hasNextPage()) {%>
<a href="javascript:gotoPage(<%=recipeSearch.getCurrentPage() + 1 %>)"
class="next">Next <%=recipeSearch.getNextPageSize() %> &raquo;</a>
<%} %>
</p>
<%} // pages? %>
<%} //total >= 0 %>
</div>
</div>
<br clear="all">
<%@ include file="demoLabel.inc" %>
</div>
<%@ include file="footer.inc" %>
</body>
</html>
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<display-name>Google Base Recipe Search</display-name>
<description>Search Recipes on Google Base</description>
<context-param>
<param-name>baseUrl</param-name>
<param-value>http://www.google.com/base/</param-value>
<description>URL of the google base server to connect to.</description>
</context-param>
<context-param>
<param-name>applicationName</param-name>
<param-value>Google-RecipeDemo-1.0</param-value>
<description>Application name used when authenticating.</description>
</context-param>
<context-param>
<param-name>key</param-name>
<param-value></param-value>
<description>Developer key used to authenticate against the Google Base data API servers.</description>
</context-param>
<filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>sample.gbase.recipe.AuthenticationFilter</filter-class>
<init-param>
<param-name>authsubProtocol</param-name>
<param-value>https</param-value>
<description>Protocol to be used when connecting to AuthSub.</description>
</init-param>
<init-param>
<param-name>authsubHostname</param-name>
<param-value>www.google.com</param-value>
<description>Hostname of the authentication server.</description>
</init-param>
</filter>
<listener>
<listener-class>sample.gbase.recipe.RecipeListener</listener-class>
</listener>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<servlet-name>OwnRecipeSearchServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<servlet-name>RecipeAddServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<servlet-name>RecipeUpdateServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<servlet-name>RecipeDeleteServlet</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>AllRecipeSearchServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeSearchServlet</servlet-class>
<init-param>
<param-name>scope</param-name>
<param-value>all</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>OwnRecipeSearchServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeSearchServlet</servlet-class>
<init-param>
<param-name>scope</param-name>
<param-value>own</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RecipeAddServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeActionServlet</servlet-class>
<init-param>
<param-name>action</param-name>
<param-value>add</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RecipeUpdateServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeActionServlet</servlet-class>
<init-param>
<param-name>action</param-name>
<param-value>update</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RecipeDeleteServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeActionServlet</servlet-class>
<init-param>
<param-name>action</param-name>
<param-value>delete</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RecipeDisplayServlet</servlet-name>
<servlet-class>sample.gbase.recipe.RecipeDisplayServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AllRecipeSearchServlet</servlet-name>
<url-pattern>/recipeSearch</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>OwnRecipeSearchServlet</servlet-name>
<url-pattern>/recipeList</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RecipeAddServlet</servlet-name>
<url-pattern>/recipeAdd</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RecipeUpdateServlet</servlet-name>
<url-pattern>/recipeUpdate</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RecipeDeleteServlet</servlet-name>
<url-pattern>/recipeDelete</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RecipeDisplayServlet</servlet-name>
<url-pattern>/recipeDisplay</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>