- Added community and collection home pages

- LocationServlet added to handle user navigating within communities and
  collections
- Invalid ID error added
- Home page is now called "index.jsp" (was called home.jsp)


git-svn-id: http://scm.dspace.org/svn/repo/trunk@171 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robert Tansley
2002-06-16 21:06:43 +00:00
parent 910c7e6f6d
commit c27b293e11
10 changed files with 782 additions and 15 deletions

View File

@@ -52,17 +52,31 @@
<description>@@dspace.name@@ running at @@dspace.hostname@@</description>
<!-- Community list page -->
<!-- Servlets -->
<servlet>
<servlet-name>community-list</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.CommunityListServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>location</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.LocationServlet</servlet-class>
</servlet>
<!-- Servlet Mappings -->
<servlet-mapping>
<servlet-name>community-list</servlet-name>
<url-pattern>/community-list</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>location</servlet-name>
<url-pattern>/communities/*</url-pattern>
</servlet-mapping>
<!-- DSpace JSP Tag Library -->
<taglib>

View File

@@ -0,0 +1,166 @@
<%--
- collection-home.jsp
-
- Version: $Revision$
-
- Date: $Date$
-
- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
- Institute of Technology. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- - Neither the name of the Hewlett-Packard Company nor the name of the
- Massachusetts Institute of Technology nor the names of their
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
--%>
<%--
- Collection home JSP
-
- Attributes required:
- community - Collection to render home page for
- collection - Community this collection is in
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.content.Collection" %>
<%
Community community = (Community) request.getAttribute("community");
Collection collection = (Collection) request.getAttribute("collection");
// Put the metadata values into guaranteed non-null variables
String name = collection.getMetadata("name");
String intro = collection.getMetadata("introductory_text");
if (intro == null)
{
intro = "";
}
String copyright = collection.getMetadata("copyright_text");
if (copyright == null)
{
copyright = "";
}
String sidebar = collection.getMetadata("side_bar_text");
if(sidebar == null)
{
sidebar = "";
}
String communityName = community.getMetadata("name");
String communityLink = "/communities/" + community.getID() + "/";
%>
<%--
<dspace:layout locbar="links"
parent="<%= communityName" %>"
parentlink="<%= "/communities/" + community.getID() + "/" %>"
title="<%= name %>">
--%>
<dspace:layout locbar="link" parenttitle="<%= communityName %>" parentlink="<%= communityLink %>" title="<%= name %>">
<table border=0 cellpadding=5 width=100%>
<tr>
<td width=100%>
<H1><%= name %></H1>
<H3>Collection home page</H3>
</td>
<%-- FIXME: Logo
<td valign=top><% if( logo != null && !logo.equals( "" ) ) { %><img alt="Logo" src="<%= logo %>" /><% } %></td>
--%>
</tr>
</table>
<%= intro %>
<%-- Search --%>
<form action="simple-search" method=GET>
<table class=miscTable align=center>
<tr>
<td class="evenRowEvenCol">
<table>
<tr>
<td>
<strong>Search:</strong>&nbsp;<select name="location">
<option value="ALL">All of DSpace</option>
<option selected value="<%= community.getID() %>"><%= communityName %></option>
<option selected value="<%= community.getID() %>/<%= collection.getID() %>"><%= name %></option>
</select>
</td>
</tr>
<tr>
<td align=center>
for&nbsp;<input type="text" name="query">&nbsp;<input type="submit" value="Go">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<P align=center><strong>Browse</strong> the collection by <A HREF="browse-title">Title</A>,
<A HREF="browse-author">Author</A>, or <A HREF="browse-date">Date</A>.</P>
<%-- HACK: <center> used for Netscape 4.x, which doesn't accept align=center
for a paragraph with a button in it --%>
<center>
<form action="<%= request.getContextPath() %>/submit" method=POST>
<input type=hidden name=collection value="<%= collection.getID() %>">
<P><input type=submit name=submit value="Submit to This Collection"></P>
</form>
</center>
<P class="copyrightText"><%= copyright %></P>
<dspace:sidebar>
<H3>Recent&nbsp;Submissions</H3>
<%-- FIXME: Recent items
while( recentItems.hasNext() )
{
Item item = (Item) recentItems.next();
String handle = (String) recentItemHandles.next();
String titles[] = item.getDCField( "title", null );
String title = (titles.length==0 ? "Untitled" : titles[0]);
%>
<P class="recentItem"><A HREF="item/<%= handle %>"><%= title %></A></P>
<%
}
%>
<P>&nbsp;</P>
--%>
<%= sidebar %>
</dspace:sidebar>
</dspace:layout>

View File

@@ -0,0 +1,184 @@
<%--
- community-home.jsp
-
- Version: $Revision$
-
- Date: $Date$
-
- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
- Institute of Technology. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- - Neither the name of the Hewlett-Packard Company nor the name of the
- Massachusetts Institute of Technology nor the names of their
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
--%>
<%--
- Community home JSP
-
- Attributes required:
- community - Community to render home page for
- collections - array of Collections in this community
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.content.Collection" %>
<%
Community community = (Community) request.getAttribute( "community" );
Collection[] collections =
(Collection[]) request.getAttribute("collections");
// Put the metadata values into guaranteed non-null variables
String name = community.getMetadata("name");
String intro = community.getMetadata("introductory_text");
if (intro == null)
{
intro = "";
}
String copyright = community.getMetadata("copyright_text");
if (copyright == null)
{
copyright = "";
}
String sidebar = community.getMetadata("side_bar_text");
if(sidebar == null)
sidebar = "";
%>
<dspace:layout locbar="link" title="<%= name %>">
<table border=0 cellpadding=5 width=100%>
<tr>
<td width=100%>
<H1><%= name %></H1>
<H3>Community home page</H3>
</td>
<%-- FIXME: Logo
<td valign=top><% if( logo != null && !logo.equals( "" ) ) { %><img alt="Logo" src="<%= logo %>" /><% } %></td>
--%>
</tr>
</table>
<%= intro %>
<%-- Search --%>
<form action="simple-search" method=GET>
<table class=miscTable align=center>
<tr>
<td class="evenRowEvenCol">
<table>
<tr>
<td>
<strong>Search:</strong>&nbsp;<select name="location">
<option value="ALL">All of DSpace</option>
<option selected value="<%= community.getID() %>"><%= name %></option>
<%
for (int i = 0; i < collections.length; i++)
{
%>
<option value="<%= community.getID() %>/<%= collections[i].getID() %>"><%= collections[i].getMetadata("name") %></option>
<%
}
%>
</select>
</td>
</tr>
<tr>
<td align=center>
for&nbsp;<input type="text" name="query">&nbsp;<input type="submit" value="Go">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<P align=center><strong>Browse</strong> the community by <A HREF="browse-title">Title</A>,
<A HREF="browse-author">Author</A>, or <A HREF="browse-date">Date</A>.</P>
<H2>Collections in this community</H2>
<%
if (collections.length == 0)
{
%>
<P>This community contains no collections.</P>
<%
}
else
{
%>
<UL class="collectionListItem">
<%
for (int i = 0; i < collections.length; i++)
{
%>
<LI>
<A HREF="collections/<%= collections[i].getID() %>/">
<%= collections[i].getMetadata("name") %></A>
<P class="collectionDescription"><%= collections[i].getMetadata("short_description") %></P>
</LI>
<%
}
%>
</UL>
<%
}
%>
<P class="copyrightText"><%= copyright %></P>
<dspace:sidebar>
<H3>Recent&nbsp;Submissions</H3>
<%-- FIXME: Recent items
while( recentItems.hasNext() )
{
Item item = (Item) recentItems.next();
String handle = (String) recentItemHandles.next();
String titles[] = item.getDCField( "title", null );
String title = (titles.length==0 ? "Untitled" : titles[0]);
%>
<P class="recentItem"><A HREF="item/<%= handle %>"><%= title %></A></P>
<%
}
%>
<P>&nbsp;</P>
--%>
<%= sidebar %>
</dspace:sidebar>
</dspace:layout>

View File

@@ -45,17 +45,17 @@
<%@ page import="org.dspace.core.ConfigurationManager" %>
<center>
<P><%= ConfigurationManager.getProperty("dspace.name") %> administation
<P><%= ConfigurationManager.getProperty("dspace.name") %> administration
contact details:</P>
<table>
<tr>
<td>By e-mail:</td>
<td><a href="mailto:dspace-help@mit.edu">dspace-help@mit.edu</a></td>
<td class="standard">By e-mail:</td>
<td class="standard"><a href="mailto:dspace-help@mit.edu">dspace-help@mit.edu</a></td>
</tr>
<tr>
<td>Or telephone:</td>
<td>617-452-3485</td>
<td class="standard">Or telephone:</td>
<td class="standard">617-452-3485</td>
</tr>
</table>
</center>

View File

@@ -0,0 +1,97 @@
<%--
- invalid-id.jsp
-
- Version: $Revision$
-
- Date: $Date$
-
- Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
- Institute of Technology. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- - Neither the name of the Hewlett-Packard Company nor the name of the
- Massachusetts Institute of Technology nor the names of their
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
--%>
<%--
- Page representing an invalid ID error
-
- Attributes:
- bad.id - Optional. The ID that is invalid.
- bad.type - Optional. The type of the ID (or the type the system thought
- is was!) from org.dspace.core.Constants.
--%>
<%@ page isErrorPage="true" %>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.core.Constants" %>
<%
String badID = (String) request.getAttribute("bad.id");
Integer type = (Integer) request.getAttribute("bad.type");
// Make sure badID isn't null
if (badID == null)
{
badID = "";
}
// Get text for the type
String typeString = "object";
if (type != null)
{
typeString = Constants.typetext[type.intValue()].toLowerCase();
}
%>
<dspace:layout locbar="off" title="Invalid Identifier">
<H1>Invalid Identifier</H1>
<P>The identifier <%= badID %> does not correspond to a valid
<%= typeString %> in DSpace. This may be because of one of the following
reasons:</P>
<UL>
<LI>The URL of the current page is incorrect - if you followed a link
from outside of DSpace it may be mistyped or corrupt.</LI>
<LI>You entered an invalid ID into a form - please try again.</LI>
</UL>
<P>If you're having problems, or you expected the ID to work, feel free to
contact the site administrators.</P>
<%@ include file="/contact-info.jsp" %>
<P align=center>
<A HREF="<%= request.getContextPath() %>/">Go to the DSpace home page</A>
</P>
</dspace:layout>

View File

@@ -1,5 +1,5 @@
<%--
- home.jsp
- index.jsp
-
- Version: $Revision$
-
@@ -38,7 +38,14 @@
- DAMAGE.
--%>
<%-- Home page JSP --%>
<%--
- Home page JSP
-
- Note that this is a "stand-alone" JSP that is invoked directly, and not
- via a Servlet. This is because the standard servlet 2.3 deployment
- descriptor does not seem to allow a servlet to be deployed at "/" without
- it becoming the servlet for dealing with every request to the site.
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>

View File

@@ -53,6 +53,8 @@ import javax.servlet.RequestDispatcher;
import org.apache.log4j.Logger;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.core.ConfigurationManager;
/**
@@ -133,6 +135,8 @@ public class Layout extends TagSupport
locbar = "auto";
}
// These lists will contain titles and links to put in the location
// bar
List parents = new ArrayList();
List parentLinks = new ArrayList();
@@ -143,7 +147,7 @@ public class Layout extends TagSupport
}
else
{
// Add DSpace Home
// We'll always add "DSpace Home" to the a location bar
parents.add(ConfigurationManager.getProperty("dspace.name"));
if (locbar.equalsIgnoreCase("nolink"))
@@ -158,6 +162,8 @@ public class Layout extends TagSupport
// Add other relevant components to the location bar
if (locbar.equalsIgnoreCase("link"))
{
// "link" mode - next thing in location bar is taken from
// parameters of tag, with a link
if (parentTitle != null)
{
parents.add(parentTitle);
@@ -166,6 +172,8 @@ public class Layout extends TagSupport
}
else if (locbar.equalsIgnoreCase("nolink"))
{
// "nolink" mode - next thing in location bar is taken from
// parameters of tag, with no link
if (parentTitle != null)
{
parents.add(parentTitle);
@@ -177,7 +185,23 @@ public class Layout extends TagSupport
// Grab parents from the URL - these should have been picked up
// by the LocationServlet
// FIXME: Add community + collection locations
Community com = (Community)
request.getAttribute("dspace.community");
Collection col = (Collection)
request.getAttribute("dspace.collection");
if (com != null)
{
parents.add(com.getMetadata("name"));
parentLinks.add("/communities/" + com.getID() + "/");
if (col != null)
{
parents.add(col.getMetadata("name"));
parentLinks.add("/communities/" + com.getID() +
"/collections/" + col.getID() + "/");
}
}
}
request.setAttribute("dspace.layout.locbar", new Boolean(true));
@@ -337,7 +361,7 @@ public class Layout extends TagSupport
* Get the value of parentTitle.
* @return Value of parentTitle.
*/
public String getParentTitle()
public String getParenttitle()
{
return parentTitle;
}
@@ -346,7 +370,7 @@ public class Layout extends TagSupport
* Set the value of parent.
* @param v Value to assign to parent.
*/
public void setParentTitle(String v)
public void setParenttitle(String v)
{
this.parentTitle = v;
}

View File

@@ -54,7 +54,6 @@ import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.EPerson;
/**

View File

@@ -0,0 +1,271 @@
/*
* LocationServlet.java
*
* Version: $Revision$
*
* Date: $Date$
*
* Copyright (c) 2001, Hewlett-Packard Company and Massachusetts
* Institute of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Hewlett-Packard Company nor the name of the
* Massachusetts Institute of Technology nor the names of their
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package org.dspace.app.webui.servlet;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
/**
* Servlet for handling requests within communities and collections.
* This servlet extracts the community and collection ID from the URL. It
* then either displays the community or collection home page if the URL
* after the community/collection portion is "/". Otherwise, the request
* is forwarded to the appropriate servlet. Examples:
* <P>
* <code>/community/XX/</code> - Community <code>XX</code> home page<BR>
* <code>/community/XX/collection/YY/</code> - Collection <code>YY</code> home
* page<BR>
* <code>/community/XX/foo</code> - Location is set to community <code>XX</code>
* and request is forwarded to <code>/foo</code>.
*
* @author Robert Tansley
* @version $Revision$
*/
public class LocationServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(DSpaceServlet.class);
protected void doDSGet(Context context,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
Community community = null;
Collection collection = null;
boolean locationOK = true;
int slash;
String path = request.getPathInfo();
try
{
if (path == null)
{
locationOK = false;
}
else
{
// Grab the community ID.
slash = path.indexOf('/', 1);
if (slash > -1)
{
String communityIdString = path.substring(1, slash);
int communityID = Integer.parseInt(communityIdString);
community = Community.find(context, communityID);
if (community == null)
{
locationOK = false;
}
else
{
path = path.substring(slash);
}
}
else
{
locationOK = false;
}
if (path.startsWith("/collections/"))
{
// We also have a collection location
slash = path.indexOf('/', 13);
if (slash > -1)
{
String collectionIdString = path.substring(13, slash);
int collectionID = Integer.parseInt(collectionIdString);
collection = Collection.find(context, collectionID);
if (collection == null)
{
locationOK = false;
}
else
{
path = path.substring(slash);
}
}
else
{
locationOK = false;
}
}
}
}
catch (NumberFormatException nfe)
{
// Mangled IDs
locationOK = false;
}
if (locationOK)
{
// Location is fine
request.setAttribute("dspace.community", community);
request.setAttribute("dspace.collection", collection);
// Show community or collection home page?
if (path.equals("/"))
{
if (collection == null)
{
showCommunityHome(context, request, response, community);
}
else
{
showCollectionHome(context,
request,
response,
community,
collection);
}
}
else
{
// Forward to another servlet
request.getRequestDispatcher(path).forward(
request,
response);
}
}
else
{
// Invalid location.
// Was it a collection or community ID that was bad?
int type = Constants.COMMUNITY;
if (community != null)
{
// We found a collection OK so it must have been the community
type = Constants.COLLECTION;
}
JSPManager.showInvalidIDError(request, response, null, type);
}
}
protected void doDSPost(Context context,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
// A POST has the same effect as a GET.
doDSGet(context, request, response);
}
/**
* Show a community home page
*
* @param context Context object
* @param request the HTTP request
* @param response the HTTP response
* @param community the Community home page
*/
private void showCommunityHome(Context context,
HttpServletRequest request,
HttpServletResponse response,
Community community )
throws ServletException, IOException, SQLException
{
log.info(LogManager.getHeader(context, "view_community",
"community_id=" + community.getID()));
// Get the collections within the community
Collection[] collections = community.getCollections();
// FIXME: Logo
// FIXME: Last submitted items
request.setAttribute("community", community);
request.setAttribute("collections", collections);
JSPManager.showJSP(request, response, "/community-home.jsp");
}
/**
* Show a collection home page
*
* @param context Context object
* @param request the HTTP request
* @param response the HTTP response
* @param community the community the collection is in
* @param collection the Collection home page
*/
private void showCollectionHome(Context context,
HttpServletRequest request,
HttpServletResponse response,
Community community,
Collection collection )
throws ServletException, IOException, SQLException
{
log.info(LogManager.getHeader(context, "view_collection",
"collection_id=" + collection.getID()));
// FIXME: Logo
// FIXME: Last submitted items
request.setAttribute("community", community);
request.setAttribute("collection", collection);
JSPManager.showJSP(request, response, "/collection-home.jsp");
}
}

View File

@@ -149,7 +149,12 @@ public class JSPManager
int type)
throws ServletException, IOException
{
// FIXME: Tailor message
showJSP(request, response, "/error/invalidID.jsp");
request.setAttribute("bad.id", badID);
if (type != -1)
{
request.setAttribute("bad.type", new Integer(type));
}
showJSP(request, response, "/error/invalid-id.jsp");
}
}