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."); - } - -}