From d93068bdfa4ec78d318c0666c876db54740f3fcf Mon Sep 17 00:00:00 2001 From: j2blake Date: Tue, 13 Nov 2012 17:19:45 -0500 Subject: [PATCH 1/7] validateUpload.js is no longer used in Vitro, VIVO or vivoCornell --- webapp/web/js/imageUpload/validateUpload.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 webapp/web/js/imageUpload/validateUpload.js diff --git a/webapp/web/js/imageUpload/validateUpload.js b/webapp/web/js/imageUpload/validateUpload.js deleted file mode 100644 index d769d201a..000000000 --- a/webapp/web/js/imageUpload/validateUpload.js +++ /dev/null @@ -1,9 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -function validate_upload_file(form_passed){ - - if (form_passed.datafile.value == "") { - alert ("Please browse and select a photo"); - return false; - } -} From e10274aaf7fadab782cc4b3c604c244448cafcfc Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 14 Nov 2012 11:25:17 -0500 Subject: [PATCH 2/7] NIHVIVO-4010 Log requests for invalid file-based URLs as INFO, not WARN. When a request comes in like /file/n1645/Ashdown_Susan_1.jpg, and either there is no such entity, or it is not a FileBytestream, or its name is different from requested, continue to serve the Missing Link image, but log the error with an INFO message, not a WARN message. --- .../vitro/webapp/filestorage/serving/FileServingServlet.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java index 53c30e304..388b71e38 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/serving/FileServingServlet.java @@ -94,6 +94,10 @@ public class FileServingServlet extends VitroHttpServlet { String actualFilename = findAndValidateFilename(fileInfo, path); in = openImageInputStream(fileInfo, actualFilename); + } catch (FileServingException e) { + log.info("Failed to serve the file at '" + path + "' -- " + e.getMessage()); + in = openMissingLinkImage(request); + mimeType = "image/png"; } catch (Exception e) { log.warn("Failed to serve the file at '" + path + "' -- " + e.getMessage()); in = openMissingLinkImage(request); From ccdd37b02301785fb3ad4513855a93700e3801ee Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 14 Nov 2012 16:10:54 -0500 Subject: [PATCH 3/7] An intention compile-error to break the build --- .../controller/admin/ShowBackgroundThreadsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java index f8241ca6b..0dacad944 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java @@ -28,7 +28,7 @@ public class ShowBackgroundThreadsController extends FreemarkerHttpServlet { @Override - protected ResponseValues processRequest(VitroRequest vreq) throws Exception { + protected ResponseValues processRequest(VitroRequest vreq) throws ExceptionXX { SortedMap threadMap = new TreeMap(); From 6b743f8b365c6ff68bc617ed9db220cc1afec97d Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 14 Nov 2012 16:33:34 -0500 Subject: [PATCH 4/7] Remove intentional error - Jenkins has responded correctly. --- .../controller/admin/ShowBackgroundThreadsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java index 0dacad944..f8241ca6b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/ShowBackgroundThreadsController.java @@ -28,7 +28,7 @@ public class ShowBackgroundThreadsController extends FreemarkerHttpServlet { @Override - protected ResponseValues processRequest(VitroRequest vreq) throws ExceptionXX { + protected ResponseValues processRequest(VitroRequest vreq) throws Exception { SortedMap threadMap = new TreeMap(); From 24a57841101cc6548377980222d990e328efecea Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 15 Nov 2012 11:43:19 -0500 Subject: [PATCH 5/7] NIHVIVO-4017 Always get the ApplicationBean from the DAO. Don't store the ApplicationBean in the request or in the context, and don't look for it there. --- .../vitro/webapp/beans/ApplicationBean.java | 9 -------- .../webapp/controller/OntologyController.java | 5 +---- .../vitro/webapp/controller/VitroRequest.java | 4 ---- .../admin/StartupStatusController.java | 8 +++---- .../filters/StartupStatusDisplayFilter.java | 21 ++++++++++--------- .../webapp/filters/VitroRequestPrep.java | 13 ------------ webapp/web/error.jsp | 1 - webapp/web/templates/page/basicPage.jsp | 3 --- webapp/web/templates/page/blankPage.jsp | 3 --- 9 files changed, 15 insertions(+), 52 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java index bcf83a979..99dec7616 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java @@ -49,15 +49,6 @@ public class ApplicationBean { private String copyrightAnchor; private String themeDir; - public static ApplicationBean getAppBean(ServletContext sc){ - if( sc != null ){ - Object obj = sc.getAttribute("applicationBean"); - if( obj != null ) - return (ApplicationBean)obj; - } - return new ApplicationBean(); - } - public String toString() { String output = "Application Bean Contents:\n"; output += " initialized from DB: [" + initialized + "]\n"; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index da86839ca..6d85141e2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -33,9 +33,6 @@ import edu.cornell.mannlib.vitro.webapp.web.ContentType; public class OntologyController extends VitroHttpServlet{ private static final Log log = LogFactory.getLog(OntologyController.class.getName()); - private String default_jsp = Controllers.BASIC_JSP; - private ApplicationBean appBean; - public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ doGet(request, response); @@ -242,7 +239,7 @@ public class OntologyController extends VitroHttpServlet{ throws IOException, ServletException { VitroRequest vreq = new VitroRequest(req); - ApplicationBean appBean = ApplicationBean.getAppBean(getServletContext()); + ApplicationBean appBean = vreq.getAppBean(); //set title before we do the highlighting so we don't get markup in it. req.setAttribute("title","not found"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java index 7e67e0886..88416f911 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java @@ -283,12 +283,8 @@ public class VitroRequest extends HttpServletRequestWrapper { } public ApplicationBean getAppBean(){ - //return (ApplicationBean) getAttribute("appBean"); return getWebappDaoFactory().getApplicationDao().getApplicationBean(); } - public void setAppBean(ApplicationBean ab){ - setAttribute("appBean",ab); - } @SuppressWarnings("unchecked") @Override diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java index 2b5866b5a..fb587eb20 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java @@ -7,7 +7,6 @@ import java.util.Map; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -31,7 +30,7 @@ public class StartupStatusController extends FreemarkerHttpServlet { body.put("title", "Startup Status"); body.put("status", StartupStatus.getBean(getServletContext())); body.put("contextPath", getContextPath()); - body.put("applicationName", getApplicationName()); + body.put("applicationName", getApplicationName(vreq)); return new TemplateResponseValues("startupStatus-display.ftl", body); } @@ -45,11 +44,10 @@ public class StartupStatusController extends FreemarkerHttpServlet { } } - private Object getApplicationName() { + private Object getApplicationName(VitroRequest vreq) { String name = ""; try { - ApplicationBean app = ApplicationBean.getAppBean(getServletContext()); - name = app.getApplicationName(); + name = vreq.getAppBean().getApplicationName(); } catch (Exception e) { // deal with problems below } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java index 4a145dc8d..789be6947 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import freemarker.cache.WebappTemplateLoader; import freemarker.template.Configuration; @@ -69,34 +70,34 @@ public class StartupStatusDisplayFilter implements Filter { private void displayStartupStatus(ServletRequest req, ServletResponse resp) throws IOException, ServletException { - HttpServletResponse hResp = (HttpServletResponse) resp; + HttpServletResponse hresp = (HttpServletResponse) resp; + HttpServletRequest hreq = (HttpServletRequest) req; try { Map bodyMap = new HashMap(); bodyMap.put("status", ss); bodyMap.put("showLink", !isFatal()); bodyMap.put("contextPath", getContextPath()); - bodyMap.put("applicationName", getApplicationName()); + bodyMap.put("applicationName", getApplicationName(hreq)); - HttpServletRequest httpreq = (HttpServletRequest) req; String url = ""; - String path = httpreq.getRequestURI(); + String path = hreq.getRequestURI(); if( path != null ){ url = path; } - String query = httpreq.getQueryString(); + String query = hreq.getQueryString(); if( !StringUtils.isEmpty( query )){ url = url + "?" + query; } bodyMap.put("url", url ); - hResp.setContentType("text/html;charset=UTF-8"); - hResp.setStatus(SC_INTERNAL_SERVER_ERROR); + hresp.setContentType("text/html;charset=UTF-8"); + hresp.setStatus(SC_INTERNAL_SERVER_ERROR); Template tpl = loadFreemarkerTemplate(); - tpl.process(bodyMap, hResp.getWriter()); + tpl.process(bodyMap, hresp.getWriter()); } catch (TemplateException e) { throw new ServletException("Problem with Freemarker Template", e); } @@ -111,10 +112,10 @@ public class StartupStatusDisplayFilter implements Filter { } } - private Object getApplicationName() { + private Object getApplicationName(HttpServletRequest hreq) { String name = ""; try { - ApplicationBean app = ApplicationBean.getAppBean(ctx); + ApplicationBean app = new VitroRequest(hreq).getAppBean(); name = app.getApplicationName(); } catch (Exception e) { // deal with problems below diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java index 02924963f..f1d7a6e71 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java @@ -38,7 +38,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList; -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -82,19 +81,10 @@ public class VitroRequestPrep implements Filter { }; private ServletContext _context; - private ApplicationBean _appbean; @Override public void init(FilterConfig filterConfig) throws ServletException { _context = filterConfig.getServletContext(); - - Object o = _context.getAttribute("applicationBean"); - if (o instanceof ApplicationBean) { - _appbean = (ApplicationBean) o; - } else { - _appbean = new ApplicationBean(); - } - log.debug("VitroRequestPrep: AppBean theme " + _appbean.getThemeDir()); } @Override @@ -132,9 +122,6 @@ public class VitroRequestPrep implements Filter { VitroRequest vreq = new VitroRequest(req); - //-- setup appBean --// - vreq.setAppBean(_appbean); - //-- setup DAO factory --// WebappDaoFactory wdf = getWebappDaoFactory(vreq); //TODO: get accept-language from request and set as preferred languages diff --git a/webapp/web/error.jsp b/webapp/web/error.jsp index 00622fc76..a429ebed2 100755 --- a/webapp/web/error.jsp +++ b/webapp/web/error.jsp @@ -13,7 +13,6 @@ request.setAttribute("bodyJsp", "/errorbody.jsp"); request.setAttribute("title", "Error"); request.setAttribute("css", ""); - request.setAttribute("appBean", appBean); request.setAttribute("themeDir", themeDir); %> diff --git a/webapp/web/templates/page/basicPage.jsp b/webapp/web/templates/page/basicPage.jsp index 4685288bc..07b328d72 100644 --- a/webapp/web/templates/page/basicPage.jsp +++ b/webapp/web/templates/page/basicPage.jsp @@ -38,9 +38,6 @@ if (request.getAttribute("css") == null){ e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n"; } - if( request.getAttribute("appBean") == null){ - e+="basicPage.jsp expects that request attribute 'appBean' be set.\n"; - } if( e.length() > 0 ){ throw new JspException(e); } diff --git a/webapp/web/templates/page/blankPage.jsp b/webapp/web/templates/page/blankPage.jsp index 62e65e0a7..9fec63cb2 100644 --- a/webapp/web/templates/page/blankPage.jsp +++ b/webapp/web/templates/page/blankPage.jsp @@ -31,9 +31,6 @@ if (request.getAttribute("css") == null){ e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n"; } - if( request.getAttribute("appBean") == null){ - e+="basicPage.jsp expects that request attribute 'appBean' be set.\n"; - } if( e.length() > 0 ){ throw new JspException(e); } From 4422fd07b9d93485bebe0c6781a47f2a2d0bfa39 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 15 Nov 2012 12:01:47 -0500 Subject: [PATCH 6/7] NIHVIVO-4017 Get the Application Bean from the context WebappDaoFactory Since this was caught by a filter, the request is not likely to have a WebappDaoFactory in it. --- .../filters/StartupStatusDisplayFilter.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java index 789be6947..3ef123eb4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java @@ -22,6 +22,7 @@ import org.apache.commons.lang.StringUtils; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import freemarker.cache.WebappTemplateLoader; import freemarker.template.Configuration; @@ -68,31 +69,31 @@ public class StartupStatusDisplayFilter implements Filter { statusAlreadyDisplayed = true; } - private void displayStartupStatus(ServletRequest req, ServletResponse resp) throws IOException, - ServletException { + private void displayStartupStatus(ServletRequest req, ServletResponse resp) + throws IOException, ServletException { HttpServletResponse hresp = (HttpServletResponse) resp; - HttpServletRequest hreq = (HttpServletRequest) req; + HttpServletRequest hreq = (HttpServletRequest) req; try { Map bodyMap = new HashMap(); bodyMap.put("status", ss); bodyMap.put("showLink", !isFatal()); bodyMap.put("contextPath", getContextPath()); - bodyMap.put("applicationName", getApplicationName(hreq)); - - String url = ""; - - String path = hreq.getRequestURI(); - if( path != null ){ - url = path; - } - - String query = hreq.getQueryString(); - if( !StringUtils.isEmpty( query )){ - url = url + "?" + query; - } - - bodyMap.put("url", url ); + bodyMap.put("applicationName", getApplicationName()); + + String url = ""; + + String path = hreq.getRequestURI(); + if (path != null) { + url = path; + } + + String query = hreq.getQueryString(); + if (!StringUtils.isEmpty(query)) { + url = url + "?" + query; + } + + bodyMap.put("url", url); hresp.setContentType("text/html;charset=UTF-8"); hresp.setStatus(SC_INTERNAL_SERVER_ERROR); @@ -112,10 +113,12 @@ public class StartupStatusDisplayFilter implements Filter { } } - private Object getApplicationName(HttpServletRequest hreq) { + private Object getApplicationName() { String name = ""; try { - ApplicationBean app = new VitroRequest(hreq).getAppBean(); + WebappDaoFactory wadf = (WebappDaoFactory) ctx + .getAttribute("webappDaoFactory"); + ApplicationBean app = wadf.getApplicationDao().getApplicationBean(); name = app.getApplicationName(); } catch (Exception e) { // deal with problems below From 81b0b2c14570d7dbafd779efc2adcad07316ef20 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 15 Nov 2012 14:28:22 -0500 Subject: [PATCH 7/7] NIHVIVO-3940 remove the implementation of /individual/prefix/localname This has been broken since before release 1.3 and nobody has missed it. --- .../IndividualRequestAnalysisContext.java | 6 - .../IndividualRequestAnalysisContextImpl.java | 21 --- .../individual/IndividualRequestAnalyzer.java | 16 --- .../IndividualRequestAnalyzerTest.java | 24 ---- .../IndividualRequestAnalysisContextStub.java | 14 -- .../webapp/utils/NamespaceMapperStub.java | 123 ------------------ 6 files changed, 204 deletions(-) delete mode 100644 webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/utils/NamespaceMapperStub.java diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContext.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContext.java index f822360cc..96300bbad 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContext.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContext.java @@ -15,12 +15,6 @@ public interface IndividualRequestAnalysisContext { */ String getDefaultNamespace(); - /** - * Is there a namespace for this prefix? If not, return an empty string, but - * never null. - */ - String getNamespaceForPrefix(String prefix); - /** * Use the IndividualDao to get this individual. * diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextImpl.java index 2198c89f5..5f3ebc7e4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextImpl.java @@ -15,8 +15,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo; -import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper; -import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory; /** * Implement all of the fiddly-bits that we need for analyzing the request for @@ -45,25 +43,6 @@ public class IndividualRequestAnalysisContextImpl implements return wadf.getDefaultNamespace(); } - @Override - public String getNamespaceForPrefix(String prefix) { - if (prefix == null) { - return ""; - } - - NamespaceMapper namespaceMapper = NamespaceMapperFactory - .getNamespaceMapper(ctx); - if (namespaceMapper == null) { - log.warn("No NamespaceMapper in ServletContext. Request URL was '" - + vreq.getRequestURL() + "'"); - return ""; - } - - String ns = namespaceMapper.getNamespaceForPrefix(prefix); - - return (ns == null) ? "" : ns; - } - @Override public Individual getIndividualByURI(String individualUri) { if (individualUri == null) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java index 2d5bad4a3..3b3c6d091 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzer.java @@ -30,7 +30,6 @@ public class IndividualRequestAnalyzer { private static Pattern RDF_REQUEST = Pattern.compile("^/individual/([^/]+)/\\1\\.(rdf|n3|ttl)$"); private static Pattern HTML_REQUEST = Pattern.compile("^/display/([^/]+)$"); private static Pattern LINKED_DATA_URL = Pattern.compile("^/individual/([^/]+)$"); - private static Pattern NS_PREFIX_URL = Pattern.compile("^/individual/([^/]*)/([^/]+)$"); private final VitroRequest vreq; private final IndividualRequestAnalysisContext analysisContext; @@ -164,7 +163,6 @@ public class IndividualRequestAnalyzer { * /individual/localname/localname.rdf * /individual/localname/localname.n3 * /individual/localname/localname.ttl - * /individual/nsprefix/localname * * * @return null on failure. @@ -202,14 +200,6 @@ public class IndividualRequestAnalyzer { return getIndividualByLocalname(rdfMatch.group(1)); } - // Does the URL look like a namespace prefix followed by a local - // name? - Matcher prefix_match = NS_PREFIX_URL.matcher(url); - if (prefix_match.matches() && prefix_match.groupCount() == 2) { - return getIndividualByPrefixAndLocalname(prefix_match.group(1), - prefix_match.group(2)); - } - // Couldn't match it to anything. return null; } catch (Throwable e) { @@ -299,12 +289,6 @@ public class IndividualRequestAnalyzer { return getIndividualByUri(uri); } - private Individual getIndividualByPrefixAndLocalname(String prefix, - String localName) { - String ns = analysisContext.getNamespaceForPrefix(prefix); - return getIndividualByUri(ns + localName); - } - private Individual getIndividualByNetId(String netId) { return analysisContext.getIndividualByNetId(netId); } diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzerTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzerTest.java index 709e72365..eca94a2f4 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzerTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalyzerTest.java @@ -52,15 +52,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass { private static final String URL_BYTESTREAM_ALIAS = URL_HOME_PAGE + "/file/" + ID_FILE_BYTESTREAM + "/" + BYTESTREAM_FILENAME; - /** - * Info about an individual that appears in a different namespace. - */ - private static final String SOME_PREFIX = "somePrefix"; - private static final String SOME_NAMESPACE = "http://some.namespace/"; - private static final String ID_INDIVIDUAL_FOREIGN = "foreignId"; - private static final String URI_INDIVIDUAL_FOREIGN = SOME_NAMESPACE - + ID_INDIVIDUAL_FOREIGN; - private IndividualRequestAnalyzer analyzer; private IndividualRequestAnalysisContextStub analysisContext; private HttpServletRequestStub req; @@ -69,7 +60,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass { private IndividualStub testIndividual; private IndividualStub bytestreamIndividual; - private IndividualStub foreignIndividual; @Before public void setup() { @@ -83,10 +73,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass { bytestreamIndividual = new IndividualStub(URI_FILE_BYTESTREAM); analysisContext.addIndividual(bytestreamIndividual); analysisContext.setAliasUrl(URI_FILE_BYTESTREAM, URL_BYTESTREAM_ALIAS); - - foreignIndividual = new IndividualStub(URI_INDIVIDUAL_FOREIGN); - analysisContext.addIndividual(foreignIndividual); - analysisContext.setNamespacePrefix(SOME_PREFIX, SOME_NAMESPACE); } // ---------------------------------------------------------------------- @@ -132,16 +118,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass { assertDefaultRequestInfo("find by display path", URI_INDIVIDUAL_TEST); } - /** /individual/nsPrefix/localname */ - @Test - public void findByPrefixAndLocalname() { - req.setRequestUrl(url(DEFAULT_NAMESPACE + SOME_PREFIX + "/" - + ID_INDIVIDUAL_FOREIGN)); - analyzeIt(); - assertDefaultRequestInfo("find by prefix and localname", - URI_INDIVIDUAL_FOREIGN); - } - /** /individual/a/b/c fails. */ @Test public void unrecognizedPath() { diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextStub.java index d303956b2..2adc18ee7 100644 --- a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextStub.java +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualRequestAnalysisContextStub.java @@ -21,7 +21,6 @@ public class IndividualRequestAnalysisContextStub implements private final String defaultNamespace; private final Map individualsByUri = new HashMap(); private final Map profilePages = new HashMap(); - private final Map namespacesByPrefix = new HashMap(); private final Map aliasUrlsByIndividual = new HashMap(); public IndividualRequestAnalysisContextStub(String defaultNamespace) { @@ -36,10 +35,6 @@ public class IndividualRequestAnalysisContextStub implements profilePages.put(netId, individual); } - public void setNamespacePrefix(String prefix, String namespace) { - namespacesByPrefix.put(prefix, namespace); - } - public void setAliasUrl(String individualUri, String aliasUrl) { aliasUrlsByIndividual.put(individualUri, aliasUrl); } @@ -53,15 +48,6 @@ public class IndividualRequestAnalysisContextStub implements return defaultNamespace; } - @Override - public String getNamespaceForPrefix(String prefix) { - if (prefix == null) { - return ""; - } - String namespace = namespacesByPrefix.get(prefix); - return (namespace == null) ? "" : namespace; - } - @Override public Individual getIndividualByURI(String individualUri) { if (individualUri == null) { diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/utils/NamespaceMapperStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/utils/NamespaceMapperStub.java deleted file mode 100644 index 5995d57e3..000000000 --- a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/utils/NamespaceMapperStub.java +++ /dev/null @@ -1,123 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package stubs.edu.cornell.mannlib.vitro.webapp.utils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper; - -/** - * A minimal implementation of the NamespaceMapper. - * - * I have only implemented the methods that I needed. Feel free to implement - * others. - */ -public class NamespaceMapperStub implements NamespaceMapper { - // ---------------------------------------------------------------------- - // Stub infrastructure - // ---------------------------------------------------------------------- - - private final Map prefixMap = new HashMap(); - - public void setPrefixForNamespace(String prefix, String namespace) { - prefixMap.put(prefix, namespace); - } - - // ---------------------------------------------------------------------- - // Stub methods - // ---------------------------------------------------------------------- - - @Override - public String getNamespaceForPrefix(String prefix) { - return prefixMap.get(prefix); - } - - // ---------------------------------------------------------------------- - // Un-implemented methods - // ---------------------------------------------------------------------- - - @Override - public void addedStatement(Statement arg0) { - throw new RuntimeException( - "NamespaceMapperStub.addedStatement() not implemented."); - } - - @Override - public void addedStatements(Statement[] arg0) { - throw new RuntimeException( - "NamespaceMapperStub.addedStatements() not implemented."); - } - - @Override - public void addedStatements(List arg0) { - throw new RuntimeException( - "NamespaceMapperStub.addedStatements() not implemented."); - } - - @Override - public void addedStatements(StmtIterator arg0) { - throw new RuntimeException( - "NamespaceMapperStub.addedStatements() not implemented."); - } - - @Override - public void addedStatements(Model arg0) { - throw new RuntimeException( - "NamespaceMapperStub.addedStatements() not implemented."); - } - - @Override - public void notifyEvent(Model arg0, Object arg1) { - throw new RuntimeException( - "NamespaceMapperStub.notifyEvent() not implemented."); - } - - @Override - public void removedStatement(Statement arg0) { - throw new RuntimeException( - "NamespaceMapperStub.removedStatement() not implemented."); - } - - @Override - public void removedStatements(Statement[] arg0) { - throw new RuntimeException( - "NamespaceMapperStub.removedStatements() not implemented."); - } - - @Override - public void removedStatements(List arg0) { - throw new RuntimeException( - "NamespaceMapperStub.removedStatements() not implemented."); - } - - @Override - public void removedStatements(StmtIterator arg0) { - throw new RuntimeException( - "NamespaceMapperStub.removedStatements() not implemented."); - } - - @Override - public void removedStatements(Model arg0) { - throw new RuntimeException( - "NamespaceMapperStub.removedStatements() not implemented."); - } - - @Override - public String getPrefixForNamespace(String namespace) { - throw new RuntimeException( - "NamespaceMapperStub.getPrefixForNamespace() not implemented."); - } - - @Override - public List getPrefixesForNamespace(String namespace) { - throw new RuntimeException( - "NamespaceMapperStub.getPrefixesForNamespace() not implemented."); - } - -}