本文整理了Java中org.vertexium.Graph.createAuthorizations()
方法的一些代码示例,展示了Graph.createAuthorizations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.createAuthorizations()
方法的具体详情如下:
包路径:org.vertexium.Graph
类名称:Graph
方法名:createAuthorizations
[英]Creates an authorizations object.
[中]创建授权对象。
代码示例来源:origin: org.visallo/visallo-core
private Authorizations getAuthorizations(String[] authorizations) {
return graph.createAuthorizations(authorizations);
}
}
代码示例来源:origin: org.visallo/visallo-core
public Authorizations getAuthorizations(Authorizations authorizations) {
return graph.createAuthorizations(authorizations, VISIBILITY_STRING);
}
代码示例来源:origin: visallo/vertexium
public Authorizations getAuthorizations(Graph graph) {
return graph.createAuthorizations(authorizations == null ? null : authorizations.split(","));
}
}
代码示例来源:origin: visallo/vertexium
public static Authorizations getAuthorizations() {
if (authorizations == null) {
authorizations = getGraph().createAuthorizations();
}
return authorizations;
}
代码示例来源:origin: org.visallo/visallo-core
public org.vertexium.Authorizations getGraphAuthorizations(User user, String... additionalAuthorizations) {
checkNotNull(user, "User cannot be null");
Set<String> userAuthorizations = getAuthorizations(user);
Collections.addAll(userAuthorizations, additionalAuthorizations);
return graph.createAuthorizations(userAuthorizations);
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
protected Authorizations getAuthorizations(String workspaceId, String... otherAuthorizations) {
if (isPublic(workspaceId) && (otherAuthorizations == null || otherAuthorizations.length == 0)) {
return publicOntologyAuthorizations;
}
if (isPublic(workspaceId)) {
return graph.createAuthorizations(publicOntologyAuthorizations, otherAuthorizations);
} else if (otherAuthorizations == null || otherAuthorizations.length == 0) {
return graph.createAuthorizations(publicOntologyAuthorizations, workspaceId);
}
return graph.createAuthorizations(publicOntologyAuthorizations, ArrayUtils.add(otherAuthorizations, workspaceId));
}
代码示例来源:origin: org.visallo/visallo-graph-property-worker-plugin-test
protected Authorizations getGraphAuthorizations(String... authorizations) {
return getGraph().createAuthorizations(authorizations);
}
代码示例来源:origin: org.visallo/visallo-core-test
protected Authorizations getGraphAuthorizations(String... authorizations) {
return getGraph().createAuthorizations(authorizations);
}
代码示例来源:origin: org.visallo/visallo-core-test
public Authorizations getGraphAuthorizations(String... authorizations) {
return getGraph().createAuthorizations(authorizations);
}
代码示例来源:origin: visallo/vertexium
@Override
public Object execute(List<String> args) {
List<String> auths = parseAuths(args);
Authorizations authorizations = VertexiumScript.getGraph().createAuthorizations(auths.toArray(new String[auths.size()]));
VertexiumScript.setAuthorizations(authorizations);
return authorizations;
}
代码示例来源:origin: org.visallo/visallo-core-test
public void before() {
Map config = new HashMap();
ConfigurationLoader hashMapConfigurationLoader = new HashMapConfigurationLoader(config);
configuration = new Configuration(hashMapConfigurationLoader, new HashMap<>());
graph = InMemoryGraph.create(getGraphConfiguration());
visibility = new Visibility("");
authorizations = graph.createAuthorizations("");
}
代码示例来源:origin: org.visallo/visallo-model-vertexium
@Inject
public VertexiumOntologyRepository(
Graph graph,
GraphRepository graphRepository,
VisibilityTranslator visibilityTranslator,
Configuration config,
GraphAuthorizationRepository graphAuthorizationRepository,
LockRepository lockRepository,
CacheService cacheService
) throws Exception {
super(config, lockRepository, cacheService);
try {
this.graph = graph;
this.graphRepository = graphRepository;
this.visibilityTranslator = visibilityTranslator;
graphAuthorizationRepository.addAuthorizationToGraph(VISIBILITY_STRING);
defineRequiredProperties(graph);
publicOntologyAuthorizations = graph.createAuthorizations(Collections.singleton(VISIBILITY_STRING));
loadOntologies(config, publicOntologyAuthorizations);
} catch (Exception ex) {
LOGGER.error("Could not initialize: %s", this.getClass().getName(), ex);
throw ex;
}
}
代码示例来源:origin: org.visallo/visallo-core-test
@Test
public void testPushWorkspaceChangeDifferentUser() {
ClientApiWorkspace clientApiWorkspace = new ClientApiWorkspace();
clientApiWorkspace.setWorkspaceId("ws1");
List<ClientApiWorkspace.User> previousUsers = new ArrayList<>();
ClientApiWorkspace.User previousUser = new ClientApiWorkspace.User();
previousUser.setUserId("mockUser1");
previousUsers.add(previousUser);
String changedByUserId = "mockUser2";
String changedBySourceGuid = "123-123-1234";
Authorizations mockUser1Auths = graph.createAuthorizations("mockUser1Auths");
when(userRepository.findById(changedByUserId)).thenReturn(mockUser2);
when(workspaceRepository.findById(eq("ws1"), eq(mockUser2))).thenReturn(workspace);
when(userRepository.findById(eq("mockUser1"))).thenReturn(mockUser1);
when(authorizationRepository.getGraphAuthorizations(eq(mockUser1), eq("ws1"))).thenReturn(mockUser1Auths);
when(workspaceRepository.toClientApi(eq(workspace), eq(mockUser1), any())).thenReturn(clientApiWorkspace);
workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, changedByUserId, changedBySourceGuid);
assertEquals(1, workQueueRepository.broadcastJsonValues.size());
JSONObject json = workQueueRepository.broadcastJsonValues.get(0);
assertEquals("workspaceChange", json.getString("type"));
assertEquals("mockUser2", json.getString("modifiedBy"));
assertEquals(new JSONObject("{\"users\":[\"mockUser1\"]}").toString(), json.getJSONObject("permissions").toString());
assertEquals(
new JSONObject("{\"editable\":false,\"users\":[],\"commentable\":false,\"workspaceId\":\"ws1\",\"sharedToUser\":false}").toString(),
json.getJSONObject("data").toString()
);
assertEquals("123-123-1234", json.getString("sourceGuid"));
}
代码示例来源:origin: visallo/vertexium
@Override
protected void addAuthorizations(String... authorizations) {
getGraph().createAuthorizations(authorizations);
}
代码示例来源:origin: org.visallo/visallo-core-test
@Before
public void before() {
graph = InMemoryGraph.create();
authorizations = graph.createAuthorizations();
workQueueRepository = new TestWorkQueueRepository(
graph,
workQueueNames,
configuration
);
workQueueRepository.setAuthorizationRepository(authorizationRepository);
workQueueRepository.setUserRepository(userRepository);
workQueueRepository.setWorkspaceRepository(workspaceRepository);
}
代码示例来源:origin: org.visallo/visallo-core-test
@Before
public void before() throws Exception {
super.before();
authorizations = getGraph().createAuthorizations();
user = getUserRepository().findOrAddUser("junit", "Junit", "junit@visallo.com", "password");
Workspace workspace = getWorkspaceRepository().add(workspaceId, "Junit Workspace", user);
if (getPrivilegeRepository().hasPrivilege(user, Privilege.ADMIN)) {
fail("User shouldn't have admin");
}
adminUser = getUserRepository().findOrAddUser("junit-admin", "Junit Admin", "junit-admin@visallo.com", "password");
Set<String> privileges = Privilege.ALL_BUILT_IN.stream().map(Privilege::getName).collect(Collectors.toSet());
setPrivileges(adminUser, privileges);
getWorkspaceRepository().updateUserOnWorkspace(workspace, adminUser.getUserId(), WorkspaceAccess.WRITE, systemUser);
}
代码示例来源:origin: org.visallo/visallo-tools-migration-predefined-to-dynamic-ontology
@Override
protected void afterMigrate(Graph graph) {
if (graph instanceof GraphWithSearchIndex) {
LOGGER.info("Re-indexing ontology elements...");
VisalloBootstrap bootstrap = VisalloBootstrap.bootstrap(getConfiguration());
SearchIndex searchIndex = ((GraphWithSearchIndex) graph).getSearchIndex();
Authorizations authorizations = graph.createAuthorizations(VisalloVisibility.SUPER_USER_VISIBILITY_STRING, OntologyRepository.VISIBILITY_STRING);
graph.getVerticesWithPrefix(VertexiumOntologyRepository.ID_PREFIX, authorizations).forEach(vertex -> {
LOGGER.debug("Adding vertex %s to search index.", vertex.getId());
searchIndex.addElement(graph, vertex, authorizations);
});
searchIndex.flush(graph);
}
}
}
代码示例来源:origin: org.visallo/visallo-core
public void deleteProperty(String propertyIri, User user, String workspaceId) {
checkDeletePrivileges(user, workspaceId);
OntologyProperty property = getPropertyByIRI(propertyIri, workspaceId);
if (property != null) {
if (property.getSandboxStatus().equals(SandboxStatus.PRIVATE)) {
Graph graph = getGraph();
Authorizations authorizations = graph.createAuthorizations(workspaceId);
GraphQuery query = graph.query(authorizations);
query.has(propertyIri);
query.limit(0);
long results = query.search().getTotalHits();
if (results == 0) {
internalDeleteProperty(property, workspaceId);
} else {
throw new VisalloException("Unable to delete property that have elements using it");
}
} else {
throw new VisalloException("Unable to delete published properties");
}
} else throw new VisalloResourceNotFoundException("Property not found");
}
代码示例来源:origin: org.vertexium/vertexium-blueprints-test
public void testVertexEdgesWithNonVisibleVertexOnOtherEnd() {
Graph graph = graphTest.generateGraph();
if (!(graph instanceof VertexiumBlueprintsGraph)) {
throw new RuntimeException("Invalid graph");
}
org.vertexium.Graph vertexiumGraph = ((VertexiumBlueprintsGraph) graph).getGraph();
Authorizations aAuthorizations = vertexiumGraph.createAuthorizations("a");
org.vertexium.Vertex v1 = vertexiumGraph.addVertex("v1", new Visibility(""), aAuthorizations);
org.vertexium.Vertex v2 = vertexiumGraph.addVertex("v2", new Visibility("a"), aAuthorizations);
org.vertexium.Vertex v3 = vertexiumGraph.addVertex("v3", new Visibility(""), aAuthorizations);
vertexiumGraph.addEdge("e1to2", v1, v2, "label", new Visibility(""), aAuthorizations);
vertexiumGraph.addEdge("e1to3", v1, v3, "label", new Visibility(""), aAuthorizations);
vertexiumGraph.flush();
Vertex blueV1 = graph.getVertex("v1");
assertEquals(1, count(blueV1.getEdges(Direction.BOTH, "label")));
assertEquals(1, count(blueV1.getVertices(Direction.BOTH, "label")));
assertEquals(1, count((Iterable) blueV1.query().direction(Direction.BOTH).vertexIds()));
graph.shutdown();
}
}
代码示例来源:origin: visallo/vertexium
@Test
public void testExtendedDataQueryVerticesAfterVisibilityChange() {
String nameColumnName = "name.column";
String tableName = "table.one";
String rowOneName = "row.one";
String rowTwoName = "row.two";
graph.defineProperty(nameColumnName).sortable(true).textIndexHint(TextIndexHint.values()).dataType(String.class).define();
graph.prepareVertex("v1", VISIBILITY_A)
.addExtendedData(tableName, rowOneName, nameColumnName, "value 1", VISIBILITY_A)
.addExtendedData(tableName, rowTwoName, nameColumnName, "value 2", VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareVertex("v2", VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<? extends VertexiumObject> searchResults = graph.query("value", AUTHORIZATIONS_A)
.search();
assertResultsCount(2, 2, searchResults);
assertRowIdsAnyOrder(Lists.newArrayList(rowOneName, rowTwoName), searchResults);
graph.createAuthorizations(AUTHORIZATIONS_A_AND_B);
graph.getVertex("v1", FetchHints.ALL, AUTHORIZATIONS_A)
.prepareMutation()
.alterElementVisibility(VISIBILITY_B)
.save(AUTHORIZATIONS_A_AND_B);
graph.flush();
searchResults = graph.query("value", AUTHORIZATIONS_A)
.search();
assertResultsCount(0, 0, searchResults);
}
内容来源于网络,如有侵权,请联系作者删除!