public CompletableFuture<Revision> addToken(Author author, String projectName,
                                                String appId, ProjectRole role) {
        requireNonNull(author, "author");
        requireNonNull(projectName, "projectName");
        requireNonNull(appId, "appId");
        requireNonNull(role, "role");

        return getTokens().thenCompose(tokens -> {
            final Token token = tokens.appIds().get(appId);
            checkArgument(token != null, "Token not found: " + appId);

            final TokenRegistration registration = new TokenRegistration(appId, role,
                                                                         UserAndTimestamp.of(author));
            final JsonPointer path = JsonPointer.compile("/tokens" + encodeSegment(registration.id()));
            final Change<JsonNode> change =
                    Change.ofJsonPatch(METADATA_JSON,
                                       asJsonArray(new TestAbsenceOperation(path),
                                                   new AddOperation(path, Jackson.valueToTree(registration))));
            final String commitSummary = "Add a token '" + registration.id() +
                                         "' to the project " + projectName + " with a role '" + role + '\'';
            return metadataRepo.push(projectName, Project.REPO_DOGMA, author, commitSummary, change);
        });
    }
public CompletableFuture < Revision > addToken ( Author author , String projectName , String appId , ProjectRole role ) { requireNonNull ( author , "author" ) ; requireNonNull ( projectName , "projectName" ) ; requireNonNull ( appId , "appId" ) ; requireNonNull ( role , "role" ) ; return getTokens ( ) . thenCompose ( tokens -> { final Token token = tokens . appIds ( ) . get ( appId ) ; checkArgument ( token != null , "Token not found: " + appId ) ; final TokenRegistration registration = new TokenRegistration ( appId , role , UserAndTimestamp . of ( author ) ) ; final JsonPointer path = JsonPointer . compile ( "/tokens" + encodeSegment ( registration . id ( ) ) ) ; final Change < JsonNode > change = Change . ofJsonPatch ( METADATA_JSON , asJsonArray ( new TestAbsenceOperation ( path ) , new AddOperation ( path , Jackson . valueToTree ( registration ) ) ) ) ; final String commitSummary = "Add a token '" + registration . id ( ) + "' to the project " + projectName + " with a role '" + role + '\'' ; return metadataRepo . push ( projectName , Project . REPO_DOGMA , author , commitSummary , change ) ; } ) ; }
Adds a {@link Token} of the specified {@code appId} to the specified {@code projectName}.