private LockableMGraph getConfigGraph() { return tcManager.getMGraph(Constants.CONFIG_GRAPH_URI); }
private Graph getOrCreatePermisionGraph() { try { return tcManager.getMGraph(permissionGraphName); } catch (NoSuchEntityException e) { return tcManager.createGraph(permissionGraphName); } }
@Override public LockableMGraph getEnhancementGraph() { final UriRef graphUri = new UriRef(Constants.ENHANCEMENTS_GRAPH_URI); LockableMGraph enhancementGraph = null; try { enhancementGraph = tcManager.getMGraph(graphUri); } catch (NoSuchEntityException e) { log.error("Enhancement Graph must be exist"); } return enhancementGraph; }
@Override public Object getService(Bundle arg0, ServiceRegistration arg1) { return new SecuredGraph(tcManager.getMGraph(name), name, tcAccessController); }
@Override public Object getService(Bundle arg0, ServiceRegistration arg1) { return new SecuredGraph(tcManager.getMGraph(name), name, tcAccessController); }
private Graph getOrCreatePermisionGraph() { try { return tcManager.getMGraph(permissionGraphName); } catch (NoSuchEntityException e) { return tcManager.createGraph(permissionGraphName); } }
private MGraph getConceptCacheMGraph() { MGraph conceptCacheMGraph = null; TcManager tcManager = TcManager.getInstance(); try { conceptCacheMGraph = tcManager.getMGraph(CONCEPT_CACHE_MGRAPH); } catch (NoSuchEntityException nsee) { conceptCacheMGraph = tcManager.createMGraph(CONCEPT_CACHE_MGRAPH); } return conceptCacheMGraph; }
private Collection<String> getRequiredPermissionStrings(final IRI GraphUri, IRI property) { try { final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName); Lock l = permissionMGraph.getLock().readLock(); l.lock(); try { Triple t = permissionMGraph.filter(GraphUri, property, null).next(); BlankNodeOrIRI list = (BlankNodeOrIRI) t.getObject(); LinkedList<String> result = new LinkedList<String>(); readList(list, permissionMGraph, result); return result; } catch (NoSuchElementException e) { return new ArrayList<String>(0); } finally { l.unlock(); } } catch (NoSuchEntityException e) { return new ArrayList<String>(0); } }
private Collection<String> getRequiredPermissionStrings(final IRI GraphUri, IRI property) { try { final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName); Lock l = permissionMGraph.getLock().readLock(); l.lock(); try { Triple t = permissionMGraph.filter(GraphUri, property, null).next(); BlankNodeOrIRI list = (BlankNodeOrIRI) t.getObject(); LinkedList<String> result = new LinkedList<String>(); readList(list, permissionMGraph, result); return result; } catch (NoSuchElementException e) { return new ArrayList<String>(0); } finally { l.unlock(); } } catch (NoSuchEntityException e) { return new ArrayList<String>(0); } }
/** * This method creates an {@link MGraph} to store concepts' descriptions * if this graph does not already exist. * * @return * an {@link MGraph} */ public MGraph getRemoteConceptsDescriptionMGraph() { MGraph remoteConceptsDescriptionMGraph = null; TcManager tcManager = TcManager.getInstance(); try { remoteConceptsDescriptionMGraph = tcManager.getMGraph(REMOTE_CONCEPTS_DESCRIPTION_MGRAPH); } catch (NoSuchEntityException nsee) { remoteConceptsDescriptionMGraph = tcManager.createMGraph(REMOTE_CONCEPTS_DESCRIPTION_MGRAPH); } return remoteConceptsDescriptionMGraph; }
public void createEnhancementGraph() throws StoreException { final UriRef graphUri = new UriRef(Constants.ENHANCEMENTS_GRAPH_URI); MGraph enhancementGraph = null; try { enhancementGraph = tcManager.getMGraph(graphUri); String filter = String.format("(%s=%s)", "graph.uri", graphUri.getUnicodeString()); ServiceReference[] sr = bundleContext.getServiceReferences(TripleCollection.class.getName(), filter); if (sr == null) { registerEnhancementGraph(graphUri, enhancementGraph); } } catch (NoSuchEntityException e) { log.debug("Creating the enhancement graph!"); enhancementGraph = tcManager.createMGraph(graphUri); registerEnhancementGraph(graphUri, enhancementGraph); } catch (InvalidSyntaxException e) { log.error("Failed to get ServiceReference for TripleCollection"); throw new StoreException("Failed to get ServiceReference for TripleCollection", e); } }
private InternetAddress getUserAddress(String user) throws MessagingException { MGraph systemGraph = tcManager.getMGraph(systemGraphUri); final String queryString = "SELECT ?email WHERE { " + "?x " + FOAF.mbox + " ?email . " + "?x " + PLATFORM.userName + " \"" + user + "\" . " + "}"; try { SelectQuery selectQuery = (SelectQuery) QueryParser.getInstance().parse(queryString); ResultSet result = tcManager.executeSparqlQuery(selectQuery, systemGraph); if (result.hasNext()) { Resource email = result.next().get("email"); String emailString = ((UriRef) email).getUnicodeString(); //TODO should add personal name (if available) as well return new InternetAddress(emailString.substring("mailto:".length())); } } catch (ParseException ex) { throw new RuntimeException(ex); } catch (AddressException ex) { throw new RuntimeException(ex); } throw new MessagingException("No address found for user " + user); } }
/** * avtivates the component and adds the enrichment-graph to the virtual * content graph. * * gets the base content-graph from tcManager and sets the permission * required to access the enrichment-graph accordingly */ protected void activate(ComponentContext context) { contentGraph = tcManager.getMGraph(Constants.CONTENT_GRAPH_URI); Collection<Permission> requiredReadPermissions = tcManager.getTcAccessController().getRequiredReadPermissions(Constants.CONTENT_GRAPH_URI); if (requiredReadPermissions.isEmpty()) { tcManager.getTcAccessController().setRequiredReadPermissionStrings( ENRICHMENT_GRAPH_URI, Collections.singleton( new TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString() )); } else { tcManager.getTcAccessController().setRequiredReadPermissions( ENRICHMENT_GRAPH_URI, requiredReadPermissions); } cgProvider.addTemporaryAdditionGraph(ENRICHMENT_GRAPH_URI); }