protected User getUser() { if (this.user == null) { this.user = userRepository.getSystemUser(); } return this.user; }
private void prepareUser(Map map) { this.user = (User) map.get("user"); if (this.user == null) { this.user = this.userRepository.getSystemUser(); } }
@Inject public PingUtil( GraphAuthorizationRepository graphAuthorizationRepository, UserRepository userRepository, VisibilityTranslator visibilityTranslator ) { graphAuthorizationRepository.addAuthorizationToGraph(VISIBILITY_STRING); this.systemUser = userRepository.getSystemUser(); this.visibilityTranslator = visibilityTranslator; }
@Inject public ReindexLongRunningProcessWorker( Graph graph, UserRepository userRepository, AuthorizationRepository authorizationRepository ) { this.graph = graph; this.authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser()); }
@Inject public IngestRepository( Graph graph, UserRepository userRepository, AuthorizationRepository authorizationRepository, VisibilityTranslator visibilityTranslator, OntologyRepository ontologyRepository ) throws JsonProcessingException { this.graph = graph; this.authorizationRepository = authorizationRepository; this.visibilityTranslator = visibilityTranslator; this.ontologyRepository = ontologyRepository; defaultIngestOptions = new IngestOptions(userRepository.getSystemUser()); }
protected void before() { graph = InMemoryGraph.create(); when(metricsManager.counter(any())).thenReturn(mockCounter); when(metricsManager.counter(any(), any())).thenReturn(mockCounter); when(metricsManager.timer(any())).thenReturn(mockTimer); when(metricsManager.timer(any(), any())).thenReturn(mockTimer); when(metricsManager.meter(any())).thenReturn(mockMeter); when(metricsManager.meter(any(), any())).thenReturn(mockMeter); when(userRepository.getSystemUser()).thenReturn(systemUser); when(authorizationRepository.getGraphAuthorizations(systemUser)).thenReturn(systemUserAuthorizations); }
@Override protected void run() { Date now = new Date(); Date nowPlusOneMinute = DateUtils.addSeconds(now, getCheckIntervalSeconds()); systemNotificationRepository.getFutureNotifications(nowPlusOneMinute, userRepository.getSystemUser()) .forEach(workQueueRepository::pushSystemNotification); }
private int setAuthorizations(SetAuthorizationsArgs args) { Set<String> authorizations = new HashSet<>(); if (args.authorizations != null && args.authorizations.length() > 0) { authorizations.addAll(Arrays.asList(StringUtils.split(args.authorizations, ','))); } User user = findUser(args); getUserRepository().setAuthorizations(user, authorizations, getUserRepository().getSystemUser()); printUser(user); return 0; }
private void ensureOntologyDefined() { try (InputStream graphOwl = GraphWebAppPlugin.class.getResourceAsStream("graph.owl")) { byte[] inFileData = IOUtils.toByteArray(graphOwl); IRI graphIRI = IRI.create(GraphProductOntology.IRI); Authorizations authorizations = authorizationRepository.getGraphAuthorizations(this.userRepository.getSystemUser()); ontologyRepository.importFileData(inFileData, graphIRI, null, authorizations); } catch (Exception e) { throw new VisalloException("Could not read graph.owl file", e); } } }
protected void addConceptWithIntent(String conceptIri, String... intents) { Concept concept = getOntologyRepository().getOrCreateConcept( null, conceptIri, conceptIri, null, getUserRepository().getSystemUser(), null ); for (String intent : intents) { concept.addIntent(intent, getUserRepository().getSystemUser(), getGraphAuthorizations()); } } }
protected void setPrivileges(User user, Set<String> privileges) { ((UserPropertyPrivilegeRepository) getPrivilegeRepository()).setPrivileges(user, privileges, getUserRepository().getSystemUser()); }
public void updateVertexWithJson(JSONObject longRunningProcessQueueItem) { String longRunningProcessGraphVertexId = longRunningProcessQueueItem.getString("id"); Authorizations authorizations = getAuthorizations(userRepository.getSystemUser()); Vertex vertex = this.graph.getVertex(longRunningProcessGraphVertexId, authorizations); checkNotNull(vertex, "Could not find long running process vertex: " + longRunningProcessGraphVertexId); LongRunningProcessProperties.QUEUE_ITEM_JSON_PROPERTY.setProperty( vertex, longRunningProcessQueueItem, getVisibility(), authorizations ); this.graph.flush(); }
@Override protected void processInternal(JSONObject jsonObject) { PingLongRunningProcessQueueItem queueItem = ClientApiConverter.toClientApi( jsonObject.toString(), PingLongRunningProcessQueueItem.class ); Authorizations authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser()); Vertex vertex = graph.getVertex(queueItem.getVertexId(), authorizations); pingUtil.lrpUpdate(vertex, graph, authorizations); }
private void startVisalloProcesses(Configuration config) { boolean enableWebContainerProcesses = config.getBoolean("org.visallo.web.ApplicationBootstrap.enableWebContainerProcesses", true); if (!enableWebContainerProcesses) { return; } Iterable<VisalloProcess> processes = ServiceLoaderUtil.load(VisalloProcess.class, config); User user = InjectHelper.getInstance(UserRepository.class).getSystemUser(); VisalloProcessOptions options = new VisalloProcessOptions(user); for (VisalloProcess process : processes) { LOGGER.info("starting %s", process.getClass().getName()); process.startProcess(options); } }
@Test public void testPublishingNewEdgeAndRelationshipWithoutOntologyPublishPrivilege() { UserPropertyPrivilegeRepository privilegeRepository = (UserPropertyPrivilegeRepository) getPrivilegeRepository(); privilegeRepository.setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD), getUserRepository().getSystemUser()); String newRelationshipIri = "new-relationship"; getOntologyRepository().getOrCreateRelationshipType(null, Collections.singleton(thingConcept), Collections.singleton(thingConcept), newRelationshipIri, "Junit Relationship", true, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishEdgeAdd(newRelationshipIri, "Unable to publish relationship Junit Relationship", SandboxStatus.PRIVATE); }
@Test public void testPublishingNewEdgeAndRelationship() { UserPropertyPrivilegeRepository privilegeRepository = (UserPropertyPrivilegeRepository) getPrivilegeRepository(); privilegeRepository.setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH), getUserRepository().getSystemUser()); String newRelationshipIri = "new-relationship"; getOntologyRepository().getOrCreateRelationshipType(null, Collections.singleton(thingConcept), Collections.singleton(thingConcept), newRelationshipIri, "Junit Relationship", true, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishEdgeAdd(newRelationshipIri, null, SandboxStatus.PUBLIC); }
@Before public void before() throws Exception { super.before(); user = getUserRepository().getSystemUser(); authorizations = getAuthorizationRepository().getGraphAuthorizations(user); }
@Test public void testPublishingNewPropertyValueAndPropertyTypeWithoutOntologyPublishPrivilege() { UserPropertyPrivilegeRepository privilegeRepository = (UserPropertyPrivilegeRepository) getPrivilegeRepository(); privilegeRepository.setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD), getUserRepository().getSystemUser()); String newPropertyIri = "new-property"; OntologyPropertyDefinition propertyDefinition = new OntologyPropertyDefinition(Collections.singletonList(thingConcept), newPropertyIri, "New Property", PropertyType.STRING); propertyDefinition.setTextIndexHints(Collections.singleton(TextIndexHint.EXACT_MATCH)); propertyDefinition.setUserVisible(true); getOntologyRepository().getOrCreateProperty(propertyDefinition, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishPropertyAdd(newPropertyIri, "Unable to publish relationship New Property", SandboxStatus.PRIVATE); }
@Test public void testPublishingNewPropertyValueAndPropertyType() { UserPropertyPrivilegeRepository privilegeRepository = (UserPropertyPrivilegeRepository) getPrivilegeRepository(); privilegeRepository.setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH), getUserRepository().getSystemUser()); String newPropertyIri = "new-property"; OntologyPropertyDefinition propertyDefinition = new OntologyPropertyDefinition(Collections.singletonList(thingConcept), newPropertyIri, "New Property", PropertyType.STRING); propertyDefinition.setTextIndexHints(Collections.singleton(TextIndexHint.EXACT_MATCH)); propertyDefinition.setUserVisible(true); getOntologyRepository().getOrCreateProperty(propertyDefinition, user, workspace.getWorkspaceId()); getOntologyRepository().clearCache(); doTestPublishPropertyAdd(newPropertyIri, null, SandboxStatus.PUBLIC); }
private int setPrivileges(SetPrivilegesArgs args) { Set<String> privileges = Privilege.stringToPrivileges(args.privileges); User user = findUser(args); System.out.println("Assigning privileges " + privileges + " to user " + user.getUserId()); getUserRepository().setPrivileges(user, privileges, getUserRepository().getSystemUser()); user = getUserRepository().findById(user.getUserId()); printUser(user); return 0; }