1 40 package org.dspace.app.webui.jsptag; 41 42 import java.io.IOException ; 43 import java.net.URLEncoder ; 44 45 import javax.servlet.jsp.JspException ; 46 import javax.servlet.jsp.tagext.TagSupport ; 47 48 import org.dspace.content.DCPersonName; 49 import org.dspace.content.DCValue; 50 import org.dspace.content.Item; 51 import org.dspace.core.ConfigurationManager; 52 import org.dspace.core.Constants; 53 54 61 public class SFXLinkTag extends TagSupport 62 { 63 64 private Item item; 65 66 public SFXLinkTag() 67 { 68 super(); 69 } 70 71 public int doStartTag() throws JspException 72 { 73 try 74 { 75 String sfxServer = ConfigurationManager 76 .getProperty("sfx.server.url"); 77 78 if (sfxServer == null) 79 { 80 return SKIP_BODY; 82 } 83 84 String sfxQuery = ""; 85 86 DCValue[] titles = item.getDC("title", null, Item.ANY); 87 88 if (titles.length > 0) 89 { 90 sfxQuery = sfxQuery 91 + "&title=" 92 + URLEncoder.encode(titles[0].value, 93 Constants.DEFAULT_ENCODING); 94 } 95 96 DCValue[] authors = item.getDC("contributor", "author", Item.ANY); 97 98 if (authors.length > 0) 99 { 100 DCPersonName dpn = new DCPersonName(authors[0].value); 101 sfxQuery = sfxQuery 102 + "&aulast=" 103 + URLEncoder.encode(dpn.getLastName(), 104 Constants.DEFAULT_ENCODING); 105 sfxQuery = sfxQuery 106 + "&aufirst=" 107 + URLEncoder.encode(dpn.getFirstNames(), 108 Constants.DEFAULT_ENCODING); 109 } 110 111 DCValue[] isbn = item.getDC("identifier", "isbn", Item.ANY); 112 113 if (isbn.length > 0) 114 { 115 sfxQuery = sfxQuery 116 + "&isbn=" 117 + URLEncoder.encode(isbn[0].value, 118 Constants.DEFAULT_ENCODING); 119 } 120 121 DCValue[] issn = item.getDC("identifier", "issn", Item.ANY); 122 123 if (issn.length > 0) 124 { 125 sfxQuery = sfxQuery 126 + "&issn=" 127 + URLEncoder.encode(issn[0].value, 128 Constants.DEFAULT_ENCODING); 129 } 130 131 DCValue[] dates = item.getDC("date", "issued", Item.ANY); 132 133 if (dates.length > 0) 134 { 135 String fullDate = dates[0].value; 136 137 if (fullDate.length() > 10) 140 { 141 fullDate = fullDate.substring(0, 10); 142 } 143 144 sfxQuery = sfxQuery 145 + "&date=" 146 + URLEncoder.encode(fullDate, 147 Constants.DEFAULT_ENCODING); 148 } 149 150 if (sfxQuery.startsWith("&")) 152 { 153 sfxQuery = sfxQuery.substring(1); 154 } 155 156 pageContext.getOut().print(sfxServer + sfxQuery); 157 } 158 catch (IOException ie) 159 { 160 throw new JspException (ie); 161 } 162 163 return SKIP_BODY; 164 } 165 166 171 public Item getItem() 172 { 173 return item; 174 } 175 176 182 public void setItem(Item itemIn) 183 { 184 item = itemIn; 185 } 186 } 187 | Popular Tags |