mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Fixed browse index for withdrawn items. Moved DB access from BrowseItem into a DAO. Added jsp interface for browsing withdrawn items.
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2144 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -619,8 +619,15 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
||||
|
||||
try
|
||||
{
|
||||
String query = "SELECT item_id FROM " + table + " WHERE item_id NOT IN ( SELECT item_id FROM item WHERE in_archive = 1 AND withdrawn = " +
|
||||
(withdrawn ? "0" : "1") + ")";
|
||||
String query = "SELECT item_id FROM " + table + " WHERE item_id NOT IN ( SELECT item_id FROM item WHERE ";
|
||||
|
||||
if (withdrawn)
|
||||
query += "withdrawn = 1";
|
||||
else
|
||||
query += "in_archive = 1 AND withdrawn = 0";
|
||||
|
||||
query += ")";
|
||||
|
||||
tri = DatabaseManager.query(context, query);
|
||||
while (tri.hasNext())
|
||||
{
|
||||
|
@@ -619,8 +619,15 @@ public class BrowseCreateDAOPostgres implements BrowseCreateDAO
|
||||
|
||||
try
|
||||
{
|
||||
String query = "SELECT item_id FROM " + table + " WHERE item_id NOT IN ( SELECT item_id FROM item WHERE in_archive = true AND withdrawn = " +
|
||||
(withdrawn ? "true" : "false") + ")";
|
||||
String query = "SELECT item_id FROM " + table + " WHERE item_id NOT IN ( SELECT item_id FROM item WHERE ";
|
||||
|
||||
if (withdrawn)
|
||||
query += "withdrawn = true";
|
||||
else
|
||||
query += "in_archive = true AND withdrawn = false";
|
||||
|
||||
query += ")";
|
||||
|
||||
tri = DatabaseManager.query(context, query);
|
||||
while (tri.hasNext())
|
||||
{
|
||||
|
@@ -102,6 +102,32 @@ public class BrowseDAOFactory
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the relevant Read Only DAO class, which will
|
||||
* conform to the BrowseItemDAO interface
|
||||
*
|
||||
* @param context the DSpace context
|
||||
* @return the relevant DAO
|
||||
* @throws BrowseException
|
||||
*/
|
||||
public static BrowseItemDAO getItemInstance(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
String db = ConfigurationManager.getProperty("db.name");
|
||||
if ("postgres".equals(db))
|
||||
{
|
||||
return new BrowseItemDAOPostgres(context);
|
||||
}
|
||||
else if ("oracle".equals(db))
|
||||
{
|
||||
return new BrowseItemDAOOracle(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BrowseException("The configuration for db.name is either invalid, or contains an unrecognised database");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the relevant DAO Utilities class, which will
|
||||
* conform to the BrowseDAOUtils interface
|
||||
|
@@ -138,6 +138,11 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
/** whether the query (above) needs to be regenerated */
|
||||
private boolean rebuildQuery = true;
|
||||
|
||||
// FIXME Would be better to join to item table and get the correct values
|
||||
/** flags for what the items represent */
|
||||
private boolean itemsInArchive = true;
|
||||
private boolean itemsWithdrawn = false;
|
||||
|
||||
public BrowseDAOOracle(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
@@ -254,7 +259,9 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow row = tri.next();
|
||||
BrowseItem browseItem = new BrowseItem(context, row.getIntColumn("item_id"));
|
||||
BrowseItem browseItem = new BrowseItem(context, row.getIntColumn("item_id"),
|
||||
itemsInArchive,
|
||||
itemsWithdrawn);
|
||||
results.add(browseItem);
|
||||
}
|
||||
|
||||
@@ -579,6 +586,21 @@ public class BrowseDAOOracle implements BrowseDAO
|
||||
public void setTable(String table)
|
||||
{
|
||||
this.table = table;
|
||||
|
||||
// FIXME Rather than assume from the browse table, join the query to item to get the correct values
|
||||
// Check to see if this is the withdrawn browse index - if it is,
|
||||
// we need to set the flags appropriately for when we create the BrowseItems
|
||||
if (table.equals(BrowseIndex.getWithdrawnBrowseIndex().getTableName()))
|
||||
{
|
||||
itemsInArchive = false;
|
||||
itemsWithdrawn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsInArchive = true;
|
||||
itemsWithdrawn = false;
|
||||
}
|
||||
|
||||
this.rebuildQuery = true;
|
||||
}
|
||||
|
||||
|
@@ -138,6 +138,11 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
|
||||
private String whereClauseOperator = "";
|
||||
|
||||
// FIXME Would be better to join to item table and get the correct values
|
||||
/** flags for what the items represent */
|
||||
private boolean itemsInArchive = true;
|
||||
private boolean itemsWithdrawn = false;
|
||||
|
||||
/**
|
||||
* Required constructor for use by BrowseDAOFactory
|
||||
*
|
||||
@@ -261,7 +266,9 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow row = tri.next();
|
||||
BrowseItem browseItem = new BrowseItem(context, row.getIntColumn("item_id"));
|
||||
BrowseItem browseItem = new BrowseItem(context, row.getIntColumn("item_id"),
|
||||
itemsInArchive,
|
||||
itemsWithdrawn);
|
||||
results.add(browseItem);
|
||||
}
|
||||
|
||||
@@ -583,6 +590,21 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
public void setTable(String table)
|
||||
{
|
||||
this.table = table;
|
||||
|
||||
// FIXME Rather than assume from the browse table, join the query to item to get the correct values
|
||||
// Check to see if this is the withdrawn browse index - if it is,
|
||||
// we need to set the flags appropriately for when we create the BrowseItems
|
||||
if (table.equals(BrowseIndex.getWithdrawnBrowseIndex().getTableName()))
|
||||
{
|
||||
itemsInArchive = false;
|
||||
itemsWithdrawn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsInArchive = true;
|
||||
itemsWithdrawn = false;
|
||||
}
|
||||
|
||||
this.rebuildQuery = true;
|
||||
}
|
||||
|
||||
@@ -862,7 +884,7 @@ public class BrowseDAOPostgres implements BrowseDAO
|
||||
* SELECT [arguments] FROM [table]
|
||||
* </code>
|
||||
*
|
||||
* @param args the string value obtained from distinctClause, countClause or selectValues
|
||||
* @param queryBuf the string value obtained from distinctClause, countClause or selectValues
|
||||
* @return the SELECT part of the query
|
||||
*/
|
||||
private void buildSelectStatement(StringBuffer queryBuf) throws BrowseException
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -43,7 +43,6 @@ package org.dspace.browse;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -213,6 +212,8 @@ public class BrowseEngine
|
||||
|
||||
browseInfo.setResultsPerPage(scope.getResultsPerPage());
|
||||
|
||||
browseInfo.setEtAl(scope.getEtAl());
|
||||
|
||||
return browseInfo;
|
||||
}
|
||||
|
||||
@@ -367,7 +368,12 @@ public class BrowseEngine
|
||||
}
|
||||
if (prevID != -1)
|
||||
{
|
||||
prev = new BrowseItem(context, prevID);
|
||||
// If we are browsing the withdrawn index, create a 'withdrawn' browse item
|
||||
// Otherwise, assume that the item is in the archive and not withdrawn
|
||||
if (bs.getBrowseIndex() == BrowseIndex.getWithdrawnBrowseIndex())
|
||||
prev = new BrowseItem(context, prevID, false, true);
|
||||
else
|
||||
prev = new BrowseItem(context, prevID, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,6 +454,8 @@ public class BrowseEngine
|
||||
|
||||
browseInfo.setResultsPerPage(scope.getResultsPerPage());
|
||||
|
||||
browseInfo.setEtAl(scope.getEtAl());
|
||||
|
||||
return browseInfo;
|
||||
}
|
||||
catch (SQLException e)
|
||||
@@ -708,7 +716,7 @@ public class BrowseEngine
|
||||
* Return a normalized focus value. If there is no normalization that can be performed,
|
||||
* return the focus value that is passed in.
|
||||
*
|
||||
* @param String a focus value to normalize
|
||||
* @param value a focus value to normalize
|
||||
* @return the normalized focus value
|
||||
* @throws BrowseException
|
||||
*/
|
||||
|
@@ -42,7 +42,6 @@ package org.dspace.browse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -84,9 +83,6 @@ public class BrowseIndex
|
||||
/** a three part array of the metadata bits (e.g. dc.contributor.author) */
|
||||
private String[] mdBits;
|
||||
|
||||
/** array of the configured indexes */
|
||||
private static BrowseIndex[] browseIndexes = null;
|
||||
|
||||
/** additional 'internal' tables that are always defined */
|
||||
private static BrowseIndex itemIndex = new BrowseIndex("bi_item");
|
||||
private static BrowseIndex withdrawnIndex = new BrowseIndex("bi_withdrawn");
|
||||
@@ -100,7 +96,7 @@ public class BrowseIndex
|
||||
|
||||
/**
|
||||
* Constructor for creating generic / internal index objects
|
||||
* @param baseName
|
||||
* @param baseName The base of the table name
|
||||
*/
|
||||
private BrowseIndex(String baseName)
|
||||
{
|
||||
@@ -770,7 +766,6 @@ public class BrowseIndex
|
||||
/**
|
||||
* Does this browse index represent one of the internal item indexes
|
||||
*
|
||||
* @param bi
|
||||
* @return
|
||||
*/
|
||||
public boolean isInternalIndex()
|
||||
|
@@ -35,24 +35,18 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.HandleManager;
|
||||
import org.dspace.storage.rdbms.DatabaseManager;
|
||||
import org.dspace.storage.rdbms.TableRow;
|
||||
import org.dspace.storage.rdbms.TableRowIterator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Entity class to represent an item that is being used to generate Browse
|
||||
@@ -82,41 +76,15 @@ public class BrowseItem extends DSpaceObject
|
||||
/** database id of the item */
|
||||
private int id = -1;
|
||||
|
||||
/** is the item in the archive */
|
||||
private boolean in_archive = true;
|
||||
|
||||
/** is the item withdrawn */
|
||||
private boolean withdrawn = false;
|
||||
|
||||
/** item handle */
|
||||
private String handle = null;
|
||||
|
||||
/** query to obtain all the items from the database */
|
||||
private String findAll = "SELECT * FROM item WHERE in_archive = true AND withdrawn = false";
|
||||
|
||||
/** query to check the existance of an item id */
|
||||
private String getByID = "SELECT id FROM item WHERE item_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
||||
private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier IS NULL " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element and qualifier */
|
||||
private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
||||
private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** inner item, if we really absolutely have to instantiate it */
|
||||
private Item item;
|
||||
|
||||
@@ -125,33 +93,15 @@ public class BrowseItem extends DSpaceObject
|
||||
*
|
||||
* @param context the DSpace context
|
||||
* @param id the database id of the item
|
||||
* @param in_archive
|
||||
* @param withdrawn
|
||||
*/
|
||||
public BrowseItem(Context context, int id)
|
||||
public BrowseItem(Context context, int id, boolean in_archive, boolean withdrawn)
|
||||
{
|
||||
this.context = context;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an integer array of all the item ids in the database
|
||||
*
|
||||
* @return integer array of item ids
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Integer[] findAll()
|
||||
throws SQLException
|
||||
{
|
||||
TableRowIterator tri = DatabaseManager.query(context, findAll);
|
||||
ArrayList ids = new ArrayList();
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow row = tri.next();
|
||||
ids.add(new Integer(row.getIntColumn("item_id")));
|
||||
}
|
||||
|
||||
Integer[] ints = new Integer[ids.size()];
|
||||
return (Integer[]) ids.toArray((Integer[]) ints);
|
||||
this.in_archive = in_archive;
|
||||
this.withdrawn = withdrawn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,11 +117,15 @@ public class BrowseItem extends DSpaceObject
|
||||
public DCValue[] getMetadata(String schema, String element, String qualifier, String lang)
|
||||
throws SQLException
|
||||
{
|
||||
try
|
||||
{
|
||||
BrowseItemDAO dao = BrowseDAOFactory.getItemInstance(context);
|
||||
|
||||
// if the qualifier is a wildcard, we have to get it out of the
|
||||
// database
|
||||
if (Item.ANY.equals(qualifier))
|
||||
{
|
||||
return queryMetadata(schema, element, qualifier, lang);
|
||||
return dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||
}
|
||||
|
||||
if (!metadata.isEmpty())
|
||||
@@ -191,7 +145,9 @@ public class BrowseItem extends DSpaceObject
|
||||
|
||||
if (values.isEmpty())
|
||||
{
|
||||
return queryMetadata(schema, element, qualifier, lang);
|
||||
DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||
Collections.addAll(metadata, dcvs);
|
||||
return dcvs;
|
||||
}
|
||||
|
||||
// else, Create an array of matching values
|
||||
@@ -202,7 +158,15 @@ public class BrowseItem extends DSpaceObject
|
||||
}
|
||||
else
|
||||
{
|
||||
return queryMetadata(schema, element, qualifier, lang);
|
||||
DCValue[] dcvs = dao.queryMetadata(id, schema, element, qualifier, lang);
|
||||
Collections.addAll(metadata, dcvs);
|
||||
return dcvs;
|
||||
}
|
||||
}
|
||||
catch (BrowseException be)
|
||||
{
|
||||
log.error("caught exception: ", be);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,67 +297,6 @@ public class BrowseItem extends DSpaceObject
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* perform a database query to obtain the string array of values corresponding to
|
||||
* the passed parameters. In general you should use:
|
||||
*
|
||||
* <code>
|
||||
* getMetadata(schema, element, qualifier, lang);
|
||||
* </code>
|
||||
*
|
||||
* As this will obtain the value from cache if available first.
|
||||
*
|
||||
* @param schema
|
||||
* @param element
|
||||
* @param qualifier
|
||||
* @param lang
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public DCValue[] queryMetadata(String schema, String element, String qualifier, String lang)
|
||||
throws SQLException
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
TableRowIterator tri;
|
||||
|
||||
if (qualifier == null)
|
||||
{
|
||||
Object[] params = { new Integer(id), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
||||
}
|
||||
else if (Item.ANY.equals(qualifier))
|
||||
{
|
||||
Object[] params = { new Integer(id), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object[] params = { new Integer(id), element, qualifier, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadata, params);
|
||||
}
|
||||
|
||||
if (!tri.hasNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow tr = tri.next();
|
||||
DCValue dcv = new DCValue();
|
||||
dcv.schema = schema;
|
||||
dcv.element = tr.getStringColumn("element");
|
||||
dcv.qualifier = tr.getStringColumn("qualifier");
|
||||
dcv.language = tr.getStringColumn("text_lang");
|
||||
dcv.value = tr.getStringColumn("text_value");
|
||||
metadata.add(dcv);
|
||||
values.add(dcv);
|
||||
}
|
||||
|
||||
DCValue[] dcvs = new DCValue[values.size()];
|
||||
return (DCValue[]) values.toArray(dcvs);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.dspace.content.DSpaceObject#getHandle()
|
||||
*/
|
||||
@@ -506,4 +409,14 @@ public class BrowseItem extends DSpaceObject
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isArchived()
|
||||
{
|
||||
return in_archive;
|
||||
}
|
||||
|
||||
public boolean isWithdrawn()
|
||||
{
|
||||
return withdrawn;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* BrowseItemDAO.java
|
||||
*
|
||||
* Copyright (c) 2002-2007, 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.browse;
|
||||
|
||||
import org.dspace.content.DCValue;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public interface BrowseItemDAO
|
||||
{
|
||||
/**
|
||||
* Get an array of all the items in the database
|
||||
*
|
||||
* @return array of items
|
||||
* @throws java.sql.SQLException
|
||||
*/
|
||||
public BrowseItem[] findAll()
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
* perform a database query to obtain the string array of values corresponding to
|
||||
* the passed parameters. In general you should use:
|
||||
*
|
||||
* <code>
|
||||
* getMetadata(schema, element, qualifier, lang);
|
||||
* </code>
|
||||
*
|
||||
* As this will obtain the value from cache if available first.
|
||||
*
|
||||
* @param itemId
|
||||
* @param schema
|
||||
* @param element
|
||||
* @param qualifier
|
||||
* @param lang
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
|
||||
throws SQLException;
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* BrowseItemDAOOracle.java
|
||||
*
|
||||
* Copyright (c) 2002-2007, 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.browse;
|
||||
|
||||
import org.dspace.storage.rdbms.TableRowIterator;
|
||||
import org.dspace.storage.rdbms.DatabaseManager;
|
||||
import org.dspace.storage.rdbms.TableRow;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BrowseItemDAOOracle implements BrowseItemDAO
|
||||
{
|
||||
/** query to obtain all the items from the database */
|
||||
private String findAll = "SELECT item_id, in_archive, withdrawn FROM item WHERE in_archive = 1 OR withdrawn = 1";
|
||||
|
||||
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
||||
private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier IS NULL " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element and qualifier */
|
||||
private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
||||
private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** DSpace context */
|
||||
private Context context;
|
||||
|
||||
public BrowseItemDAOOracle(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public BrowseItem[] findAll() throws SQLException
|
||||
{
|
||||
TableRowIterator tri = DatabaseManager.query(context, findAll);
|
||||
ArrayList items = new ArrayList();
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow row = tri.next();
|
||||
items.add(new BrowseItem(context, row.getIntColumn("item_id"),
|
||||
row.getBooleanColumn("in_archive"),
|
||||
row.getBooleanColumn("withdrawn")));
|
||||
}
|
||||
|
||||
BrowseItem[] bis = new BrowseItem[items.size()];
|
||||
return (BrowseItem[]) items.toArray((BrowseItem[]) bis);
|
||||
}
|
||||
|
||||
public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
|
||||
throws SQLException
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
TableRowIterator tri;
|
||||
|
||||
if (qualifier == null)
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
||||
}
|
||||
else if (Item.ANY.equals(qualifier))
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, qualifier, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadata, params);
|
||||
}
|
||||
|
||||
if (!tri.hasNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow tr = tri.next();
|
||||
DCValue dcv = new DCValue();
|
||||
dcv.schema = schema;
|
||||
dcv.element = tr.getStringColumn("element");
|
||||
dcv.qualifier = tr.getStringColumn("qualifier");
|
||||
dcv.language = tr.getStringColumn("text_lang");
|
||||
dcv.value = tr.getStringColumn("text_value");
|
||||
values.add(dcv);
|
||||
}
|
||||
|
||||
DCValue[] dcvs = new DCValue[values.size()];
|
||||
return (DCValue[]) values.toArray(dcvs);
|
||||
}
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* BrowseItemDAOPostgres.java
|
||||
*
|
||||
* Copyright (c) 2002-2007, 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.browse;
|
||||
|
||||
import org.dspace.storage.rdbms.TableRowIterator;
|
||||
import org.dspace.storage.rdbms.DatabaseManager;
|
||||
import org.dspace.storage.rdbms.TableRow;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BrowseItemDAOPostgres implements BrowseItemDAO
|
||||
{
|
||||
/** query to obtain all the items from the database */
|
||||
private String findAll = "SELECT item_id, in_archive, withdrawn FROM item WHERE in_archive = true OR withdrawn = true";
|
||||
|
||||
/** query to get the text value of a metadata element only (qualifier is NULL) */
|
||||
private String getByMetadataElement = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier IS NULL " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element and qualifier */
|
||||
private String getByMetadata = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.qualifier = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** query to get the text value of a metadata element with the wildcard qualifier (*) */
|
||||
private String getByMetadataAnyQualifier = "SELECT text_value,text_lang,element,qualifier FROM metadatavalue, metadatafieldregistry, metadataschemaregistry " +
|
||||
"WHERE metadatavalue.item_id = ? " +
|
||||
" AND metadatavalue.metadata_field_id = metadatafieldregistry.metadata_field_id " +
|
||||
" AND metadatafieldregistry.element = ? " +
|
||||
" AND metadatafieldregistry.metadata_schema_id=metadataschemaregistry.metadata_schema_id " +
|
||||
" AND metadataschemaregistry.short_id = ?";
|
||||
|
||||
/** DSpace context */
|
||||
private Context context;
|
||||
|
||||
public BrowseItemDAOPostgres(Context context)
|
||||
throws BrowseException
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public BrowseItem[] findAll() throws SQLException
|
||||
{
|
||||
TableRowIterator tri = DatabaseManager.query(context, findAll);
|
||||
ArrayList items = new ArrayList();
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow row = tri.next();
|
||||
items.add(new BrowseItem(context, row.getIntColumn("item_id"),
|
||||
row.getBooleanColumn("in_archive"),
|
||||
row.getBooleanColumn("withdrawn")));
|
||||
}
|
||||
|
||||
BrowseItem[] bis = new BrowseItem[items.size()];
|
||||
return (BrowseItem[]) items.toArray((BrowseItem[]) bis);
|
||||
}
|
||||
|
||||
public DCValue[] queryMetadata(int itemId, String schema, String element, String qualifier, String lang)
|
||||
throws SQLException
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
TableRowIterator tri;
|
||||
|
||||
if (qualifier == null)
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataElement, params);
|
||||
}
|
||||
else if (Item.ANY.equals(qualifier))
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadataAnyQualifier, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object[] params = { new Integer(itemId), element, qualifier, schema };
|
||||
tri = DatabaseManager.query(context, getByMetadata, params);
|
||||
}
|
||||
|
||||
if (!tri.hasNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
while (tri.hasNext())
|
||||
{
|
||||
TableRow tr = tri.next();
|
||||
DCValue dcv = new DCValue();
|
||||
dcv.schema = schema;
|
||||
dcv.element = tr.getStringColumn("element");
|
||||
dcv.qualifier = tr.getStringColumn("qualifier");
|
||||
dcv.language = tr.getStringColumn("text_lang");
|
||||
dcv.value = tr.getStringColumn("text_value");
|
||||
values.add(dcv);
|
||||
}
|
||||
|
||||
DCValue[] dcvs = new DCValue[values.size()];
|
||||
return (DCValue[]) values.toArray(dcvs);
|
||||
}
|
||||
}
|
@@ -35,8 +35,6 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -97,6 +95,8 @@ public class BrowserScope
|
||||
/** the browse level */
|
||||
private int level = 0;
|
||||
|
||||
/** the number of authors to display in the results */
|
||||
private int etAl = 0;
|
||||
/**
|
||||
* Construct a new BrowserScope using the given Context
|
||||
*
|
||||
@@ -208,6 +208,22 @@ public class BrowserScope
|
||||
this.browseIndex = browseIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the author limit.
|
||||
*/
|
||||
public int getEtAl()
|
||||
{
|
||||
return etAl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param etAl the author limit
|
||||
*/
|
||||
public void setEtAl(int etAl)
|
||||
{
|
||||
this.etAl = etAl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the collection.
|
||||
*/
|
||||
|
@@ -40,10 +40,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
@@ -360,21 +358,17 @@ public class IndexBrowse
|
||||
removeIndex(item.getID(), BrowseIndex.getItemBrowseIndex().getTableName());
|
||||
removeIndex(item.getID(), BrowseIndex.getWithdrawnBrowseIndex().getTableName());
|
||||
|
||||
// Index any archived item
|
||||
if (item.isArchived())
|
||||
// Index any archived item that isn't withdrawn
|
||||
if (item.isArchived() && !item.isWithdrawn())
|
||||
{
|
||||
// If it's withdrawn, add it to the withdrawn items index
|
||||
if (item.isWithdrawn())
|
||||
{
|
||||
Map<Integer, String> sortMap = getSortValues(item, itemMDMap);
|
||||
dao.insertIndex(BrowseIndex.getWithdrawnBrowseIndex().getTableName(), item.getID(), sortMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, add it to the main item index
|
||||
Map<Integer, String> sortMap = getSortValues(item, itemMDMap);
|
||||
dao.insertIndex(BrowseIndex.getItemBrowseIndex().getTableName(), item.getID(), sortMap);
|
||||
}
|
||||
else if (item.isWithdrawn())
|
||||
{
|
||||
// If it's withdrawn, add it to the withdrawn items index
|
||||
Map<Integer, String> sortMap = getSortValues(item, itemMDMap);
|
||||
dao.insertIndex(BrowseIndex.getWithdrawnBrowseIndex().getTableName(), item.getID(), sortMap);
|
||||
}
|
||||
|
||||
// Now update the metadata indexes
|
||||
@@ -1041,16 +1035,15 @@ public class IndexBrowse
|
||||
}
|
||||
|
||||
// now get the ids of ALL the items in the database
|
||||
BrowseItem bi = new BrowseItem(context, -1);
|
||||
Integer[] ids = bi.findAll();
|
||||
BrowseItemDAO biDao = BrowseDAOFactory.getItemInstance(context);
|
||||
BrowseItem[] items = biDao.findAll();
|
||||
|
||||
// go through every item id, grab the relevant metadata
|
||||
// and write it into the database
|
||||
|
||||
for (int j = 0; j < ids.length; j++)
|
||||
for (int j = 0; j < items.length; j++)
|
||||
{
|
||||
BrowseItem item = new BrowseItem(context, ids[j].intValue());
|
||||
indexItem(new ItemMetadataProxy(ids[j].intValue(), item));
|
||||
indexItem(new ItemMetadataProxy(items[j].getID(), items[j]));
|
||||
|
||||
// after each item we commit the context and clear the cache
|
||||
context.commit();
|
||||
@@ -1074,7 +1067,7 @@ public class IndexBrowse
|
||||
// Make sure the deletes are written back
|
||||
context.commit();
|
||||
|
||||
return ids.length;
|
||||
return items.length;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
@@ -1170,7 +1163,6 @@ public class IndexBrowse
|
||||
|
||||
/**
|
||||
* Is the Item archived?
|
||||
* If we only have a cut down BrowseItem, assume that it is
|
||||
* @return
|
||||
*/
|
||||
public boolean isArchived()
|
||||
@@ -1180,12 +1172,11 @@ public class IndexBrowse
|
||||
return item.isArchived();
|
||||
}
|
||||
|
||||
return true;
|
||||
return browseItem.isArchived();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the Item withdrawn?
|
||||
* If we only have a cut down BrowseItem, assume that it is not
|
||||
* @return
|
||||
*/
|
||||
public boolean isWithdrawn()
|
||||
@@ -1195,7 +1186,7 @@ public class IndexBrowse
|
||||
return item.isWithdrawn();
|
||||
}
|
||||
|
||||
return false;
|
||||
return browseItem.isWithdrawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -531,6 +531,7 @@ jsp.layout.navbar-admin.logout = Log Out
|
||||
jsp.layout.navbar-admin.metadataregistry = Metadata<br/>Registry
|
||||
jsp.layout.navbar-admin.statistics = Statistics
|
||||
jsp.layout.navbar-admin.supervisors = Supervisors
|
||||
jsp.layout.navbar-admin.withdrawn = Withdrawn Items
|
||||
jsp.layout.navbar-admin.workflow = Workflow
|
||||
jsp.layout.navbar-default.about = About DSpace
|
||||
jsp.layout.navbar-default.advanced = Advanced Search
|
||||
|
@@ -0,0 +1,353 @@
|
||||
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.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseEngine;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.browse.BrowseInfo;
|
||||
import org.dspace.browse.BrowserScope;
|
||||
import org.dspace.browse.SortOption;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
|
||||
/**
|
||||
* Servlet for browsing through indices, as they are defined in
|
||||
* the configuration. This class can take a wide variety of inputs from
|
||||
* the user interface:
|
||||
*
|
||||
* - type: the type of browse (index name) being performed
|
||||
* - order: (ASC | DESC) the direction for result sorting
|
||||
* - value: A specific value to find items around. For example the author name or subject
|
||||
* - month: integer specification of the month of a date browse
|
||||
* - year: integer specification of the year of a date browse
|
||||
* - starts_with: string value at which to start browsing
|
||||
* - vfocus: start browsing with a value of this string
|
||||
* - focus: integer id of the item at which to start browsing
|
||||
* - rpp: integer number of results per page to display
|
||||
* - sort_by: integer specification of the field to search on
|
||||
* - etal: integer number to limit multiple value items specified in config to
|
||||
*
|
||||
* @author Richard Jones
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public abstract class AbstractBrowserServlet extends DSpaceServlet
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(AbstractBrowserServlet.class);
|
||||
|
||||
public AbstractBrowserServlet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BrowserScope from the current request
|
||||
*
|
||||
* @param context The database context
|
||||
* @param request The servlet request
|
||||
* @param response The servlet response
|
||||
* @return A BrowserScope for the current parameters
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected BrowserScope getBrowserScopeForRequest(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException, AuthorizeException
|
||||
{
|
||||
try
|
||||
{
|
||||
// first, lift all the stuff out of the request that we might need
|
||||
String type = request.getParameter("type");
|
||||
String order = request.getParameter("order");
|
||||
String value = request.getParameter("value");
|
||||
String valueLang = request.getParameter("value_lang");
|
||||
String month = request.getParameter("month");
|
||||
String year = request.getParameter("year");
|
||||
String startsWith = request.getParameter("starts_with");
|
||||
String valueFocus = request.getParameter("vfocus");
|
||||
String valueFocusLang = request.getParameter("vfocus_lang");
|
||||
int focus = UIUtil.getIntParameter(request, "focus");
|
||||
int resultsperpage = UIUtil.getIntParameter(request, "rpp");
|
||||
int sortBy = UIUtil.getIntParameter(request, "sort_by");
|
||||
int etAl = UIUtil.getIntParameter(request, "etal");
|
||||
|
||||
// get the community or collection location for the browse request
|
||||
// Note that we are only interested in getting the "smallest" container,
|
||||
// so if we find a collection, we don't bother looking up the community
|
||||
Collection collection = null;
|
||||
Community community = null;
|
||||
collection = UIUtil.getCollectionLocation(request);
|
||||
if (collection == null)
|
||||
{
|
||||
community = UIUtil.getCommunityLocation(request);
|
||||
}
|
||||
|
||||
// process the input, performing some inline validation
|
||||
BrowseIndex bi = null;
|
||||
if (type != null && !"".equals(type))
|
||||
{
|
||||
bi = BrowseIndex.getBrowseIndex(type);
|
||||
}
|
||||
|
||||
if (bi == null)
|
||||
{
|
||||
if (sortBy > 0)
|
||||
bi = BrowseIndex.getBrowseIndex(SortOption.getSortOption(sortBy));
|
||||
else
|
||||
bi = BrowseIndex.getBrowseIndex(SortOption.getDefaultSortOption());
|
||||
}
|
||||
|
||||
// If we don't have a sort column
|
||||
if (bi != null && sortBy == -1)
|
||||
{
|
||||
// Get the default one
|
||||
SortOption so = bi.getSortOption();
|
||||
if (so != null)
|
||||
{
|
||||
sortBy = so.getNumber();
|
||||
}
|
||||
}
|
||||
else if (bi != null && bi.isItemIndex() && !bi.isInternalIndex())
|
||||
{
|
||||
// If a default sort option is specified by the index, but it isn't
|
||||
// the same as sort option requested, attempt to find an index that
|
||||
// is configured to use that sort by default
|
||||
// This is so that we can then highlight the correct option in the navigation
|
||||
SortOption bso = bi.getSortOption();
|
||||
SortOption so = SortOption.getSortOption(sortBy);
|
||||
if ( bso != null && bso != so)
|
||||
{
|
||||
BrowseIndex newBi = BrowseIndex.getBrowseIndex(so);
|
||||
if (newBi != null)
|
||||
{
|
||||
bi = newBi;
|
||||
type = bi.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no resultsperpage set, default to 20
|
||||
if (resultsperpage == -1)
|
||||
{
|
||||
resultsperpage = 20;
|
||||
}
|
||||
|
||||
// if no order parameter, default to ascending
|
||||
if (order == null || "".equals(order))
|
||||
{
|
||||
order = "ASC";
|
||||
}
|
||||
|
||||
// if year and perhaps month have been selected, we translate these into "startsWith"
|
||||
// if startsWith has already been defined then it is overwritten
|
||||
if (year != null && !"".equals(year) && !"-1".equals(year))
|
||||
{
|
||||
startsWith = year;
|
||||
if ((month != null) && !"-1".equals(month) && !"".equals(month))
|
||||
{
|
||||
// subtract 1 from the month, so the match works appropriately
|
||||
if ("ASC".equals(order))
|
||||
{
|
||||
month = Integer.toString((Integer.parseInt(month) - 1));
|
||||
}
|
||||
|
||||
// They've selected a month as well
|
||||
if (month.length() == 1)
|
||||
{
|
||||
// Ensure double-digit month number
|
||||
month = "0" + month;
|
||||
}
|
||||
|
||||
startsWith = year + "-" + month;
|
||||
}
|
||||
}
|
||||
|
||||
// determine which level of the browse we are at: 0 for top, 1 for second
|
||||
int level = 0;
|
||||
if (value != null)
|
||||
{
|
||||
level = 1;
|
||||
}
|
||||
|
||||
// if sortBy is still not set, set it to 0, which is default to use the primary index value
|
||||
if (sortBy == -1)
|
||||
{
|
||||
sortBy = 0;
|
||||
}
|
||||
|
||||
// figure out the setting for author list truncation
|
||||
if (etAl == -1) // there is no limit, or the UI says to use the default
|
||||
{
|
||||
int limitLine = ConfigurationManager.getIntProperty("webui.browse.author-limit");
|
||||
if (limitLine != 0)
|
||||
{
|
||||
etAl = limitLine;
|
||||
}
|
||||
}
|
||||
else // if the user has set a limit
|
||||
{
|
||||
if (etAl == 0) // 0 is the user setting for unlimited
|
||||
{
|
||||
etAl = -1; // but -1 is the application setting for unlimited
|
||||
}
|
||||
}
|
||||
|
||||
// log the request
|
||||
String comHandle = "n/a";
|
||||
if (community != null)
|
||||
{
|
||||
comHandle = community.getHandle();
|
||||
}
|
||||
String colHandle = "n/a";
|
||||
if (collection != null)
|
||||
{
|
||||
colHandle = collection.getHandle();
|
||||
}
|
||||
|
||||
String arguments = "type=" + type + ",order=" + order + ",value=" + value +
|
||||
",month=" + month + ",year=" + year + ",starts_with=" + startsWith +
|
||||
",vfocus=" + valueFocus + ",focus=" + focus + ",rpp=" + resultsperpage +
|
||||
",sort_by=" + sortBy + ",community=" + comHandle + ",collection=" + colHandle +
|
||||
",level=" + level + ",etal=" + etAl;
|
||||
|
||||
log.info(LogManager.getHeader(context, "browse", arguments));
|
||||
|
||||
// set up a BrowseScope and start loading the values into it
|
||||
BrowserScope scope = new BrowserScope(context);
|
||||
scope.setBrowseIndex(bi);
|
||||
scope.setOrder(order);
|
||||
scope.setFilterValue(value);
|
||||
scope.setFilterValueLang(valueLang);
|
||||
scope.setJumpToItem(focus);
|
||||
scope.setJumpToValue(valueFocus);
|
||||
scope.setJumpToValueLang(valueFocusLang);
|
||||
scope.setStartsWith(startsWith);
|
||||
scope.setResultsPerPage(resultsperpage);
|
||||
scope.setSortBy(sortBy);
|
||||
scope.setBrowseLevel(level);
|
||||
scope.setEtAl(etAl);
|
||||
|
||||
// assign the scope of either Community or Collection if necessary
|
||||
if (community != null)
|
||||
{
|
||||
scope.setBrowseContainer(community);
|
||||
}
|
||||
else if (collection != null)
|
||||
{
|
||||
scope.setBrowseContainer(collection);
|
||||
}
|
||||
|
||||
return scope;
|
||||
}
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the usual DSpace GET method. You will notice that browse does not currently
|
||||
* respond to POST requests.
|
||||
*/
|
||||
protected void processBrowse(Context context, BrowserScope scope, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
try
|
||||
{
|
||||
BrowseIndex bi = scope.getBrowseIndex();
|
||||
|
||||
// now start up a browse engine and get it to do the work for us
|
||||
BrowseEngine be = new BrowseEngine(context);
|
||||
BrowseInfo binfo = be.browse(scope);
|
||||
|
||||
request.setAttribute("browse.info", binfo);
|
||||
|
||||
if (binfo.hasResults())
|
||||
{
|
||||
if (bi.isMetadataIndex() && !scope.isSecondLevel())
|
||||
{
|
||||
showSinglePage(context, request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
showFullPage(context, request, response);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showNoResultsPage(context, request, response);
|
||||
}
|
||||
}
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the error page
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected abstract void showError(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException;
|
||||
|
||||
/**
|
||||
* Display the No Results page
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected abstract void showNoResultsPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException;
|
||||
|
||||
/**
|
||||
* Display the single page. This is the page which lists just the single values of a
|
||||
* metadata browse, not individual items. Single values are links through to all the items
|
||||
* that match that metadata value
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected abstract void showSinglePage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException;
|
||||
|
||||
protected abstract void showFullPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException;
|
||||
}
|
@@ -48,21 +48,11 @@ 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.browse.BrowseEngine;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.browse.BrowseInfo;
|
||||
import org.dspace.browse.BrowserScope;
|
||||
import org.dspace.browse.SortOption;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
|
||||
/**
|
||||
* Servlet for browsing through indices, as they are defined in
|
||||
@@ -84,231 +74,28 @@ import org.dspace.core.LogManager;
|
||||
* @author Richard Jones
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public class BrowserServlet extends DSpaceServlet
|
||||
public class BrowserServlet extends AbstractBrowserServlet
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(BrowserServlet.class);
|
||||
|
||||
/**
|
||||
* Do the usual DSpace GET method. You will notice that browse does not currently
|
||||
* respond to POST requests.
|
||||
*/
|
||||
protected void doDSGet(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
{
|
||||
try
|
||||
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// all browse requests currently come to GET.
|
||||
BrowserScope scope = getBrowserScopeForRequest(context, request, response);
|
||||
|
||||
// first, lift all the stuff out of the request that we might need
|
||||
String type = request.getParameter("type");
|
||||
String order = request.getParameter("order");
|
||||
String value = request.getParameter("value");
|
||||
String valueLang = request.getParameter("value_lang");
|
||||
String month = request.getParameter("month");
|
||||
String year = request.getParameter("year");
|
||||
String startsWith = request.getParameter("starts_with");
|
||||
String valueFocus = request.getParameter("vfocus");
|
||||
String valueFocusLang = request.getParameter("vfocus_lang");
|
||||
int focus = UIUtil.getIntParameter(request, "focus");
|
||||
int resultsperpage = UIUtil.getIntParameter(request, "rpp");
|
||||
int sortBy = UIUtil.getIntParameter(request, "sort_by");
|
||||
int etAl = UIUtil.getIntParameter(request, "etal");
|
||||
|
||||
// get the community or collection location for the browse request
|
||||
// Note that we are only interested in getting the "smallest" container,
|
||||
// so if we find a collection, we don't bother looking up the community
|
||||
Collection collection = null;
|
||||
Community community = null;
|
||||
collection = UIUtil.getCollectionLocation(request);
|
||||
if (collection == null)
|
||||
if (scope.getBrowseIndex() == null)
|
||||
{
|
||||
community = UIUtil.getCommunityLocation(request);
|
||||
throw new ServletException("There is no browse index for the request");
|
||||
}
|
||||
|
||||
// process the input, performing some inline validation
|
||||
if (type == null || "".equals(type))
|
||||
{
|
||||
showError(context, request, response);
|
||||
// execute browse request
|
||||
processBrowse(context, scope, request, response);
|
||||
}
|
||||
|
||||
BrowseIndex bi = BrowseIndex.getBrowseIndex(type);
|
||||
if (bi == null)
|
||||
{
|
||||
throw new BrowseException("There is no browse index of the type: " + type);
|
||||
}
|
||||
|
||||
// If we don't have a sort column
|
||||
if (sortBy == -1)
|
||||
{
|
||||
// Get the default one
|
||||
SortOption so = bi.getSortOption();
|
||||
if (so != null)
|
||||
{
|
||||
sortBy = so.getNumber();
|
||||
}
|
||||
}
|
||||
else if (bi.isItemIndex() && !bi.isInternalIndex())
|
||||
{
|
||||
// If a default sort option is specified by the index, but it isn't
|
||||
// the same as sort option requested, attempt to find an index that
|
||||
// is configured to use that sort by default
|
||||
// This is so that we can then highlight the correct option in the navigation
|
||||
SortOption bso = bi.getSortOption();
|
||||
SortOption so = SortOption.getSortOption(sortBy);
|
||||
if ( bso != null && bso != so)
|
||||
{
|
||||
BrowseIndex newBi = BrowseIndex.getBrowseIndex(so);
|
||||
if (newBi != null)
|
||||
{
|
||||
bi = newBi;
|
||||
type = bi.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no resultsperpage set, default to 20
|
||||
if (resultsperpage == -1)
|
||||
{
|
||||
resultsperpage = 20;
|
||||
}
|
||||
|
||||
// if no order parameter, default to ascending
|
||||
if (order == null || "".equals(order))
|
||||
{
|
||||
order = "ASC";
|
||||
}
|
||||
|
||||
// if year and perhaps month have been selected, we translate these into "startsWith"
|
||||
// if startsWith has already been defined then it is overwritten
|
||||
if (year != null && !"".equals(year) && !"-1".equals(year))
|
||||
{
|
||||
startsWith = year;
|
||||
if ((month != null) && !"-1".equals(month) && !"".equals(month))
|
||||
{
|
||||
// subtract 1 from the month, so the match works appropriately
|
||||
if ("ASC".equals(order))
|
||||
{
|
||||
month = Integer.toString((Integer.parseInt(month) - 1));
|
||||
}
|
||||
|
||||
// They've selected a month as well
|
||||
if (month.length() == 1)
|
||||
{
|
||||
// Ensure double-digit month number
|
||||
month = "0" + month;
|
||||
}
|
||||
|
||||
startsWith = year + "-" + month;
|
||||
}
|
||||
}
|
||||
|
||||
// determine which level of the browse we are at: 0 for top, 1 for second
|
||||
int level = 0;
|
||||
if (value != null)
|
||||
{
|
||||
level = 1;
|
||||
}
|
||||
|
||||
// if sortBy is still not set, set it to 0, which is default to use the primary index value
|
||||
if (sortBy == -1)
|
||||
{
|
||||
sortBy = 0;
|
||||
}
|
||||
|
||||
// figure out the setting for author list truncation
|
||||
if (etAl == -1) // there is no limit, or the UI says to use the default
|
||||
{
|
||||
int limitLine = ConfigurationManager.getIntProperty("webui.browse.author-limit");
|
||||
if (limitLine != 0)
|
||||
{
|
||||
etAl = limitLine;
|
||||
}
|
||||
}
|
||||
else // if the user has set a limit
|
||||
{
|
||||
if (etAl == 0) // 0 is the user setting for unlimited
|
||||
{
|
||||
etAl = -1; // but -1 is the application setting for unlimited
|
||||
}
|
||||
}
|
||||
|
||||
// log the request
|
||||
String comHandle = "n/a";
|
||||
if (community != null)
|
||||
{
|
||||
comHandle = community.getHandle();
|
||||
}
|
||||
String colHandle = "n/a";
|
||||
if (collection != null)
|
||||
{
|
||||
colHandle = collection.getHandle();
|
||||
}
|
||||
|
||||
String arguments = "type=" + type + ",order=" + order + ",value=" + value +
|
||||
",month=" + month + ",year=" + year + ",starts_with=" + startsWith +
|
||||
",vfocus=" + valueFocus + ",focus=" + focus + ",rpp=" + resultsperpage +
|
||||
",sort_by=" + sortBy + ",community=" + comHandle + ",collection=" + colHandle +
|
||||
",level=" + level + ",etal=" + etAl;
|
||||
|
||||
log.info(LogManager.getHeader(context, "browse", arguments));
|
||||
|
||||
// set up a BrowseScope and start loading the values into it
|
||||
BrowserScope scope = new BrowserScope(context);
|
||||
scope.setBrowseIndex(bi);
|
||||
scope.setOrder(order);
|
||||
scope.setFilterValue(value);
|
||||
scope.setFilterValueLang(valueLang);
|
||||
scope.setJumpToItem(focus);
|
||||
scope.setJumpToValue(valueFocus);
|
||||
scope.setJumpToValueLang(valueFocusLang);
|
||||
scope.setStartsWith(startsWith);
|
||||
scope.setResultsPerPage(resultsperpage);
|
||||
scope.setSortBy(sortBy);
|
||||
scope.setBrowseLevel(level);
|
||||
|
||||
// assign the scope of either Community or Collection if necessary
|
||||
if (community != null)
|
||||
{
|
||||
scope.setBrowseContainer(community);
|
||||
}
|
||||
else if (collection != null)
|
||||
{
|
||||
scope.setBrowseContainer(collection);
|
||||
}
|
||||
|
||||
// now start up a browse engine and get it to do the work for us
|
||||
BrowseEngine be = new BrowseEngine(context);
|
||||
BrowseInfo binfo = be.browse(scope);
|
||||
|
||||
// add the etAl limit to the BrowseInfo object
|
||||
binfo.setEtAl(etAl);
|
||||
|
||||
request.setAttribute("browse.info", binfo);
|
||||
|
||||
if (binfo.hasResults())
|
||||
{
|
||||
if (bi.isMetadataIndex() && !scope.isSecondLevel())
|
||||
{
|
||||
showSinglePage(context, request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
showFullPage(context, request, response);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showNoResultsPage(context, request, response);
|
||||
}
|
||||
}
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error("caught exception: ", e);
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the error page
|
||||
@@ -321,9 +108,9 @@ public class BrowserServlet extends DSpaceServlet
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showError(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
protected void showError(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
JSPManager.showJSP(request, response, "/browse/error.jsp");
|
||||
}
|
||||
@@ -339,9 +126,9 @@ public class BrowserServlet extends DSpaceServlet
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showNoResultsPage(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
protected void showNoResultsPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/no-results.jsp");
|
||||
@@ -360,9 +147,9 @@ public class BrowserServlet extends DSpaceServlet
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showSinglePage(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
protected void showSinglePage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/single.jsp");
|
||||
@@ -379,9 +166,9 @@ public class BrowserServlet extends DSpaceServlet
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showFullPage(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response) throws ServletException, IOException,
|
||||
SQLException, AuthorizeException
|
||||
protected void showFullPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/full.jsp");
|
||||
|
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* BrowserServlet.java
|
||||
*
|
||||
* Version: $Revision: $
|
||||
*
|
||||
* Date: $Date: $
|
||||
*
|
||||
* Copyright (c) 2002-2007, 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.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.browse.BrowserScope;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
import org.dspace.app.webui.servlet.AbstractBrowserServlet;
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
|
||||
/**
|
||||
* Servlet for browsing through withdrawn items:
|
||||
*
|
||||
* @author Graham Triggs
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public class WithdrawnBrowserServlet extends AbstractBrowserServlet
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(WithdrawnBrowserServlet.class);
|
||||
|
||||
/**
|
||||
* Do the usual DSpace GET method. You will notice that browse does not currently
|
||||
* respond to POST requests.
|
||||
*/
|
||||
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
try
|
||||
{
|
||||
// all browse requests currently come to GET.
|
||||
BrowserScope scope = getBrowserScopeForRequest(context, request, response);
|
||||
|
||||
// Check that we are doing an item browse
|
||||
if (scope.getBrowseIndex() == null || scope.getBrowseIndex().isItemIndex())
|
||||
{
|
||||
// And override the index in the scope with the withdrawn items
|
||||
scope.setBrowseIndex(BrowseIndex.getWithdrawnBrowseIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
showError(context, request, response);
|
||||
}
|
||||
|
||||
// execute browse request
|
||||
processBrowse(context, scope, request, response);
|
||||
}
|
||||
catch (BrowseException be)
|
||||
{
|
||||
log.error("caught exception: ", be);
|
||||
throw new ServletException(be);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the error page
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showError(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
request.setAttribute("useAdminLayout", "yes");
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/error.jsp");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the No Results page
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showNoResultsPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
request.setAttribute("browseWithdrawn", "yes");
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/no-results.jsp");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the single page. This is the page which lists just the single values of a
|
||||
* metadata browse, not individual items. Single values are links through to all the items
|
||||
* that match that metadata value
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showSinglePage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// Show an error as this currently isn't supported
|
||||
showError(context, request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a full item listing.
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
protected void showFullPage(Context context, HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
request.setAttribute("browseWithdrawn", "yes");
|
||||
|
||||
JSPManager.showJSP(request, response, "/browse/full.jsp");
|
||||
}
|
||||
}
|
@@ -159,6 +159,11 @@
|
||||
<servlet-class>org.dspace.app.webui.servlet.BrowserServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>browsewithdrawn</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.admin.WithdrawnBrowserServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>collection-wizard</servlet-name>
|
||||
<servlet-class>org.dspace.app.webui.servlet.admin.CollectionWizardServlet</servlet-class>
|
||||
@@ -398,6 +403,11 @@
|
||||
<url-pattern>/browse</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>browsewithdrawn</servlet-name>
|
||||
<url-pattern>/dspace-admin/withdrawn</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>community-list</servlet-name>
|
||||
<url-pattern>/community-list</url-pattern>
|
||||
|
@@ -62,6 +62,14 @@
|
||||
<%@ page import="org.dspace.app.webui.util.UIUtil" %>
|
||||
|
||||
<%
|
||||
String urlFragment = "browse";
|
||||
String layoutNavbar = "default";
|
||||
if (request.getAttribute("browseWithdrawn") != null)
|
||||
{
|
||||
layoutNavbar = "admin";
|
||||
urlFragment = "dspace-admin/withdrawn";
|
||||
}
|
||||
|
||||
// First, get the browse info object
|
||||
BrowseInfo bi = (BrowseInfo) request.getAttribute("browse.info");
|
||||
BrowseIndex bix = bi.getBrowseIndex();
|
||||
@@ -119,8 +127,13 @@
|
||||
{
|
||||
valueString = "&value=" + URLEncoder.encode(bi.getValue());
|
||||
}
|
||||
String sharedLink = linkBase + "browse?type=" + URLEncoder.encode(bix.getName()) +
|
||||
"&sort_by=" + URLEncoder.encode(Integer.toString(so.getNumber())) +
|
||||
|
||||
String sharedLink = linkBase + urlFragment + "?";
|
||||
|
||||
if (bix.getName() != null)
|
||||
sharedLink += "type=" + URLEncoder.encode(bix.getName());
|
||||
|
||||
sharedLink += "&sort_by=" + URLEncoder.encode(Integer.toString(so.getNumber())) +
|
||||
"&order=" + URLEncoder.encode(direction) +
|
||||
"&rpp=" + URLEncoder.encode(Integer.toString(bi.getResultsPerPage())) +
|
||||
"&etal=" + URLEncoder.encode(Integer.toString(bi.getEtAl())) +
|
||||
@@ -165,7 +178,7 @@
|
||||
{
|
||||
formaction = formaction + "handle/" + community.getHandle() + "/";
|
||||
}
|
||||
formaction = formaction + "browse";
|
||||
formaction = formaction + urlFragment;
|
||||
|
||||
// prepare the known information about sorting, ordering and results per page
|
||||
String sortedBy = so.getName();
|
||||
@@ -187,7 +200,7 @@
|
||||
<%-- OK, so here we start to develop the various components we will use in the UI --%>
|
||||
|
||||
<%@page import="java.util.Set"%>
|
||||
<dspace:layout titlekey="browse.page-title">
|
||||
<dspace:layout titlekey="browse.page-title" navbar="<%=layoutNavbar %>">
|
||||
|
||||
<%-- Build the header (careful use of spacing) --%>
|
||||
<h2>
|
||||
|
@@ -59,6 +59,12 @@
|
||||
<%@ page import="org.dspace.content.Collection" %>
|
||||
|
||||
<%
|
||||
String layoutNavbar = "default";
|
||||
if (request.getAttribute("browseWithdrawn") != null)
|
||||
{
|
||||
layoutNavbar = "admin";
|
||||
}
|
||||
|
||||
// get the BrowseInfo object
|
||||
BrowseInfo bi = (BrowseInfo) request.getAttribute("browse.info");
|
||||
|
||||
@@ -93,7 +99,7 @@
|
||||
}
|
||||
%>
|
||||
|
||||
<dspace:layout titlekey="browse.no-results.title">
|
||||
<dspace:layout titlekey="browse.no-results.title" navbar="<%= layoutNavbar %>">
|
||||
|
||||
<h1><fmt:message key="browse.no-results.title"/></h1>
|
||||
|
||||
|
@@ -49,6 +49,8 @@
|
||||
|
||||
<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
|
||||
|
||||
<%@ page import="org.dspace.browse.BrowseInfo" %>
|
||||
<%@ page import="org.dspace.browse.SortOption" %>
|
||||
<%@ page import="org.dspace.app.webui.util.UIUtil" %>
|
||||
|
||||
|
||||
@@ -180,6 +182,23 @@
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
|
||||
<%
|
||||
// get the browse indices
|
||||
BrowseInfo binfo = (BrowseInfo) request.getAttribute("browse.info");
|
||||
%>
|
||||
<tr class="navigationBarItem">
|
||||
<td>
|
||||
<img alt="" src="<%= request.getContextPath() %>/image/<%= ( binfo != null ? "arrow-highlight" : "arrow" ) %>.gif" width="16" height="16"/>
|
||||
</td>
|
||||
<td nowrap="nowrap" class="navigationBarItem">
|
||||
<a href="<%= request.getContextPath() %>/dspace-admin/withdrawn"><fmt:message key="jsp.layout.navbar-admin.withdrawn"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
|
||||
<tr class="navigationBarItem">
|
||||
<td>
|
||||
<img alt="" src="<%= request.getContextPath() %>/image/arrow.gif" width="16" height="16"/>
|
||||
|
@@ -98,8 +98,11 @@
|
||||
// Only highlight the current browse, only if it is a metadata index,
|
||||
// or the selected sort option is the default for the index
|
||||
if (bix.isMetadataIndex() || bix.getSortOption() == binfo.getSortOption())
|
||||
{
|
||||
if (bix.getName() != null)
|
||||
browseCurrent = bix.getName();
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
<%-- Search Box --%>
|
||||
|
Reference in New Issue
Block a user