private void addNaturalText(IRI field, String text, String...languages) { if(languages == null || languages.length == 0){ languages = new String []{null}; } for(String language : languages){ graphNode.addProperty(field, RdfResourceUtils.createLiteral(text, language)); } }
@GET public GraphNode entry(@Context UriInfo uriInfo) throws IOException { AccessController.checkPermission(new LoggingManagerAccessPermission()); TrailingSlash.enforcePresent(uriInfo); SimpleMGraph resultMGraph = new SimpleMGraph(); GraphNode result = new GraphNode(new BNode(), resultMGraph); result.addPropertyValue(LOGGING.loggingConfig, getPropertiesAsString()); result.addProperty(RDF.type, PLATFORM.HeadedPage); result.addProperty(RDF.type, LOGGING.LoggingConfigPage); return result; }
private GraphNode addConceptCacheNode(MGraph conceptCacheMGraph) { GraphNode conceptCacheGraphNode = new GraphNode(new BNode(), conceptCacheMGraph); conceptCacheGraphNode.addProperty(RDF.type, CONCEPTS.ConceptCache); conceptCacheGraphNode.addProperty(CONCEPTS.sparqlEndPoint, sparqlEndPoint); if (defaultGraph != null) { conceptCacheGraphNode.addProperty(CONCEPTS.defaultGraph, defaultGraph); } return conceptCacheGraphNode; }
private void updateProperty(GraphNode node, IRI predicate, RDFTerm object) { node.deleteProperties(predicate); node.addProperty(predicate, object); }
private void addNaturalText(IRI field, String text, String...languages) { if(languages == null || languages.length == 0){ languages = new String []{null}; } for(String language : languages){ graphNode.addProperty(field, RdfResourceUtils.createLiteral(text, language)); } }
private void addTypedLiteral(IRI field, Object literalValue){ Literal literal; try { literal = RdfResourceUtils.createLiteral(literalValue); } catch (NoConvertorException e){ log.info("No Converter for value type "+literalValue.getClass() +" (parsed for field "+field+") use toString() to get String representation"); literal = RdfResourceUtils.createLiteral(literalValue.toString(), null); } graphNode.addProperty(field, literal); } @Override
private void addTypedLiteral(IRI field, Object literalValue){ Literal literal; try { literal = RdfResourceUtils.createLiteral(literalValue); } catch (NoConvertorException e){ log.info("No Converter for value type "+literalValue.getClass() +" (parsed for field "+field+") use toString() to get String representation"); literal = RdfResourceUtils.createLiteral(literalValue.toString(), null); } graphNode.addProperty(field, literal); } @Override
@Override public void addReference(String field, String reference) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } if(reference == null){ throw new IllegalArgumentException("NULL values are not supported by Representations"); } else if (reference.isEmpty()) { throw new IllegalArgumentException("References MUST NOT be empty!"); } graphNode.addProperty(new IRI(field), new IRI(reference)); } @Override
/** * Creates a new role wit the the specified role name * * @param newUserName * @return user node in system graph */ private GraphNode createRole(String newRoleName, String comment) { BlankNode subject = new BlankNode(); GraphNode roleNode = new GraphNode(subject, systemGraph); roleNode.addProperty(RDF.type, PERMISSION.Role); roleNode.addProperty(DC.title, new PlainLiteralImpl(newRoleName)); roleNode.addProperty(RDFS.comment, new PlainLiteralImpl(comment)); return roleNode; }
@Override public void addReference(String field, String reference) { if(field == null){ throw new IllegalArgumentException("The parsed field MUST NOT be NULL"); } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } if(reference == null){ throw new IllegalArgumentException("NULL values are not supported by Representations"); } else if (reference.isEmpty()) { throw new IllegalArgumentException("References MUST NOT be empty!"); } graphNode.addProperty(new IRI(field), new IRI(reference)); } @Override
/** * Coverts the value into a typed literals and sets it as object of the * specified property * * @param property the predicate of the triple to be created * @param value the value of the typed literal object */ public void addPropertyValue(IRI property, Object value) { addProperty(property, LiteralFactory.getInstance().createTypedLiteral(value)); }
/** * Coverts the value into a typed literals and sets it as object of the * specified property * * @param property the predicate of the triple to be created * @param value the value of the typed literal object */ public void addPropertyValue(IRI property, Object value) { addProperty(property, LiteralFactory.getInstance().createTypedLiteral(value)); }
private GraphNode addPermission(GraphNode subjectNode, String permissionString) { if (hasPermission(subjectNode, permissionString)) { return subjectNode; } GraphNode permissionNode = new GraphNode(new BlankNode(), systemGraph); permissionNode.addProperty(RDF.type, PERMISSION.Permission); // permissionNode.addProperty(DC.title, new PlainLiteralImpl(permissionName)); subjectNode.addProperty(PERMISSION.hasPermission, permissionNode.getNode()); permissionNode.addProperty(PERMISSION.javaPermissionEntry, new PlainLiteralImpl(permissionString)); return subjectNode; }
@Override public GraphNode getExceptionGraphNode() { GraphNode result = new GraphNode(new BlankNode(), new SimpleGraph()); result.addProperty(RDF.type, TYPERENDERING.Exception); LiteralFactory factory = LiteralFactory.getInstance(); result.addProperty(TYPERENDERING.errorSource, new IRI(renderingSpecification.toString())); if (lineNumber != -1) { result.addProperty(TYPERENDERING.line, factory.createTypedLiteral(new Integer(lineNumber))); } if (columnNumber != -1) { result.addProperty(TYPERENDERING.column, factory.createTypedLiteral(Integer.valueOf(columnNumber))); } result.addProperty(TYPERENDERING.message, new PlainLiteralImpl(getMessage())); return result; }
@Override public GraphNode getExceptionGraphNode() { GraphNode result = new GraphNode(new BlankNode(), new SimpleGraph()); result.addProperty(RDF.type, TYPERENDERING.Exception); result.addProperty(TYPERENDERING.errorSource, new IRI(renderingSpecification.toString())); result.addProperty(TYPERENDERING.message, new PlainLiteralImpl(getMessage())); result.addProperty(TYPERENDERING.stackTrace, getStackTraceLiteral()); return result; }
/** * Creates a new user withe the specified user name * * @param newUserName * @return user node in system graph */ private GraphNode createUser(String newUserName) { BlankNode subject = new BlankNode(); GraphNode userNode = new GraphNode(subject, systemGraph); userNode.addProperty(RDF.type, FOAF.Agent); userNode.addProperty(PLATFORM.userName, new PlainLiteralImpl(newUserName)); addRole(userNode, "BasePermissionsRole"); return userNode; } // move later?
private void addAvailableRoles(GraphNode result) { Iterator<NonLiteral> roles = userManager.getRoles(); while (roles.hasNext()) { GraphNode role = new GraphNode(roles.next(), systemGraph); result.addProperty(USERMANAGER.role, role.getNode()); addCustomPropertiesOfRole(role, result); } }
private void addBaseRoles(GraphNode result) { Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { Iterator<Triple> baseRoles = systemGraph.filter(null, RDF.type, PERMISSION.BaseRole); if (baseRoles.hasNext()) { GraphNode baseRole = new GraphNode(baseRoles.next().getSubject(), systemGraph); result.addProperty(USERMANAGER.role, baseRole.getNode()); addCustomPropertiesOfRole(baseRole, result); } } finally { readLock.unlock(); } } private void addCustomPropertiesOfRole(GraphNode role, GraphNode result) {
@Override public GraphNode addUserContext(GraphNode node) { node.addProperty(GLOBALMENU.globalMenu, asRdfList(createMenus(), node.getGraph())); return node; }
@GET public GraphNode resetPage(@Context UriInfo uriInfo) { TrailingSlash.enforcePresent(uriInfo); GraphNode result = new GraphNode(new BNode(), new SimpleMGraph()); result.addProperty(RDF.type, USERMANAGER.PasswordResetPage); return result; }