use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class ClerezzaTripleCallback method triple.
private void triple(String s, String p, String value, String datatype, String language, String graph) {
final BlankNodeOrIRI subject = getBlankNodeOrIRI(s);
final IRI predicate = new IRI(p);
RDFTerm object;
if (language != null) {
object = new PlainLiteralImpl(value, new Language(language));
} else if (datatype == null || RDF_LANG_STRING.equals(datatype)) {
object = new PlainLiteralImpl(value);
} else {
object = new TypedLiteralImpl(value, new IRI(datatype));
}
mGraph.add(new TripleImpl(subject, predicate, object));
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class ClerezzaRDFParser method handleStatement.
private void handleStatement(RDFDataset result, Triple t, Map<BlankNode, String> bNodeMap) {
final String subject = getResourceValue(t.getSubject(), bNodeMap);
final String predicate = getResourceValue(t.getPredicate(), bNodeMap);
final RDFTerm object = t.getObject();
if (object instanceof Literal) {
final String value = ((Literal) object).getLexicalForm();
final String language;
final String datatype;
datatype = getResourceValue(((Literal) object).getDataType(), bNodeMap);
Language l = ((Literal) object).getLanguage();
if (l == null) {
language = null;
} else {
language = l.toString();
}
result.addTriple(subject, predicate, value, datatype, language);
count++;
} else {
result.addTriple(subject, predicate, getResourceValue((BlankNodeOrIRI) object, bNodeMap));
count++;
}
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class UserResource method storeRole.
private Response storeRole(GraphNode roleNode, UriInfo uriInfo, String roleName, String comment, List<String> permissions) {
BlankNodeOrIRI roleResource = (BlankNodeOrIRI) roleNode.getNode();
if (permissions != null) {
clearPermissions(roleResource);
Lock writeLock = systemGraph.getLock().writeLock();
writeLock.lock();
try {
for (int i = 0; i < permissions.size(); i++) {
permissions.set(i, permissions.get(i).trim());
if (!permissions.get(i).equals("")) {
addPermission(roleNode, permissions.get(i));
}
}
} finally {
writeLock.unlock();
}
}
//refresh the policy so it will recheck the permissions
Policy.getPolicy().refresh();
// showSystem();
URI pageUri = uriInfo.getBaseUriBuilder().path("system/console/usermanagement").build();
// header Cache-control: no-cache, just in case intermediaries are
// holding onto old stuff
CacheControl cc = new CacheControl();
cc.setNoCache(true);
// the jax-rs things available
return Response.seeOther(pageUri).cacheControl(cc).build();
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class UserAwarePolicy method getAllPermissionsOfAUserByName.
/**
* Returns the string representations of all permissions of a user. Those
* are his/her own permissions and the permissions of his roles
*
*/
private List<String> getAllPermissionsOfAUserByName(String userName) throws UserUnregisteredException {
BlankNodeOrIRI user = getUserByName(userName);
List<String> result = getPermissionEntriesOfAUser(user, userName);
Iterator<Triple> roleTriples = systemGraph.filter(user, SIOC.has_function, null);
while (roleTriples.hasNext()) {
BlankNodeOrIRI anotherRole = (BlankNodeOrIRI) roleTriples.next().getObject();
result.addAll(getPermissionEntriesOfARole(anotherRole, userName, user));
}
Iterator<BlankNodeOrIRI> baseRoles = getResourcesOfType(PERMISSION.BaseRole);
while (baseRoles.hasNext()) {
result.addAll(getPermissionEntriesOfARole(baseRoles.next(), userName, user));
}
return result;
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class JenaToClerezzaConverterTest method setupClass.
@BeforeClass
public static void setupClass() {
/*
* Set-up the Jena model for the test.
* Simply add the triples:
* AndreaNuzzolese isA Person
* EnricoDaga isA Person
* AndreaNuzzolese knows EnricoDaga
*/
model = ModelFactory.createDefaultModel();
Resource foafPersonInJena = model.createResource(foaf + "Person");
Property knowsInJena = model.createProperty(foaf + "knows");
Resource andreaNuzzoleseInJena = model.createResource(ns + "AndreaNuzzolese", foafPersonInJena);
Resource enricoDagaInJena = model.createResource(ns + "EnricoDaga", foafPersonInJena);
andreaNuzzoleseInJena.addProperty(knowsInJena, enricoDagaInJena);
/*
* Set-up the Clerezza model for the test.
* As before simply add the triples:
* AndreaNuzzolese isA Person
* EnricoDaga isA Person
* AndreaNuzzolese knows EnricoDaga
*/
mGraph = new SimpleGraph();
IRI knowsInClerezza = new IRI(ns + "knows");
IRI rdfType = new IRI(RDF.getURI() + "type");
IRI foafPersonInClerezza = new IRI(foaf + "Person");
BlankNodeOrIRI andreaNuzzoleseInClerezza = new IRI(ns + "AndreaNuzzolese");
BlankNodeOrIRI enricoDagaInClerezza = new IRI(ns + "EnricoDaga");
Triple triple = new TripleImpl(andreaNuzzoleseInClerezza, rdfType, foafPersonInClerezza);
mGraph.add(triple);
triple = new TripleImpl(enricoDagaInClerezza, rdfType, foafPersonInClerezza);
mGraph.add(triple);
triple = new TripleImpl(andreaNuzzoleseInClerezza, knowsInClerezza, enricoDagaInClerezza);
mGraph.add(triple);
}
Aggregations