Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Dec 11, 2024
1 parent b096bad commit c054553
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ public CompletableFuture<Revision> removeMember(Author author, String projectNam
projectMetadata.creation(),
projectMetadata.removal()));
});
return metadataRepo.pushIgnoringRedundantChange(projectName, Project.REPO_DOGMA,
author, commitSummary, transformer);
return metadataRepo.push(projectName, Project.REPO_DOGMA, author, commitSummary, transformer);
}

private static ProjectMetadata projectMetadata(JsonNode node) {
Expand Down Expand Up @@ -606,8 +605,7 @@ private CompletableFuture<Revision> removeToken(String projectName, Author autho
projectMetadata.creation(),
projectMetadata.removal()));
});
return metadataRepo.pushIgnoringRedundantChange(projectName, Project.REPO_DOGMA, author,
commitSummary, transformer);
return metadataRepo.push(projectName, Project.REPO_DOGMA, author, commitSummary, transformer);
}

private static ImmutableMap<String, RepositoryMetadata> removeTokenFromRepositories(
Expand Down Expand Up @@ -1175,8 +1173,7 @@ public CompletableFuture<Revision> destroyToken(Author author, String appId) {
final Map<String, Token> newAppIds = appIdsBuilder.build();
return Jackson.valueToTree(new Tokens(newAppIds, tokens.secrets()));
});
return tokenRepo.pushIgnoringRedundantChange(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author,
commitSummary, transformer);
return tokenRepo.push(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author, commitSummary, transformer);
}

/**
Expand Down Expand Up @@ -1220,8 +1217,7 @@ public Revision purgeToken(Author author, String appId) {

return Jackson.valueToTree(new Tokens(newAppIds, newSecrets));
});
return tokenRepo.pushIgnoringRedundantChange(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author,
commitSummary, transformer)
return tokenRepo.push(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author, commitSummary, transformer)
.join();
}

Expand Down Expand Up @@ -1283,8 +1279,7 @@ public CompletableFuture<Revision> activateToken(Author author, String appId) {

return Jackson.valueToTree(new Tokens(newAppIds, newSecrets));
});
return tokenRepo.pushIgnoringRedundantChange(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author,
commitSummary, transformer);
return tokenRepo.push(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author, commitSummary, transformer);
}

/**
Expand Down Expand Up @@ -1322,8 +1317,7 @@ public CompletableFuture<Revision> deactivateToken(Author author, String appId)

return Jackson.valueToTree(new Tokens(newAppIds, newSecrets));
});
return tokenRepo.pushIgnoringRedundantChange(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author,
commitSummary, transformer);
return tokenRepo.push(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author, commitSummary, transformer);
}

/**
Expand Down Expand Up @@ -1354,8 +1348,7 @@ public CompletableFuture<Revision> updateTokenLevel(Author author, String appId,
final Map<String, Token> newAppIds = appIdsBuilder.build();
return Jackson.valueToTree(new Tokens(newAppIds, tokens.secrets()));
});
return tokenRepo.pushIgnoringRedundantChange(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author,
commitSummary, transformer);
return tokenRepo.push(INTERNAL_PROJECT_DOGMA, Project.REPO_DOGMA, author, commitSummary, transformer);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public RepositoryMetadata deserialize(JsonParser p, DeserializationContext ctxt)
final Map<String, Collection<Permission>> perUserPermissions;
final Map<String, Collection<Permission>> perTokenPermissions;
if (perRolePermissionsNode != null) {
assert jsonNode.get("roles") == null;
// legacy format
perRolePermissions = Jackson.treeToValue(perRolePermissionsNode, PerRolePermissions.class);
perUserPermissions = Jackson.readValue(jsonNode.get("perUserPermissions").traverse(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.linecorp.centraldogma.common.Change;
import com.linecorp.centraldogma.common.Entry;
import com.linecorp.centraldogma.common.Markup;
import com.linecorp.centraldogma.common.RedundantChangeException;
import com.linecorp.centraldogma.common.Revision;
import com.linecorp.centraldogma.internal.Jackson;
import com.linecorp.centraldogma.server.command.Command;
Expand Down Expand Up @@ -118,20 +117,6 @@ CompletableFuture<Revision> push(String projectName, String repoName,
.thenApply(CommitResult::revision);
}

CompletableFuture<Revision> pushIgnoringRedundantChange(String projectName, String repoName,
Author author, String commitSummary,
ContentTransformer<JsonNode> transformer) {
return push(projectName, repoName, author, commitSummary, transformer).exceptionally(cause -> {
final Throwable peeled = Exceptions.peel(cause);
if (peeled instanceof RedundantChangeException) {
final Revision revision = ((RedundantChangeException) peeled).headRevision();
assert revision != null;
return revision;
}
return Exceptions.throwUnsafely(peeled);
});
}

Revision normalize(Repository repository) {
requireNonNull(repository, "repository");
try {
Expand Down

0 comments on commit c054553

Please sign in to comment.