Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop
I haven't a clue what git is trying to do. I kind of miss svn at this point.
This commit is contained in:
commit
11a83c4c1c
17 changed files with 35 additions and 278 deletions
|
@ -49,15 +49,6 @@ public class ApplicationBean {
|
||||||
private String copyrightAnchor;
|
private String copyrightAnchor;
|
||||||
private String themeDir;
|
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() {
|
public String toString() {
|
||||||
String output = "Application Bean Contents:\n";
|
String output = "Application Bean Contents:\n";
|
||||||
output += " initialized from DB: [" + initialized + "]\n";
|
output += " initialized from DB: [" + initialized + "]\n";
|
||||||
|
|
|
@ -33,9 +33,6 @@ import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
||||||
public class OntologyController extends VitroHttpServlet{
|
public class OntologyController extends VitroHttpServlet{
|
||||||
private static final Log log = LogFactory.getLog(OntologyController.class.getName());
|
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)
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException,IOException{
|
throws ServletException,IOException{
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
|
@ -242,7 +239,7 @@ public class OntologyController extends VitroHttpServlet{
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
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.
|
//set title before we do the highlighting so we don't get markup in it.
|
||||||
req.setAttribute("title","not found");
|
req.setAttribute("title","not found");
|
||||||
|
|
|
@ -283,12 +283,8 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationBean getAppBean(){
|
public ApplicationBean getAppBean(){
|
||||||
//return (ApplicationBean) getAttribute("appBean");
|
|
||||||
return getWebappDaoFactory().getApplicationDao().getApplicationBean();
|
return getWebappDaoFactory().getApplicationDao().getApplicationBean();
|
||||||
}
|
}
|
||||||
public void setAppBean(ApplicationBean ab){
|
|
||||||
setAttribute("appBean",ab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
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.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
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("title", "Startup Status");
|
||||||
body.put("status", StartupStatus.getBean(getServletContext()));
|
body.put("status", StartupStatus.getBean(getServletContext()));
|
||||||
body.put("contextPath", getContextPath());
|
body.put("contextPath", getContextPath());
|
||||||
body.put("applicationName", getApplicationName());
|
body.put("applicationName", getApplicationName(vreq));
|
||||||
|
|
||||||
return new TemplateResponseValues("startupStatus-display.ftl", body);
|
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 = "";
|
String name = "";
|
||||||
try {
|
try {
|
||||||
ApplicationBean app = ApplicationBean.getAppBean(getServletContext());
|
name = vreq.getAppBean().getApplicationName();
|
||||||
name = app.getApplicationName();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// deal with problems below
|
// deal with problems below
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,10 @@ public class FileServingServlet extends VitroHttpServlet {
|
||||||
String actualFilename = findAndValidateFilename(fileInfo, path);
|
String actualFilename = findAndValidateFilename(fileInfo, path);
|
||||||
|
|
||||||
in = openImageInputStream(fileInfo, actualFilename);
|
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) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to serve the file at '" + path + "' -- " + e.getMessage());
|
log.warn("Failed to serve the file at '" + path + "' -- " + e.getMessage());
|
||||||
in = openMissingLinkImage(request);
|
in = openMissingLinkImage(request);
|
||||||
|
|
|
@ -21,6 +21,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
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 edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
import freemarker.cache.WebappTemplateLoader;
|
import freemarker.cache.WebappTemplateLoader;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
@ -67,9 +69,10 @@ public class StartupStatusDisplayFilter implements Filter {
|
||||||
statusAlreadyDisplayed = true;
|
statusAlreadyDisplayed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayStartupStatus(ServletRequest req, ServletResponse resp) throws IOException,
|
private void displayStartupStatus(ServletRequest req, ServletResponse resp)
|
||||||
ServletException {
|
throws IOException, ServletException {
|
||||||
HttpServletResponse hResp = (HttpServletResponse) resp;
|
HttpServletResponse hresp = (HttpServletResponse) resp;
|
||||||
|
HttpServletRequest hreq = (HttpServletRequest) req;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Object> bodyMap = new HashMap<String, Object>();
|
Map<String, Object> bodyMap = new HashMap<String, Object>();
|
||||||
|
@ -78,25 +81,24 @@ public class StartupStatusDisplayFilter implements Filter {
|
||||||
bodyMap.put("contextPath", getContextPath());
|
bodyMap.put("contextPath", getContextPath());
|
||||||
bodyMap.put("applicationName", getApplicationName());
|
bodyMap.put("applicationName", getApplicationName());
|
||||||
|
|
||||||
HttpServletRequest httpreq = (HttpServletRequest) req;
|
String url = "";
|
||||||
String url = "";
|
|
||||||
|
|
||||||
String path = httpreq.getRequestURI();
|
String path = hreq.getRequestURI();
|
||||||
if( path != null ){
|
if (path != null) {
|
||||||
url = path;
|
url = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = httpreq.getQueryString();
|
String query = hreq.getQueryString();
|
||||||
if( !StringUtils.isEmpty( query )){
|
if (!StringUtils.isEmpty(query)) {
|
||||||
url = url + "?" + query;
|
url = url + "?" + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyMap.put("url", url );
|
bodyMap.put("url", url);
|
||||||
|
|
||||||
hResp.setContentType("text/html;charset=UTF-8");
|
hresp.setContentType("text/html;charset=UTF-8");
|
||||||
hResp.setStatus(SC_INTERNAL_SERVER_ERROR);
|
hresp.setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||||
Template tpl = loadFreemarkerTemplate();
|
Template tpl = loadFreemarkerTemplate();
|
||||||
tpl.process(bodyMap, hResp.getWriter());
|
tpl.process(bodyMap, hresp.getWriter());
|
||||||
} catch (TemplateException e) {
|
} catch (TemplateException e) {
|
||||||
throw new ServletException("Problem with Freemarker Template", e);
|
throw new ServletException("Problem with Freemarker Template", e);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +116,9 @@ public class StartupStatusDisplayFilter implements Filter {
|
||||||
private Object getApplicationName() {
|
private Object getApplicationName() {
|
||||||
String name = "";
|
String name = "";
|
||||||
try {
|
try {
|
||||||
ApplicationBean app = ApplicationBean.getAppBean(ctx);
|
WebappDaoFactory wadf = (WebappDaoFactory) ctx
|
||||||
|
.getAttribute("webappDaoFactory");
|
||||||
|
ApplicationBean app = wadf.getApplicationDao().getApplicationBean();
|
||||||
name = app.getApplicationName();
|
name = app.getApplicationName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// deal with problems below
|
// deal with problems below
|
||||||
|
|
|
@ -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.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
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.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -82,19 +81,10 @@ public class VitroRequestPrep implements Filter {
|
||||||
};
|
};
|
||||||
|
|
||||||
private ServletContext _context;
|
private ServletContext _context;
|
||||||
private ApplicationBean _appbean;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
_context = filterConfig.getServletContext();
|
_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
|
@Override
|
||||||
|
@ -132,9 +122,6 @@ public class VitroRequestPrep implements Filter {
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
VitroRequest vreq = new VitroRequest(req);
|
||||||
|
|
||||||
//-- setup appBean --//
|
|
||||||
vreq.setAppBean(_appbean);
|
|
||||||
|
|
||||||
//-- setup DAO factory --//
|
//-- setup DAO factory --//
|
||||||
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
|
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
|
||||||
//TODO: get accept-language from request and set as preferred languages
|
//TODO: get accept-language from request and set as preferred languages
|
||||||
|
|
|
@ -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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@
|
||||||
request.setAttribute("bodyJsp", "/errorbody.jsp");
|
request.setAttribute("bodyJsp", "/errorbody.jsp");
|
||||||
request.setAttribute("title", "Error");
|
request.setAttribute("title", "Error");
|
||||||
request.setAttribute("css", "");
|
request.setAttribute("css", "");
|
||||||
request.setAttribute("appBean", appBean);
|
|
||||||
request.setAttribute("themeDir", themeDir);
|
request.setAttribute("themeDir", themeDir);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,9 +38,6 @@
|
||||||
if (request.getAttribute("css") == null){
|
if (request.getAttribute("css") == null){
|
||||||
e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n";
|
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 ){
|
if( e.length() > 0 ){
|
||||||
throw new JspException(e);
|
throw new JspException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
if (request.getAttribute("css") == null){
|
if (request.getAttribute("css") == null){
|
||||||
e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n";
|
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 ){
|
if( e.length() > 0 ){
|
||||||
throw new JspException(e);
|
throw new JspException(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue