Added browse UI pages for title, date and author browse.

- Renamed tag classes to end in Tag to avoid clashes (e.g. "Date")


git-svn-id: http://scm.dspace.org/svn/repo/trunk@184 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robert Tansley
2002-06-19 18:31:18 +00:00
parent 935fbed55b
commit bc0634f8fe
11 changed files with 1585 additions and 8 deletions

View File

@@ -54,6 +54,33 @@
<!-- Servlets --> <!-- Servlets -->
<servlet>
<servlet-name>browse-author</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.BrowseServlet</servlet-class>
<init-param>
<param-name>browse</param-name>
<param-value>authors</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>browse-date</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.BrowseServlet</servlet-class>
<init-param>
<param-name>browse</param-name>
<param-value>dates</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>browse-title</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.BrowseServlet</servlet-class>
<init-param>
<param-name>browse</param-name>
<param-value>titles</param-value>
</init-param>
</servlet>
<servlet> <servlet>
<servlet-name>community-list</servlet-name> <servlet-name>community-list</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.CommunityListServlet</servlet-class> <servlet-class>org.dspace.app.webui.servlet.CommunityListServlet</servlet-class>
@@ -69,10 +96,30 @@
<servlet-class>org.dspace.app.webui.servlet.LocationServlet</servlet-class> <servlet-class>org.dspace.app.webui.servlet.LocationServlet</servlet-class>
</servlet> </servlet>
<servlet>
<servlet-name>retrieve</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.RetrieveServlet</servlet-class>
</servlet>
<!-- Servlet Mappings --> <!-- Servlet Mappings -->
<servlet-mapping>
<servlet-name>browse-author</servlet-name>
<url-pattern>/browse-author</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>browse-date</servlet-name>
<url-pattern>/browse-date</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>browse-title</servlet-name>
<url-pattern>/browse-title</url-pattern>
</servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>community-list</servlet-name> <servlet-name>community-list</servlet-name>
<url-pattern>/community-list</url-pattern> <url-pattern>/community-list</url-pattern>
@@ -88,6 +135,11 @@
<url-pattern>/communities/*</url-pattern> <url-pattern>/communities/*</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>retrieve</servlet-name>
<url-pattern>/retrieve/*</url-pattern>
</servlet-mapping>
<!-- DSpace JSP Tag Library --> <!-- DSpace JSP Tag Library -->
<taglib> <taglib>

View File

@@ -83,7 +83,7 @@
--> -->
<tag> <tag>
<name>layout</name> <name>layout</name>
<tagclass>org.dspace.app.webui.jsptag.Layout</tagclass> <tagclass>org.dspace.app.webui.jsptag.LayoutTag</tagclass>
<info>Lays out an HTML page</info> <info>Lays out an HTML page</info>
<attribute> <attribute>
<name>title</name> <name>title</name>
@@ -119,10 +119,28 @@
<tag> <tag>
<name>sidebar</name> <name>sidebar</name>
<tagclass>org.dspace.app.webui.jsptag.Sidebar</tagclass> <tagclass>org.dspace.app.webui.jsptag.SidebarTag</tagclass>
<info> <info>
The contents of the tag are displayed in a column on the right-hand side The contents of the tag are displayed in a column on the right-hand side
of the page.can be used only must be included within a layout tag. of the page.can be used only must be included within a layout tag.
</info> </info>
</tag> </tag>
<tag>
<name>date</name>
<tagclass>org.dspace.app.webui.jsptag.DateTag</tagclass>
<info>
Displays a DCDate in a readable form
</info>
<attribute>
<name>date</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>notime</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib> </taglib>

View File

@@ -0,0 +1,212 @@
<%--
- authors.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.
--%>
<%--
- Display the results of browsing the author index
-
- Attributes to pass in:
- community - pass in if the scope of the browse is a community, or
- a collection within this community
- collection - pass in if the scope of the browse is a collection
- browse.info - the BrowseInfo containing the authors to display
- highlight - Boolean. If true, the focus point of the browse
- is highlighted
- previous.query - The query string to pass to the servlet to get the
- previous page of authors
- next.query - The query string to pass to the servlet to get the next
- page of aitjprs
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.List" %>
<%@ page import="org.dspace.browse.BrowseInfo" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.content.Collection" %>
<%@ page import="org.dspace.content.DCDate" %>
<%@ page import="org.dspace.content.DCValue" %>
<%@ page import="org.dspace.content.Item" %>
<%
// Get attributes
Collection collection = (Collection) request.getAttribute("collection");
Community community = (Community) request.getAttribute("community");
BrowseInfo browseInfo = (BrowseInfo) request.getAttribute("browse.info");
boolean highlight = ((Boolean) request.getAttribute("highlight")).booleanValue();
String prevQuery = (String) request.getAttribute("previous.query");
String nextQuery = (String) request.getAttribute("next.query");
// Description of what the user is actually browsing
String scopeName = "All of DSpace";
if (collection != null)
{
scopeName = collection.getMetadata("name");
}
else if (community != null)
{
scopeName = community.getMetadata("name");
}
%>
<dspace:layout title="Browse by Author">
<H2>Browsing <%= scopeName %> by Author</H2>
<form action="browse-author" method=GET>
<%-- Browse controls --%>
<table align=center border=0 bgcolor="#CCCCCC" cellpadding=0>
<tr>
<td>
<table border=0 bgcolor="#EEEEEE" cellpadding=2>
<tr>
<td class="browseBar">
<span class="browseBarLabel">Jump&nbsp;to:&nbsp;</span>
<A HREF="browse-author?starts_with=0">0-9</A>
<%
for (char c = 'A'; c <= 'Z'; c++)
{
%>
<A HREF="browse-author?starts_with=<%= c %>"><%= c %></A>
<%
}
%>
</td>
</tr>
<tr>
<td class="browseBar" align=center>
<span class="browseBarLabel">or enter first few letters:&nbsp;</span>
<input type="text" name="starts_with">&nbsp;<input type="submit" value="Go!">
</td>
</tr>
</table>
</td>
</tr>
</table>
<BR />
<P align=center>Showing authors <%= browseInfo.getOverallPosition() + 1 %>-<%= browseInfo.getOverallPosition() + browseInfo.getResultCount() %> of <%= browseInfo.getTotal() %>.</P>
<%-- Previous page/Next page --%>
<table align=center border=0 width=70%>
<tr>
<td class=standard align=left>
<%
if (prevQuery != null)
{
%>
<A HREF="browse-author?<%= prevQuery %>">Previous page</A>
<%
}
%>
</td>
<td class=standard align=right>
<%
if (nextQuery != null)
{
%>
<A HREF="browse-author?<%= nextQuery %>">Next page</A>
<%
}
%>
</td>
</tr>
</table>
<%-- The authors --%>
<table align=center class="miscTable">
<%
// Row: toggles between Odd and Even
String row = "Odd";
List results = browseInfo.getResults();
for (int i = 0; i < results.size(); i++)
{
String name = (String) results.get(i);
%>
<tr>
<td class="<%= highlight && i==browseInfo.getOffset() ? "Highlight" : row %>RowOddCol">
<A HREF="items-by-author?author=<%= URLEncoder.encode(name) %>"><%= name %></A>
</td>
</tr>
<%
row = ( row.equals( "Odd" ) ? "Even" : "Odd" );
}
%>
</table>
<%-- Previous page/Next page --%>
<table align=center border=0 width=70%>
<tr>
<td class=standard align=left>
<%
if (prevQuery != null)
{
%>
<A HREF="browse-author?<%= prevQuery %>">Previous page</A>
<%
}
%>
</td>
<td class=standard align=right>
<%
if (nextQuery != null)
{
%>
<A HREF="browse-author?<%= nextQuery %>">Next page</A>
<%
}
%>
</td>
</tr>
</table>
</form>
</dspace:layout>

389
dspace/jsp/browse/items.jsp Normal file
View File

@@ -0,0 +1,389 @@
<%--
- items.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.
--%>
<%--
- Display the results of browsing a title or date index
-
- Attributes to pass in:
- browse.dates - Boolean - if True, browsing by date, otherwise by title
- community - pass in if the scope of the browse is a community, or
- a collection within this community
- collection - pass in if the scope of the browse is a collection
- browse.info - the BrowseInfo containing the items to display
- handles - String[] of Handles corresponding to the browse results
- highlight - Boolean. If true, the focus point of the browse
- is highlighted
- previous.query - The query string to pass to the servlet to get the
- previous page of items
- next.query - The query string to pass to the servlet to get the next
- page of items
-
- Specific to browsing by date - these can be omitted if browsing titles
-
- oldest.first - Boolean - if browsing dates, indicates whether oldest
- items are first
- flip.ordering.query - the query string for flipping the order of the
- index between oldest first and most recent first
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.browse.BrowseInfo" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.content.Collection" %>
<%@ page import="org.dspace.content.DCDate" %>
<%@ page import="org.dspace.content.DCValue" %>
<%@ page import="org.dspace.content.Item" %>
<%
// Get attributes
boolean browseDates = ((Boolean) request.getAttribute("browse.dates")).booleanValue();
Collection collection = (Collection) request.getAttribute("collection");
Community community = (Community) request.getAttribute("community");
BrowseInfo browseInfo = (BrowseInfo) request.getAttribute("browse.info");
String[] handles = (String[]) request.getAttribute("handles");
boolean highlight = ((Boolean) request.getAttribute("highlight")).booleanValue();
String prevQuery = (String) request.getAttribute("previous.query");
String nextQuery = (String) request.getAttribute("next.query");
// Browse by date only stuff
boolean oldestFirst = false;
String flipOrderingQuery = "";
if (browseDates)
{
oldestFirst = ((Boolean) request.getAttribute("oldest.first")).booleanValue();
flipOrderingQuery = (String) request.getAttribute("flip.ordering.query");
}
// Description of what the user is actually browsing
String scopeName = "All of DSpace";
if (collection != null)
{
scopeName = collection.getMetadata("name");
}
else if (community != null)
{
scopeName = community.getMetadata("name");
}
// Title
String pageTitle = "Browse by " + (browseDates ? "Date" : "Title");
String link = "browse-" + (browseDates ? "date" : "title");
%>
<dspace:layout title="<%= pageTitle %>">
<H2>Browsing <%= scopeName %> by <%= browseDates ? "Date" : "Title" %></H2>
<form action="<%= link %>" method=GET>
<%
if (browseDates)
{
%>
<%-- Date browse controls table --%>
<table align=center border=0 bgcolor="#CCCCCC" cellpadding=0>
<tr>
<td>
<table border=0 bgcolor="#EEEEEE" cellpadding=2>
<tr>
<td class="browseBar">
<span class="browseBarLabel">Jump to a point in the index: </span>
<select name=month>
<option selected value="-1">(Choose month)</option>
<%
for( int i=1; i<=12; i++ )
{
%>
<option value=<%= i %>><%= DCDate.getMonthName(i) %></option>
<%
}
%>
</select>
<select name=year>
<option selected value="-1">(Choose year)</option>
<%
for( int i=2001; i>=1990; i-- )
{
%>
<option><%= i %></option>
<%
}
%>
<option>1985</option>
<option>1980</option>
<option>1975</option>
<option>1970</option>
<option>1960</option>
<option>1950</option>
</select>
</td>
<td class="browseBar" rowspan=2>
<input type=submit value="Go">
</td>
</tr>
<tr>
<%-- HACK: Shouldn't use align here --%>
<td class="browseBar" align=center>
<span class="browseBarLabel">Or type in a year:</span>
<input type=text name=starts_with size=4 maxlength=4>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%-- Flip the ordering controls --%>
<table border=0 width=70% align=center>
<tr>
<td align=left class=standard>
<%
if (oldestFirst)
{
%>
<a href="<%= link %>?<%= flipOrderingQuery %>">Show Most Recent First</A>
<%
}
else
{
%>
<strong>Ordering With Most Recent First</strong>
<%
}
%>
</td>
<td align=right class=standard>
<%
if( oldestFirst )
{
%>
<strong>Ordering With Oldest First</strong>
<%
}
else
{
%>
<a href="<%= link %>?<%= flipOrderingQuery %>order=oldestfirst">Show Oldest First</A>
<%
}
%>
</td>
</tr>
</table>
<%
}
else
{
%>
<%-- Title browse controls table --%>
<table align=center border=0 bgcolor="#CCCCCC" cellpadding=0>
<tr>
<td>
<table border=0 bgcolor="#EEEEEE" cellpadding=2>
<tr>
<td class="browseBar">
<span class="browseBarLabel">Jump&nbsp;to:&nbsp;</span>
<A HREF="<%= link %>?starts_with=0">0-9</A>
<%
for (char c = 'A'; c <= 'Z'; c++)
{
%>
<A HREF="<%= link %>?starts_with=<%= c %>"><%= c %></A>
<%
}
%>
</td>
</tr>
<tr>
<td class="browseBar" align=center>
<span class="browseBarLabel">or enter first few letters:&nbsp;</span>
<input type="text" name="starts_with"/>&nbsp;<input type="submit" value="Go!">
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
}
%>
<BR>
<P align=center>Showing items <%= browseInfo.getOverallPosition()+1 %>-<%= browseInfo.getOverallPosition()+browseInfo.getResultCount() %> of <%= browseInfo.getTotal() %>.</P>
<%-- Previous page/Next page --%>
<table align=center border=0 width=70%>
<tr>
<td class=standard align=left>
<%
if (prevQuery != null)
{
%>
<A HREF="<%= link %>?<%= prevQuery %>">Previous page</A>
<%
}
%>
</td>
<td class=standard align=right>
<%
if (nextQuery != null)
{
%>
<A HREF="<%= link %>?<%= nextQuery %>">Next page</A>
<%
}
%>
</td>
</tr>
</table>
<%-- The items --%>
<table align=center class="miscTable">
<%
// Row: toggles between Odd and Even
String row = "odd";
for (int i = 0; i < browseInfo.getResults().size(); i++)
{
// Get the item
Item item = (Item) browseInfo.getResults().get(i);
// Title - we just use the first one
DCValue[] titleArray = item.getDC("title", null, Item.ANY);
String title = "Untitled";
if (titleArray.length > 0)
{
title = titleArray[0].value;
}
// Authors....
DCValue[] authors = item.getDC("contributor", "author", Item.ANY);
// Date issued
DCValue[] dateIssued = item.getDC("date", "issued", Item.ANY);
DCDate dd = null;
if(dateIssued.length > 0)
{
dd = new DCDate(dateIssued[0].value);
}
// Even, odd, or highlight row?
String rowClass = row;
if (highlight && i == browseInfo.getOffset())
{
rowClass = "highlight";
}
// We emphasise the index field
String beforeDate = (browseDates ? "<strong>" : "");
String afterDate = (browseDates ? "</strong>" : "");
String beforeTitle = (browseDates ? "" : "<strong>");
String afterTitle = (browseDates ? "" : "</strong>");
%>
<tr>
<td nowrap class="<%= rowClass %>RowOddCol" align=right>
<%= beforeDate %><dspace:date date="<%= dd %>" notime="true" /><%= afterDate %>
</td>
<td class="<%= rowClass %>RowEvenCol">
<%= beforeTitle %><A HREF="item/<%= handles[i] %>"><%= title %></A><%= afterTitle %>
</td>
<td class="<%= rowClass %>RowOddCol">
<%
for( int j=0; j<authors.length; j++ )
{
%>
<em><%= authors[j].value %></em><% if (j < authors.length - 1) { %>; <% } %>
<%
}
%>
</td>
</tr>
<%
row = ( row.equals( "odd" ) ? "even" : "odd" );
}
%>
</table>
<%-- Previous page/Next page --%>
<table align=center border=0 width=70%>
<tr>
<td class=standard align=left>
<%
if (prevQuery != null)
{
%>
<A HREF="<%= link %>?<%= prevQuery %>">Previous page</A>
<%
}
%>
</td>
<td class=standard align=right>
<%
if (nextQuery != null)
{
%>
<A HREF="<%= link %>?<%= nextQuery %>">Next page</A>
<%
}
%>
</td>
</tr>
</table>
</form>
</dspace:layout>

View File

@@ -0,0 +1,87 @@
<%--
- no-results.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.
--%>
<%--
- Message indicating that there are no entries in the browse index.
-
- Attributes required:
- community - community the browse was in, or null
- collection - collection the browse was in, or null
--%>
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.content.Community" %>
<%@ page import="org.dspace.content.Collection" %>
<%
// Retrieve attributes
Community community = (Community) request.getAttribute("community");
Collection collection = (Collection) request.getAttribute("collection");
// Description of what the user is actually browsing, and where link back
String scopeName = "All of DSpace";
String linkText = "DSpace Home";
String linkBack = "/";
if(collection != null)
{
scopeName = collection.getMetadata("name");
linkText = collection.getMetadata("name");
linkBack = "/communities/" + community.getID() + "/collections/" +
collection.getID() + "/";
}
else if(community != null)
{
scopeName = community.getMetadata("name");
linkText = community.getMetadata("name");
linkBack = "/communities/" + community.getID() + "/";
}
%>
<dspace:layout locbar="link" title="No Entries in Index">
<H1>No Entries in Index</H1>
<P>There are no entries in the index for <%= scopeName %>.</P>
<P><A HREF="<%= request.getContextPath() %><%= linkBack %>"><%= linkText %></A></P>
</dspace:layout>

Binary file not shown.

View File

@@ -0,0 +1,212 @@
/*
* DateTag.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.jsptag;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.dspace.content.DCDate;
/**
* Date rendering tag for DCDates. Takes two parameter - "date", a DCDate,
* and "notime", which, if present, means the date is rendered without the
* time
*
* @author Robert Tansley
* @version $Revision$
*/
public class DateTag extends TagSupport
{
/** The date to display */
private DCDate date;
/** Display the time? */
private boolean displayTime = true;
/**
* Get the date
*
* @return the date to display
*/
public DCDate getDate()
{
return date;
}
/**
* Set the date
*
* @param s the date to display
*/
public void setDate(DCDate d)
{
date = d;
}
/**
* Get the "don't display the time" flag
*
* @return the date to display
*/
public String getNotime()
{
// Note inverse of internal flag
return (displayTime ? "false" : "true");
}
/**
* Set the "don't display the time" flag
*
* @param dummy can be anything - always sets the flag if present
*/
public void setNotime(String dummy)
{
displayTime = false;
}
public int doStartTag()
throws JspException
{
String toDisplay = displayDate(date, displayTime, true);
try
{
pageContext.getOut().print(toDisplay);
}
catch (IOException ie)
{
throw new JspException(ie);
}
return SKIP_BODY;
}
/**
* Write a human-readable version of a DCDate.
*
* @param d the date
* @param time if true, display the time with the date
* @param localTime if true, adjust for local timezone, otherwise GMT
*
* @return the date in a human-readable form.
*/
public static String displayDate(DCDate d,
boolean time,
boolean localTime)
{
StringBuffer sb = new StringBuffer();
if (d != null)
{
int year, month, day, hour, minute, second;
if (localTime)
{
year = d.getYear();
month = d.getMonth();
day = d.getDay();
hour = d.getHour();
minute = d.getMinute();
second = d.getSecond();
}
else
{
year = d.getYearGMT();
month = d.getMonthGMT();
day = d.getDayGMT();
hour = d.getHourGMT();
minute = d.getMinuteGMT();
second = d.getSecondGMT();
}
if (year > -1)
{
if (month > -1)
{
if (day > -1)
{
sb.append(day + "-");
}
sb.append(DCDate.getMonthName(month).substring(0, 3) + "-");
}
sb.append(year + " ");
}
if (time && hour > -1)
{
String hr = String.valueOf(hour);
while (hr.length() < 2)
{
hr = "0" + hr;
}
String mn = String.valueOf(minute);
while (mn.length() < 2)
{
mn = "0" + mn;
}
String sc = String.valueOf(second);
while (sc.length() < 2)
{
sc = "0" + sc;
}
sb.append(hr + ":" + mn + ":" + sc + " ");
}
}
else
{
sb.append("Unset");
}
return (sb.toString());
}
}

View File

@@ -82,10 +82,10 @@ import org.dspace.core.ConfigurationManager;
* @author Robert Tansley * @author Robert Tansley
* @version $Revision$ * @version $Revision$
*/ */
public class Layout extends TagSupport public class LayoutTag extends TagSupport
{ {
/** log4j logger */ /** log4j logger */
private static Logger log = Logger.getLogger(Layout.class); private static Logger log = Logger.getLogger(LayoutTag.class);
/** layout style name */ /** layout style name */
private String style; private String style;
@@ -109,7 +109,7 @@ public class Layout extends TagSupport
private String sidebar; private String sidebar;
public Layout() public LayoutTag()
{ {
super(); super();
} }

View File

@@ -54,13 +54,19 @@ import javax.servlet.jsp.tagext.BodyTagSupport;
* @author Peter Breton * @author Peter Breton
* @version $Revision$ * @version $Revision$
*/ */
public class Sidebar extends BodyTagSupport public class SidebarTag extends BodyTagSupport
{ {
public SidebarTag()
{
super();
}
public int doAfterBody() public int doAfterBody()
throws JspException throws JspException
{ {
Layout tag = (Layout) TagSupport.findAncestorWithClass(this, LayoutTag tag = (LayoutTag) TagSupport.findAncestorWithClass(this,
Layout.class); LayoutTag.class);
if (tag == null) if (tag == null)
{ {

View File

@@ -0,0 +1,460 @@
/*
* BrowseServlet.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.InputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.sql.SQLException;
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.log4j.Logger;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.browse.Browse;
import org.dspace.browse.BrowseInfo;
import org.dspace.browse.BrowseScope;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.Item;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.Utils;
import org.dspace.handle.HandleManager;
/**
* Servlet for browsing through indices. This can be used to browse authors,
* items by date, or items by title. In the deployment description, the
* parameter "browse" should be set to one of these values:
* <P>
* <UL>
* <LI><code>titles</code> - for browsing items by title (the default)</LI>
* <LI><code>authors</code> - for browsing authors</LI>
* <LI><code>dates</code> - for browsing items by date</LI>
* </UL>
* <P>
* Hence there should be three instances of this servlet, one for each type of
* browse.
*
* @author Robert Tansley
* @version $Revision$
*/
public class BrowseServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(BrowseServlet.class);
/** Is this servlet for browsing authors? */
private boolean browseAuthors;
/** Is this servlet for browsing items by title? */
private boolean browseTitles;
/** Is this servlet for browsing items by date? */
private boolean browseDates;
public void init()
{
// Sort out what we're browsing - default is titles
String browseWhat = getInitParameter("browse");
browseAuthors = (browseWhat != null &&
browseWhat.equalsIgnoreCase("authors"));
browseDates = (browseWhat != null &&
browseWhat.equalsIgnoreCase("dates"));
browseTitles = (!browseAuthors && !browseDates);
}
protected void doDSGet(Context context,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
// We will resolve the HTTP request parameters into a scope
BrowseScope scope = new BrowseScope(context);
// Will need to know whether to highlight the "focus" point
boolean highlight = false;
// Build up log information
String logInfo = "";
// For browse by date, we'll need to work out the URL query string to
// use when the user swaps the ordering, so that they stay at the same
// point in the index
String flipOrderingQuery = "";
// Grab HTTP request parameters
String focus = request.getParameter("focus");
String startsWith = request.getParameter("starts_with");
String top = request.getParameter("top");
String bottom = request.getParameter("bottom");
// The following three are specific to browsing items by date
String month = request.getParameter("month");
String year = request.getParameter("year");
String order = request.getParameter("order");
// For browse by date: oldest item first?
boolean oldestFirst = false;
if (order != null && order.equalsIgnoreCase("oldestfirst"))
{
oldestFirst = true;
}
if (browseDates &&
year != null &&
!year.equals("") &&
startsWith == null)
{
// We're browsing items by date, the user hasn't typed anything
// into the "year" text box, and they've selected a year from
// the drop-down list. From this we work out where to start
// the browse.
startsWith = year;
if (month != null & !month.equals("-1"))
{
// They've selected a month as well
startsWith = year + "-" + month;
}
}
// Set the scope according to the parameters passed in
if (focus != null)
{
// ----------------------------------------------
// Browse should start at a specified focus point
// ----------------------------------------------
if (browseAuthors)
{
// For browsing authors, focus is just a text value
scope.setFocus(focus);
}
else
{
// For browsing items by title or date, focus is a Handle
Item item = (Item) HandleManager.resolveToObject(context,
focus);
if (item == null)
{
// Handle is invalid one. Show an error.
JSPManager.showInvalidIDError(request, response, focus,
Constants.ITEM);
return;
}
scope.setFocus(item);
}
// Will need to highlight the focus
highlight = true;
logInfo = "focus=" + focus;
if (browseDates)
{
// if the date order is flipped, we'll keep the same focus
flipOrderingQuery = "focus=" + URLEncoder.encode(focus) + "&";
}
}
else if (!browseDates && startsWith != null)
{
// ----------------------------------------------
// Start the browse using user-specified text
// ----------------------------------------------
scope.setFocus(startsWith);
highlight = true;
logInfo = "starts_with=" + startsWith;
if (browseDates)
{
// if the date order is flipped, we'll keep the same focus
flipOrderingQuery = "starts_with=" +
URLEncoder.encode(startsWith) + "&";
}
}
else if (top != null || bottom != null)
{
// ----------------------------------------------
// Paginating: put specified entry at top or bottom
// ----------------------------------------------
// Use a single value and a boolean to simplify the code below
String val = bottom;
boolean isTop = false;
if (top != null)
{
val = top;
isTop = true;
}
if (browseAuthors)
{
// Value will be a text value for author browse
scope.setFocus(val);
}
else
{
// Value is Handle if we're browsing items by title or date
Item item = (Item) HandleManager.resolveToObject(context,
val);
if (item == null)
{
// Handle is invalid one. Show an error.
JSPManager.showInvalidIDError(request, response, focus,
Constants.ITEM);
return;
}
scope.setFocus(item);
}
// This entry appears at the top or bottom, and so needs to have
// 0 or 20 entries shown before it
scope.setNumberBefore(isTop ? 0 : 20);
logInfo = (isTop ? "top" : "bottom") + "=" + val;
if (browseDates)
{
// If the date order is flipped, we'll flip the table upside
// down - i.e. the top will become the bottom and the bottom
// the top.
if (top != null)
{
flipOrderingQuery = "bottom=" + URLEncoder.encode(top) +
"&";
}
else
{
flipOrderingQuery = "top=" + URLEncoder.encode(bottom) +
"&";
}
}
}
else
{
// ----------------------------------------------
// No positioning parameters set - use start of index
// ----------------------------------------------
// Don't need to do anything for most browses
if (browseDates && oldestFirst)
{
// For a browse by date starting with the most recent item,
// we need to start at the most recent, so we'll set the focus
// to be very high
scope.setFocus("9999");
}
}
// Are we in a community or collection?
Community community = UIUtil.getCommunityLocation(request);
Collection collection = UIUtil.getCollectionLocation(request);
if (collection != null)
{
logInfo = logInfo + ",collection_id=" + collection.getID();
scope.setScope(collection);
}
else if (community != null)
{
logInfo = logInfo + ",community_id=" + community.getID();
scope.setScope(community);
}
BrowseInfo browseInfo;
// Query the browse index
if (browseAuthors)
{
browseInfo = Browse.getAuthors(scope);
}
else if (browseDates)
{
browseInfo = Browse.getItemsByDate(scope, oldestFirst);
}
else
{
browseInfo = Browse.getItemsByTitle(scope);
}
List results = browseInfo.getResults();
// Write log entry
String what = "title";
if (browseAuthors)
{
what = "author";
}
else if (browseDates)
{
what = "date";
}
log.info(LogManager.getHeader(context,
"browse_" + what,
logInfo + ",results=" + results.size()));
if (results.size() == 0)
{
// No results!
request.setAttribute("community", community);
request.setAttribute("collection", collection);
JSPManager.showJSP(request, response, "/browse/no-results.jsp");
}
else
{
// If we're browsing items by title or date, we need to work
// out the Handles for the items
if (browseDates || browseTitles)
{
String[] handles = new String[results.size()];
for (int i = 0; i < results.size(); i++)
{
Item item = (Item) results.get(i);
handles[i] = HandleManager.findHandle(context, item);
}
request.setAttribute("handles", handles);
}
// Work out what the query strings will be for the previous
// and next pages
if (!browseInfo.isFirst())
{
// Not the first page, so we'll need a "previous page" button
// The top entry of the current page becomes the bottom
// entry of the "previous page"
String s;
if (browseAuthors)
{
s = (String) results.get(0);
}
else
{
Item firstItem = (Item) results.get(0);
s = HandleManager.findHandle(context, firstItem);
}
request.setAttribute("previous.query",
"bottom=" + URLEncoder.encode(s));
}
if (!browseInfo.isLast())
{
// Not the last page, so we'll need a "next page" button
// The bottom entry of the current page will be the top
// entry in the next page
String s;
if (browseAuthors)
{
s = (String) results.get(results.size() - 1);
}
else
{
Item lastItem = (Item) results.get(results.size() - 1);
s = HandleManager.findHandle(context, lastItem);
}
request.setAttribute("next.query",
"top=" + URLEncoder.encode(s));
}
// Set appropriate attributes and forward to results page
request.setAttribute("community", community);
request.setAttribute("collection", collection);
request.setAttribute("browse.info", browseInfo);
request.setAttribute("highlight", new Boolean(highlight));
if (browseAuthors)
{
JSPManager.showJSP(request, response, "/browse/authors.jsp");
}
else if (browseDates)
{
request.setAttribute("browse.dates", new Boolean(true));
request.setAttribute("oldest.first", new Boolean(oldestFirst));
request.setAttribute("flip.ordering.query", flipOrderingQuery);
JSPManager.showJSP(request, response,
"/browse/items.jsp");
}
else
{
request.setAttribute("browse.dates", new Boolean(false));
JSPManager.showJSP(request, response,
"/browse/items.jsp");
}
}
}
}

View File

@@ -0,0 +1,141 @@
/*
* RetrieveServlet.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.InputStream;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
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.authorize.AuthorizeException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.Bitstream;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.core.Utils;
/**
* Servlet for retrieving bitstreams. The bits are simply piped to the user.
* <P>
* <code>/retrieve/bitstream-id</code>
*
* @author Robert Tansley
* @version $Revision$
*/
public class RetrieveServlet extends DSpaceServlet
{
/** log4j category */
private static Logger log = Logger.getLogger(RetrieveServlet.class);
protected void doDSGet(Context context,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
Bitstream bitstream = null;
// Get the ID from the URL
String idString = request.getPathInfo();
if (idString != null)
{
// Remove leading slash
if (idString.startsWith("/"))
{
idString = idString.substring(1);
}
// Find the corresponding bitstream
try
{
int id = Integer.parseInt(idString);
bitstream = Bitstream.find(context, id);
}
catch (NumberFormatException nfe)
{
// Invalid ID - this will be dealt with below
}
}
// Did we get a bitstream?
if (bitstream != null)
{
log.info(LogManager.getHeader(context,
"view_bitstream",
"bitstream_id=" + bitstream.getID()));
// Set the response MIME type
response.setContentType(bitstream.getFormat().getMIMEType());
// Response length
response.setHeader("Content-Length",
String.valueOf(bitstream.getSize()));
// Pipe the bits
InputStream is = bitstream.retrieve();
Utils.bufferedCopy(is, response.getOutputStream());
is.close();
response.getOutputStream().flush();
}
else
{
// No bitstream - we got an invalid ID
log.info(LogManager.getHeader(context,
"view_bitstream",
"invalid_bitstream_id=" + idString));
JSPManager.showInvalidIDError(request,
response,
idString,
Constants.BITSTREAM);
}
}
}