History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-1034
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Jeen Broekstra
Reporter: Chris Lott
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sesame

getStatements() with contexts does not produce statement objects with context via HTTPRepositoryConnection

Created: 08/Jun/12 10:42 PM   Updated: 13/Jun/12 11:16 PM
Component/s: Repository API, HTTP Server
Affects Version/s: 2.6.6
Fix Version/s: 2.6.7


 Description   
Invoking getStatements() on a particular context on a HTTPRepositoryConnection does not produce statement objects that contain the appropriate context for the statement. The cause is that the response serialization format is not fixed to an RDF format that can encode statement context (such as TriX). A fix is to have the HTTPClient explicitly request TriX format responses when context is important in serialization.

 All   Comments   Change History      Sort Order:
Comment by Chris Lott [08/Jun/12 10:48 PM]
This started as a clone of http://www.openrdf.org/issues/browse/SES-366, which just might have recurred. I am using Sesame 2.6.6, connected via HTTP to a remote repository. I can use the Sesame workbench to look in my repository for statements and there I find many with non-null context. One particular wrinkle is that I am using BNodes, both in the repository and to limit the search. I don't see why that would affect the result tho. I checked in a debugger and the implementation of the Statement interface is org.openrdf.model.impl.StatementImpl, not ContextStatementImpl.

Comment by Chris Lott [08/Jun/12 10:54 PM]
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryResult;
import org.openrdf.repository.http.HTTPRepository;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.rdbms.mysql.MySqlStore;

/**
 * Tests context implementation by searching for statements that have context.
 *
 * @author clott
 */
public class TestGetStatementsWithContext {

/**
* Arguments control which repository implementation is used. Invoke with:
* <UL>
* <LI>1 argument: the URI of a remote repository
* <LI>4 arguments: the host name, database name, user name and password for
* a MySQL repository
* </UL>
*
* @param args
*/
public static void main(String[] args) {

try {
// Get started
Repository repo = null;
if (args.length == 4) {
System.out.println("Using mysql repository on host " + args[0]);
MySqlStore sqlStore = new MySqlStore(args[1]);
sqlStore.setServerName(args[0]);
sqlStore.setPortNumber(3306);
sqlStore.setUser(args[2]);
sqlStore.setPassword(args[3]);
repo = new SailRepository(sqlStore);
} else if (args.length == 1) {
System.out.println("Using remote repository at " + args[0]);
repo = new HTTPRepository(args[0]);
} else {
System.err.println("Too few arguments");
return;
}

// Init the repo
System.out.println("Initializating and connecting");
repo.initialize();
RepositoryConnection con = repo.getConnection();

// Get statements in context
System.out.println("Retrieving statements in known context");
URI context = new URIImpl(
"http://www.mydomain.org/foo/bar#baz");
RepositoryResult<Statement> stmts = con.getStatements(null, null,
null, false, context);

// Show the statements. Context is always null.
// Same result if the context arg is omitted above.
while (stmts.hasNext()) {
Statement stmt = stmts.next();
System.out.println("Object type is "
+ stmt.getClass().getName());
System.out.println(stmt.toString());
}
stmts.close();

System.out.println("Closing connection and repository");
con.close();

// Release the lock on the repository
repo.shutDown();

} catch (Exception ex) {
ex.printStackTrace();
}
}
}

Comment by Chris Lott [08/Jun/12 11:06 PM]
I cannot figure out how to edit the applies-to version in this bug, it's definitely not 2.0beta, sorry for confusion.

Anyhow I tried one more experiment, namely adjusting the preferred RDF format used by the HTTP client to TRIG, but that did not work either, still no context in the result. I also tried TRIX.

if (repo instanceof HTTPRepository) {
HTTPRepository httpRepo = (HTTPRepository) repo;
httpRepo.setPreferredRDFFormat(RDFFormat.TRIG);
}

Comment by Jeen Broekstra [11/Jun/12 12:47 AM]
not a problem chris, I think only admins can fix those fields, done now.

Comment by Jeen Broekstra [13/Jun/12 07:03 AM]
I can not reproduce this issue at all. Please note that core functionality like this is covered by the conformance tests which are run on every SVN commit. These tests all greenline, which makes me suspicious that something else is going on in your surroundings.

You should not need to set a preferred RDF format at all for this, by the way: the HTTPClient automatically selects only those formats that support contexts for the accept header.

Can you set your server logs to record debug-level info and then see what the incoming request parameters on the server look like? server logging is configured by going to the Sesame application datadir (see http://www.openrdf.org/doc/sesame2/users/ch05.html) and editing /conf/logback.xml. You may need to restart Sesame for the changes to take effect.

Comment by Chris Lott [13/Jun/12 01:43 PM]
Thanks for trying. Today I cannot reproduce the problem either :( Must be some error between the chair and the keyboard. Sorry to waste your time. Please close this issue. If I find a reliable reproduce-by example I will reopen or post.

Comment by Jeen Broekstra [13/Jun/12 11:16 PM]
No problem :)