Getting Started with Open Anzo JavaScript Client

133 views
Skip to first unread message

Michael McIntosh

unread,
Dec 14, 2010, 9:06:36 AM12/14/10
to OpenAnzo
Hi Open Anzo Team,

I am evaluating Open Anzo for use in a project. I have successfully
downloaded and started the Application Server. I am struggling to find
documentation for the JavaScript client API setup. I have searched the
archives and seen mention of a tutorial, but haven't found it. Is
there a .js script file I need to include? Is there a browser
extension/DLL?

Regards,
Mike McIntosh

Rouben Meschian

unread,
Dec 14, 2010, 1:59:44 PM12/14/10
to open...@googlegroups.com
Hi Mike,

Go here: http://www.openanzo.org/projects/openanzo/wiki
Look for the Anzo.JS Development Guide

hope this helps,
-Rouben Meschian

> --
> You received this message because you are currently subscribed to the "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com
> To unsubscribe from this group, send email to openanzo-u...@googlegroups.com
>
> For more options, visit this group at http://groups.google.com/group/openanzo?hl=en

Michael McIntosh

unread,
Dec 15, 2010, 8:40:26 AM12/15/10
to open...@googlegroups.com
Rouben,

Thanks for responding. I've gone through that and gotten it working. I've found a few places where the documentation didn't match the implementation. Should I send that information to someone specific or just post it here?

Regards,
Mike

Rouben Meschian

unread,
Dec 15, 2010, 11:49:36 AM12/15/10
to open...@googlegroups.com
Hi Michael,

I'm glad you were able to get going with openanzo. Please post
document discrepancies here and we will try to update the docs as soon
as we can.

Thanks for you interest in openanzo,
-Rouben

Michael McIntosh

unread,
Dec 15, 2010, 2:54:09 PM12/15/10
to open...@googlegroups.com
The two main documentation problems I've found so far are:
- The 2nd param in getReplicaGraph seems to default to "false", not "true" as is documented. At least, the only way I was able to get it to work was to explicitly provide the parameter set to true.
- The getMetadataGraph function does not exist. I was able to figure out how to work around it by looking at the js files.

I have an initial set of questions:

When I create a local replica ... Does it persist between browser sessions? Where is it stored? Just in browser memory?
- Could we write a pair of functions (using a browser plugin) to serialize and deserialize graphs to/from local storage?
- Which client APIs only work on graphs that have been saved to the server?
- What obvious problems are there with this approach?

In a Browser - does each tab have its own replica cache?

Can we place the JS code in a browser extension and connect to a specific server? (it seems to just connect back to where it came from, not sure how to tell it to connect to a specific server).

Is anyone building a C++ client library?

Are graph names scoped by user?
- How does the access control work? Is the granularity a context? a statement?
- Is the access control documented?
- How do we manage users? Can we integrate OAuth?

Can App Server work with a load balancing solution?

Regards,
Mike

Rouben Meschian

unread,
Dec 16, 2010, 12:13:11 PM12/16/10
to open...@googlegroups.com
Hi Michael,

When I create a local replica ... Does it persist between browser

sessions? No. You can simply re-download the graph by calling
getReplicaGraph. Where is it stored? Graphs are stored on the server,
then downloaded and stored in a local quad store. Just in browser
memory? Yes, the cache is in the browser mem.
If you get a replica graph using the getReplicaGraph method it is
synced with the server. A copy is downloaded and cached locally but
it stays in sync with the server (if the server copy changes so will
the local cache). After you make changes you can send them back up to
the server. All this stuff is in the docs.

- Could we write a pair of functions (using a browser plugin) to

serialize and deserialize graphs to/from local storage? - Sure you
can...just do a graph.find() and store those stmts wherever you want


- Which client APIs only work on graphs that have been saved to the

server? -The methods that are on the AnzoClient are the ones that deal
with the server
- What obvious problems are there with this approach? - with what approach?

In a Browser - does each tab have its own replica cache? - yes

Can we place the JS code in a browser extension and connect to a
specific server? (it seems to just connect back to where it came from,

not sure how to tell it to connect to a specific server). -Not sure
what you mean, read the docs on the AnzoClient.js API on how to
connect to a server.

Is anyone building a C++ client library? -Not that i know of

Are graph names scoped by user? -not sure what you mean by scoped...we
have role based access control if that's what u mean


- How does the access control work? Is the granularity a context? a

statement? -it's at a named graph level...the metadata graph of each
graph says what roles have what access
- Is the access control documented? -yes, but i'm not sure if we
pushed it out onto the openanzo wiki...it may still be internal. i'll
see what's going on with that

Jordi Albornoz Mulligan

unread,
Dec 16, 2010, 1:27:31 PM12/16/10
to open...@googlegroups.com
I see Rouben replied. I try to give some more details here too.

On 12/15/2010 2:54 PM, Michael McIntosh wrote:
> The two main documentation problems I've found so far are:
> - The 2nd param in getReplicaGraph seems to default to "false", not
> "true" as is documented. At least, the only way I was able to get it to
> work was to explicitly provide the parameter set to true.
> - The getMetadataGraph function does not exist. I was able to figure out
> how to work around it by looking at the js files.

The API documentation is written in an abstract way. Each language
implementation of the API tries to abide by the conventions of that
language, so in JavaScript, it's a metadataGraph property rather than a
getMetadataGraph method.

> I have an initial set of questions:
>
> When I create a local replica ... Does it persist between browser
> sessions?

No. It does not.

> Where is it stored? Just in browser memory?

Correct. When using the JavaScript API (a.k.a Anzo.js), the replica
contents are in browser memory.

> - Could we write a pair of functions (using a browser plugin) to
> serialize and deserialize graphs to/from local storage?

It's certainly possible, yes. The Java client API has experimented in
the past with persistent storage of the replicas using embedded RDBs
like Derby.

> - Which client APIs only work on graphs that have been saved to the server?

I'm pretty sure there aren't any APIs you can call on a graph object
that only work on server-backed graphs or only work on straight memory
graphs.

If you just want to work completely in memory, without having a graph
backed by the server, the typical object you instantiate is the
anzo.rdf.NamedGraph object. If you instead want to be able to commit the
graph to the server you obtain a graph from a logged-in AnzoClient
instance with the getReplicaGraph method. The getReplicaGraph returns
instances of the anzo.client.ClientGraph class. The anzo.rdf.NamedGraph
class and anzo.client.ClientGraph class both implement all of the same
graph methods (as defined by the anzo.rdf.INamedGraph interface). The
only exception to that is that an anzo.client.ClientGraph has a
metadataGraph property. That property is for the metadata graph which
holds metadata about the graph like access control, etc.

The main difference between graphs just held in memory
(anzo.rdf.NamedGraph) and graphs backed by the server
(anzo.client.ClientGraph) is just in behavior. It's just in the fact
that graphs backed by the server the graphs can be persisted whch gives
you various capabilities. For example, you can send SPARQL queries to
the server which look at those graphs, you can subscribe to
notifications when other applications change the graph on the server, etc.

> - What obvious problems are there with this approach?

I'm not sure what approach you are talking about. Do you mean the idea
of persisting the client replicas? There aren't any obvious problems,
just challenges to ensure you can efficiently make use of the data
you've persisted. In particular, if a graph changes while the user is
not using the app, when the user returns the graph should be
synchronized efficiently. A naive approach is to throw out the replica
in that case but the Anzo server's replication service can help you
obtain just the differences that have changed. The naive approach That
is enough for many situations. But for the replication approach the
challenge is just that it means tying in at a lower level in the API
than for the naive approach.

If security is a concern, then that is another challenge. You need to
protect the persisted replicas appropriately across users.

> In a Browser - does each tab have its own replica cache?

Yes.

> Can we place the JS code in a browser extension and connect to a
> specific server? (it seems to just connect back to where it came from,
> not sure how to tell it to connect to a specific server).

That sounds possible. The JavaScript API can connect only to the server
where it came from due to typical same-origin/cross-domain browser
restrictions. You may also have some luck playing with some of the new
Cross-Origin Resource Sharing functionality in some browsers as well
(http://www.w3.org/TR/cors/)

> Is anyone building a C++ client library?

Not that we know of. But there is a .NET implementation of the client
API (written in C#) called Anzo.NET that you can download.

> Are graph names scoped by user?

No. Named Graph URIs are global on the server.

> - How does the access control work? Is the granularity a context? a
> statement?

Granularity is a context (a.k.a. a named graph). Access control works by
setting statements in a named graph's metadata graph.

For example, for a named graph with URI: ex:MyGraph, the metadata graph
would contain statements such as (in TTL syntax):
@prefix ex: <http://example.org/> .
@prefix anzo: <http://openanzo.org/ontologies/2008/07/Anzo#> .
ex:MyGraph anzo:canBeReadyBy ex:User1 ;
anzo:canBeReadBy ex:User1 ;
anzo:canBeAddedToBy ex:User1 ;
anzo:canBeRemovedFromBy ex:User1 ;
.

Writing those statements is how you control access. The URI of the
logged in user can be found in the AnzoClient object's 'userUri' property.

canBeAddedToBy means adding triples to the graph, canBeRemovedFromBy
means removing triples from the graph, canBeReadBy means reading the
triples in the graph.

The metadata graph is also useful for provenance information which the
server records such as the version number of the graph, the user which
created and when, the user which last modified it and when.

Have you setup the Anzo Command Line Interface? It's a great way to
browse around to learn about what's in a metadata graph. For example, to
view a graphs data as well as its metadata graph, I could do:
anzo get -m http://example.org/MyGraph

See http://www.openanzo.org/projects/openanzo/wiki/CommandLineInterface

> - Is the access control documented?
> - How do we manage users? Can we integrate OAuth?

Users in Anzo are determined by an LDAP directory. You can set it up to
connect to an existing one. By default, Anzo uses an embedded one. When
Anzo is running, you should be able to connect to it using an LDAP
client like JXplorer. Connect on port 31389 with user DN:
uid=admin,ou=system
password:
secret
at least that's the default config on the downloaded server I believe.
You can use that to manage users. But in a real deployment, you should
be using a real LDAP server rather than the embedded one.

> Can App Server work with a load balancing solution?

It should be able to but you'll need session affinity to the server. And
you should also consider that the Anzo.js implementation is based around
comet long-polling techniques so the load balancer will need to be able
to handle that well (that is, not close connections held open a long
time, handle many simultaneous open connections well, etc.)

> On Wed, Dec 15, 2010 at 11:49 AM, Rouben Meschian <rmes...@gmail.com
> <mailto:rmes...@gmail.com>> wrote:
>
> Hi Michael,
>
> I'm glad you were able to get going with openanzo. Please post
> document discrepancies here and we will try to update the docs as soon
> as we can.
>
> Thanks for you interest in openanzo,
> -Rouben
>
> On Wed, Dec 15, 2010 at 8:40 AM, Michael McIntosh <mmci...@acm.org
> <mailto:mmci...@acm.org>> wrote:
> > Rouben,
> > Thanks for responding. I've gone through that and gotten it
> working. I've
> > found a few places where the documentation didn't match the
> implementation.
> > Should I send that information to someone specific or just post
> it here?
> > Regards,
> > Mike
> >
> > On Tue, Dec 14, 2010 at 1:59 PM, Rouben Meschian

> <rmes...@gmail.com <mailto:rmes...@gmail.com>>


> > wrote:
> >>
> >> Hi Mike,
> >>
> >> Go here: http://www.openanzo.org/projects/openanzo/wiki
> >> Look for the Anzo.JS Development Guide
> >>
> >> hope this helps,
> >> -Rouben Meschian
> >>
> >> On Tue, Dec 14, 2010 at 9:06 AM, Michael McIntosh

> >> <mike.g....@gmail.com <mailto:mike.g....@gmail.com>>


> wrote:
> >> > Hi Open Anzo Team,
> >> >
> >> > I am evaluating Open Anzo for use in a project. I have
> successfully
> >> > downloaded and started the Application Server. I am struggling
> to find
> >> > documentation for the JavaScript client API setup. I have
> searched the
> >> > archives and seen mention of a tutorial, but haven't found it. Is
> >> > there a .js script file I need to include? Is there a browser
> >> > extension/DLL?
> >> >
> >> > Regards,
> >> > Mike McIntosh
> >> >
> >> > --
> >> > You received this message because you are currently subscribed
> to the
> >> > "OpenAnzo" group.
> >> >
> >> > To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> >> > To unsubscribe from this group, send email to
> >> > openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


> >> >
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/openanzo?hl=en
> >>
> >> --
> >> You received this message because you are currently subscribed
> to the
> >> "OpenAnzo" group.
> >>
> >> To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> >> To unsubscribe from this group, send email to
> >> openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


> >>
> >> For more options, visit this group at
> >> http://groups.google.com/group/openanzo?hl=en
> >
> > --
> > You received this message because you are currently subscribed to the
> > "OpenAnzo" group.
> >
> > To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> > To unsubscribe from this group, send email to
> > openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


> >
> > For more options, visit this group at
> > http://groups.google.com/group/openanzo?hl=en
>
> --
> You received this message because you are currently subscribed to
> the "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en
>
>
> --
> You received this message because you are currently subscribed to the
> "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com
> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en


--
Jordi Albornoz Mulligan
Founding Engineer - Cambridge Semantics
jo...@cambridgesemantics.com
(617) 401-7321

Michael McIntosh

unread,
Dec 17, 2010, 3:30:06 PM12/17/10
to open...@googlegroups.com
Rouben and Jordi,

Thanks for taking the time to respond in such detail - it has helped tremendously.

My "app" is really a browser extension that injects JavaScript onto each page. Since this JavaScript is not downloaded, it is able to send requests to any server it wants to. Assuming I distributed the Open Anzo JavaScripts in the browser extension, I am not sure there is a way for me to specify where my server is for replication. I will look thru the code to see if there is an obvious way later tonight, but I haven't found any docs that specify how to connect the client to a specific server. I think it just assumes that it should connect to the server it came from (and in my case it doesn't come from a server).

Most of the graphs that I will want to access from the scripts that run on most pages are shared generic/read-only (or write very rarely) graphs. But some of them are large and there are quite a few. The graphs that are frequently modified are usually user specific, though some are shared.

In order to cut down on the data transfer needed for the graphs to be avialable to the scripts running on each page, I'd like to cache them locally. Since I have a browser extension that can access local storage (in the browser or otherwise), I am considering options for caching.

Presumably I could create a function like getReplicaGraph that tries to load the graph from local storage before trying to get it from the server. If it is loaded from the server, its obvious that the replication logic will work correctly. If its loaded from disk I am not sure how to let the replication framework know that it exists and should be treated like a local replica that might need updating. I also suspect I need to be careful not to just create a local graph and add statements from those on disk or the replication logic might see those as new statements and add them to the graph on the server, again.

Any advice derived from prior experimentations with persisting graphs locally would be appreciated.

Regards,
Mike

Sean Martin

unread,
Dec 17, 2010, 4:14:01 PM12/17/10
to open...@googlegroups.com

I wonder if it would be viable to serialize the cached in memory quad store (perhaps using Json) and hold this as a javascript in the the browser extension and then inject that into new pages as needed? Another option, depending on the implementation of the browser extension, might be to re-implement the current replica store to run in the extension and then inject JavaScript into the pages that can access that shared replica store.

 

Kindest regards, Sean

 

--

Sean Martin,

Founder & CTO, Cambridge Semantics Inc. 

email/XMPP: se...@cambridgesemantics.com 

phone: +1 617 606 3411

FOAF:  http://www.cambridgesemantics.com/people/sean

Jordi Albornoz Mulligan

unread,
Dec 17, 2010, 6:04:55 PM12/17/10
to open...@googlegroups.com
On 12/17/2010 3:30 PM, Michael McIntosh wrote:
> Rouben and Jordi,
>
> Thanks for taking the time to respond in such detail - it has helped
> tremendously.
>
> My "app" is really a browser extension that injects JavaScript onto each
> page. Since this JavaScript is not downloaded, it is able to send
> requests to any server it wants to. Assuming I distributed the Open Anzo
> JavaScripts in the browser extension, I am not sure there is a way for
> me to specify where my server is for replication. I will look thru the
> code to see if there is an obvious way later tonight, but I haven't
> found any docs that specify how to connect the client to a specific
> server. I think it just assumes that it should connect to the server it
> came from (and in my case it doesn't come from a server).

You should be able to just set an absolute URI for 'location' in the
properties you give the AnzoClient constructor. See the documentation
for the constructor in the code:
http://www.openanzo.org/projects/openanzo/browser/openanzo/trunk/org.openanzo.js/src/main/resources/docroot/anzo/client/AnzoClient.js#L64

You may want to download the code as there are documentation comment
blocks in many of the methods.

You can checkout the code from SVN with a command like:
svn co http://svn.openanzo.org/svn/openanzo/openanzo/trunk/org.openanzo.js/

> Most of the graphs that I will want to access from the scripts that run
> on most pages are shared generic/read-only (or write very rarely)
> graphs. But some of them are large and there are quite a few. The graphs
> that are frequently modified are usually user specific, though some are
> shared.
>
> In order to cut down on the data transfer needed for the graphs to be
> avialable to the scripts running on each page, I'd like to cache them
> locally. Since I have a browser extension that can access local storage
> (in the browser or otherwise), I am considering options for caching.

Could you get away with just using a single AnzoClient connection that
belongs to the plugin? Then the replica would be part of the JavaScript
plugin's memory world and if you can simply get the injected JavaScript
to communicate with the plugin to do the operations on the page's
behalf, then the replicas will be shared by all pages. Could that be
enough? Or do you really need to persist them to disk?

> Presumably I could create a function like getReplicaGraph that tries to
> load the graph from local storage before trying to get it from the
> server. If it is loaded from the server, its obvious that the
> replication logic will work correctly. If its loaded from disk I am not
> sure how to let the replication framework know that it exists and should
> be treated like a local replica that might need updating. I also suspect
> I need to be careful not to just create a local graph and add statements
> from those on disk or the replication logic might see those as new
> statements and add them to the graph on the server, again.
>
> Any advice derived from prior experimentations with persisting graphs
> locally would be appreciated.

The getReplicaGraph wrapper approach that you suggest is likely a good
start. I would suggest that your wrapper would check if a graph exists
in your persisted store and, if so, it should check the version number
on the graph's metadata graph that's stored in your store. Then it
should send a simple request to the server to see if the graph exists
AND what its version number is. If it exists and it's the same version
as your persisted version, then you can use your persisted one. If it
exists but it's a different version, then wipe your persisted one and
retrieve the latest version from the server.

A request to check if a graph exists and what it's version number is
would look something like this:
dojo.require("anzo.client.Vocabulary");
dojo.require("anzo.utils.UriGenerator");

var anzoClient = // .. initialize AnzoClient

var myGraphUri = "http://example.org/MyGraph";
var metadataGraphUri =
anzo.utils.UriGenerator.getMetadataGraphUri(myGraphUri);

var statements = anzoClient.serverFind(
myGraphUri,
anzo.client.Vocabulary.revisionProperty,
null,
metadataGraphUri);

You should also subscribe to graph add and remove notifications and
apply those changes to your persisted version. You can subscribe to
notifications using dojo.connect on the graph object's 'statementsAdded'
and 'statementsRemoved' methods.

> <mailto:rmes...@gmail.com <mailto:rmes...@gmail.com>>> wrote:
>
> Hi Michael,
>
> I'm glad you were able to get going with openanzo. Please post
> document discrepancies here and we will try to update the
> docs as soon
> as we can.
>
> Thanks for you interest in openanzo,
> -Rouben
>
> On Wed, Dec 15, 2010 at 8:40 AM, Michael McIntosh
> <mmci...@acm.org <mailto:mmci...@acm.org>

> <mailto:mmci...@acm.org <mailto:mmci...@acm.org>>> wrote:
> > Rouben,
> > Thanks for responding. I've gone through that and gotten it
> working. I've
> > found a few places where the documentation didn't match the
> implementation.
> > Should I send that information to someone specific or just post
> it here?
> > Regards,
> > Mike
> >
> > On Tue, Dec 14, 2010 at 1:59 PM, Rouben Meschian
> <rmes...@gmail.com <mailto:rmes...@gmail.com>

> <mailto:rmes...@gmail.com <mailto:rmes...@gmail.com>>>


>
> > wrote:
> >>
> >> Hi Mike,
> >>
> >> Go here: http://www.openanzo.org/projects/openanzo/wiki
> >> Look for the Anzo.JS Development Guide
> >>
> >> hope this helps,
> >> -Rouben Meschian
> >>
> >> On Tue, Dec 14, 2010 at 9:06 AM, Michael McIntosh
> >> <mike.g....@gmail.com
> <mailto:mike.g....@gmail.com>

> <mailto:mike.g....@gmail.com


> <mailto:mike.g....@gmail.com>>>
>
> wrote:
> >> > Hi Open Anzo Team,
> >> >
> >> > I am evaluating Open Anzo for use in a project. I have
> successfully
> >> > downloaded and started the Application Server. I am struggling
> to find
> >> > documentation for the JavaScript client API setup. I have
> searched the
> >> > archives and seen mention of a tutorial, but haven't found
> it. Is
> >> > there a .js script file I need to include? Is there a browser
> >> > extension/DLL?
> >> >
> >> > Regards,
> >> > Mike McIntosh
> >> >
> >> > --
> >> > You received this message because you are currently subscribed
> to the
> >> > "OpenAnzo" group.
> >> >
> >> > To post to this group, send email to
> open...@googlegroups.com <mailto:open...@googlegroups.com>

> <mailto:open...@googlegroups.com


> <mailto:open...@googlegroups.com>>
>
> >> > To unsubscribe from this group, send email to
> >> > openanzo-u...@googlegroups.com
> <mailto:openanzo-u...@googlegroups.com>

> <mailto:openanzo-u...@googlegroups.com


> <mailto:openanzo-u...@googlegroups.com>>
>
> >> >
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/openanzo?hl=en
> >>
> >> --
> >> You received this message because you are currently subscribed
> to the
> >> "OpenAnzo" group.
> >>
> >> To post to this group, send email to
> open...@googlegroups.com <mailto:open...@googlegroups.com>

> <mailto:open...@googlegroups.com


> <mailto:open...@googlegroups.com>>
>
> >> To unsubscribe from this group, send email to
> >> openanzo-u...@googlegroups.com
> <mailto:openanzo-u...@googlegroups.com>

> <mailto:openanzo-u...@googlegroups.com


> <mailto:openanzo-u...@googlegroups.com>>
>
> >>
> >> For more options, visit this group at
> >> http://groups.google.com/group/openanzo?hl=en
> >
> > --
> > You received this message because you are currently
> subscribed to the
> > "OpenAnzo" group.
> >
> > To post to this group, send email to
> open...@googlegroups.com <mailto:open...@googlegroups.com>

> <mailto:open...@googlegroups.com


> <mailto:open...@googlegroups.com>>
>
> > To unsubscribe from this group, send email to
> > openanzo-u...@googlegroups.com
> <mailto:openanzo-u...@googlegroups.com>

> <mailto:openanzo-u...@googlegroups.com


> <mailto:openanzo-u...@googlegroups.com>>
>
> >
> > For more options, visit this group at
> > http://groups.google.com/group/openanzo?hl=en
>
> --
> You received this message because you are currently
> subscribed to
> the "OpenAnzo" group.
>
> To post to this group, send email to
> open...@googlegroups.com <mailto:open...@googlegroups.com>

> <mailto:open...@googlegroups.com


> <mailto:open...@googlegroups.com>>
>
> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com
> <mailto:openanzo-u...@googlegroups.com>

> <mailto:openanzo-u...@googlegroups.com


> <mailto:openanzo-u...@googlegroups.com>>
>
>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en
>
>
> --
> You received this message because you are currently subscribed
> to the
> "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com
> <mailto:open...@googlegroups.com>
> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com
> <mailto:openanzo-u...@googlegroups.com>
>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en
>
>
>
> --

> Jordi Albornoz Mulligan
> Founding Engineer - Cambridge Semantics

> jo...@cambridgesemantics.com <mailto:jo...@cambridgesemantics.com>

Michael McIntosh

unread,
Dec 19, 2010, 4:25:28 PM12/19/10
to open...@googlegroups.com
Can Open Anzo work thru a proxy server? Do the communications between client and server flow over ports other than 80 and 443? Can the server be extended to deal with other data sources (in addition to the Quad store DB)?

Regards,
Mike

Jordi Albornoz Mulligan

unread,
Dec 20, 2010, 5:38:04 PM12/20/10
to open...@googlegroups.com
On 12/19/2010 4:25 PM, Michael McIntosh wrote:
> Can Open Anzo work thru a proxy server?

Sure.

> Do the communications between
> client and server flow over ports other than 80 and 443?

The JavaScript client (Anzo.js) only uses HTTP to communicate. So by
default it'll stick to 80 and 443 but, of course, you can use alternate
ports in the location like 8080, etc.

It sticks to just HTTP over some port.

The Java and .NET clients communicate via a long-lived TCP connection
that carries JMS messages (using one of the various wire format
incarnations for JMS).

> Can the server
> be extended to deal with other data sources (in addition to the Quad
> store DB)?

Yes.

For example, at Cambridge Semantics we've created a data source
implementation for LDAP and some other sources.

This involves writing a Java Open Anzo data source implementation which
essentially implements the basic operations like retrieving a graph,
writing to a graph (if applicable), etc. It also is where the concept of
what actually is a 'graph' in your datasource is defined.

> <mailto:jo...@cambridgesemantics.com

> Jordi Albornoz Mulligan
> Founding Engineer - Cambridge Semantics
> jo...@cambridgesemantics.com
> <mailto:jo...@cambridgesemantics.com>

> <mailto:jo...@cambridgesemantics.com

Michael McIntosh

unread,
Dec 28, 2010, 12:21:46 PM12/28/10
to open...@googlegroups.com
All of the examples and docs I've found for the Command Line Client seem to show it running on same machine as server. Is it possible to configure it to talk to a server running on another machine?

Regards,
Mike McIntosh

Michael McIntosh

unread,
Dec 28, 2010, 12:54:47 PM12/28/10
to open...@googlegroups.com
http://www.openanzo.org/projects/openanzo/wiki/ConfigureAnzo#ApacheDerby implies that Apache Derby is supported, but that conflicts with other information on other pages. IS it supported?

Danny Kahn

unread,
Dec 28, 2010, 1:09:14 PM12/28/10
to open...@googlegroups.com
Yes, you can use the Command Line Client to talk to a server running on another machine. Just use the -h option to specify the host.

On Tue, Dec 28, 2010 at 12:21 PM, Michael McIntosh <mmci...@acm.org> wrote:

Jordi Albornoz Mulligan

unread,
Dec 29, 2010, 2:40:58 PM12/29/10
to open...@googlegroups.com
On 12/28/2010 12:54 PM, Michael McIntosh wrote:
> http://www.openanzo.org/projects/openanzo/wiki/ConfigureAnzo#ApacheDerby implies
> that Apache Derby is supported, but that conflicts with other
> information on other pages. IS it supported?

No. It may work but the preferred embedded-style database at this point
is H2.

> On Tue, Dec 28, 2010 at 12:21 PM, Michael McIntosh <mmci...@acm.org
> <mailto:mmci...@acm.org>> wrote:
>
> All of the examples and docs I've found for the Command Line Client
> seem to show it running on same machine as server. Is it possible to
> configure it to talk to a server running on another machine?
>
> Regards,
> Mike McIntosh
>
> On Mon, Dec 20, 2010 at 5:38 PM, Jordi Albornoz Mulligan

> <jo...@cambridgesemantics.com <mailto:jo...@cambridgesemantics.com>>

> Jordi Albornoz Mulligan
> Founding Engineer - Cambridge Semantics
> jo...@cambridgesemantics.com
> <mailto:jo...@cambridgesemantics.com>
> <mailto:jo...@cambridgesemantics.com
> <mailto:jo...@cambridgesemantics.com>>

Michael McIntosh

unread,
Jan 7, 2011, 1:31:25 PM1/7/11
to open...@googlegroups.com
I've made a lot of progress in getting my Chrome extension to work, so far...

The only changes I've had to make were inside Dojo (convincing it that "chrome-extension:" is a local prefix and not to use cross domain logic since cross domain XHR works fine from inside an extension).

The current challenge is that I need to get the access controls to work. I am not sure if I am doing something wrong or not but...

It seems like by default all graphs are open to all operations by all users? (I created/modified a graph as sysadmin, read/modified it as peter).

I added this statement to the metagraph and still could read as peter:
Is there something I need to configure beyond the defaults to make the access controls work?

Also, are there any tools that can be used to add/manage users in the LDAP or do I need to right something using the LDAP API?

Regards,
Mike

Michael McIntosh

unread,
Jan 7, 2011, 3:28:04 PM1/7/11
to open...@googlegroups.com
I've noticed that my changes to the metagraph are not being persisted to the server. Is there some secret to this?
Also, while trying to debug that I've tried to find the getServerGraph function and cannot, is there a JS version of this function?

Regards,
Mike

Ben Szekely

unread,
Jan 7, 2011, 3:33:08 PM1/7/11
to open...@googlegroups.com
Hi Mike -
     Because of the asynchronous nature of JS, we chose not to implement getServerGraph in JS because all calls would require callbacks and could become quite unwieldy.  Are you sure you are committing your transactions and calling updateRepository after the metadata graph changes?  Let me know if you want a second pair of eyes on any code.

- Ben

Michael McIntosh

unread,
Jan 7, 2011, 3:52:31 PM1/7/11
to open...@googlegroups.com
Id be glad to have you look. Since I'm still in learning mode, I've mostly just taken the testapp sample, moved the code into my extension, and made small changes, so the code should look familiar. Other than the changes to dojo that I mentioned previously, I've added code to get the metagraph replica, add a canBeReadBy statement, and print out the statements in the metagraph. The code below comes from the extension's background.html file. The first set of output is the output from running the extension code. The second set of output is from running the example on the server. The code running on the server is the same as what is on the extension except that is does not add the canBeReadBy statement to the metadata. However, since the extension has already run and added that statement you would presume that it would show up in the output (but it doesn't).

-----BEGIN CODE-----
<script type="text/javascript">
var djConfig = {
modulePaths: {
'anzo': '/openanzo-js/anzo',
'dojo': '/openanzo-js/dojo',
'dojox': '/openanzo-js/dojox',
'util': '/openanzo-js/util'
}
};

</script>

<script type="text/javascript" src="chrome-extension://aopebkbickjilecocnpojpellaiiahlc/openanzo-js/dojo/dojo.js"></script>
<script type="text/javascript">
// Patches XHR response validation for requests from background pages to the chrome-extension:// protocol. 
(function(){ 
var _isDocumentOk = dojo._isDocumentOk; 
dojo._isDocumentOk = function(http){ 
return !http.status || _isDocumentOk(http); 
};
})(); 
console.log("Dojo Require.");
dojo.require("anzo.client.AnzoClient");
dojo.require("anzo.rdf.Statement");
dojo.require("dojo.io.script");

console.log("Creating AnzoClient instance.");
// UPDATE THE VALUES BELOW TO CONNECT TO YOUR SERVER
var properties = {
location            : "http://" + localStorage.server + "/cometd/", // location of the comet service
username            : localStorage.username, // username for authentication (sysadmin)
password            : localStorage.password // password for authentication (123)
}
function setStatus(msg, isLoading) {
console.log(msg);
}

var anzoClient = new anzo.client.AnzoClient(properties);

// connect to the server
setStatus("Connecting to the server.");
anzoClient.connect(function(status, message) {

// check if the connect was successful
if (status != anzo.messaging.CONNECTION_STATUS_CONNECTED) {
setStatus("Failed to connect to the server: " + message);
throw Error("Failed to connect to the server: " + message);
}

setStatus("Connected to the server.");

// use the anzo node API to create some URIs and statements.
var graphUri = anzo.createURI("http://example.org/graph1");
var predUri = anzo.createURI("http://example.org/pred1");
var stmt1 = anzo.createStatement(graphUri, predUri, "val1", graphUri);
var stmt2 = anzo.createStatement(graphUri, predUri, "val2", graphUri);
var stmt3 = anzo.createStatement(graphUri, predUri, "val3", graphUri);
// begin a transaction
anzoClient.begin();

setStatus("Tranaction begun, getting replica.");
// create a new graph.  getReplicaGraph creates a new graph if it doesn't exist
anzoClient.getReplicaGraph(graphUri, false, function(graph, error) {
setStatus("Got replica graph: " + graphUri);
var metaGraphUri  = anzo.utils.UriGenerator.getMetadataGraphUri(graphUri);

anzoClient.getReplicaGraph(metaGraphUri, false, function(metagraph, error) {
setStatus("Got replica metadata graph: " + metaGraphUri);

var canBeReadByURI = anzo.createURI("http://openanzo.org/ontologies/2008/07/Anzo#canBeReadyBy");
var accessControlStmt = anzo.createStatement(graphUri, canBeReadByURI, "http://openanzo.org/system/internal/sysadmin", metaGraphUri);
metagraph.add(accessControlStmt);

var metastmts = metagraph.getStatements();
for (var i=0;i<metastmts.length;i++) {
setStatus("Meatadata Statement: " + metastmts[i].subject + ", " + metastmts[i].predicate + ", " + metastmts[i].object);
}
metagraph.close();
});
// add couple statements to the graph
graph.add(stmt1);
console.log("after add1");
graph.add(stmt2);
console.log("after add2");
graph.add(stmt3);
console.log("after add3");
// commit the transaction
anzoClient.commit();
console.log("after commit");
setStatus("Tranaction committed.");

// setup a callback for the updateRepository call.
var handle = dojo.connect(anzoClient,"updateRepositoryComplete", function(success, errors) {
dojo.disconnect(handle);
setStatus("Repository udpate complete");

// check that the statements are in the graph
var stmts = graph.getStatements();
for (var i=0;i<stmts.length;i++) {
setStatus("Statement added: " + stmts[i].subject + ", " + stmts[i].predicate + ", " + stmts[i].object);
}

// close the graph and disconnect the client
graph.close();
anzoClient.close(function(status){
setStatus("Disconnected from server");
});
});
anzoClient.updateRepository();

});
setStatus("Done.");
});
</script>
-----END CODE-----

-----BEGIN EXTENSION OUTPUT-----
Dojo Require.
background.html:543Creating AnzoClient instance.
background.html:553Connecting to the server.
background.html:553Connected to the server.
background.html:553Tranaction begun, getting replica.
background.html:611after commit
background.html:553Tranaction committed.
background.html:553Repository udpate complete
background.html:553Disconnected from server
-----END EXTENSION OUTPUT-----

-----BEGIN SERVER OUTPUT-----
Status: Done
Connecting to the server.
Connected to the server.
Tranaction begun, getting replica.
Done.
Got replica graph: http://example.org/graph1
Tranaction committed.
Got replica metadata graph: http://openanzo.org/metadataGraphs(http%3A%2F%2Fexample.org%2Fgraph1)
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#lastModifiedByUser, http://openanzo.org/system/internal/sysadmin
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#uuid, http://openanzo.org/namedGraphUUID/revisioned/0d6da7ef-abb3-45bb-abd7-acea484ae00a
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#persisted, true
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#modified, 2011-01-07T20:32:41.488Z
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#hasMetadataGraph, http://openanzo.org/metadataGraphs(http%3A%2F%2Fexample.org%2Fgraph1)
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#datasource, http://openanzo.org/datasource/systemDatasource
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#revisioned, true
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#createdBy, http://openanzo.org/system/internal/sysadmin
Meatadata Statement: http://example.org/graph1, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://openanzo.org/ontologies/2008/07/Anzo#NamedGraph
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#created, 2011-01-07T20:28:11.152Z
Meatadata Statement: http://example.org/graph1, http://openanzo.org/ontologies/2008/07/Anzo#revision, 1
Repository udpate complete
Statement added: http://example.org/graph1, http://example.org/pred1, val2
Statement added: http://example.org/graph1, http://example.org/pred1, val1
Statement added: http://example.org/graph1, http://example.org/pred1, val3
Disconnected from server
-----END SERVER OUTPUT-----

Ben Szekely

unread,
Jan 7, 2011, 3:57:53 PM1/7/11
to open...@googlegroups.com
Hi Mike -
    Ah, an easy mistake to make - in the Anzo API, metadata graphs are not accessed the same way as regular graphs.  To access a metadata graph, you aquire a replica graph for the graph itself and the metadata graph is accessible from that. So you'd have


// create a new graph.  getReplicaGraph creates a new graph if it doesn't exist
anzoClient.getReplicaGraph(graphUri, false, function(graph, error) {
setStatus("Got replica graph: " + graphUri);
        var metadataGraph = graph.metadataGraph;
   
And you can skip the URI generator and the second call to getReplicaGraph.

- Ben

Sean Martin

unread,
Jan 7, 2011, 4:08:52 PM1/7/11
to open...@googlegroups.com

 

>Also, are there any tools that can be used to add/manage users in the LDAP or do I need to right something using the LDAP API?

 

Jexplorer works well http://jxplorer.org/   

 

Use the following config:

 

Host: localhost

Port: 31389

Protocol LDAP V3

Base DN:   <leave this field empty>

Level: User + Password

User DN: uid=admin,ou=system

Michael McIntosh

unread,
Jan 7, 2011, 4:20:27 PM1/7/11
to open...@googlegroups.com
Ben, 

That fixed part of the problem. I now see the statement in the metadata graph from the server:
There is still the problem that I can login as peter and see all the statements in the graph (there is no "canBeReadBy" statement for peter). Preferably, I'd like all graphs to be accessible only by the creator, unless they explicitly add read/add/etc for other users/groups. I am not sure what I am doing wrong by the access control statement (or absence thereof) have no effect.

Regards,
Mike

Ben Szekely

unread,
Jan 7, 2011, 4:38:59 PM1/7/11
to open...@googlegroups.com
It's possible that there is a "canBeReadyBy everyone" statement in your metadata graph.  How are exploring the data on the server at the moment?   The NamedGraphInitializer is a function that you ma pass in with every getReplicaGraph call and this can be used to set the permissions on graph using the available metadata graph before the graph is created or asserts one or preconditions before graph creation.  Take a look at AnzoClient.getGraphMustExistInitializer.  This is a built-in example using a precondition.  In your case, you will wan to add your ACL logic to the initializeNamedGraph method. 

- Ben

Michael McIntosh

unread,
Jan 7, 2011, 4:58:04 PM1/7/11
to open...@googlegroups.com
Ben,

I am using the code I sent you to get the metadata graph and print out all of the stmts in it (with the fix to not get the metadata replica). I see the canBeReadBy sysadmin statement (BTW if you look closely at the code you will see a typo I fixed "canBeReadyBy" with no change in result) but cannot see any other canBeXXXBy statement.

BTW, the server I am running on is externally visible so I can send you the address for you to hit directly if you want...

Regards,
Mike

Jordi Albornoz Mulligan

unread,
Jan 7, 2011, 5:13:44 PM1/7/11
to open...@googlegroups.com
On 1/7/2011 4:58 PM, Michael McIntosh wrote:
> Ben,
>
> I am using the code I sent you to get the metadata graph and print out
> all of the stmts in it (with the fix to not get the metadata replica). I
> see the canBeReadBy sysadmin statement (BTW if you look closely at the
> code you will see a typo I fixed "canBeRead*y*By" with no change in

> result) but cannot see any other canBeXXXBy statement.

Hi Mike,

Just a tip that might help reduce typos like this in the future. There
is an object with properties for these URIs "well-known" URIs already.

To use it do:
dojo.require("anzo.client.Vocabulary");
at the start of your component and then you can reference the properties as:
anzo.client.Vocabulary.canBeReadByProperty
anzo.client.Vocabulary.canBeAddedToByProperty
etc.

I find it useful to do something like:
var vocab = anzo.client.Vocabulary;
vocab.canBeReadByProperty

See the .../anzo/client/Vocabulary.js in the source for the properties
available.

There are also a few other vocabulary files you can find in
.../anzo/rdf/vocabulary.
For example:

dojo.require("anzo.rdf.vocabulary.RDF");
dojo.require("anzo.rdf.vocabulary.RDFS");

anzo.rdf.vocabulary.RDF.type
anzo.rdf.vocabulary.RDFS.label
etc.

>> <b...@cambridgesemantics.com <mailto:b...@cambridgesemantics.com>>

>>> <http://openanzo.org/metadataGraphs%28http%3A%2F%2Fexample.org%2Fgraph1>)

>>> <http://openanzo.org/metadataGraphs%28http%3A%2F%2Fexample.org%2Fgraph1>)

>>> <http://openanzo.org/metadataGraphs%28http%3A%2F%2Fexample.org%2Fgraph1%29>

>>> <http://openanzo.org/metadataGraphs%28http%3A%2F%2Fexample.org%2Fgraph1%29>

>>>> open...@googlegroups.com <mailto:open...@googlegroups.com>


>>>> To unsubscribe from this group, send email to
>>>> openanzo-u...@googlegroups.com

>>>> <mailto:openanzo-u...@googlegroups.com>


>>>>
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/openanzo?hl=en
>>>
>>> --
>>> You received this message because you are currently
>>> subscribed to the "OpenAnzo" group.
>>>
>>> To post to this group, send email to

>>> open...@googlegroups.com <mailto:open...@googlegroups.com>


>>> To unsubscribe from this group, send email to
>>> openanzo-u...@googlegroups.com

>>> <mailto:openanzo-u...@googlegroups.com>


>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/openanzo?hl=en
>>>
>>>
>>> --
>>> You received this message because you are currently
>>> subscribed to the "OpenAnzo" group.
>>>
>>> To post to this group, send email to

>>> open...@googlegroups.com <mailto:open...@googlegroups.com>


>>> To unsubscribe from this group, send email to
>>> openanzo-u...@googlegroups.com

>>> <mailto:openanzo-u...@googlegroups.com>


>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/openanzo?hl=en
>>
>> --
>> You received this message because you are currently subscribed
>> to the "OpenAnzo" group.
>>
>> To post to this group, send email to open...@googlegroups.com

>> <mailto:open...@googlegroups.com>


>> To unsubscribe from this group, send email to
>> openanzo-u...@googlegroups.com

>> <mailto:openanzo-u...@googlegroups.com>


>>
>> For more options, visit this group at
>> http://groups.google.com/group/openanzo?hl=en
>>
>>
>> --
>> You received this message because you are currently subscribed to
>> the "OpenAnzo" group.
>>
>> To post to this group, send email to open...@googlegroups.com

>> <mailto:open...@googlegroups.com>


>> To unsubscribe from this group, send email to
>> openanzo-u...@googlegroups.com

>> <mailto:openanzo-u...@googlegroups.com>


>>
>> For more options, visit this group at
>> http://groups.google.com/group/openanzo?hl=en
>
> --
> You received this message because you are currently subscribed to
> the "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en
>
>
> --
> You received this message because you are currently subscribed to the
> "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com
> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en


--

Michael McIntosh

unread,
Jan 10, 2011, 10:44:44 AM1/10/11
to open...@googlegroups.com
Do you have any client sample code (JS prefered but Java or C# would be fine) that shows how to create a graph with access control and then shows them working?
Reply all
Reply to author
Forward
0 new messages