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(""); - } - } - - listCollections(); - - out.println("
"); - 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("

"); - - 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(""); - - 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(""); - } - } - - listCollections(); - - out.println("
DC FieldValueLanguage
"); - 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("

"); - - 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(""); - if (multiFile) - { - out.println(""); - } - out.println(""); - - // if primary bitstream is html, display a link for only that one to HTMLServlet - if (html) - { - // If no real Handle yet (e.g. because Item is in workflow) - // we use the 'fake' Handle db-id/1234 where 1234 is the - // database ID of the item. - if (handle == null) - { - handle = "db-id/" + item.getID(); - } - - out.print(""); - } - else - { - for (int i = 0; i < bundles.length; i++) - { - Bitstream[] bitstreams = bundles[i].getBitstreams(); - - for (int k = 0; k < bitstreams.length ; k++) - { - // Skip internal types - if (!bitstreams[k].getFormat().isInternal()) - { - out.print(""); - } - } - } - } - out.println("
FileDescriptionSizeFormat
"); - out.print(primaryBitstream.getName()); - if (multiFile) - { - out.print(""); - String desc = primaryBitstream.getDescription(); - out.print(desc != null ? desc : ""); - } - out.print(""); - out.print(primaryBitstream.getSize() / 1024); - out.print("Kb"); - out.print(primaryBitstream.getFormatDescription()); - out.print("View/Open
"); - out.print(bitstreams[k].getName()); - if (multiFile) - { - out.print(""); - String desc = bitstreams[k].getDescription(); - out.print(desc != null ? desc : ""); - } - out.print(""); - out.print(bitstreams[k].getSize() / 1024); - out.print("Kb"); - out.print(bitstreams[k].getFormatDescription()); - out.print(""); - - // Work out what the bitstream link should be (persistent ID if item has Handle) - String bsLink = " 0) - { - bsLink = bsLink + "/bitstream/" + item.getHandle() + "/" + - bitstreams[k].getSequenceID() + "/"; - } - else - { - bsLink = bsLink + "/retrieve/" + bitstreams[k].getID() + "/"; - } - - bsLink = bsLink + URLEncoder.encode(bitstreams[k].getName()) + "\">"; - - // is there a thumbnail bundle? - if(thumbs.length > 0) - { - String tName = bitstreams[k].getName()+".jpg"; - Bitstream tb = thumbs[0].getBitstreamByName(tName); - - if( tb != null ) - { - String myPath = request.getContextPath() + "/retrieve/" + tb.getID() - + "/" + URLEncoder.encode(tb.getName()); - - out.print(bsLink); - out.print("
"); - } - } - - out.print(bsLink + "View/Open
"); - } - - 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(""); + } + } + + listCollections(); + + out.println("
"); + 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("

"); + + 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(""); + + 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(""); + } + } + + listCollections(); + + out.println("
" + res.getString("ItemTag.field") + "" + res.getString("ItemTag.value") + "" + res.getString("ItemTag.lang") + "
"); + 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("

"); + + 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(""); + if (multiFile) + { + out.println(""); + } + out.println(""); + + // if primary bitstream is html, display a link for only that one to HTMLServlet + if (html) + { + // If no real Handle yet (e.g. because Item is in workflow) + // we use the 'fake' Handle db-id/1234 where 1234 is the + // database ID of the item. + if (handle == null) + { + handle = "db-id/" + item.getID(); + } + + out.print(""); + } + else + { + for (int i = 0; i < bundles.length; i++) + { + Bitstream[] bitstreams = bundles[i].getBitstreams(); + + for (int k = 0; k < bitstreams.length ; k++) + { + // Skip internal types + if (!bitstreams[k].getFormat().isInternal()) + { + out.print(""); + } + } + } + } + out.println("
" + res.getString("ItemTag.file") + "" + res.getString("ItemTag.fileDesc") + "" + res.getString("ItemTag.size") + "" + res.getString("ItemTag.format") + "
"); + out.print(primaryBitstream.getName()); + if (multiFile) + { + out.print(""); + String desc = primaryBitstream.getDescription(); + out.print(desc != null ? desc : ""); + } + out.print(""); + out.print(primaryBitstream.getSize() / 1024); + out.print("Kb"); + out.print(primaryBitstream.getFormatDescription()); + out.print("View/Open
"); + out.print(bitstreams[k].getName()); + if (multiFile) + { + out.print(""); + String desc = bitstreams[k].getDescription(); + out.print(desc != null ? desc : ""); + } + out.print(""); + out.print(bitstreams[k].getSize() / 1024); + out.print("Kb"); + out.print(bitstreams[k].getFormatDescription()); + out.print(""); + + // Work out what the bitstream link should be (persistent ID if item has Handle) + String bsLink = " 0) + { + bsLink = bsLink + "/bitstream/" + item.getHandle() + "/" + + bitstreams[k].getSequenceID() + "/"; + } + else + { + bsLink = bsLink + "/retrieve/" + bitstreams[k].getID() + "/"; + } + + bsLink = bsLink + URLEncoder.encode(bitstreams[k].getName()) + "\">"; + + // is there a thumbnail bundle? + if(thumbs.length > 0) + { + String tName = bitstreams[k].getName()+".jpg"; + Bitstream tb = thumbs[0].getBitstreamByName(tName); + + if( tb != null ) + { + String myPath = request.getContextPath() + "/retrieve/" + tb.getID() + + "/" + URLEncoder.encode(tb.getName()); + + out.print(bsLink); + out.print("
"); + } + } + + out.print(bsLink + res.getString("ItemTag.view") + "
"); + } + + 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(""); - + if (multiple) { out.print("
    "); @@ -157,16 +160,25 @@ { out.print(""); } - - String p = (multiple ? "people" : "person"); - out.print(""); - + if (multiple) { out.print(""); - out.print(""); + out.print(""); } out.println("
    "); @@ -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 Item fromCache = (Item) context.fromCache(Item.class, id); - + if (fromCache != null) { return fromCache; @@ -269,13 +269,13 @@ { TableRow row = DatabaseManager.create(context, "item"); Item i = new Item(context, row); - + // Call update to give the item a last modified date. OK this isn't // amazingly efficient but creates don't happen that often. context.setIgnoreAuthorization(true); i.update(); context.setIgnoreAuthorization(false); - + HistoryManager.saveHistory(context, i, HistoryManager.CREATE, @@ -330,7 +330,7 @@ return new ItemIterator(context, rows); } - + /** * Get the internal ID of this item. In general, this shouldn't be * exposed to users @@ -370,7 +370,7 @@ return itemRow.getBooleanColumn("withdrawn"); } - + /** * Get the date the item was last modified, or the current date * if last_modified is null @@ -381,13 +381,13 @@ public Date getLastModified() { Date myDate = itemRow.getDateColumn("last_modified"); - - if( myDate == null ) { myDate = new Date(); } + + if( myDate == null ) { myDate = new Date(); } return myDate; } - + /** * Set the "is_archived" flag. This is public and only * WorkflowItem.archive() should set this. @@ -415,7 +415,7 @@ * Get the owning Collection for the item * * @returns Collection that is the owner of the item - */ + */ public Collection getOwningCollection() throws java.sql.SQLException { @@ -423,7 +423,7 @@ // get the collection ID int cid = itemRow.getIntColumn("owning_collection"); - + myCollection = Collection.find(ourContext, cid); return myCollection; @@ -820,23 +820,23 @@ public Bundle[] getBundles(String name) { List matchingBundles = new ArrayList(); - + Iterator i = bundles.iterator(); - + // now only keep bundles with matching names while(i.hasNext()) { Bundle b = (Bundle)i.next(); - + if(name.equals(b.getName() )) { matchingBundles.add(b); } } - + Bundle [] bundleArray = new Bundle[matchingBundles.size()]; bundleArray = (Bundle[])matchingBundles.toArray(bundleArray); - + return bundleArray; } @@ -858,7 +858,7 @@ Bundle b = Bundle.create(ourContext); b.setName(name); b.update(); - + addBundle(b); return b; } @@ -976,7 +976,7 @@ return bitstream; } - + /** * Just for backwards compatibility - bitstream stored * in bundle "ORIGINAL" @@ -1050,7 +1050,7 @@ BitstreamFormat bf = BitstreamFormat.findByShortDescription( ourContext, "License"); b.setFormat(bf); - + b.update(); } @@ -1068,13 +1068,13 @@ // search through bundles, looking for bitstream type license Bundle[] buns = getBundles(); - + for(int i = 0; i < buns.length; i++) { boolean removethisbundle = false; - + Bitstream [] bits = buns[i].getBitstreams(); - + for(int j=0; j 0) { @@ -1370,8 +1383,8 @@ "reinstate_item", "user=" + e.getEmail() + ",item_id=" + getID())); } - - + + /** * Delete (expunge) the item. Bundles and bitstreams are also deleted if * they are not also included in another item. The Dublin Core metadata is @@ -1442,7 +1455,7 @@ if( this.getType() == other.getType() ) if( this.getID() == other.getID() ) return true; - + return false; } @@ -1458,7 +1471,7 @@ public boolean isOwningCollection(Collection c) { int owner_id = itemRow.getIntColumn("owning_collection"); - + if(c.getID() == owner_id) return true; else return false; } @@ -1484,14 +1497,14 @@ return Constants.ITEM; } - + /** * remove all of the policies for item and replace them * with a new list of policies * * @param newpolicies - this will be all of the new policies for * the item and its contents - */ + */ public void replaceAllItemPolicies( List newpolicies ) throws SQLException, AuthorizeException { @@ -1499,14 +1512,14 @@ AuthorizeManager.removeAllPolicies(ourContext, this); AuthorizeManager.addPolicies(ourContext, newpolicies, this); } - + /** * remove all of the policies for item's bitstreams and bundles * and replace them with a new list of policies * * @param newpolicies - this will be all of the new policies for * the bundle and bitstream contents - */ + */ public void replaceAllBitstreamPolicies( List newpolicies ) throws SQLException, AuthorizeException { @@ -1517,30 +1530,30 @@ for (int i = 0; i < bundles.length; i++) { Bundle mybundle = bundles[i]; - + Bitstream[] bs = mybundle.getBitstreams(); - + for(int j = 0; j < bs.length; j++ ) { Bitstream mybitstream = bs[j]; - // change bitstream policies + // change bitstream policies AuthorizeManager.removeAllPolicies(ourContext, bs[j]); AuthorizeManager.addPolicies(ourContext, newpolicies, bs[j]); } - // change bundle policies + // change bundle policies AuthorizeManager.removeAllPolicies(ourContext, mybundle); AuthorizeManager.addPolicies(ourContext, newpolicies, mybundle); } } - + /** * remove all of the policies for item's bitstreams and bundles - * that belong to a given Group + * that belong to a given Group * * @param g Group referenced by policies that needs to be removed - */ + */ public void removeGroupPolicies( Group g ) throws SQLException, AuthorizeException { @@ -1553,23 +1566,23 @@ for (int i = 0; i < bundles.length; i++) { Bundle mybundle = bundles[i]; - + Bitstream[] bs = mybundle.getBitstreams(); - + for(int j = 0; j < bs.length; j++ ) { Bitstream mybitstream = bs[j]; - // remove bitstream policies + // remove bitstream policies AuthorizeManager.removeGroupPolicies(ourContext, bs[j], g); } - // change bundle policies + // change bundle policies AuthorizeManager.removeGroupPolicies(ourContext, mybundle, g); } } - + /** * remove all policies on an item and its contents, and * replace them with the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ @@ -1597,13 +1610,13 @@ { throw new java.sql.SQLException( "Collection " + c.getID() + " has no default item READ policies"); } - + while( i.hasNext() ) { ResourcePolicy rp = (ResourcePolicy)i.next(); rp.setAction( Constants.READ ); } - + replaceAllItemPolicies(policies); policies = AuthorizeManager.getPoliciesActionFilter(ourContext, @@ -1617,7 +1630,7 @@ { throw new java.sql.SQLException( "Collection " + c.getID() + " has no default bitstream READ policies"); } - + while( i.hasNext() ) { ResourcePolicy rp = (ResourcePolicy)i.next(); @@ -1626,9 +1639,9 @@ replaceAllBitstreamPolicies(policies); } - - - + + + /** * return TRUE if context's user can edit item, false otherwise * @@ -1642,14 +1655,14 @@ { return true; } - + // is this person an COLLECTION_EDITOR for the owning collection? if( AuthorizeManager.authorizeActionBoolean(ourContext, getOwningCollection(), Constants.COLLECTION_ADMIN)) { return true; - } - + } + return false; } } 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/eperson/EPerson.java ./eperson/EPerson.java --- ../../../../dspace-1.2-source-devel/src/org/dspace/eperson/EPerson.java 2004-03-31 14:38:12.000000000 -0200 +++ ./eperson/EPerson.java 2005-04-19 17:34:59.000000000 -0200 @@ -1,9 +1,9 @@ /* * EPerson * - * Version: $Revision: 1.22 $ + * Version: $Revision: 1.24 $ * - * Date: $Date: 2004/03/31 17:38:12 $ + * Date: $Date: 2004/12/22 17:48:36 $ * * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts * Institute of Technology. All rights reserved. @@ -37,22 +37,20 @@ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ - package org.dspace.eperson; -import org.apache.log4j.Logger; - import java.sql.SQLException; import java.util.List; import java.util.Vector; +import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeManager; import org.dspace.content.DSpaceObject; -import org.dspace.core.Context; import org.dspace.core.Constants; -import org.dspace.core.Utils; +import org.dspace.core.Context; import org.dspace.core.LogManager; +import org.dspace.core.Utils; import org.dspace.history.HistoryManager; import org.dspace.storage.rdbms.DatabaseManager; import org.dspace.storage.rdbms.TableRow; @@ -60,9 +58,9 @@ /** * Class representing an e-person. - * + * * @author David Stuve - * @version $Revision: 1.22 $ + * @version $Revision: 1.24 $ */ public class EPerson extends DSpaceObject { @@ -75,22 +73,27 @@ /** The e-mail field (for sorting) */ public static final int ID = 3; + /** The netid field (for sorting) */ + public static final int NETID = 4; + + /** log4j logger */ + private static Logger log = Logger.getLogger(EPerson.class); + /** Our context */ private Context myContext; /** The row in the table representing this eperson */ private TableRow myRow; - /** log4j logger */ - private static Logger log = Logger.getLogger(EPerson.class); - - /** * Construct an EPerson - * @param context the context this object exists in - * @param row the corresponding row in the table + * + * @param context + * the context this object exists in + * @param row + * the corresponding row in the table */ - EPerson( Context context, TableRow row ) + EPerson(Context context, TableRow row) { myContext = context; myRow = row; @@ -101,14 +104,15 @@ /** * Get an EPerson from the database. - * - * @param context DSpace context object - * @param id ID of the EPerson - * - * @return the EPerson format, or null if the ID is invalid. + * + * @param context + * DSpace context object + * @param id + * ID of the EPerson + * + * @return the EPerson format, or null if the ID is invalid. */ - public static EPerson find(Context context, int id) - throws SQLException + public static EPerson find(Context context, int id) throws SQLException { // First check the cache EPerson fromCache = (EPerson) context.fromCache(EPerson.class, id); @@ -118,29 +122,62 @@ return fromCache; } - TableRow row = DatabaseManager.find( context, "eperson", id ); + TableRow row = DatabaseManager.find(context, "eperson", id); - if ( row == null ) + if (row == null) { return null; } else { - return new EPerson( context, row ); + return new EPerson(context, row); } } - /** * Find the eperson by their email address - * + * * @return EPerson */ public static EPerson findByEmail(Context context, String email) + throws SQLException, AuthorizeException + { + TableRow row = DatabaseManager.findByUnique(context, "eperson", + "email", email); + + if (row == null) + { + return null; + } + else + { + // First check the cache + EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row + .getIntColumn("eperson_id")); + + if (fromCache != null) + { + return fromCache; + } + else + { + return new EPerson(context, row); + } + } + } + + /** + * Find the eperson by their netid + * + * @author John Finlay + * @return EPerson + */ + public static EPerson findByNetid(Context context, String netid) throws SQLException, AuthorizeException { + if (netid==null) return null; - TableRow row = DatabaseManager.findByUnique( context, "eperson", "email", email ); + TableRow row = DatabaseManager.findByUnique( context, "eperson", "netid", netid ); if ( row == null ) { @@ -166,19 +203,20 @@ /** - * Retrieve all e-person records from the database, sorted by a - * particular field. Fields are: + * Retrieve all e-person records from the database, sorted by a particular + * field. Fields are: *

    */ public static EPerson[] findAll(Context context, int sortField) - throws SQLException + throws SQLException { String s; - + switch (sortField) { case ID: @@ -189,25 +227,28 @@ s = "email"; break; + case NETID: + s = "netid"; + break; + default: s = "lastname"; } - + TableRowIterator rows = DatabaseManager.query(context, - "SELECT * FROM eperson ORDER BY " + s); + "SELECT * FROM eperson ORDER BY " + s); List epeopleRows = rows.toList(); - + EPerson[] epeople = new EPerson[epeopleRows.size()]; - + for (int i = 0; i < epeopleRows.size(); i++) { TableRow row = (TableRow) epeopleRows.get(i); // First check the cache - EPerson fromCache = (EPerson) context.fromCache( - EPerson.class, - row.getIntColumn("eperson_id")); + EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row + .getIntColumn("eperson_id")); if (fromCache != null) { @@ -220,101 +261,87 @@ } return epeople; - } - + } /** * Create a new eperson - * - * @param context DSpace context object + * + * @param context + * DSpace context object */ - public static EPerson create(Context context) - throws SQLException, AuthorizeException + public static EPerson create(Context context) throws SQLException, + AuthorizeException { // authorized? - if( !AuthorizeManager.isAdmin(context) ) + if (!AuthorizeManager.isAdmin(context)) { throw new AuthorizeException( - "You must be an admin to create an EPerson"); + "You must be an admin to create an EPerson"); } - + // Create a table row TableRow row = DatabaseManager.create(context, "eperson"); EPerson e = new EPerson(context, row); - log.info( - LogManager.getHeader(context, - "create_eperson", - "eperson_id=" + e.getID() ) - ); - - HistoryManager.saveHistory(context, - e, - HistoryManager.REMOVE, - context.getCurrentUser(), - context.getExtraLogInfo()); + log.info(LogManager.getHeader(context, "create_eperson", "eperson_id=" + + e.getID())); + + HistoryManager.saveHistory(context, e, HistoryManager.REMOVE, context + .getCurrentUser(), context.getExtraLogInfo()); return e; } - /** * Delete an eperson - * + * */ - public void delete() - throws SQLException, AuthorizeException, EPersonDeletionException + public void delete() throws SQLException, AuthorizeException, + EPersonDeletionException { // authorized? - if( !AuthorizeManager.isAdmin(myContext) ) + if (!AuthorizeManager.isAdmin(myContext)) { throw new AuthorizeException( - "You must be an admin to delete an EPerson"); + "You must be an admin to delete an EPerson"); } - HistoryManager.saveHistory(myContext, - this, - HistoryManager.REMOVE, - myContext.getCurrentUser(), - myContext.getExtraLogInfo()); + HistoryManager.saveHistory(myContext, this, HistoryManager.REMOVE, + myContext.getCurrentUser(), myContext.getExtraLogInfo()); //check for presence of eperson in tables that //have constraints on eperson_id Vector constraintList = getDeleteConstraints(); - + //if eperson exists in tables that have constraints //on eperson, throw an exception - if(constraintList.size() > 0) + if (constraintList.size() > 0) + { throw new EPersonDeletionException(constraintList); - + } + // Remove from cache myContext.removeCached(this, getID()); - // Remove any group memberships first - DatabaseManager.updateQuery(myContext, - "DELETE FROM EPersonGroup2EPerson WHERE eperson_id=" + - getID() ); - + // Remove any group memberships first + DatabaseManager.updateQuery(myContext, + "DELETE FROM EPersonGroup2EPerson WHERE eperson_id=" + getID()); + // Remove any subscriptions - DatabaseManager.updateQuery(myContext, - "DELETE FROM subscription WHERE eperson_id=" + - getID() ); + DatabaseManager.updateQuery(myContext, + "DELETE FROM subscription WHERE eperson_id=" + getID()); // Remove ourself DatabaseManager.delete(myContext, myRow); - log.info( - LogManager.getHeader(myContext, - "delete_eperson", - "eperson_id=" + getID() ) - ); + log.info(LogManager.getHeader(myContext, "delete_eperson", + "eperson_id=" + getID())); } - /** * Get the e-person's internal identifier - * + * * @return the internal identifier */ public int getID() @@ -322,29 +349,27 @@ return myRow.getIntColumn("eperson_id"); } - public String getHandle() { // No Handles for e-people return null; } - /** * Get the e-person's email address - * - * @return their email address + * + * @return their email address */ public String getEmail() { return myRow.getStringColumn("email"); } - /** * Set the EPerson's email - * - * @param s the new email + * + * @param s + * the new email */ public void setEmail(String s) { @@ -352,23 +377,48 @@ { s = s.toLowerCase(); } - + myRow.setColumn("email", s); } + /** + * Get the e-person's netid + * + * @return their netid + */ + public String getNetid() + { + return myRow.getStringColumn("netid"); + } + /** - * Get the e-person's full name, combining first and last name - * in a displayable string. + * Set the EPerson's netid * - * @return their full name + * @param s the new netid + */ + public void setNetid(String s) + { + if (s != null) + { + s = s.toLowerCase(); + } + + myRow.setColumn("netid", s); + } + + /** + * Get the e-person's full name, combining first and last name in a + * displayable string. + * + * @return their full name */ public String getFullName() { String f = myRow.getStringColumn("firstname"); String l = myRow.getStringColumn("lastname"); - - if (l == null && f == null) + + if ((l == null) && (f == null)) { return getEmail(); } @@ -382,10 +432,9 @@ } } - /** * Get the eperson's first name. - * + * * @return their first name */ public String getFirstName() @@ -393,21 +442,20 @@ return myRow.getStringColumn("firstname"); } - /** * Set the eperson's first name - * - * @param firstname the person's first name + * + * @param firstname + * the person's first name */ public void setFirstName(String firstname) { myRow.setColumn("firstname", firstname); } - /** * Get the eperson's last name. - * + * * @return their last name */ public String getLastName() @@ -415,22 +463,22 @@ return myRow.getStringColumn("lastname"); } - /** * Set the eperson's last name - * - * @param lastname the person's last name + * + * @param lastname + * the person's last name */ public void setLastName(String lastname) { myRow.setColumn("lastname", lastname); } - /** * Indicate whether the user can log in - * - * @param login boolean yes/no + * + * @param login + * boolean yes/no */ public void setCanLogIn(boolean login) { @@ -439,7 +487,7 @@ /** * Can the user log in? - * + * * @return boolean, yes/no */ public boolean canLogIn() @@ -447,21 +495,20 @@ return myRow.getBooleanColumn("can_log_in"); } - /** * Set require cert yes/no - * - * @param isrequired boolean yes/no + * + * @param isrequired + * boolean yes/no */ public void setRequireCertificate(boolean isrequired) { myRow.setColumn("require_certificate", isrequired); } - /** * Get require certificate or not - * + * * @return boolean, yes/no */ public boolean getRequireCertificate() @@ -469,11 +516,11 @@ return myRow.getBooleanColumn("require_certificate"); } - /** * Indicate whether the user self-registered - * - * @param sr boolean yes/no + * + * @param sr + * boolean yes/no */ public void setSelfRegistered(boolean sr) { @@ -482,7 +529,7 @@ /** * Can the user log in? - * + * * @return boolean, yes/no */ public boolean getSelfRegistered() @@ -490,56 +537,57 @@ return myRow.getBooleanColumn("self_registered"); } - /** * Get the value of a metadata field - * - * @param field the name of the metadata field to get - * - * @return the value of the metadata field - * - * @exception IllegalArgumentException if the requested metadata - * field doesn't exist + * + * @param field + * the name of the metadata field to get + * + * @return the value of the metadata field + * + * @exception IllegalArgumentException + * if the requested metadata field doesn't exist */ public String getMetadata(String field) { - return myRow.getStringColumn(field); + return myRow.getStringColumn(field); } - /** * Set a metadata value - * - * @param field the name of the metadata field to get - * @param value value to set the field to - * - * @exception IllegalArgumentException if the requested metadata - * field doesn't exist + * + * @param field + * the name of the metadata field to get + * @param value + * value to set the field to + * + * @exception IllegalArgumentException + * if the requested metadata field doesn't exist */ public void setMetadata(String field, String value) { - myRow.setColumn(field, value); + myRow.setColumn(field, value); } - /** * Set the EPerson's password - * - * @param s the new email + * + * @param s + * the new email */ public void setPassword(String s) { - // FIXME: encoding + // FIXME: encoding String encoded = Utils.getMD5(s); myRow.setColumn("password", encoded); } - /** * Check EPerson's password - * - * @param attempt the password attempt + * + * @param attempt + * the password attempt * @return boolean successful/unsuccessful */ public boolean checkPassword(String attempt) @@ -549,45 +597,38 @@ return (encoded.equals(myRow.getStringColumn("password"))); } - /** * Update the EPerson */ - public void update() - throws SQLException, AuthorizeException + public void update() throws SQLException, AuthorizeException { // Check authorisation - if you're not the eperson // see if the authorization system says you can - if(!myContext.ignoreAuthorization() && - (myContext.getCurrentUser() == null || - getID() != myContext.getCurrentUser().getID())) + if (!myContext.ignoreAuthorization() + && ((myContext.getCurrentUser() == null) || (getID() != myContext + .getCurrentUser().getID()))) { AuthorizeManager.authorizeAction(myContext, this, Constants.WRITE); } - + DatabaseManager.update(myContext, myRow); - log.info( - LogManager.getHeader(myContext, - "update_eperson", - "eperson_id=" + getID() ) - ); - - HistoryManager.saveHistory(myContext, - this, - HistoryManager.MODIFY, - myContext.getCurrentUser(), - myContext.getExtraLogInfo()); + log.info(LogManager.getHeader(myContext, "update_eperson", + "eperson_id=" + getID())); + + HistoryManager.saveHistory(myContext, this, HistoryManager.MODIFY, + myContext.getCurrentUser(), myContext.getExtraLogInfo()); } /** * Return true if other is the same EPerson as * this object, false otherwise - * - * @param other object to compare to - * - * @return true if object passed in represents the same - * eperson as this object + * + * @param other + * object to compare to + * + * @return true if object passed in represents the same + * eperson as this object */ public boolean obsolete_equals(Object other) { @@ -599,7 +640,6 @@ return (getID() == ((EPerson) other).getID()); } - /** * return type found in Constants */ @@ -607,53 +647,50 @@ { return Constants.EPERSON; } - - + /** - * Check for presence of EPerson in tables that have constraints - * on EPersons. Called by delete() to determine whether the - * eperson can actually be deleted. - * - * An EPerson cannot be deleted if it exists in the item, - * workflowitem, or tasklistitem tables. - * - * @return Vector of tables that contain a reference to the - * eperson. + * Check for presence of EPerson in tables that have constraints on + * EPersons. Called by delete() to determine whether the eperson can + * actually be deleted. + * + * An EPerson cannot be deleted if it exists in the item, workflowitem, or + * tasklistitem tables. + * + * @return Vector of tables that contain a reference to the eperson. */ - public Vector getDeleteConstraints() - throws SQLException + public Vector getDeleteConstraints() throws SQLException { Vector tableList = new Vector(); - + //check for eperson in item table TableRowIterator tri = DatabaseManager.query(myContext, - "SELECT * from item where submitter_id=" + getID()); - - if(tri.hasNext()) + "SELECT * from item where submitter_id=" + getID()); + + if (tri.hasNext()) { tableList.add("item"); } - + //check for eperson in workflowitem table tri = DatabaseManager.query(myContext, - "SELECT * from workflowitem where owner=" + getID()); - - if(tri.hasNext()) + "SELECT * from workflowitem where owner=" + getID()); + + if (tri.hasNext()) { tableList.add("workflowitem"); } - - //check for eperson in tasklistitem table + + //check for eperson in tasklistitem table tri = DatabaseManager.query(myContext, "SELECT * from tasklistitem where eperson_id=" + getID()); - if(tri.hasNext()) + if (tri.hasNext()) { - tableList.add("tasklistitem"); + tableList.add("tasklistitem"); } - - //the list of tables can be used to construct an error message + + //the list of tables can be used to construct an error message //explaining to the user why the eperson cannot be deleted. - return tableList; + return tableList; } -} +} \ No newline at end of file Only in ./eperson: EPerson.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/search/DSIndexer.java ./search/DSIndexer.java --- ../../../../dspace-1.2-source-devel/src/org/dspace/search/DSIndexer.java 2004-07-23 12:34:36.000000000 -0200 +++ ./search/DSIndexer.java 2005-04-19 17:34:59.000000000 -0200 @@ -132,7 +132,7 @@ else { // FIXME: no handle, fail quietly - should log failure - //System.out.println("Error in unIndexContent: Object had no handle!"); + //System.out.println("Error in unIndexContent: Object had no handle!"); } } @@ -145,7 +145,7 @@ throws SQLException, IOException { unIndexContent(c, dso); - indexContent(c, dso); + indexContent(c, dso); } @@ -165,7 +165,7 @@ // optimize the index - important to do regularly to reduce filehandle usage // and keep performance fast! writer.optimize(); - + closeIndex(c, writer); } @@ -185,7 +185,7 @@ unIndexContent(c, args[1]); } else - { + { c.setIgnoreAuthorization(true); createIndex(c); @@ -386,6 +386,8 @@ DCValue [] mimetypes = myitem.getDC( "format", "mimetype", Item.ANY ); DCValue [] sponsors = myitem.getDC( "description", "sponsorship", Item.ANY ); DCValue [] identifiers = myitem.getDC( "identifier", Item.ANY, Item.ANY ); + DCValue [] languages = myitem.getDC( "language", Item.ANY, Item.ANY ); + // put them all from an array of strings to one string for writing out @@ -400,6 +402,7 @@ String mime_text = ""; String sponsor_text = ""; String id_text = ""; + String lang_text = ""; // pack all of the arrays of DCValues into plain text strings for the indexer @@ -407,7 +410,7 @@ { author_text = new String(author_text + authors[j].value + " "); } - + for(j=0; j 0 ) { sb.append(charBuffer, 0, bytesIn); } } - - + + // now sb has the full text - tack on to fullText string extractedText = extractedText.concat(new String(sb)); - + // System.out.println("Found extracted text!\n" + new String(sb)); } catch(AuthorizeException e) @@ -520,7 +529,9 @@ textvalues.put("mimetype", mime_text ); textvalues.put("sponsor", sponsor_text ); textvalues.put("identifier",id_text ); - + textvalues.put("language", lang_text ); + + // write out the metatdata (for scalability, using hash instead of individual strings) writeIndexRecord(writer, Constants.ITEM, itemhandle, textvalues, extractedText); } @@ -541,7 +552,7 @@ doc.add(Field.UnIndexed("type", ty.toString() )); // want to be able to search for handle, so use keyword - // (not tokenized, but it is indexed) + // (not tokenized, but it is indexed) if(handle != null) { doc.add(Field.Keyword ("handle", handle )); @@ -564,7 +575,7 @@ } fulltext = fulltext.concat(extractedText); - + // System.out.println("Full Text:\n" + fulltext + "------------\n\n"); // add the full text 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/search/QueryArgs.java ./search/QueryArgs.java --- ../../../../dspace-1.2-source-devel/src/org/dspace/search/QueryArgs.java 2004-06-10 19:40:00.000000000 -0200 +++ ./search/QueryArgs.java 2005-04-19 17:34:59.000000000 -0200 @@ -42,6 +42,7 @@ package org.dspace.search; +import java.net.URLEncoder; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Iterator; @@ -55,7 +56,7 @@ { // the query string private String query; - + // start and count defines a search 'cursor' or page // query will return 'count' hits beginning at offset 'start' private int start = 0; // default values @@ -68,14 +69,14 @@ */ public void setQuery( String newQuery ) { query = newQuery; } - + /** * retrieve the query string * @return the current query string */ public String getQuery() { return query; } - - + + /** * set the offset of the desired search results, * beginning with 0 ; used to page results @@ -83,15 +84,15 @@ * @param newStart index of first desired result */ public void setStart( int newStart ) { start = newStart; } - - + + /** * read the search's starting offset * @return current index of first desired result */ public int getStart() { return start; } - - + + /** * set the count of hits to return; * used to implement paged searching @@ -99,56 +100,57 @@ * @param newSize number of hits per page */ public void setPageSize( int newSize ) { pageSize = newSize; } - - + + /** * get the count of hits to return * @return number of results per page */ public int getPageSize() { return pageSize; } - + public String buildQuery (HttpServletRequest request) { - String newquery = "("; + + String newquery = "("; String query1 = request.getParameter("query1"); String query2 = request.getParameter("query2"); String query3 = request.getParameter("query3"); - + String field1 = request.getParameter("field1"); String field2 = request.getParameter("field2"); String field3 = request.getParameter("field3"); String conjunction1 = request.getParameter("conjunction1"); String conjunction2 = request.getParameter("conjunction2"); - + if (query1.length() > 0) - { - newquery = newquery + buildQueryPart(query1, field1); + { + newquery = newquery + buildQueryPart(query1, field1); } - + if (query2.length() > 0) { newquery = newquery + " " + conjunction1 + " "; - newquery = newquery + buildQueryPart(query2, field2); + newquery = newquery + buildQueryPart(query2, field2); } - + newquery = newquery + ")"; - + if (query3.length() > 0) { newquery = newquery + " " + conjunction2 + " "; - newquery = newquery + buildQueryPart(query3, field3); + newquery = newquery + buildQueryPart(query3, field3); } return (newquery); } - + private String buildQueryPart (String myquery, String myfield) - { + { Perl5Util util = new Perl5Util(); String newquery = "("; String pattern = ""; - + if (!myfield.equals("ANY")) { newquery = newquery + myfield + ":"; myquery = util.substitute("s/\'(.*)\'/\"$1\"/g", myquery); @@ -163,37 +165,37 @@ } public HashMap buildQueryHash (HttpServletRequest request) - { + { HashMap queryHash = new HashMap(); queryHash.put("query1", request.getParameter("query1") == null ? "" : request.getParameter("query1")); queryHash.put("query2", request.getParameter("query2") == null ? "" : request.getParameter("query2")); queryHash.put("query3", request.getParameter("query3") == null ? "" : request.getParameter("query3")); - + queryHash.put("field1", request.getParameter("field1") == null ? "ANY" : request.getParameter("field1")); queryHash.put("field2", request.getParameter("field2") == null ? "ANY" : request.getParameter("field2")); queryHash.put("field3", request.getParameter("field3") == null ? "ANY" : request.getParameter("field3")); queryHash.put("conjunction1", request.getParameter("conjunction1") == null ? "AND" : request.getParameter("conjunction1")); queryHash.put("conjunction2", request.getParameter("conjunction2") == null ? "AND" : request.getParameter("conjunction1")); - + return (queryHash); } public String buildHTTPQuery (HttpServletRequest request) - { + { String querystring = ""; HashMap queryHash = buildQueryHash(request); - + Iterator i = queryHash.keySet().iterator(); while(i.hasNext()) { String key = (String)i.next(); String value = (String)queryHash.get(key); - + try {value = URLEncoder.encode(value,"UTF-8");} catch(Exception e) {} querystring = querystring + "&" + key + "=" + value; } - + return (querystring); }