ico
diff --unified --recursive --new-file dspace-1.4.1-source/jsp/WEB-INF/dspace-tags.tld dspace-1.4.1-source-modified/jsp/WEB-INF/dspace-tags.tld
--- dspace-1.4.1-source/jsp/WEB-INF/dspace-tags.tld 2006-03-15 15:14:02.000000000 -0600
+++ dspace-1.4.1-source-modified/jsp/WEB-INF/dspace-tags.tld 2007-04-04 11:03:02.412379000 -0500
@@ -415,5 +415,18 @@
+
+ reflink
+ edu.wisc.doit.lira.dspace.RefworksLinkTag
+
+ Tag to display an Refworks query for a particular item. This just gives the
+ query URL, it does not render an actual link.
+
+
+ handle
+ true
+ true
+
+
diff --unified --recursive --new-file dspace-1.4.1-source/jsp/display-item.jsp dspace-1.4.1-source-modified/jsp/display-item.jsp
--- dspace-1.4.1-source/jsp/display-item.jsp 2006-09-11 19:00:36.000000000 -0500
+++ dspace-1.4.1-source-modified/jsp/display-item.jsp 2007-04-04 11:03:49.618739000 -0500
@@ -227,6 +227,18 @@
<%
}
%>
+ <%-- REF Link --%>
+<%
+ if (ConfigurationManager.getProperty("refworks.server.url") != null)
+ {
+%>
+
+ "/>" target="RefWorksMain">
+
+<%
+ }
+%>
+
<%-- SFX Link --%>
<%
if (ConfigurationManager.getProperty("sfx.server.url") != null)
diff --unified --recursive --new-file dspace-1.4.1-source/src/edu/wisc/doit/lira/dspace/RefworksLinkTag.java dspace-1.4.1-source-modified/src/edu/wisc/doit/lira/dspace/RefworksLinkTag.java
--- dspace-1.4.1-source/src/edu/wisc/doit/lira/dspace/RefworksLinkTag.java 1969-12-31 18:00:00.000000000 -0600
+++ dspace-1.4.1-source-modified/src/edu/wisc/doit/lira/dspace/RefworksLinkTag.java 2007-04-04 10:54:39.000000000 -0500
@@ -0,0 +1,91 @@
+/*
+ * RefworksLinkTag.java
+ *
+ * Version: $Id: $
+ *
+ * Date: $Date: $
+ *
+ */
+package edu.wisc.doit.lira.dspace;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.dspace.core.ConfigurationManager;
+
+
+/**
+ * Renders an Refworks query link.
+ *
+ *
+ * @author Rose Smith (adapted from Gabriela Mircea)
+ * @version $Revision: 1.0 $
+ */
+public class RefworksLinkTag extends TagSupport
+{
+ /** Item to display Refworks link for */
+ private String handle;
+
+ public RefworksLinkTag()
+ {
+ super();
+ }
+
+ public int doStartTag() throws JspException
+ {
+ try
+ {
+ String refServer = ConfigurationManager
+ .getProperty("refworks.server.url");
+
+ String refServlet = ConfigurationManager
+ .getProperty("refworks.servlet.path");
+
+ if ((refServer == null) || (refServlet == null))
+ {
+ // No RefWorks server or servlet
+ return SKIP_BODY;
+ }
+
+ HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
+ String thisURL = request.getRequestURL().toString();
+ String servletPath = request.getServletPath();
+ int i = thisURL.lastIndexOf(servletPath);
+ thisURL = thisURL.substring(0, i);
+
+ pageContext.getOut().print(refServer + URLEncoder.encode(thisURL + refServlet + handle, "UTF-8") );
+ }
+ catch (IOException ie)
+ {
+ throw new JspException(ie);
+ }
+
+ return SKIP_BODY;
+ }
+
+ /**
+ * Get the handle this tag should display Refworks Link for
+ *
+ * @return the handle
+ */
+ public String getHandle()
+ {
+ return handle;
+ }
+
+ /**
+ * Set the handle this tag should display Refworks Link for
+ *
+ * @param handleIn
+ */
+ public void setHandle(String handleIn)
+ {
+ handle = handleIn;
+ }
+}
+
+
diff --unified --recursive --new-file dspace-1.4.1-source/src/edu/wisc/doit/lira/dspace/RefworksServlet.java dspace-1.4.1-source-modified/src/edu/wisc/doit/lira/dspace/RefworksServlet.java
--- dspace-1.4.1-source/src/edu/wisc/doit/lira/dspace/RefworksServlet.java 1969-12-31 18:00:00.000000000 -0600
+++ dspace-1.4.1-source-modified/src/edu/wisc/doit/lira/dspace/RefworksServlet.java 2007-04-04 10:54:39.000000000 -0500
@@ -0,0 +1,344 @@
+/*
+ * RefworksServlet.java
+ *
+ * Version: $Id: $
+ *
+ * Date: $Date: $
+ *
+ */
+
+package edu.wisc.doit.lira.dspace;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.sql.SQLException;
+import java.util.Date;
+import java.text.DateFormat;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+import org.apache.log4j.Logger;
+
+import org.dspace.app.webui.servlet.DSpaceServlet;
+import org.dspace.content.DCPersonName;
+import org.dspace.content.DCValue;
+import org.dspace.content.Item;
+import org.dspace.core.Context;
+import org.dspace.core.LogManager;
+import org.dspace.handle.HandleManager;
+
+
+/**
+ * Servlet for exporting an item to RefWorks
+ *
+ * A handle is extracted from the query string
+ * and used to obtain the item and its DC metadata
+ *
+ * A record in Refworks Tagged Format is assembled and output
+ *
+ * @author Rose Smith (adapted from Gabriela Mircea)
+ * @version $Revision: 1.0 $
+ */
+public class RefworksServlet extends DSpaceServlet
+{
+ /** log4j category */
+ private static Logger log = Logger.getLogger(RefworksServlet.class);
+
+ protected void doDSGet(Context context, HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException, SQLException, UnsupportedEncodingException
+ {
+ // Obtain information from request
+ String handle = request.getParameter("handle");
+ Item item;
+ String exportString = null;
+
+ if (handle != null && !handle.equals(""))
+ {
+ item = (Item) HandleManager.resolveToObject(context, handle);
+ if (item != null)
+ {
+ exportString = getExportOutput(item);
+ if (exportString != null && exportString.length() > 0)
+ {
+ //export the Refworks-formatted record
+ response.setContentType("text/plain");
+ PrintWriter out = response.getWriter();
+ out.print(exportString);
+ out.flush();
+ out.close();
+ }
+ }
+ return;
+ }
+ else
+ {
+ log.info(LogManager.getHeader(context, "invalid handle", "handle=" + handle));
+ return;
+ }
+
+ }
+
+ protected void doDSPost(Context context, HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException, SQLException, UnsupportedEncodingException
+ {
+ // Treat as a GET
+ doDSGet(context, request, response);
+ }
+
+/**
+* Build the output that gets sent to Refworks
+* This code was taken from Gabriela Mircea's
+* RefworksLinkTag code for UToronto
+*/
+ private String getExportOutput(Item item) throws UnsupportedEncodingException
+ {
+ StringBuffer sb = new StringBuffer();
+ DCValue[] type = item.getDC("type", null, Item.ANY);
+ if (type.length > 0)
+ {
+ String s_type = type[0].value;
+
+ if (s_type.equals("Animation"))
+ s_type = "Computer Program";
+ else if (s_type.equals("Article"))
+ s_type = "Journal, Electronic";
+ else if (s_type.equals("Book"))
+ s_type = "Book, Whole";
+ else if (s_type.equals("Book chapter"))
+ s_type = "Book, Section";
+ else if (s_type.equals("Dataset"))
+ s_type = "Generic";
+ else if (s_type.equals("Image"))
+ s_type = "Artwork";
+ else if (s_type.equals("Image, 3-D"))
+ s_type = "Artwork";
+ else if (s_type.equals("Learning Object"))
+ s_type = "Generic";
+ else if (s_type.equals("Map"))
+ s_type = "Map";
+ else if (s_type.equals("Musical Score"))
+ s_type = "Music Score";
+ else if (s_type.equals("Other"))
+ s_type = "Generic";
+ else if (s_type.equals("Plan or blueprint"))
+ s_type = "Generic";
+ else if (s_type.equals("Preprint"))
+ s_type = "Generic";
+ else if (s_type.equals("Presentation"))
+ s_type = "Generic";
+ else if (s_type.equals("Recording, acoustical"))
+ s_type = "Sound Recording";
+ else if (s_type.equals("Recording, musical"))
+ s_type = "Sound Recording";
+ else if (s_type.equals("Recording, oral"))
+ s_type = "Sound Recording";
+ else if (s_type.equals("Software"))
+ s_type = "Computer Program";
+ else if (s_type.equals("Technical Report"))
+ s_type = "Report";
+ else if (s_type.equals("Thesis"))
+ s_type = "Dissertation/Thesis";
+ else if (s_type.equals("Video"))
+ s_type = "Video/DVD";
+ else if (s_type.equals("Working Paper"))
+ s_type = "Report";
+
+ sb.append("RT " + s_type + "\n");
+ }
+
+ DCValue[] titles = item.getDC("title", null, Item.ANY);
+
+ if (titles.length > 0)
+ sb.append("T1 " + titles[0].value + "\n");
+
+ DCValue[] titlesa = item.getDC("title", "alternative", Item.ANY);
+
+ if (titlesa.length > 0)
+ sb.append("T2 " + titlesa[0].value + "\n");
+
+ DCValue[] authors = item.getDC("contributor", "author", Item.ANY);
+
+ if (authors.length > 0)
+ {
+ for (int i = 0; i < authors.length; i++ )
+ {
+ String auth = authors[i].value;
+ int commafirstIndex = auth.indexOf(",");
+ int commalastIndex = auth.lastIndexOf(",");
+
+ if ( commalastIndex > commafirstIndex)
+ {
+ sb.append("A1 " + auth.substring(0, commalastIndex) +"\n");
+ if (!auth.substring(commalastIndex+1).equals(null) ||!auth.substring(commalastIndex+1).equals(" ") )
+ sb.append("AD " + auth.substring(commalastIndex+1) + "\n");
+ }
+ else
+ sb.append("A1 " + auth +"\n");
+ }
+ }
+
+
+ DCValue[] editor = item.getDC("contributor", "editor", Item.ANY);
+
+ if (editor.length > 0)
+ {
+ for (int i = 0; i < editor.length; i++ )
+ {
+ DCPersonName dpn = new DCPersonName(editor[i].value);
+ sb.append("A2 " + dpn.getLastName() + dpn.getFirstNames() +"\n");
+ }
+ }
+
+ DCValue[] illustrator = item.getDC("contributor", "illustrator", Item.ANY);
+
+ if (illustrator.length > 0)
+ {
+ for (int i = 0; i < illustrator.length; i++ )
+ {
+ DCPersonName dpn = new DCPersonName(illustrator[i].value);
+ sb.append("A2 " + dpn.getLastName() + dpn.getFirstNames() +"\n");
+ }
+ }
+
+ DCValue[] other = item.getDC("contributor", "other", Item.ANY);
+
+ if (other.length > 0)
+ {
+ for (int i = 0; i < other.length; i++ )
+ {
+ DCPersonName dpn = new DCPersonName(other[i].value);
+ sb.append("A2 " + dpn.getLastName() + dpn.getFirstNames() +"\n");
+ }
+ }
+
+ DCValue[] keyword = item.getDC("subject", Item.ANY, Item.ANY);
+
+ if (keyword.length > 0)
+ {
+ for (int i = 0; i < keyword.length; i++ )
+ {
+ sb.append("K1 " + keyword[i].value + "\n");
+ }
+ }
+
+ DCValue[] abs = item.getDC("description", "abstract", Item.ANY);
+
+ if (abs.length > 0)
+ {
+ byte [] b_abs = ((abs[0].value).replaceAll("\n","").replaceAll("\r","")).getBytes("UTF-8");
+ String s_abs = new String(b_abs);
+ sb.append("AB " + s_abs + "\n");
+ }
+
+ DCValue[] publisher = item.getDC("publisher", null, Item.ANY);
+
+ if (publisher.length > 0)
+ {
+ sb.append("PB " + publisher[0].value + "\n");
+ }
+
+ DCValue[] isbn = item.getDC("identifier", "isbn", Item.ANY);
+
+ if (isbn.length > 0)
+ {
+ sb.append("SN " + isbn[0].value + "\n");
+ }
+
+ DCValue[] issn = item.getDC("identifier", "issn", Item.ANY);
+
+ if (issn.length > 0)
+ {
+ sb.append("SN " + issn[0].value + "\n");
+ }
+
+ DCValue[] dates = item.getDC("date", "issued", Item.ANY);
+
+ if (dates.length > 0)
+ {
+ String fullDate = dates[0].value;
+
+ String yearDate = fullDate.substring(0, 4);
+
+ sb.append("YR " + yearDate + "\n");
+
+ sb.append("FD " + fullDate + "\n");
+ }
+
+ DCValue[] identifier = item.getDC("identifier", "uri", Item.ANY);
+
+ if (identifier.length > 2)
+ {
+ for(int i =0; i < identifier.length; i++)
+ {
+ if (identifier[i].value.startsWith("http://hdl.handle.net"))
+ sb.append("LK " + identifier[i].value + "\n");
+ }
+ }
+ else
+ {
+ sb.append("LK " + identifier[0].value + "\n");
+ }
+
+ DCValue[] uri = item.getDC("identifier", "uri", Item.ANY);
+ for (int i = 0; i < uri.length; i++ )
+ {
+ sb.append("UL " + uri[i].value + "\n");
+ }
+
+ DCValue[] lang = item.getDC("language", "iso", Item.ANY);
+ if (lang.length > 0)
+ {
+ sb.append("LA " + lang[0].value + "\n");
+ }
+
+ DCValue[] citation = item.getDC("identifier", "citation", Item.ANY);
+ DCValue[] descn = item.getDC("description", null, Item.ANY);
+ DCValue[] descs = item.getDC("description", "sponsorship", Item.ANY);
+ DCValue[] descst = item.getDC("description", "statementofresponsibility", Item.ANY);
+ DCValue[] desct = item.getDC("description", "tableofcontents", Item.ANY);
+ DCValue[] descu = item.getDC("description", "uri", Item.ANY);
+
+ if (citation.length > 0)
+ {
+ sb.append("NO " + citation[0].value.replaceAll("\n","").replaceAll("\r","") + "\n");
+ }
+ if (descn.length > 0)
+ {
+ for (int i =0; i < descn.length; i++)
+ {
+ sb.append("NO " + descn[i].value.replaceAll("\n","").replaceAll("\r","") + "\n");
+ }
+ }
+ if (descs.length > 0)
+ {
+ sb.append("NO " + descs[0].value.replaceAll("\n","").replaceAll("\r","") + "\n");
+ }
+ if (descst.length >0)
+ {
+ sb.append("NO " + descst[0].value.replaceAll("\n","").replaceAll("\r","") + "\n");
+ }
+ if (desct.length >0)
+ {
+ sb.append("NO " + desct[0].value.replaceAll("\n","").replaceAll("\r","") + "\n");
+ }
+ if (descu.length >0)
+ {
+ byte [] b_descu = descu[0].value.replaceAll("\n","").replaceAll("\r","").getBytes("UTF-8");
+ String s_descu = new String(b_descu);
+ sb.append("NO " + s_descu + "\n");
+ }
+
+ sb.append("DS " + "MINDS@UW" + "\n");
+
+ Date d = new Date();
+ String df = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d);
+ sb.append("RD " + df + "\n");
+
+ return sb.toString();
+ }
+}