"My Github page" ======= ODRLAPI by vroddon @ OEG-UPM

ODRLAPI

A Java API to manipulate ODRL2.0 RDF expressions

Introduction

ODRL2.0 is a language to express policies: permissions, prohibitions, obligations. It is specified by the ODRL W3C Community and Business Group

This API is able to manipulate (read/write) expressions conformant to a subset of the Core Model specification and Common Vocabulary.

ODRL2.0 can be serialized as XML, as JSON or as RDF based on the draft ODRL2.0 Ontology. The only serialization this Java API supports in this version is the RDF

ODRL2.0 Core Model is abstract, i.e., serialization independent. The examples in this document assume the RDF serialization. The most common prefixes are:
prefixnamespace
odrlhttp://www.w3.org/ns/odrl/2/
dcthttp://purl.org/dc/terms/

Examples

A policy may represent the following statement: "The asset 9898 can be read and written".

The following example is taken from the official ODRL example 1

http://example.com/policy:0099
        a                 odrl:Policy , odrl:Set ;
        odrl:permission   [ a            odrl:Permission ;
                            odrl:action  odrl:write , odrl:read ;
                            odrl:target  "http://example.com/asset:9898"
                          ] ;

In order to produce that code, the ODRLAPI can be used, by typing the excerpt shown below

This may have been defined in Java with the
        Policy policy = new Policy("http://example.com/policy:0099");
        Permission permission = new Permission();
        permission.setTarget("http://example.com/asset:9898");
        permission.setActions(Arrays.asList(new Action("http://www.w3.org/ns/odrl/2/read"), new Action("http://www.w3.org/ns/odrl/2/write")));
        policy.addRule(permission);
        System.out.println(ODRLRDF.getRDF(policy, Lang.TTL));

The first line creates an object of type Policy An empty string creates anonymous objects.

Note we have created a resource, policy:01, of class odrl:Set, with a single permission: the permitted Actions (read, write), and the resource, an Asset (asset9898).

The last line converts objects in the ODRL2.0 Simple API Model to the RDF (Turtle by default) serialization. Indeed, RDF/XML, N-Triples etc. are also supported.

The source code includes 7 full examples of working source code for you to start digging. Look into the examples folder.

Full documentation

Full documentation here

License

This software is under a totally permisive MIT license. We are happy if you mention us, though.
The MIT License (MIT) Copyright (c) 2014 Ontology Engineering Group (OEG-UPM) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.