NIHVIVO-3940 remove the implementation of /individual/prefix/localname
This has been broken since before release 1.3 and nobody has missed it.
This commit is contained in:
parent
4422fd07b9
commit
81b0b2c145
6 changed files with 0 additions and 204 deletions
|
@ -15,12 +15,6 @@ public interface IndividualRequestAnalysisContext {
|
||||||
*/
|
*/
|
||||||
String getDefaultNamespace();
|
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.
|
* Use the IndividualDao to get this individual.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo;
|
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
|
* 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();
|
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
|
@Override
|
||||||
public Individual getIndividualByURI(String individualUri) {
|
public Individual getIndividualByURI(String individualUri) {
|
||||||
if (individualUri == null) {
|
if (individualUri == null) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ public class IndividualRequestAnalyzer {
|
||||||
private static Pattern RDF_REQUEST = Pattern.compile("^/individual/([^/]+)/\\1\\.(rdf|n3|ttl)$");
|
private static Pattern RDF_REQUEST = Pattern.compile("^/individual/([^/]+)/\\1\\.(rdf|n3|ttl)$");
|
||||||
private static Pattern HTML_REQUEST = Pattern.compile("^/display/([^/]+)$");
|
private static Pattern HTML_REQUEST = Pattern.compile("^/display/([^/]+)$");
|
||||||
private static Pattern LINKED_DATA_URL = Pattern.compile("^/individual/([^/]+)$");
|
private static Pattern LINKED_DATA_URL = Pattern.compile("^/individual/([^/]+)$");
|
||||||
private static Pattern NS_PREFIX_URL = Pattern.compile("^/individual/([^/]*)/([^/]+)$");
|
|
||||||
|
|
||||||
private final VitroRequest vreq;
|
private final VitroRequest vreq;
|
||||||
private final IndividualRequestAnalysisContext analysisContext;
|
private final IndividualRequestAnalysisContext analysisContext;
|
||||||
|
@ -164,7 +163,6 @@ public class IndividualRequestAnalyzer {
|
||||||
* /individual/localname/localname.rdf
|
* /individual/localname/localname.rdf
|
||||||
* /individual/localname/localname.n3
|
* /individual/localname/localname.n3
|
||||||
* /individual/localname/localname.ttl
|
* /individual/localname/localname.ttl
|
||||||
* /individual/nsprefix/localname
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return null on failure.
|
* @return null on failure.
|
||||||
|
@ -202,14 +200,6 @@ public class IndividualRequestAnalyzer {
|
||||||
return getIndividualByLocalname(rdfMatch.group(1));
|
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.
|
// Couldn't match it to anything.
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -299,12 +289,6 @@ public class IndividualRequestAnalyzer {
|
||||||
return getIndividualByUri(uri);
|
return getIndividualByUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Individual getIndividualByPrefixAndLocalname(String prefix,
|
|
||||||
String localName) {
|
|
||||||
String ns = analysisContext.getNamespaceForPrefix(prefix);
|
|
||||||
return getIndividualByUri(ns + localName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Individual getIndividualByNetId(String netId) {
|
private Individual getIndividualByNetId(String netId) {
|
||||||
return analysisContext.getIndividualByNetId(netId);
|
return analysisContext.getIndividualByNetId(netId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass {
|
||||||
private static final String URL_BYTESTREAM_ALIAS = URL_HOME_PAGE + "/file/"
|
private static final String URL_BYTESTREAM_ALIAS = URL_HOME_PAGE + "/file/"
|
||||||
+ ID_FILE_BYTESTREAM + "/" + BYTESTREAM_FILENAME;
|
+ 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 IndividualRequestAnalyzer analyzer;
|
||||||
private IndividualRequestAnalysisContextStub analysisContext;
|
private IndividualRequestAnalysisContextStub analysisContext;
|
||||||
private HttpServletRequestStub req;
|
private HttpServletRequestStub req;
|
||||||
|
@ -69,7 +60,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass {
|
||||||
|
|
||||||
private IndividualStub testIndividual;
|
private IndividualStub testIndividual;
|
||||||
private IndividualStub bytestreamIndividual;
|
private IndividualStub bytestreamIndividual;
|
||||||
private IndividualStub foreignIndividual;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
@ -83,10 +73,6 @@ public class IndividualRequestAnalyzerTest extends AbstractTestClass {
|
||||||
bytestreamIndividual = new IndividualStub(URI_FILE_BYTESTREAM);
|
bytestreamIndividual = new IndividualStub(URI_FILE_BYTESTREAM);
|
||||||
analysisContext.addIndividual(bytestreamIndividual);
|
analysisContext.addIndividual(bytestreamIndividual);
|
||||||
analysisContext.setAliasUrl(URI_FILE_BYTESTREAM, URL_BYTESTREAM_ALIAS);
|
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);
|
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. */
|
/** /individual/a/b/c fails. */
|
||||||
@Test
|
@Test
|
||||||
public void unrecognizedPath() {
|
public void unrecognizedPath() {
|
||||||
|
|
|
@ -21,7 +21,6 @@ public class IndividualRequestAnalysisContextStub implements
|
||||||
private final String defaultNamespace;
|
private final String defaultNamespace;
|
||||||
private final Map<String, Individual> individualsByUri = new HashMap<String, Individual>();
|
private final Map<String, Individual> individualsByUri = new HashMap<String, Individual>();
|
||||||
private final Map<String, Individual> profilePages = new HashMap<String, Individual>();
|
private final Map<String, Individual> profilePages = new HashMap<String, Individual>();
|
||||||
private final Map<String, String> namespacesByPrefix = new HashMap<String, String>();
|
|
||||||
private final Map<String, String> aliasUrlsByIndividual = new HashMap<String, String>();
|
private final Map<String, String> aliasUrlsByIndividual = new HashMap<String, String>();
|
||||||
|
|
||||||
public IndividualRequestAnalysisContextStub(String defaultNamespace) {
|
public IndividualRequestAnalysisContextStub(String defaultNamespace) {
|
||||||
|
@ -36,10 +35,6 @@ public class IndividualRequestAnalysisContextStub implements
|
||||||
profilePages.put(netId, individual);
|
profilePages.put(netId, individual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNamespacePrefix(String prefix, String namespace) {
|
|
||||||
namespacesByPrefix.put(prefix, namespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAliasUrl(String individualUri, String aliasUrl) {
|
public void setAliasUrl(String individualUri, String aliasUrl) {
|
||||||
aliasUrlsByIndividual.put(individualUri, aliasUrl);
|
aliasUrlsByIndividual.put(individualUri, aliasUrl);
|
||||||
}
|
}
|
||||||
|
@ -53,15 +48,6 @@ public class IndividualRequestAnalysisContextStub implements
|
||||||
return defaultNamespace;
|
return defaultNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNamespaceForPrefix(String prefix) {
|
|
||||||
if (prefix == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
String namespace = namespacesByPrefix.get(prefix);
|
|
||||||
return (namespace == null) ? "" : namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Individual getIndividualByURI(String individualUri) {
|
public Individual getIndividualByURI(String individualUri) {
|
||||||
if (individualUri == null) {
|
if (individualUri == 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<String, String> prefixMap = new HashMap<String, String>();
|
|
||||||
|
|
||||||
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<Statement> 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<Statement> 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<String> getPrefixesForNamespace(String namespace) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"NamespaceMapperStub.getPrefixesForNamespace() not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue