Only in ./app/mediafilter: MediaFilterManager.java.orig
Only in ./app/mediafilter: MediaFilterManager.java.patch
Only in ./app/mediafilter: MediaFilterManager.java.rej
Only in ./app/mediafilter: PDFFilter.java.orig
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/CollectionListTag.java ./app/webui/jsptag/CollectionListTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/CollectionListTag.java 2002-11-01 15:59:10.000000000 -0200
+++ ./app/webui/jsptag/CollectionListTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -51,6 +51,9 @@
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+
import org.dspace.content.Collection;
/**
@@ -69,7 +72,7 @@
{
super();
}
-
+
public int doStartTag()
throws JspException
@@ -82,7 +85,7 @@
// Write column headings
out.print("
| " +
- "Collection Name" +
+ LocaleSupport.getLocalizedMessage(pageContext,"CollectionListTag.ColName") +
" |
");
// Row: toggles between Odd and Even
@@ -92,7 +95,7 @@
{
// name
String name = collections[i].getMetadata("name");
-
+
// first and only column is 'name'
out.print("");
out.print("");
out.print(name);
out.print("");
-
+
out.println(" | ");
row = (row.equals("odd") ? "even" : "odd");
}
-
+
out.println("");
}
catch (IOException ie)
@@ -117,7 +120,7 @@
}
return SKIP_BODY;
- }
+ }
/**
@@ -129,11 +132,11 @@
{
return collections;
}
-
+
/**
* Set the collections to list
- *
+ *
* @param collectionsIn the collections
*/
public void setCollections(Collection[] collectionsIn)
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/CommunityListTag.java ./app/webui/jsptag/CommunityListTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/CommunityListTag.java 2002-11-01 15:59:10.000000000 -0200
+++ ./app/webui/jsptag/CommunityListTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -51,6 +51,9 @@
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+
import org.dspace.content.Community;
/**
@@ -63,13 +66,13 @@
{
/** Communities to display */
private Community[] communities;
-
+
public CommunityListTag()
{
super();
}
-
+
public int doStartTag()
throws JspException
@@ -82,7 +85,7 @@
// Write column headings
out.print("| " +
- "Community Name" +
+ LocaleSupport.getLocalizedMessage(pageContext,"CommunityListTag.ComName") +
" |
");
// Row: toggles between Odd and Even
@@ -92,7 +95,7 @@
{
// name
String name = communities[i].getMetadata("name");
-
+
// first and only column is 'name'
out.print("");
out.print("");
out.print(name);
out.print("");
-
+
out.println(" | ");
row = (row.equals("odd") ? "even" : "odd");
}
-
+
out.println("");
}
catch (IOException ie)
@@ -117,7 +120,7 @@
}
return SKIP_BODY;
- }
+ }
/**
@@ -129,11 +132,11 @@
{
return communities;
}
-
+
/**
* Set the communities to list
- *
+ *
* @param communitiesIn the communities
*/
public void setCommunities(Community[] communitiesIn)
@@ -141,7 +144,7 @@
communities = communitiesIn;
}
-
+
public void release()
{
communities = null;
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/DateTag.java ./app/webui/jsptag/DateTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/DateTag.java 2002-11-01 15:59:10.000000000 -0200
+++ ./app/webui/jsptag/DateTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -46,6 +46,10 @@
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+import java.util.Locale;
+
import org.dspace.app.webui.util.UIUtil;
import org.dspace.content.DCDate;
@@ -77,7 +81,7 @@
return date;
}
-
+
/**
* Set the date
*
@@ -115,8 +119,12 @@
public int doStartTag()
throws JspException
{
- String toDisplay = UIUtil.displayDate(date, displayTime, true);
-
+ LocalizationContext locCtxt = null;
+ locCtxt = BundleSupport.getLocalizationContext(pageContext);
+ Locale loc = locCtxt.getLocale();
+
+ String toDisplay = UIUtil.displayDate(date, displayTime, true, loc);
+
try
{
pageContext.getOut().print(toDisplay);
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/ItemListTag.java ./app/webui/jsptag/ItemListTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/ItemListTag.java 2004-03-22 23:53:52.000000000 -0200
+++ ./app/webui/jsptag/ItemListTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -45,12 +45,17 @@
import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
+import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+
+
import org.dspace.app.webui.util.UIUtil;
import org.dspace.content.DCDate;
import org.dspace.content.DCValue;
@@ -67,28 +72,28 @@
{
/** Items to display */
private Item[] items;
-
+
/** Row to highlight, -1 for no row */
private int highlightRow = -1;
-
+
/** Column to emphasise - null, "title" or "date" */
private String emphColumn;
-
+
public ItemListTag()
{
super();
}
-
+
public int doStartTag()
throws JspException
{
JspWriter out = pageContext.getOut();
-
+
boolean emphasiseDate = false;
boolean emphasiseTitle = false;
-
+
if (emphColumn != null)
{
emphasiseDate = emphColumn.equalsIgnoreCase("date");
@@ -102,15 +107,20 @@
// Write column headings
out.print("| " +
(emphasiseDate ? "" : "") +
- "Date of Issue" +
+ //"Date of Issue" +
+ LocaleSupport.getLocalizedMessage(pageContext,"ItemListTag.Date") +
(emphasiseDate ? "" : "") + " | ");
out.println("" +
(emphasiseTitle ? "" : "") +
- "Title" +
+ //"Title" +
+ LocaleSupport.getLocalizedMessage(pageContext,"ItemListTag.Title") +
(emphasiseTitle ? "" : "") + " | ");
- out.println("Authors |
");
+ //out.println("Authors | ");
+ out.println("" +
+ LocaleSupport.getLocalizedMessage(pageContext,"ItemListTag.Author") +
+ " | ");
// Row: toggles between Odd and Even
String row = "even";
@@ -139,34 +149,38 @@
{
dd = new DCDate(dateIssued[0].value);
}
-
+
// First column is date
out.print("| ");
-
+
if (emphasiseDate)
{
out.print("");
}
-
- out.print(UIUtil.displayDate(dd, false, false));
-
+
+ LocalizationContext locCtxt = null;
+ locCtxt = BundleSupport.getLocalizationContext(pageContext);
+ Locale loc = locCtxt.getLocale();
+
+ out.print(UIUtil.displayDate(dd, false, false, loc));
+
if (emphasiseDate)
{
out.print("");
}
-
+
// Second column is title
out.print(" | ");
-
+
if (emphasiseTitle)
{
out.print("");
}
-
+
out.print("");
out.print(Utils.addEntities(title));
out.print("");
-
+
if (emphasiseTitle)
{
out.print("");
}
-
+
// Third column is authors
out.print(" | " + Utils.addEntities(authors[j].value) + "");
-
+
if (j < authors.length - 1)
{
out.print("; ");
}
}
-
+
out.println(" |
");
row = (row.equals("odd") ? "even" : "odd");
}
-
+
out.println("");
}
catch (IOException ie)
@@ -210,7 +224,7 @@
}
return SKIP_BODY;
- }
+ }
/**
@@ -222,11 +236,11 @@
{
return items;
}
-
+
/**
* Set the items to list
- *
+ *
* @param itemsIn the items
*/
public void setItems(Item[] itemsIn)
@@ -244,11 +258,11 @@
{
return String.valueOf(highlightRow);
}
-
+
/**
* Set the row to highlight
- *
+ *
* @param highlightRowIn the row to highlight or -1 for no highlight
*/
public void setHighlightrow(String highlightRowIn)
@@ -280,11 +294,11 @@
{
return emphColumn;
}
-
+
/**
* Set the column to emphasise - "title", "date" or null
- *
+ *
* @param emphcolumnIn column to emphasise
*/
public void setEmphcolumn(String emphColumnIn)
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/ItemTag.java ./app/webui/jsptag/ItemTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/ItemTag.java 2004-08-10 16:18:22.000000000 -0200
+++ ./app/webui/jsptag/ItemTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -1,551 +1,615 @@
-/*
- * ItemTag.java
- *
- * Version: $Revision: 1.20 $
- *
- * Date: $Date: 2004/08/10 19:18:22 $
- *
- * Copyright (c) 2002, 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 java.net.URLEncoder;
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-import javax.servlet.jsp.tagext.TagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.http.HttpServletRequest;
-
-import org.dspace.app.webui.util.UIUtil;
-import org.dspace.content.Bitstream;
-import org.dspace.content.Bundle;
-import org.dspace.content.Collection;
-import org.dspace.content.DCDate;
-import org.dspace.content.DCValue;
-import org.dspace.content.Item;
-import org.dspace.core.Utils;
-
-/**
- * Tag for displaying an item
- *
- * @author Robert Tansley
- * @version $Revision: 1.20 $
- */
-public class ItemTag extends TagSupport
-{
- /** Item to display */
- private Item item;
-
- /** Collections this item appears in */
- private Collection[] collections;
-
- /** The style to use - "default" or "full" */
- private String style;
-
-
- public ItemTag()
- {
- super();
- }
-
-
- public int doStartTag()
- throws JspException
- {
- try
- {
- if (style != null && style.equals("full"))
- {
- renderFull();
- }
- else
- {
- renderDefault();
- }
- }
- catch (java.sql.SQLException e)
- {
- throw new JspException(e);
- }
- catch (IOException ie)
- {
- throw new JspException(ie);
- }
-
- return SKIP_BODY;
- }
-
-
- /**
- * Get the item this tag should display
- *
- * @return the item
- */
- public Item getItem()
- {
- return item;
- }
-
-
- /**
- * Set the item this tag should display
- *
- * @param itemIn the item to display
- */
- public void setItem(Item itemIn)
- {
- item = itemIn;
- }
-
-
- /**
- * Get the collections this item is in
- *
- * @return the collections
- */
- public Collection[] getCollections()
- {
- return collections;
- }
-
-
- /**
- * Set the collections this item is in
- *
- * @param collectionsIn the collections
- */
- public void setCollections(Collection[] collectionsIn)
- {
- collections = collectionsIn;
- }
-
-
- /**
- * Get the style this tag should display
- *
- * @return the style
- */
- public String getStyle()
- {
- return style;
- }
-
-
- /**
- * Set the style this tag should display
- *
- * @param styleIn the Style to display
- */
- public void setStyle(String styleIn)
- {
- style = styleIn;
- }
-
-
- public void release()
- {
- style = "default";
- item = null;
- collections = null;
- }
-
-
- /**
- * Render an item in the default style
- */
- private void renderDefault()
- throws IOException, java.sql.SQLException
- {
- JspWriter out = pageContext.getOut();
-
- // Build up a list of things to display.
- // To display a DC field from the item, do
- // fields.add(new String[] {"Display Name", "element", "qualifier"});
- // (or "qualifier" as null for unqualified)
- // to display an actual value without getting it from the item, do
- // fields.add(new String[] {"Display Name", "The value to display")
- List fields = new LinkedList();
-
- // Title - special case, if there is no title, use "Untitled"
- DCValue[] titleDC = item.getDC("title", null, Item.ANY);
- if (titleDC.length == 0)
- {
- fields.add(new String[] {"Title", "Untitled"});
- }
- else
- {
- fields.add(new String[] {"Title", "title", null});
- }
-
- fields.add(new String[] {"Other Titles", "title", "alternative"});
- fields.add(new String[] {"Authors", "contributor", Item.ANY});
- fields.add(new String[] {"Keywords", "subject", null});
-
- // Date issued
- DCValue[] dateIssued = item.getDC("date",
- "issued",
- Item.ANY);
- DCDate dd = null;
- if(dateIssued.length > 0)
- {
- dd = new DCDate(dateIssued[0].value);
- }
- String displayDate = UIUtil.displayDate(dd, false, false);
-
- fields.add(new String[] {"Issue Date", displayDate});
-
- fields.add(new String[] {"Publisher", "publisher", null});
- fields.add(new String[] {"Citation", "identifier", "citation"});
- fields.add(new String[] {"Series/Report no.", "relation", "ispartofseries"});
-
- // Truncate abstract
- DCValue[] abstrDC = item.getDC("description", "abstract", Item.ANY);
- if (abstrDC.length > 0)
- {
- String abstr = abstrDC[0].value;
- if (abstr.length() > 1000)
- {
- abstr = abstr.substring(0, 1000) + "...";
- }
-
- fields.add(new String[] {"Abstract", abstr});
- }
-
- fields.add(new String[] {"Description", "description", null});
- fields.add(new String[] {"Gov't Doc # ", "identifier", "govdoc"});
- fields.add(new String[] {"URI", "identifier", "uri"});
- fields.add(new String[] {"ISBN", "identifier", "isbn"});
- fields.add(new String[] {"ISSN", "identifier", "issn"});
- fields.add(new String[] {"ISMN", "identifier", "ismn"});
- fields.add(new String[] {"Other Identifiers", "identifier", null});
-
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
-
- out.println("");
-
- Iterator fieldIterator = fields.iterator();
- while (fieldIterator.hasNext())
- {
- String[] fieldData = (String[]) fieldIterator.next();
- DCValue[] values;
-
- if (fieldData.length == 2)
- {
- // Value direct from field data
- DCValue v = new DCValue();
- v.value = fieldData[1];
- values = new DCValue[1];
- values[0] = v;
- }
- else
- {
- // Grab the value from the item
- values = item.getDC(fieldData[1], fieldData[2], Item.ANY);
- }
-
- // Only display the field if we have an actual value
- if (values.length > 0)
- {
- out.print("| ");
- out.print(fieldData[0]);
- out.print(": | ");
- out.print(Utils.addEntities(values[0].value));
-
- for (int j = 1; j < values.length; j++)
- {
- out.print(" ");
- out.print(Utils.addEntities(values[j].value));
- }
- out.println(" |
");
- }
- }
-
- listCollections();
-
- out.println("
");
-
- listBitstreams();
- }
-
-
- /**
- * Render full item record
- */
- private void renderFull()
- throws IOException, java.sql.SQLException
- {
- JspWriter out = pageContext.getOut();
-
- // Get all the metadata
- DCValue[] values = item.getDC(Item.ANY, Item.ANY, Item.ANY);
-
- out.println("Full metadata record
");
-
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
-
- // Three column table - DC field, value, language
- out.println("");
- out.println("| DC Field | Value | Language |
");
-
- for (int i = 0; i < values.length; i++)
- {
- boolean hidden = false;
-
- // Mask description.provenance
- if (values[i].element.equals("description") &&
- (values[i].qualifier != null &&
- values[i].qualifier.equals("provenance")))
- {
- hidden = true;
- }
-
- if (!hidden)
- {
- out.print("| ");
- out.print(values[i].element);
- if (values[i].qualifier != null)
- {
- out.print("." + values[i].qualifier);
- }
- out.print(" | ");
- out.print(Utils.addEntities(values[i].value));
- out.print(" | ");
-
- if (values[i].language == null)
- {
- out.print("-");
- }
- else
- {
- out.print(values[i].language);
- }
-
- out.println(" |
");
- }
- }
-
- listCollections();
-
- out.println("
");
-
- listBitstreams();
- }
-
-
- /**
- * List links to collections if information is available
- */
- private void listCollections()
- throws IOException
- {
- JspWriter out = pageContext.getOut();
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
-
- if (collections != null)
- {
- out.print("| " +
- "Appears in Collections: | ");
-
- for (int i = 0; i < collections.length; i++)
- {
- out.print("");
- out.print(collections[i].getMetadata("name"));
- out.print(" ");
- }
-
- out.println(" |
");
- }
- }
-
-
- /**
- * List bitstreams in the item
- */
- private void listBitstreams()
- throws IOException
- {
- JspWriter out = pageContext.getOut();
- HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
-
- out.print("");
- out.println("Files in This Item: ");
-
- Bundle[] bundles = item.getBundles("ORIGINAL");
-
- if (bundles.length == 0)
- {
- out.println("There are no files associated with this item. ");
- }
- else
- {
- boolean html = false;
- String handle = item.getHandle();
- Bitstream primaryBitstream = null;
-
- Bundle[] bunds = item.getBundles("ORIGINAL");
- // if item contains multiple bitstreams, display bitstream description
- boolean multiFile = bunds[0].getBitstreams().length > 1;
- Bundle[] thumbs= item.getBundles("THUMBNAIL");
-
- // check if primary bitstream is html
- if (bunds[0] != null)
- {
- Bitstream[] bits = bunds[0].getBitstreams();
- for (int i = 0; i < bits.length && !html; i++)
- {
- if (bits[i].getID() == bunds[0].getPrimaryBitstreamID())
- {
- html = bits[i].getFormat().getMIMEType().equals("text/html");
- primaryBitstream = bits[i];
- }
- }
- }
-
- out.println("");
- }
-
- out.println(" |
");
- }
-}
-
+/*
+ * ItemTag.java
+ *
+ * Version: $Revision: 1.20 $
+ *
+ * Date: $Date: 2004/08/10 19:18:22 $
+ *
+ * Copyright (c) 2002, 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 java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Vector;
+import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.http.HttpServletRequest;
+
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.dspace.app.webui.util.UIUtil;
+import org.dspace.content.Bitstream;
+import org.dspace.content.Bundle;
+import org.dspace.content.Collection;
+import org.dspace.content.DCDate;
+import org.dspace.content.DCValue;
+import org.dspace.content.Item;
+import org.dspace.core.Utils;
+
+/**
+ * Tag for displaying an item
+ *
+ * @author Robert Tansley
+ * @version $Revision: 1.20 $
+ */
+public class ItemTag extends TagSupport
+{
+ /** Item to display */
+ private Item item;
+
+ /** Collections this item appears in */
+ private Collection[] collections;
+
+ /** The style to use - "default" or "full" */
+ private String style;
+
+
+ /** The language to display metadata in (only for the "default" style) - default lang = Item.ANY */
+ private String lang;
+
+ private Locale loc;
+
+ private ResourceBundle res;
+
+
+
+ public ItemTag()
+ {
+ super();
+ }
+
+
+ public int doStartTag()
+ throws JspException
+ {
+ try
+ {
+ //get current locale first and bundle
+ LocalizationContext locCtxt = null;
+ locCtxt = BundleSupport.getLocalizationContext(pageContext);
+ loc = locCtxt.getLocale();
+ res = ResourceBundle.getBundle("Messages",loc);
+
+
+ if (style != null && style.equals("full"))
+ {
+ renderFull();
+ }
+ else
+ {
+ renderDefault();
+ }
+ }
+ catch (java.sql.SQLException e)
+ {
+ throw new JspException(e);
+ }
+ catch (IOException ie)
+ {
+ throw new JspException(ie);
+ }
+
+ return SKIP_BODY;
+ }
+
+
+ /**
+ * Get the item this tag should display
+ *
+ * @return the item
+ */
+ public Item getItem()
+ {
+ return item;
+ }
+
+
+ /**
+ * Set the item this tag should display
+ *
+ * @param itemIn the item to display
+ */
+ public void setItem(Item itemIn)
+ {
+ item = itemIn;
+ }
+
+
+ /**
+ * Get the collections this item is in
+ *
+ * @return the collections
+ */
+ public Collection[] getCollections()
+ {
+ return collections;
+ }
+
+
+ /**
+ * Set the collections this item is in
+ *
+ * @param collectionsIn the collections
+ */
+ public void setCollections(Collection[] collectionsIn)
+ {
+ collections = collectionsIn;
+ }
+
+
+ /**
+ * Get the style this tag should display
+ *
+ * @return the style
+ */
+ public String getStyle()
+ {
+ return style;
+ }
+
+
+ /**
+ * Set the style this tag should display
+ *
+ * @param styleIn the Style to display
+ */
+ public void setStyle(String styleIn)
+ {
+ style = styleIn;
+ }
+
+
+
+ public String getLang()
+ {
+ return lang;
+ }
+
+
+ public void setLang(String langIn)
+ {
+ lang = langIn;
+ }
+
+
+ public void release()
+ {
+ style = "default";
+ item = null;
+ collections = null;
+ lang = null;
+ }
+
+
+ /**
+ * Render an item in the default style
+ */
+ private void renderDefault()
+ throws IOException, java.sql.SQLException
+ {
+ JspWriter out = pageContext.getOut();
+
+ if (lang==null || lang.equals("")) lang = Item.ANY;
+
+ Locale dateLoc = (lang.equals(Item.ANY) ? loc : new Locale (lang));
+
+ // Build up a list of things to display.
+ // To display a DC field from the item, do
+ // fields.add(new String[] {"Display Name", "element", "qualifier"});
+ // (or "qualifier" as null for unqualified)
+ // to display an actual value without getting it from the item, do
+ // fields.add(new String[] {"Display Name", "The value to display")
+ List fields = new LinkedList();
+
+ // Title - special case, if there is no title, use "Untitled"
+ DCValue[] titleDC = item.getDC("title", null, Item.ANY);
+ if (titleDC.length == 0)
+ {
+ fields.add(new String[] {res.getString("ItemTag.title"), res.getString("ItemTag.untitled")});
+ }
+ else if (titleDC.length ==1)
+ {
+ fields.add(new String[] {res.getString("ItemTag.title"), titleDC[0].value}); //display title irrelevant of lang selected
+ }
+ else
+ {
+
+ fields.add(new String[] {res.getString("ItemTag.title"), "title", null});
+
+ }
+
+ fields.add(new String[] {res.getString("ItemTag.otherTitles"), "title", "alternative"});
+ fields.add(new String[] {res.getString("ItemTag.authors"), "contributor", Item.ANY});
+ fields.add(new String[] {res.getString("ItemTag.keywords"), "subject", null});
+
+ // Date issued
+ DCValue[] dateIssued = item.getDC("date",
+ "issued",
+ Item.ANY);
+ DCDate dd = null;
+ if(dateIssued.length > 0)
+ {
+ dd = new DCDate(dateIssued[0].value);
+ }
+
+ String displayDate = UIUtil.displayDate(dd, false, false, dateLoc );
+
+ fields.add(new String[] {res.getString("ItemTag.date"), displayDate});
+
+ fields.add(new String[] {res.getString("ItemTag.publisher"), "publisher", null});
+ fields.add(new String[] {res.getString("ItemTag.citation"), "identifier", "citation"});
+ fields.add(new String[] {res.getString("ItemTag.seriesno"), "relation", "ispartofseries"});
+
+ // Truncate abstract
+ DCValue[] abstrDC = item.getDC("description", "abstract", lang);
+ if (abstrDC.length > 0)
+ {
+ String abstr = abstrDC[0].value;
+ if (abstr.length() > 1000)
+ {
+ abstr = abstr.substring(0, 1000) + "...";
+ }
+
+ fields.add(new String[] {res.getString("ItemTag.abstract"), abstr});
+ }
+
+ fields.add(new String[] {res.getString("ItemTag.description"), "description", null});
+ fields.add(new String[] {res.getString("ItemTag.govdoc"), "identifier", "govdoc"});
+ fields.add(new String[] {"URI", "identifier", "uri"});
+ fields.add(new String[] {"ISBN", "identifier", "isbn"});
+ fields.add(new String[] {"ISSN", "identifier", "issn"});
+ fields.add(new String[] {"ISMN", "identifier", "ismn"});
+ fields.add(new String[] {res.getString("ItemTag.otherIdentifiers"), "identifier", null});
+
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
+ out.println("");
+
+ Iterator fieldIterator = fields.iterator();
+ while (fieldIterator.hasNext())
+ {
+ String[] fieldData = (String[]) fieldIterator.next();
+ DCValue[] values1; //lang-specific values
+ DCValue[] values2; //unspecified lang values
+ Vector allValues = new Vector();
+
+ if (fieldData.length == 2)
+ {
+ // Value direct from field data
+ DCValue v = new DCValue();
+ v.value = fieldData[1];
+ allValues.add (v);
+ }
+ else
+ {
+ // Grab the value from the item
+ // Create a vector including unspecified language metadata (lang=null)
+ values1 = item.getDC(fieldData[1], fieldData[2], lang);
+ for (int l=0; l < values1.length; l++) {
+ allValues.add (values1[l]);
+ }
+
+ if (!lang.equals(Item.ANY)) {
+ values2 = item.getDC(fieldData[1], fieldData[2], null);
+ for (int l=0; l < values2.length; l++) {
+ allValues.add (values2[l]);
+ }
+ }
+ else
+ {
+ values2 = null;
+ }
+
+ }
+
+ // Only display the field if we have an actual value
+ if (allValues.size() > 0)
+ {
+ out.print("| ");
+ out.print(fieldData[0]);
+ out.print(": | ");
+ out.print(Utils.addEntities(((DCValue) allValues.get(0)).value));
+
+ for (int j = 1; j < allValues.size(); j++)
+ {
+ out.print(" ");
+ out.print(Utils.addEntities(((DCValue) allValues.get(j)).value));
+ }
+ out.println(" |
");
+ }
+ }
+
+ listCollections();
+
+ out.println("
");
+
+ listBitstreams();
+ }
+
+
+ /**
+ * Render full item record
+ */
+ private void renderFull()
+ throws IOException, java.sql.SQLException
+ {
+ JspWriter out = pageContext.getOut();
+
+ // Get all the metadata
+ DCValue[] values = item.getDC(Item.ANY, Item.ANY, Item.ANY);
+
+ out.println("" + res.getString("ItemTag.full")+ "
");
+
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
+ // Three column table - DC field, value, language
+ out.println("");
+ out.println("| " + res.getString("ItemTag.field") + " | " + res.getString("ItemTag.value") + " | " + res.getString("ItemTag.lang") + " |
");
+
+ for (int i = 0; i < values.length; i++)
+ {
+ boolean hidden = false;
+
+ // Mask description.provenance
+ if (values[i].element.equals("description") &&
+ (values[i].qualifier != null &&
+ values[i].qualifier.equals("provenance")))
+ {
+ hidden = true;
+ }
+
+ if (!hidden)
+ {
+ out.print("| ");
+ out.print(values[i].element);
+ if (values[i].qualifier != null)
+ {
+ out.print("." + values[i].qualifier);
+ }
+ out.print(" | ");
+ out.print(Utils.addEntities(values[i].value));
+ out.print(" | ");
+
+ if (values[i].language == null)
+ {
+ out.print("-");
+ }
+ else
+ {
+ out.print(values[i].language);
+ }
+
+ out.println(" |
");
+ }
+ }
+
+ listCollections();
+
+ out.println("
");
+
+ listBitstreams();
+ }
+
+
+ /**
+ * List links to collections if information is available
+ */
+ private void listCollections()
+ throws IOException
+ {
+ JspWriter out = pageContext.getOut();
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
+ if (collections != null)
+ {
+ out.print("| " +
+ res.getString("ItemTag.appearsIn") + " | ");
+
+ for (int i = 0; i < collections.length; i++)
+ {
+ out.print("");
+ out.print(collections[i].getMetadata("name"));
+ out.print(" ");
+ }
+
+ out.println(" |
");
+ }
+ }
+
+
+ /**
+ * List bitstreams in the item
+ */
+ private void listBitstreams()
+ throws IOException
+ {
+ JspWriter out = pageContext.getOut();
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+
+ out.print("");
+ out.println("" + res.getString("ItemTag.filesIn") + " ");
+
+ Bundle[] bundles = item.getBundles("ORIGINAL");
+
+ if (bundles.length == 0)
+ {
+ out.println("" + res.getString("ItemTag.nofiles") + " ");
+ }
+ else
+ {
+ boolean html = false;
+ String handle = item.getHandle();
+ Bitstream primaryBitstream = null;
+
+ Bundle[] bunds = item.getBundles("ORIGINAL");
+ // if item contains multiple bitstreams, display bitstream description
+ boolean multiFile = bunds[0].getBitstreams().length > 1;
+ Bundle[] thumbs= item.getBundles("THUMBNAIL");
+
+ // check if primary bitstream is html
+ if (bunds[0] != null)
+ {
+ Bitstream[] bits = bunds[0].getBitstreams();
+ for (int i = 0; i < bits.length && !html; i++)
+ {
+ if (bits[i].getID() == bunds[0].getPrimaryBitstreamID())
+ {
+ html = bits[i].getFormat().getMIMEType().equals("text/html");
+ primaryBitstream = bits[i];
+ }
+ }
+ }
+
+ out.println("");
+ }
+
+ out.println(" |
");
+ }
+}
+
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/LayoutTag.java ./app/webui/jsptag/LayoutTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/LayoutTag.java 2004-03-09 16:32:32.000000000 -0200
+++ ./app/webui/jsptag/LayoutTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -72,7 +72,7 @@
* dspace.layout.parentlinks - a List of
* Strings corresponding with links to put in the location bar.
* Empty strings mean no link. Will only be set if
- * dspace.layout.locbar is true.
+ * dspace.layout.locbar is true.
* dspace.layout.navbar - value will be "off", or the
* navigation bar to include, e.g. "/layout/navbar_default.jsp"
* dspace.layout.sidebar - contents of the sidebar
@@ -90,16 +90,16 @@
/** layout style name */
private String style;
-
+
/** title */
private String title;
-
+
/** Navigation bar type, null means none */
private String navbar;
-
+
/** Location bar type */
private String locbar;
-
+
/** Name of "parent" page */
private String parentTitle;
@@ -110,9 +110,9 @@
private String sidebar;
/** Whether to add headers to prevent browsers caching the page */
- private String noCache;
+ private String noCache;
+
-
public LayoutTag()
{
super();
@@ -126,7 +126,7 @@
// header file
String header = "/layout/header-default.jsp";
-
+
// Choose default style unless one is specified
if (style != null)
{
@@ -162,7 +162,7 @@
{
parentLinks.add("/");
}
-
+
// Add other relevant components to the location bar
if (locbar.equalsIgnoreCase("link"))
{
@@ -227,7 +227,7 @@
request.setAttribute("dspace.layout.parenttitles", parents);
request.setAttribute("dspace.layout.parentlinks", parentLinks);
-
+
// Navigation bar: "default" is default :)
if (navbar == null)
{
@@ -255,17 +255,17 @@
// Set headers to prevent browser caching, if appropriate
if (noCache != null && noCache.equalsIgnoreCase("true"))
- {
+ {
response.addDateHeader("expires", 1);
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-control", "no-store");
}
-
+
ServletConfig config = pageContext.getServletConfig();
RequestDispatcher rd =
config.getServletContext().getRequestDispatcher(header);
-
+
rd.include(request, response);
}
catch (IOException ioe)
@@ -311,7 +311,7 @@
RequestDispatcher rd =
config.getServletContext().getRequestDispatcher(footer);
-
+
rd.include(request, response);
}
catch (ServletException se)
@@ -471,7 +471,7 @@
{
this.noCache = v;
}
-
+
public void release()
{
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/SelectEPersonTag.java ./app/webui/jsptag/SelectEPersonTag.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/jsptag/SelectEPersonTag.java 2004-04-01 10:52:50.000000000 -0200
+++ ./app/webui/jsptag/SelectEPersonTag.java 2005-04-19 17:34:57.000000000 -0200
@@ -47,6 +47,9 @@
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.jstl.fmt.*;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
+
import org.dspace.eperson.EPerson;
/**
@@ -71,9 +74,9 @@
{
/** Multiple e-people? */
private boolean multiple;
-
+
/** Which eperson/epeople are initially in the list? */
- private EPerson[] epeople;
+ private EPerson[] epeople;
public SelectEPersonTag()
@@ -81,10 +84,10 @@
super();
}
-
+
/**
* Setter for multiple attribute
- *
+ *
* @param s attribute from JSP
*/
public void setMultiple(String s)
@@ -101,7 +104,7 @@
/**
* Setter for e-people in list
- *
+ *
* @param e attribute from JSP
*/
public void setSelected(Object e)
@@ -117,7 +120,7 @@
}
}
-
+
public void release()
{
multiple = false;
@@ -132,11 +135,11 @@
{
JspWriter out = pageContext.getOut();
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
-
+
out.print("");
@@ -174,8 +186,8 @@
catch (IOException ie)
{
throw new JspException(ie);
- }
-
+ }
+
return SKIP_BODY;
}
}
Only in ./app/webui/servlet/admin: EPersonAdminServlet.java.orig
Only in ./app/webui/servlet/admin: EPersonAdminServlet.old
Only in ./app/webui/servlet/admin: GroupEditServlet.java.orig
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/admin/ItemMapServlet.java ./app/webui/servlet/admin/ItemMapServlet.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/admin/ItemMapServlet.java 2004-06-08 15:40:58.000000000 -0200
+++ ./app/webui/servlet/admin/ItemMapServlet.java 2005-04-19 17:34:58.000000000 -0200
@@ -66,6 +66,9 @@
import org.dspace.storage.rdbms.TableRowIterator;
import org.dspace.storage.rdbms.TableRow;
+import javax.servlet.jsp.jstl.fmt.*;
+
+
/**
* Servlet for editing and deleting (expunging) items
*
@@ -80,14 +83,14 @@
{
doDSPost( context, request, response );
}
-
+
protected void doDSPost(Context context, HttpServletRequest request,
HttpServletResponse response)
throws java.sql.SQLException, javax.servlet.ServletException,
java.io.IOException, AuthorizeException
{
String jspPage = null;
-
+
// get with a collection ID means put up browse window
int myID = UIUtil.getIntParameter(request, "cid");
@@ -98,7 +101,7 @@
AuthorizeManager.authorizeAction(context, myCollection, Constants.COLLECTION_ADMIN);
String action = request.getParameter("action");
-
+
if( action == null ) { action = ""; }
if( action.equals("") )
@@ -114,7 +117,7 @@
// get all items from that collection, add them to a hash
ItemIterator i = myCollection.getItems();
-
+
// iterate through the items in this collection, and count how many
// are native, and how many are imports, and which collections they came from
while(i.hasNext())
@@ -123,19 +126,19 @@
// get key for hash
Integer myKey = new Integer(myItem.getID());
-
+
if(myItem.isOwningCollection(myCollection)) count_native++;
else count_import++;
-
+
// is the collection in the hash?
Collection owningCollection = myItem.getOwningCollection();
Integer cKey = new Integer(owningCollection.getID());
-
+
if( myCollections.containsKey(cKey) )
{
Integer x = (Integer)myCounts.get(cKey);
int myCount = x.intValue() + 1;
-
+
// increment count for that collection
myCounts.put(cKey, new Integer(myCount));
}
@@ -143,12 +146,12 @@
{
// store and initialize count
myCollections.put(cKey, owningCollection);
- myCounts.put(cKey, new Integer(1));
+ myCounts.put(cKey, new Integer(1));
}
-
+
// store the item
myItems.put(myKey, myItem);
-
+
}
// remove this collection's entry because we already have a native count
@@ -164,11 +167,11 @@
request.setAttribute("collection_counts", myCounts);
request.setAttribute("all_collections",
Collection.findAll(context));
-
- // show this page when we're done
+
+ // show this page when we're done
jspPage = "itemmap-main.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
/*
@@ -178,31 +181,31 @@
String handle = (String)request.getParameter("handle");
boolean error = true;
Item itemToAdd = null;
-
+
if( itemID > 0 )
{
itemToAdd = Item.find(context, itemID);
-
+
if( itemToAdd != null ) error = false;
}
else if(handle != null && !handle.equals(""))
{
DSpaceObject dso=HandleManager.resolveToObject(context, handle);
-
+
if(dso != null && dso.getType() == Constants.ITEM)
{
itemToAdd = (Item)dso;
error = false;
}
}
-
+
//FIXME: error handling!
if( !error )
{
String myTitle =
itemToAdd.getDC("title",null,Item.ANY)[0].value;
String ownerName =
- itemToAdd.getOwningCollection().getMetadata("name");
+ itemToAdd.getOwningCollection().getMetadata("name");
// hook up item, but first, does it belong already?
TableRowIterator tri = DatabaseManager.query(context,
@@ -210,13 +213,13 @@
"SELECT collection2item.* FROM collection2item WHERE " +
"collection_id=" + myCollection.getID() +
" AND item_id=" + itemToAdd.getID());
-
+
if(tri.hasNext())
{
- request.setAttribute("message", "Item is already part of that collection!");
+ request.setAttribute("message", "Item is already part of that collection!");
}
else
- {
+ {
// Create mapping
myCollection.addItem( itemToAdd );
@@ -228,10 +231,10 @@
request.setAttribute("collection", myCollection);
- // show this page when we're done
+ // show this page when we're done
jspPage = "itemmap-info.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
else
@@ -242,53 +245,53 @@
else if( action.equals("Add Entire Collection") )
{
int targetID = UIUtil.getIntParameter(request, "collection2import");
-
+
Collection targetCollection = Collection.find(context, targetID);
-
+
// get all items from that collection and add them if not
// already added
-
+
// get all items to be added
ItemIterator i = targetCollection.getItems();
Map toAdd = new HashMap();
String message = "";
-
+
while( i.hasNext() )
{
Item myItem = i.next();
-
+
toAdd.put(new Integer(myItem.getID()), myItem);
}
-
+
// now see what we already have, removing dups from the 'toAdd' list
i = myCollection.getItems();
-
+
while( i.hasNext() )
{
Item myItem = i.next();
Integer myKey = new Integer(myItem.getID());
-
+
// remove works even if key isn't present
toAdd.remove(myKey);
}
// what's left in toAdd should be added
Iterator addKeys = toAdd.keySet().iterator();
-
+
while( addKeys.hasNext() )
{
Item myItem = (Item)toAdd.get(addKeys.next());
myCollection.addItem(myItem);
message += "
Added item ID: " + myItem.getID();
- }
+ }
request.setAttribute("message", message);
request.setAttribute("collection", myCollection);
- // show this page when we're done
+ // show this page when we're done
jspPage = "itemmap-info.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
*/
@@ -296,35 +299,47 @@
{
// get item IDs to remove
String [] itemIDs = request.getParameterValues("item_ids");
+ request.setAttribute ("item_ids", itemIDs);
+ request.setAttribute ("action", action);
String message = "";
-
- for( int j = 0; j < itemIDs.length; j++ )
+
+ if( itemIDs == null ) //CORRECTED by gio-vou
{
- int i = Integer.parseInt(itemIDs[j]);
- message += "
Remove item " + i;
-
- Item myItem = Item.find(context, i);
-
- // make sure item doesn't belong to this collection
- if( !myItem.isOwningCollection(myCollection) )
- {
- myCollection.removeItem(myItem);
- }
+ message = "No items selected, none removed.";
}
-
+ else
+ {
+
+ for( int j = 0; j < itemIDs.length; j++ )
+ {
+ int i = Integer.parseInt(itemIDs[j]);
+ message += "
Remove item " + i;
+
+ Item myItem = Item.find(context, i);
+
+ // make sure item doesn't belong to this collection
+ if( !myItem.isOwningCollection(myCollection) )
+ {
+ myCollection.removeItem(myItem);
+ }
+ }
+ }
+
request.setAttribute("message", message);
request.setAttribute("collection", myCollection);
-
- // show this page when we're done
+
+ // show this page when we're done
jspPage = "itemmap-info.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
else if( action.equals("Add") )
{
// get item IDs to add
String [] itemIDs = request.getParameterValues("item_ids");
+ request.setAttribute ("item_ids", itemIDs);
+ request.setAttribute ("action", action);
String message = "";
if( itemIDs == null )
@@ -350,14 +365,14 @@
}
}
}
-
+
request.setAttribute("message", message);
request.setAttribute("collection", myCollection);
-
- // show this page when we're done
+
+ // show this page when we're done
jspPage = "itemmap-info.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
else if( action.equals("Search Authors") )
@@ -376,7 +391,7 @@
while( tri.hasNext() )
{
TableRow tr = tri.next();
-
+
// now instantiate and pass items to 'Add' page
int itemID = tr.getIntColumn("item_id");
@@ -386,11 +401,12 @@
if( AuthorizeManager.authorizeActionBoolean(context, myItem, Constants.READ) )
{
items.put(new Integer(itemID), myItem);
- }
+ }
}
request.setAttribute("collection", myCollection);
- request.setAttribute("browsetext", "Items matching author '" + myQuery + "'");
+ //request.setAttribute("browsetext", "Items matching author '" + myQuery + "'");
+ request.setAttribute("browsetext", "'" + myQuery + "'");
request.setAttribute("items", items);
request.setAttribute("browsetype", new String("Add"));
@@ -403,16 +419,16 @@
int t = UIUtil.getIntParameter(request, "t");
Collection targetCollection = Collection.find(context, t);
-
+
// now find all imported items from that collection
// seemingly inefficient, but database should have this query cached
ItemIterator i = myCollection.getItems();
Map items = new HashMap();
-
+
while(i.hasNext())
{
Item myItem = i.next();
-
+
if( myItem.isOwningCollection(targetCollection) )
{
Integer myKey = new Integer(myItem.getID());
@@ -425,13 +441,13 @@
request.setAttribute("items", items);
request.setAttribute("browsetype", new String("Remove"));
- // show this page when we're done
+ // show this page when we're done
jspPage = "itemmap-browse.jsp";
- // show the page
+ // show the page
JSPManager.showJSP(request, response, jspPage);
}
-
- context.complete();
+
+ context.complete();
}
}
Only in ./app/webui/servlet: LDAPServlet.java
Only in ./app/webui/servlet: RegisterServlet.java.orig
Only in ./app/webui/servlet: RegisterServlet.old
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/SimpleSearchServlet.java ./app/webui/servlet/SimpleSearchServlet.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/SimpleSearchServlet.java 2004-02-23 17:45:42.000000000 -0200
+++ ./app/webui/servlet/SimpleSearchServlet.java 2005-04-19 17:34:59.000000000 -0200
@@ -92,23 +92,27 @@
{
/** log4j category */
private static Logger log = Logger.getLogger(SimpleSearchServlet.class);
-
+
protected void doDSGet(Context context,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
+
+ request.setCharacterEncoding("UTF-8");
// Get the query
String query = request.getParameter("query");
+
+ //query = URLEncoder.encode(query, "UTF-8");
int start = UIUtil.getIntParameter(request, "start");
String advanced = request.getParameter("advanced");
String fromAdvanced = request.getParameter("from_advanced");
String advancedQuery = "";
HashMap queryHash = new HashMap();
-
+
// can't start earlier than 0 in the results!
if( start < 0 ) { start = 0; }
-
+
List itemHandles = new ArrayList();
List collectionHandles = new ArrayList();
List communityHandles = new ArrayList();
@@ -120,13 +124,13 @@
QueryResults qResults = null;
QueryArgs qArgs = new QueryArgs();
- // if the "advanced" flag is set, build the query string from the
+ // if the "advanced" flag is set, build the query string from the
// multiple query fields
- if (advanced != null)
+ if (advanced != null)
{
query = qArgs.buildQuery(request);
advancedQuery = qArgs.buildHTTPQuery(request);
- }
+ }
// Ensure the query is non-null
if (query == null)
@@ -149,13 +153,15 @@
// Location is a Handle
url = "/handle/" + location;
}
-
+
// Encode the query
- query = URLEncoder.encode(query);
-
- if (advancedQuery.length() > 0)
+ query = URLEncoder.encode(query, "UTF-8");
+
+ if (advancedQuery.length() > 0)
{
+ //advancedQuery = URLEncoder.encode(query,"UTF-8");
query = query + "&from_advanced=true&" + advancedQuery;
+
}
// Do the redirect
response.sendRedirect(response.encodeRedirectURL(
@@ -172,14 +178,14 @@
Collection collection = UIUtil.getCollectionLocation(request);
// get the start of the query results page
-
+
// List resultObjects = null;
-
+
qArgs.setQuery( query );
qArgs.setStart( start );
-
+
// Perform the search
if (collection != null)
{
@@ -291,18 +297,18 @@
logInfo + "query=\"" + query + "\",results=(" + resultsCommunities.length + "," + resultsCollections.length + "," + resultsItems.length + ")"));
// Pass in some page qualities
-
+
// total number of pages
int pageTotal = 1 + (qResults.getHitCount() - 1)/qResults.getPageSize();
-
+
// current page being displayed
int pageCurrent= 1 + (qResults.getStart()/qResults.getPageSize());
-
+
// pageLast = min(pageCurrent+9,pageTotal)
int pageLast = (pageCurrent + 9) > pageTotal ? pageTotal : (pageCurrent+9);
-
+
// pageFirst = max(1,pageCurrent-9)
- int pageFirst = (pageCurrent - 9) > 1 ? (pageCurrent - 9) : 1;
+ int pageFirst = (pageCurrent - 9) > 1 ? (pageCurrent - 9) : 1;
// Pass the results to the display JSP
request.setAttribute("items", resultsItems );
@@ -317,8 +323,9 @@
request.setAttribute("queryresults", qResults );
// And the original query string
- request.setAttribute("query", query);
-
+ request.setAttribute("query", query);
+
+
if ((fromAdvanced != null) && (qResults.getHitCount() == 0))
{
// send back to advanced form if no results
@@ -327,20 +334,20 @@
request.setAttribute("no_results", "yes");
queryHash = qArgs.buildQueryHash(request);
-
+
Iterator i = queryHash.keySet().iterator();
-
+
while(i.hasNext())
{
String key = (String)i.next();
String value = (String)queryHash.get(key);
request.setAttribute(key, value);
-
+
}
JSPManager.showJSP(request, response, "/search/advanced.jsp");
- } else
+ } else
{
JSPManager.showJSP(request, response, "/search/results.jsp");
}
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/SubmitServlet.java ./app/webui/servlet/SubmitServlet.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/servlet/SubmitServlet.java 2004-06-24 17:46:12.000000000 -0200
+++ ./app/webui/servlet/SubmitServlet.java 2005-04-19 17:34:59.000000000 -0200
@@ -50,6 +50,9 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.util.ResourceBundle;
+import java.util.Locale;
+
import org.apache.log4j.Logger;
@@ -584,7 +587,7 @@
if (bundles.length > 0)
{
Bitstream[] bitstreams = bundles[0].getBitstreams();
-
+
willRemoveFiles = bitstreams.length > 1;
}
}
@@ -783,7 +786,7 @@
readNames(request, item, "contributor", "author", true);
readText(request, item, "title", null, false, "en");
// verify that a title has been entered
- DCValue[] dcValues = item.getDC("title", null, "en");
+ DCValue[] dcValues = item.getDC("title", null, Item.ANY);
boolean titleMissing = dcValues.length == 0;
if (subInfo.submission.hasMultipleTitles())
@@ -796,11 +799,18 @@
// Type
item.clearDC("type", null, Item.ANY);
String[] types = request.getParameterValues("type");
+
+ ResourceBundle mon_en = ResourceBundle.getBundle("months", new Locale("en"));
+ ResourceBundle mon_el = ResourceBundle.getBundle("months", new Locale("el"));
+ String[] allTypes_en = (String[])mon_en.getObject("submit_types");
+ String[] allTypes_el = (String[])mon_el.getObject("submit_types");
+
if (types != null)
{
for (int i = 0; i < types.length; i++)
{
- item.addDC("type", null, "en", types[i]);
+ item.addDC("type", null, "en", allTypes_en[Integer.parseInt(types[i])]);
+ item.addDC("type", null, "el", allTypes_el[Integer.parseInt(types[i])]);
}
}
@@ -843,8 +853,8 @@
// Careful that this happens AFTER identifier.* is blown away
// above!!
- readText(request, item, "identifier", "citation", false, "en");
- readText(request, item, "publisher", null, false, "en");
+ readText(request, item, "identifier", "citation", false, null);
+ readText(request, item, "publisher", null, true, "en");
}
int nextStep = -1;
@@ -951,9 +961,9 @@
// Update object from form values
readText(request, item, "subject", null, true, "en");
- readText(request, item, "description", "abstract", false, "en");
- readText(request, item, "description", "sponsorship", false, "en");
- readText(request, item, "description", null, false, "en");
+ readText(request, item, "description", "abstract", true, "en");
+ readText(request, item, "description", "sponsorship", true, "en");
+ readText(request, item, "description", null, true, "en");
// Proceed according to button pressed
int nextStep = -1;
@@ -1042,13 +1052,13 @@
// Read the temp file into a bitstream
InputStream is = new BufferedInputStream(
new FileInputStream(temp));
-
- // do we already have a bundle?
+
+ // do we already have a bundle?
Bundle [] bundles = item.getBundles("ORIGINAL");
-
+
if( bundles.length < 1)
{
- // set bundle's name to ORIGINAL
+ // set bundle's name to ORIGINAL
b = item.createSingleBitstream(is, "ORIGINAL");
}
else
@@ -1056,7 +1066,7 @@
// we have a bundle already, just add bitstream
b = bundles[0].createBitstream(is);
}
-
+
// Strip all but the last filename. It would be nice
// to know which OS the file came from.
String noPath = wrapper.getFilesystemName("file");
@@ -1361,11 +1371,11 @@
// delete bundle if it's now empty
Bundle[] bundles = bitstream.getBundles();
-
+
bundles[0].removeBitstream(bitstream);
-
+
Bitstream[] bitstreams = bundles[0].getBitstreams();
-
+
// remove bundle if it's now empty
if( bitstreams.length < 1)
{
@@ -1626,7 +1636,7 @@
// FIXME: pass in more information about what happens next?
JSPManager.showJSP(request, response, "/submit/complete.jsp");
-
+
context.complete();
}
else if (request.getParameter("submit_reject") != null)
@@ -1700,7 +1710,7 @@
if (ccLicenseUrl != null && ccLicenseUrl.length() > 0 )
{
Item item = subInfo.submission.getItem();
-
+
// set the CC license
CreativeCommons.setLicense(context, item, ccLicenseUrl);
@@ -1713,7 +1723,7 @@
doStepJump(context, request, response, subInfo);
}
}
-
+
}
//****************************************************************
@@ -2276,8 +2286,10 @@
{
dcname = element + "_" + qualifier;
}
+ String dclanguage = dcname+ "_lang";
// Names to add
+ List langs = new LinkedList();
List firsts = new LinkedList();
List lasts = new LinkedList();
@@ -2285,6 +2297,7 @@
{
firsts = getRepeatedParameter(request, dcname + "_first");
lasts = getRepeatedParameter(request, dcname + "_last");
+ langs = getRepeatedParameter(request, dclanguage);
// Find out if the relevant "remove" button was pressed
String buttonPressed = UIUtil.getSubmitButton(request, "");
@@ -2297,6 +2310,7 @@
firsts.remove(valToRemove);
lasts.remove(valToRemove);
+ langs.remove(valToRemove);
}
}
else
@@ -2304,7 +2318,7 @@
// Just a single name
String lastName = request.getParameter(dcname + "_last");
String firstNames = request.getParameter(dcname + "_first");
-
+ langs.add(request.getParameter(dclanguage));
lasts.add(lastName);
firsts.add(firstNames);
}
@@ -2345,7 +2359,7 @@
}
// Add to the database
- item.addDC(element, qualifier, null,
+ item.addDC(element, qualifier, (String) langs.get(i),
new DCPersonName(l, f).toString());
}
}
@@ -2393,12 +2407,16 @@
dcname = element + "_" + qualifier;
}
+ String dclanguage = dcname + "_lang";
+
// Values to add
List vals = new LinkedList();
+ List langs = new LinkedList();
if (repeated)
{
vals = getRepeatedParameter(request, dcname);
+ langs = getRepeatedParameter(request, dclanguage);
// Find out if the relevant "remove" button was pressed
String buttonPressed = UIUtil.getSubmitButton(request, "");
@@ -2410,12 +2428,20 @@
buttonPressed.substring(removeButton.length()));
vals.remove(valToRemove);
+ langs.remove(valToRemove);
}
}
else
{
// Just a single name
vals.add(request.getParameter(dcname).trim());;
+ if (lang!=null) {
+ langs.add(request.getParameter(dclanguage).trim());
+ }
+ else {
+ langs.add(null); //
+ }
+
}
// Remove existing values
@@ -2428,7 +2454,13 @@
String s = (String) vals.get(i);
if (s != null && !s.equals(""))
{
- item.addDC(element, qualifier, lang, s);
+ if (lang!=null)
+ {
+ item.addDC(element, qualifier, (String) langs.get(i), s);
+ }
+ else {
+ item.addDC(element, qualifier, null, s); //
+ }
}
}
}
@@ -2528,11 +2560,15 @@
// Names to add
List series = new LinkedList();
List numbers = new LinkedList();
+ List langs = new LinkedList();
+
if (repeated)
{
series = getRepeatedParameter(request, dcname + "_series");
numbers = getRepeatedParameter(request, dcname + "_number");
+ langs = getRepeatedParameter(request, dcname + "_lang");
+
// Find out if the relevant "remove" button was pressed
String buttonPressed = UIUtil.getSubmitButton(request, "");
@@ -2545,6 +2581,7 @@
series.remove(valToRemove);
numbers.remove(valToRemove);
+ langs.remove(valToRemove);
}
}
else
@@ -2552,12 +2589,21 @@
// Just a single name
String s = request.getParameter(dcname + "_series");
String n = request.getParameter(dcname + "_number");
+ String lang = request.getParameter(dcname + "_lang");
+
// Only put it in if there was a name present
if (s != null && !s.equals(""))
{
series.add(s);
numbers.add(n);
+ if (lang!=null) {
+ langs.add(lang);
+ }
+ else {
+ langs.add(Item.ANY);
+ }
+
}
}
@@ -2573,7 +2619,7 @@
// Only add non-empty
if (!s.equals("") || !n.equals(""))
{
- item.addDC(element, qualifier, null,
+ item.addDC(element, qualifier, ((String) langs.get(i)).trim(),
new DCSeriesNumber(s, n).toString());
}
}
Only in ./app/webui: SimpleAuthenticator.java.orig
Only in ./app/webui: SimpleAuthenticator.old
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/util/UIUtil.java ./app/webui/util/UIUtil.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/app/webui/util/UIUtil.java 2004-01-28 23:09:22.000000000 -0200
+++ ./app/webui/util/UIUtil.java 2005-04-19 17:34:59.000000000 -0200
@@ -1,513 +1,521 @@
-/*
- * UIUtil.java
- *
- * Version: $Revision: 1.12 $
- *
- * Date: $Date: 2004/01/29 01:09:22 $
- *
- * Copyright (c) 2002, 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.util;
-
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.log4j.Logger;
-
-import org.dspace.app.webui.SiteAuthenticator;
-import org.dspace.content.Collection;
-import org.dspace.content.Community;
-import org.dspace.content.DCDate;
-import org.dspace.core.ConfigurationManager;
-import org.dspace.core.Context;
-import org.dspace.core.Email;
-import org.dspace.eperson.EPerson;
-
-
-/**
- * Miscellaneous UI utility methods
- *
- * @author Robert Tansley
- * @version $Revision: 1.12 $
- */
-public class UIUtil
-{
-
- /** log4j category */
- private static Logger log = Logger.getLogger(UIUtil.class);
-
- /**
- * Obtain a new context object. If a context object has already been
- * created for this HTTP request, it is re-used, otherwise it is created.
- * If a user has authenticated with the system, the current user of the
- * context is set appropriately.
- *
- * @param request the HTTP request
- *
- * @return a context object
- */
- public static Context obtainContext(HttpServletRequest request)
- throws SQLException
- {
- Context c = (Context) request.getAttribute("dspace.context");
-
- if (c == null)
- {
- // No context for this request yet
- c = new Context();
-
- // See if a user has authentication
- Integer userID = (Integer)
- request.getSession().getAttribute("dspace.current.user.id");
-
- if (userID != null)
- {
- EPerson e = EPerson.find(c, userID.intValue());
-
- Authenticate.loggedIn(c, request, e);
- }
-
- // Set any special groups - invoke the site authenticator
- SiteAuthenticator siteAuth = Authenticate.getSiteAuth();
- int[] groupIDs = siteAuth.getSpecialGroups(c, request);
- for (int i = 0; i < groupIDs.length; i++)
- {
- c.setSpecialGroup(groupIDs[i]);
- }
-
-
- // Set the session ID
- c.setExtraLogInfo("session_id=" + request.getSession().getId());
-
- // Store the context in the request
- request.setAttribute("dspace.context", c);
- }
-
- return c;
- }
-
- /**
- * Get the current community location, that is, where the user "is".
- * This returns null if there is no location, i.e. "all of
- * DSpace" is the location.
- *
- * @param request current HTTP request
- *
- * @return the current community location, or null
- */
- public static Community getCommunityLocation(HttpServletRequest request)
- {
- return ((Community) request.getAttribute("dspace.community"));
- }
-
- /**
- * Get the current collection location, that is, where the user "is".
- * This returns null if there is no collection location, i.e. the
- * location is "all of DSpace" or a community.
- *
- * @param request current HTTP request
- *
- * @return the current collection location, or null
- */
- public static Collection getCollectionLocation(HttpServletRequest request)
- {
- return ((Collection) request.getAttribute("dspace.collection"));
- }
-
- /**
- * Put the original request URL into the request object as an attribute
- * for later use. This is necessary because forwarding a request removes
- * this information. The attribute is only written if it hasn't been
- * before; thus it can be called after a forward safely.
- *
- * @param request the HTTP request
- */
- public static void storeOriginalURL(HttpServletRequest request)
- {
- String orig = (String) request.getAttribute("dspace.original.url");
-
- if (orig == null)
- {
- String fullURL = request.getRequestURL().toString();
-
- if (request.getQueryString() != null)
- {
- fullURL = fullURL + "?" + request.getQueryString();
- }
-
- request.setAttribute("dspace.original.url", fullURL);
- }
- }
-
- /**
- * Get the original request URL.
- *
- * @param request the HTTP request
- *
- * @return the original request URL
- */
- public static String getOriginalURL(HttpServletRequest request)
- {
- // Make sure there's a URL in the attribute
- storeOriginalURL(request);
-
- return ((String) request.getAttribute("dspace.original.url"));
- }
-
- /**
- * Utility method to convert spaces in a string to HTML non-break space
- * elements.
- *
- * @param s string to change spaces in
- * @return the string passed in with spaces converted to HTML non-break
- * spaces
- */
- public static String nonBreakSpace(String s)
- {
- StringBuffer newString = new StringBuffer();
-
- for (int i = 0; i < s.length(); i++)
- {
- char ch = s.charAt(i);
-
- if (ch == ' ')
- {
- newString.append(" ");
- }
- else
- {
- newString.append(ch);
- }
- }
-
- return newString.toString();
- }
-
- /**
- * 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());
- }
-
- /**
- * Return a string for logging, containing useful information about the
- * current request - the URL, the method and parameters.
- *
- * @param request the request object.
- * @return a multi-line string containing information about
- * the request.
- */
- public static String getRequestLogInfo(HttpServletRequest request)
- {
- String report;
-
- report = "-- URL Was: " + getOriginalURL(request) + "\n";
- report = report + "-- Method: " + request.getMethod() + "\n";
-
- // First write the parameters we had
- report = report + "-- Parameters were:\n";
- Enumeration e = request.getParameterNames();
-
- while (e.hasMoreElements())
- {
- String name = (String) e.nextElement();
-
- if (name.equals("login_password"))
- {
- // We don't want to write a clear text password
- // to the log, even if it's wrong!
- report = report + "-- " + name + ": *not logged*\n";
- }
- else
- {
- report = report + "-- " + name + ": \"" + request.getParameter(name) + "\"\n";
- }
- }
-
- return report;
- }
-
-
- /**
- * Obtain a parameter from the given request as an int. -1
- * is returned if the parameter is garbled or does not exist.
- *
- * @param request the HTTP request
- * @param param the name of the parameter
- *
- * @return the integer value of the parameter, or -1
- */
- public static int getIntParameter(HttpServletRequest request, String param)
- {
- String val = request.getParameter(param);
-
- try
- {
- return Integer.parseInt(val);
- }
- catch (Exception e)
- {
- // Problem with parameter
- return -1;
- }
- }
-
-
- /**
- * Obtain an array of int parameters from the given request as an int.
- * null is returned if parameter doesn't exist. -1
- * is returned in array locations if that particular value is garbled.
- *
- * @param request the HTTP request
- * @param param the name of the parameter
- *
- * @return array of integers or null
- */
- public static int [] getIntParameters(HttpServletRequest request, String param)
- {
- String [] request_values = request.getParameterValues(param);
-
- if( request_values == null ) return null;
-
- int [] return_values = new int[request_values.length];
-
- for( int x = 0; x < return_values.length; x++ )
- {
- try
- {
- return_values[x] = Integer.parseInt(request_values[x]);
- }
- catch (Exception e)
- {
- // Problem with parameter, stuff -1 in this slot
- return_values[x] = -1;
- }
- }
-
- return return_values;
- }
-
-
- /**
- * Obtain a parameter from the given request as a boolean.
- * false is returned if the parameter is garbled or does not
- * exist.
- *
- * @param request the HTTP request
- * @param param the name of the parameter
- *
- * @return the integer value of the parameter, or -1
- */
- public static boolean getBoolParameter(HttpServletRequest request,
- String param)
- {
- return (request.getParameter(param) != null &&
- request.getParameter(param).equals("true"));
- }
-
-
- /**
- * Get the button the user pressed on a submitted form. All buttons
- * should start with the text submit for this to work.
- * A default should be supplied, since often the browser will submit a form
- * with no submit button pressed if the user presses enter.
- *
- * @param request the HTTP request
- * @param def the default button
- *
- * @return the button pressed
- */
- public static String getSubmitButton(HttpServletRequest request, String def)
- {
- Enumeration e = request.getParameterNames();
-
- while (e.hasMoreElements())
- {
- String parameterName = (String) e.nextElement();
-
- if (parameterName.startsWith("submit"))
- {
- return parameterName;
- }
- }
-
- return def;
- }
-
-
- /**
- * Send an alert to the designated "alert recipient" - that is, when a
- * database error or internal error occurs, this person is sent an
- * e-mail with details.
- *
- * The recipient is configured via the "alert.recipient" property in
- * dspace.cfg. If this property is omitted, no alerts
- * are sent.
- *
- * This method "swallows" any exception that might occur - it will just
- * be logged. This is because this method will usually be invoked as
- * part of an error handling routine anyway.
- *
- * @param request the HTTP request leading to the error
- * @param exception the exception causing the error, or null
- */
- public static void sendAlert(HttpServletRequest request,
- Exception exception)
- {
- String logInfo = UIUtil.getRequestLogInfo(request);
-
- try
- {
- String recipient =
- ConfigurationManager.getProperty("alert.recipient");
-
- if (recipient != null)
- {
- Email email = ConfigurationManager.getEmail("internal_error");
-
- email.addRecipient(recipient);
- email.addArgument(
- ConfigurationManager.getProperty("dspace.url"));
- email.addArgument(new Date());
- email.addArgument(request.getSession().getId());
- email.addArgument(logInfo);
-
- String stackTrace;
-
- if (exception != null)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- exception.printStackTrace(pw);
- pw.flush();
- stackTrace = sw.toString();
- }
- else
- {
- stackTrace = "No exception";
- }
-
- email.addArgument(stackTrace);
- email.send();
- }
- }
- catch (Exception e)
- {
- // Not much we can do here!
- log.warn("Unable to send email alert", e);
- }
- }
-
-}
+/*
+ * UIUtil.java
+ *
+ * Version: $Revision: 1.12 $
+ *
+ * Date: $Date: 2004/01/29 01:09:22 $
+ *
+ * Copyright (c) 2002, 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.util;
+
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.Enumeration;
+
+import java.util.Locale;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.jstl.fmt.*;
+
+
+import org.apache.log4j.Logger;
+
+import org.dspace.app.webui.SiteAuthenticator;
+import org.dspace.content.Collection;
+import org.dspace.content.Community;
+import org.dspace.content.DCDate;
+import org.dspace.core.ConfigurationManager;
+import org.dspace.core.Context;
+import org.dspace.core.Email;
+import org.dspace.eperson.EPerson;
+import java.util.ResourceBundle;
+
+/**
+ * Miscellaneous UI utility methods
+ *
+ * @author Robert Tansley
+ * @version $Revision: 1.12 $
+ */
+public class UIUtil
+{
+
+ /** log4j category */
+ private static Logger log = Logger.getLogger(UIUtil.class);
+
+ /**
+ * Obtain a new context object. If a context object has already been
+ * created for this HTTP request, it is re-used, otherwise it is created.
+ * If a user has authenticated with the system, the current user of the
+ * context is set appropriately.
+ *
+ * @param request the HTTP request
+ *
+ * @return a context object
+ */
+ public static Context obtainContext(HttpServletRequest request)
+ throws SQLException
+ {
+ Context c = (Context) request.getAttribute("dspace.context");
+
+ if (c == null)
+ {
+ // No context for this request yet
+ c = new Context();
+
+ // See if a user has authentication
+ Integer userID = (Integer)
+ request.getSession().getAttribute("dspace.current.user.id");
+
+ if (userID != null)
+ {
+ EPerson e = EPerson.find(c, userID.intValue());
+
+ Authenticate.loggedIn(c, request, e);
+ }
+
+ // Set any special groups - invoke the site authenticator
+ SiteAuthenticator siteAuth = Authenticate.getSiteAuth();
+ int[] groupIDs = siteAuth.getSpecialGroups(c, request);
+ for (int i = 0; i < groupIDs.length; i++)
+ {
+ c.setSpecialGroup(groupIDs[i]);
+ }
+
+
+ // Set the session ID
+ c.setExtraLogInfo("session_id=" + request.getSession().getId());
+
+ // Store the context in the request
+ request.setAttribute("dspace.context", c);
+ }
+
+ return c;
+ }
+
+ /**
+ * Get the current community location, that is, where the user "is".
+ * This returns null if there is no location, i.e. "all of
+ * DSpace" is the location.
+ *
+ * @param request current HTTP request
+ *
+ * @return the current community location, or null
+ */
+ public static Community getCommunityLocation(HttpServletRequest request)
+ {
+ return ((Community) request.getAttribute("dspace.community"));
+ }
+
+ /**
+ * Get the current collection location, that is, where the user "is".
+ * This returns null if there is no collection location, i.e. the
+ * location is "all of DSpace" or a community.
+ *
+ * @param request current HTTP request
+ *
+ * @return the current collection location, or null
+ */
+ public static Collection getCollectionLocation(HttpServletRequest request)
+ {
+ return ((Collection) request.getAttribute("dspace.collection"));
+ }
+
+ /**
+ * Put the original request URL into the request object as an attribute
+ * for later use. This is necessary because forwarding a request removes
+ * this information. The attribute is only written if it hasn't been
+ * before; thus it can be called after a forward safely.
+ *
+ * @param request the HTTP request
+ */
+ public static void storeOriginalURL(HttpServletRequest request)
+ {
+ String orig = (String) request.getAttribute("dspace.original.url");
+
+ if (orig == null)
+ {
+ String fullURL = request.getRequestURL().toString();
+
+ if (request.getQueryString() != null)
+ {
+ fullURL = fullURL + "?" + request.getQueryString();
+ }
+
+ request.setAttribute("dspace.original.url", fullURL);
+ }
+ }
+
+ /**
+ * Get the original request URL.
+ *
+ * @param request the HTTP request
+ *
+ * @return the original request URL
+ */
+ public static String getOriginalURL(HttpServletRequest request)
+ {
+ // Make sure there's a URL in the attribute
+ storeOriginalURL(request);
+
+ return ((String) request.getAttribute("dspace.original.url"));
+ }
+
+ /**
+ * Utility method to convert spaces in a string to HTML non-break space
+ * elements.
+ *
+ * @param s string to change spaces in
+ * @return the string passed in with spaces converted to HTML non-break
+ * spaces
+ */
+ public static String nonBreakSpace(String s)
+ {
+ StringBuffer newString = new StringBuffer();
+
+ for (int i = 0; i < s.length(); i++)
+ {
+ char ch = s.charAt(i);
+
+ if (ch == ' ')
+ {
+ newString.append(" ");
+ }
+ else
+ {
+ newString.append(ch);
+ }
+ }
+
+ return newString.toString();
+ }
+
+ /**
+ * 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, Locale loc)
+ {
+
+
+ ResourceBundle res = ResourceBundle.getBundle ("Messages", loc);
+ 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, loc).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(res.getString("remove-item.itemDate.unset"));
+ }
+
+ return (sb.toString());
+ }
+
+ /**
+ * Return a string for logging, containing useful information about the
+ * current request - the URL, the method and parameters.
+ *
+ * @param request the request object.
+ * @return a multi-line string containing information about
+ * the request.
+ */
+ public static String getRequestLogInfo(HttpServletRequest request)
+ {
+ String report;
+
+ report = "-- URL Was: " + getOriginalURL(request) + "\n";
+ report = report + "-- Method: " + request.getMethod() + "\n";
+
+ // First write the parameters we had
+ report = report + "-- Parameters were:\n";
+ Enumeration e = request.getParameterNames();
+
+ while (e.hasMoreElements())
+ {
+ String name = (String) e.nextElement();
+
+ if (name.equals("login_password"))
+ {
+ // We don't want to write a clear text password
+ // to the log, even if it's wrong!
+ report = report + "-- " + name + ": *not logged*\n";
+ }
+ else
+ {
+ report = report + "-- " + name + ": \"" + request.getParameter(name) + "\"\n";
+ }
+ }
+
+ return report;
+ }
+
+
+ /**
+ * Obtain a parameter from the given request as an int. -1
+ * is returned if the parameter is garbled or does not exist.
+ *
+ * @param request the HTTP request
+ * @param param the name of the parameter
+ *
+ * @return the integer value of the parameter, or -1
+ */
+ public static int getIntParameter(HttpServletRequest request, String param)
+ {
+ String val = request.getParameter(param);
+
+ try
+ {
+ return Integer.parseInt(val);
+ }
+ catch (Exception e)
+ {
+ // Problem with parameter
+ return -1;
+ }
+ }
+
+
+ /**
+ * Obtain an array of int parameters from the given request as an int.
+ * null is returned if parameter doesn't exist. -1
+ * is returned in array locations if that particular value is garbled.
+ *
+ * @param request the HTTP request
+ * @param param the name of the parameter
+ *
+ * @return array of integers or null
+ */
+ public static int [] getIntParameters(HttpServletRequest request, String param)
+ {
+ String [] request_values = request.getParameterValues(param);
+
+ if( request_values == null ) return null;
+
+ int [] return_values = new int[request_values.length];
+
+ for( int x = 0; x < return_values.length; x++ )
+ {
+ try
+ {
+ return_values[x] = Integer.parseInt(request_values[x]);
+ }
+ catch (Exception e)
+ {
+ // Problem with parameter, stuff -1 in this slot
+ return_values[x] = -1;
+ }
+ }
+
+ return return_values;
+ }
+
+
+ /**
+ * Obtain a parameter from the given request as a boolean.
+ * false is returned if the parameter is garbled or does not
+ * exist.
+ *
+ * @param request the HTTP request
+ * @param param the name of the parameter
+ *
+ * @return the integer value of the parameter, or -1
+ */
+ public static boolean getBoolParameter(HttpServletRequest request,
+ String param)
+ {
+ return (request.getParameter(param) != null &&
+ request.getParameter(param).equals("true"));
+ }
+
+
+ /**
+ * Get the button the user pressed on a submitted form. All buttons
+ * should start with the text submit for this to work.
+ * A default should be supplied, since often the browser will submit a form
+ * with no submit button pressed if the user presses enter.
+ *
+ * @param request the HTTP request
+ * @param def the default button
+ *
+ * @return the button pressed
+ */
+ public static String getSubmitButton(HttpServletRequest request, String def)
+ {
+ Enumeration e = request.getParameterNames();
+
+ while (e.hasMoreElements())
+ {
+ String parameterName = (String) e.nextElement();
+
+ if (parameterName.startsWith("submit"))
+ {
+ return parameterName;
+ }
+ }
+
+ return def;
+ }
+
+
+ /**
+ * Send an alert to the designated "alert recipient" - that is, when a
+ * database error or internal error occurs, this person is sent an
+ * e-mail with details.
+ *
+ * The recipient is configured via the "alert.recipient" property in
+ * dspace.cfg. If this property is omitted, no alerts
+ * are sent.
+ *
+ * This method "swallows" any exception that might occur - it will just
+ * be logged. This is because this method will usually be invoked as
+ * part of an error handling routine anyway.
+ *
+ * @param request the HTTP request leading to the error
+ * @param exception the exception causing the error, or null
+ */
+ public static void sendAlert(HttpServletRequest request,
+ Exception exception)
+ {
+ String logInfo = UIUtil.getRequestLogInfo(request);
+
+ try
+ {
+ String recipient =
+ ConfigurationManager.getProperty("alert.recipient");
+
+ if (recipient != null)
+ {
+ Email email = ConfigurationManager.getEmail("internal_error");
+
+ email.addRecipient(recipient);
+ email.addArgument(
+ ConfigurationManager.getProperty("dspace.url"));
+ email.addArgument(new Date());
+ email.addArgument(request.getSession().getId());
+ email.addArgument(logInfo);
+
+ String stackTrace;
+
+ if (exception != null)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ exception.printStackTrace(pw);
+ pw.flush();
+ stackTrace = sw.toString();
+ }
+ else
+ {
+ stackTrace = "No exception";
+ }
+
+ email.addArgument(stackTrace);
+ email.send();
+ }
+ }
+ catch (Exception e)
+ {
+ // Not much we can do here!
+ log.warn("Unable to send email alert", e);
+ }
+ }
+
+}
Only in ./content: Collection.bak
Only in ./content: Community.bak
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/content/DCDate.java ./content/DCDate.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/content/DCDate.java 2003-04-11 14:49:06.000000000 -0200
+++ ./content/DCDate.java 2005-04-19 17:34:59.000000000 -0200
@@ -46,6 +46,12 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
+import java.util.ResourceBundle;
+import java.util.Locale;
+import javax.servlet.jsp.jstl.fmt.*;
+//import javax.servlet.jsp.PageContext;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
// FIXME: No tests
@@ -273,7 +279,7 @@
return utcGC.getTime();
}
-
+
/**
* Set the date. The date passed in is assumed to be in the current
* time zone, and is adjusting to fit the current time zone.
@@ -559,11 +565,20 @@
*
* @return the month name.
*/
- public static String getMonthName(int m)
+ //ResourceBundle added by kotsomit
+
+ public static String getMonthName(int m, Locale loc)
{
+
+
+ ResourceBundle mon =
+ ResourceBundle.getBundle("months", loc);
+ String[] monthnames = (String[])mon.getObject("Months");
+
+
if (m > 0 && m < 13)
{
- return MONTHNAMES[m - 1];
+ return monthnames[m - 1];
}
else
{
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/content/DCLanguage.java ./content/DCLanguage.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/content/DCLanguage.java 2002-11-01 15:59:12.000000000 -0200
+++ ./content/DCLanguage.java 2005-04-19 17:34:59.000000000 -0200
@@ -57,7 +57,7 @@
/** The language code. Special values: "" and "other". */
private String language;
-
+
/**
* Construct a language object from a database entry
*
@@ -67,7 +67,7 @@
{
setLanguage(l);
}
-
+
/**
* Write the language out to the database
*
@@ -88,14 +88,14 @@
return country + "_" + language;
}
}
-
+
/**
* Set the language and country
*
* @param l The language and country code, e.g. "en_US" or "fr"
*/
public void setLanguage(String l)
- {
+ {
if (l.equals("other"))
{
language = "other";
@@ -123,7 +123,7 @@
*
* @return the displayable name
*/
- public String getDisplayName()
+ public String getDisplayName(Locale inLocale)
{
Locale locale;
@@ -137,9 +137,9 @@
}
else
{
- locale = new Locale(language, country);
- return locale.getDisplayName();
+ locale = new Locale(language,country);
+ return locale.getDisplayName(inLocale);
}
}
-
+
}
diff -aur --exclude=MediaFilterManager.java --exclude=PDFFilter.java --exclude=EPersonAdminServlet.java --exclude=GroupEditServlet.java --exclude=RegisterServlet.java --exclude=SimpleAuthenticator.java ../../../../dspace-1.2-source-devel/src/org/dspace/content/Item.java ./content/Item.java
--- ../../../../dspace-1.2-source-devel/src/org/dspace/content/Item.java 2004-06-08 12:14:12.000000000 -0200
+++ ./content/Item.java 2005-04-19 17:34:59.000000000 -0200
@@ -220,7 +220,7 @@
{
// First check the cache