Query userGroupQuery = AuthUtil.buildQueryForUsers(userGroupSelfLink); UserGroupState userGroupState = UserGroupState.Builder .create() .withQuery(userGroupQuery) .withSelfLink(userGroupSelfLink) .build();
userGroupQuery.setTermMatchType(MatchType.TERM); userGroupQuery.setTermMatchValue(userState.email); UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(user + "-user-group") .withQuery(userGroupQuery) .build();
userGroupQuery.setTermMatchType(MatchType.TERM); userGroupQuery.setTermMatchValue(userState.email); UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(user + "-user-group") .withQuery(userGroupQuery) .build();
.build(); UserGroupState groupState = UserGroupState.Builder.create() .withSelfLink(userGroupUri) .withQuery(userGroupQuery).build();
UserGroupState state = UserGroupState.Builder.create() .withSelfLink(servicePath) .withQuery(query) .build();
UserGroupState state = UserGroupState.Builder.create() .withSelfLink(servicePath) .withQuery(query) .build();
UserGroupState group = UserGroupState.Builder.create() .withQuery(userGroupQuery) .withSelfLink(this.userGroupSelfLink) .build();
private void createUserGroup(LocalPrincipalState state, Operation op) { String userGroupSelfLink = UriUtils.buildUriPath(UserGroupService.FACTORY_LINK, encode(state.name)); Query userGroupQuery = AuthUtil.buildQueryForUsers(userGroupSelfLink); UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(userGroupSelfLink) .withQuery(userGroupQuery) .build(); URI userGroupFactoryUri = UriUtils.buildUri(getHost(), ServiceUriPaths.CORE_AUTHZ_USER_GROUPS); Operation postGroup = Operation.createPost(userGroupFactoryUri) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setBody(userGroupState) .setReferer(op.getUri()) .setCompletion((o, ex) -> { if (ex != null) { logWarning("Unable to create user group %s: %s", state.name, Utils.toString(ex)); return; } UserGroupState groupState = o.getBody(UserGroupState.class); addUsersToGroup(state, groupState.documentSelfLink, op); }); addReplicationFactor(postGroup); sendRequest(postGroup); }
@Test public void testFactoryPost() throws Throwable { Query query = new Query(); query.setTermPropertyName("name"); query.setTermMatchValue("value"); UserGroupState state = UserGroupState.Builder.create() .withQuery(query) .build(); final UserGroupState[] outState = new UserGroupState[1]; Operation op = Operation.createPost(this.factoryUri) .setBody(state) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } outState[0] = o.getBody(UserGroupState.class); this.host.completeIteration(); }); this.host.testStart(1); this.host.send(op); this.host.testWait(); assertEquals(state.query.term.propertyName, outState[0].query.term.propertyName); assertEquals(state.query.term.matchValue, outState[0].query.term.matchValue); }
@Test public void testFactoryPost() throws Throwable { Query query = new Query(); query.setTermPropertyName("name"); query.setTermMatchValue("value"); UserGroupState state = UserGroupState.Builder.create() .withQuery(query) .build(); final UserGroupState[] outState = new UserGroupState[1]; Operation op = Operation.createPost(this.factoryUri) .setBody(state) .setCompletion((o, e) -> { if (e != null) { this.host.failIteration(e); return; } outState[0] = o.getBody(UserGroupState.class); this.host.completeIteration(); }); this.host.testStart(1); this.host.send(op); this.host.testWait(); assertEquals(state.query.term.propertyName, outState[0].query.term.propertyName); assertEquals(state.query.term.matchValue, outState[0].query.term.matchValue); }
private static DeferredResult<UserGroupState> createUserGroup(Service service, String principalId) { String userGroupSelfLink = UriUtils .buildUriPath(UserGroupService.FACTORY_LINK, encode(principalId)); Query userGroupQuery = AuthUtil.buildQueryForUsers(userGroupSelfLink); UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(userGroupSelfLink) .withQuery(userGroupQuery) .build(); Operation postGroup = Operation.createPost(service, ServiceUriPaths.CORE_AUTHZ_USER_GROUPS) .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE) .setBody(userGroupState); addReplicationFactor(postGroup); return service.sendWithDeferredResult(postGroup, UserGroupState.class); }
public String createUserGroup(ServiceHost target, String name, Query q) throws Throwable { URI postUserGroupsUri = UriUtils.buildUri(target, ServiceUriPaths.CORE_AUTHZ_USER_GROUPS); String selfLink = UriUtils.extendUri(postUserGroupsUri, name).getPath(); // Create user group UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(selfLink) .withQuery(q) .build(); this.host.sendAndWaitExpectSuccess(Operation .createPost(postUserGroupsUri) .setBody(userGroupState)); return selfLink; }
public String createUserGroup(ServiceHost target, String name, Query q) throws Throwable { URI postUserGroupsUri = UriUtils.buildUri(target, ServiceUriPaths.CORE_AUTHZ_USER_GROUPS); String selfLink = UriUtils.extendUri(postUserGroupsUri, name).getPath(); // Create user group UserGroupState userGroupState = UserGroupState.Builder.create() .withSelfLink(selfLink) .withQuery(q) .build(); this.host.sendAndWaitExpectSuccess(Operation .createPost(postUserGroupsUri) .setBody(userGroupState)); return selfLink; }
public static Builder create() { return new Builder(); }
public static UserGroupState buildUserGroupState(String identifier) { String selfLink = UriUtils.buildUriPath(UserGroupService.FACTORY_LINK, identifier); Query userGroupQuery = buildQueryForUsers(selfLink); UserGroupState userGroupState = UserGroupState.Builder .create() .withQuery(userGroupQuery) .withSelfLink(selfLink) .build(); return userGroupState; }