Merge branch 'maint-rel-1.6' into develop

This commit is contained in:
brianjlowe 2013-12-04 10:37:59 -05:00
commit d861f17d0c
21 changed files with 888 additions and 254 deletions

View file

@ -0,0 +1,115 @@
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<script src="js/jquery.js"></script>
<script>
function TestLOD() {
self = this;
this.setup = setupButtons;
this.uri = "lodFacultyMember";
function setupButtons() {
document.getElementById("RDFXML_button").onclick = function() {
requestWithAcceptHeader(self.uri, "application/rdf+xml");
}
document.getElementById("N3_button").onclick = function() {
requestWithAcceptHeader(self.uri, "text/n3");
}
document.getElementById("TTL_button").onclick = function() {
requestWithAcceptHeader(self.uri, "text/turtle");
}
document.getElementById("JSONLD_button").onclick = function() {
requestWithAcceptHeader(self.uri, "application/json");
}
document.getElementById("BOGUS_URI_button").onclick = function() {
requestWithAcceptHeader(self.uri + "XX", "application/rdf+xml");
}
document.getElementById("BOGUS_ACCEPT_button").onclick = function() {
requestWithAcceptHeader(self.uri, "image/png");
}
document.getElementById("BOGUS_FORMAT_button").onclick = function() {
requestWithFormat(self.uri, "bogus");
}
document.getElementById("BOGUS_EXTENSION_button").onclick = function() {
requestWithExtension(self.uri, "bogus");
}
document.getElementById("CLEAR_button").onclick = clearResult
}
function requestWithAcceptHeader(uri, mimetype) {
$.ajax({
url: "individual/" + uri,
headers: {Accept: mimetype},
dataType: "text",
complete: displayResult
});
}
function requestWithFormat(uri, format) {
$.ajax({
url: "individual/" + uri + "?format=" + format,
dataType: "text",
complete: displayResult
});
}
function requestWithExtension(uri, extension) {
$.ajax({
url: "individual/" + uri + "/" + uri + "." + extension,
dataType: "text",
complete: displayResult
});
}
function displayResult(xhr, status) {
$("#responseCode").text(xhr.status);
$("#mimeType").text(getMimeType(xhr));
$("#responseText").text(xhr.responseText);
}
function clearResult() {
$("#responseCode").text("000");
$("#mimeType").text("No type");
$("#responseText").text("No text");
}
function getMimeType(xhr) {
var header = xhr.getResponseHeader("Content-Type");
var where = header.indexOf(";");
if (where == -1) {
return header;
} else {
return header.substring(0, where);
}
}
}
$(document).ready(function() {
new TestLOD().setup();
});
</script>
<h1>Test the Linked Open Data requests</h1>
<h3>Try various accept headers</h3>
<input type="submit" value="get RDFXML" id="RDFXML_button">
<input type="submit" value="get N3" id="N3_button">
<input type="submit" value="get TTL" id="TTL_button">
<input type="submit" value="get JSONLD" id="JSONLD_button">
<h3>Try non-existent URI with RDFXML accept header</h3>
<input type="submit" value="get BOGUS Individual" id="BOGUS_URI_button">
<input type="submit" value="use BOGUS Accept header" id="BOGUS_ACCEPT_button">
<input type="submit" value="use BOGUS format" id="BOGUS_FORMAT_button">
<input type="submit" value="use BOGUS extension" id="BOGUS_EXTENSION_button">
<h3>Response data</h3>
<input type="submit" value="CLEAR response" id="CLEAR_button">
<div>Response code is <b><span id="responseCode">000</span></b></div>
<div>MIME type is <b><span id="mimeType">No type</span></b></div>
<div>Text is:</div>
<div id="responseText" style="font-size:small;">No text</div>

View file

@ -0,0 +1,56 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xmls: <http://www.w3.org/2001/XMLSchema#> .
@prefix local: <http://vivo.mydomain.edu/individual/> .
@prefix vivo: <http://vivoweb.org/ontology/core#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
local:lodFacultyMember
a vivo:FacultyMember ;
rdfs:label "Example, Bad "^^xmls:string ;
obo:ARG_2000028 local:lodVcard ;
obo:RO_0000053 local:lodMembership ;
vivo:overview "Not someone on whom you should base your actions." ;
vivo:scopusId "10982375409" ;
vivo:eRACommonsId "My_eRA_ID" .
local:lodVcard
a vcard:Kind , vcard:Individual ;
obo:ARG_2000029 local:lodFacultyMember ;
vcard:hasName local:lodName ;
vcard:hasURL local:lodWebsite .
local:lodName
a vcard:Name ;
vcard:familyName "Example"^^xmls:string ;
vcard:givenName "Bad"^^xmls:string ;
vcard:honorificPrefix "Mr."^^xmls:string .
local:lodWebsite
a vcard:URL ;
rdfs:label "Slashdot" ;
vivo:rank "1"^^xmls:int ;
vcard:url "http://www.slashdot.org"^^xmls:anyURI .
local:lodMembership
a vivo:MemberRole ;
rdfs:label "Bozo"^^xmls:string ;
obo:RO_0000052 local:lodFacultyMember ;
vivo:dateTimeInterval local:lodInterval ;
vivo:roleContributesTo local:lodDepartment .
local:lodInterval
a vivo:DateTimeInterval ;
vivo:start local:lodStartDate .
local:lodStartDate
a vivo:DateTimeValue ;
vivo:dateTime "1992-01-01T00:00:00"^^xmls:dateTime ;
vivo:dateTimePrecision vivo:yearPrecision .
local:lodDepartment
a vivo:AcademicDepartment ;
rdfs:label "Department of Redundancy Department"^^xmls:string ;
vivo:contributingRole local:lodMembership .

View file

@ -0,0 +1,8 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix auth: <http://vitro.mannlib.cornell.edu/ns/vitro/authorization#> .
@prefix simplePermission: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission#> .
@prefix displayByRole: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.DisplayByRolePermission#> .
@prefix editByRole: <java:edu.cornell.mannlib.vitro.webapp.auth.permissions.EditByRolePermission#> .
auth:ADMIN
auth:hasPermission simplePermission:UseSparqlUpdateApi ;

View file

@ -0,0 +1,163 @@
<style>
form {
border: 2 solid black;
background-color: #E0E0E0;
}
input, textarea {
margin: 6px;
}
form a {
float: right;
}
</style>
<h1>Test the SPARQL API</h1>
<form action="api/sparqlUpdate" method="POST">
<a href="individual?uri=http%3A%2F%2Ftest.domain%2Fns%23book1&format=rdfxml">Get RDF</a>
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="6" cols="70" wrap="soft">
INSERT DATA {
GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> {
<http://test.domain/ns#book1>
<http://purl.org/dc/elements/1.1/title>
"Fundamentals of Compiler Design" .
}
}
</textarea>
<br/>
<input type="submit" value="Successful INSERT">
</form>
<form action="api/sparqlUpdate" method="POST">
<a href="individual?uri=http%3A%2F%2Ftest.domain%2Fns%23book1&format=rdfxml">Get RDF</a>
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="7" cols="70" wrap="soft">
DELETE DATA {
GRAPH <http://vitro.mannlib.cornell.edu/default/vitro-kb-2> {
<http://test.domain/ns#book1>
<http://purl.org/dc/elements/1.1/title>
"Fundamentals of Compiler Design" .
}
}
</textarea>
<br/>
<input type="submit" value="Successful DELETE">
</form>
<form action="api/sparqlUpdate" method="GET">
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="GET method not allowed">
</form>
<form action="api/sparqlUpdate" method="POST">
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="Email and password missing">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="bogus@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="No such user">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="BOGUS" />
<br/>
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="Wrong password">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="joeUser@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="Account not authorized">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<input type="submit" value="SPARQL is missing">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="4" cols="70" wrap="soft">
INSERT DATA } {
GRAPH <bogus> {
}
}
</textarea>
<br/>
<input type="submit" value="SPARQL is invalid">
</form>
<form action="api/sparqlUpdate" method="POST">
<input type="text" name="email" value="testAdmin@cornell.edu" />
<input type="text" name="password" value="Password" />
<br/>
<textarea name="update" rows="5" cols="70" wrap="soft">
INSERT DATA {
<http://test.domain/ns#book1>
<http://purl.org/dc/elements/1.1/title>
"Fundamentals of Compiler Design" .
}
</textarea>
<br/>
<input type="submit" value="SPARQL doesn't specify a GRAPH">
</form>
<pre>
200 Success
400 Failed to parse SPARQL update
400 SPARQL update must specify a GRAPH URI.
403 username/password combination is not valid
403 Account is not authorized
405 Method not allowed
500 Unknown error
</pre>