use of com.google.gerrit.extensions.common.InputWithCommitMessage in project gerrit by GerritCodeReview.
the class DeleteLabel method apply.
@Override
public Response<?> apply(LabelResource rsrc, InputWithCommitMessage input) throws AuthException, ResourceNotFoundException, PermissionBackendException, IOException, ConfigInvalidException {
if (!user.get().isIdentifiedUser()) {
throw new AuthException("Authentication required");
}
permissionBackend.currentUser().project(rsrc.getProject().getNameKey()).check(ProjectPermission.WRITE_CONFIG);
if (input == null) {
input = new InputWithCommitMessage();
}
try (MetaDataUpdate md = updateFactory.create(rsrc.getProject().getNameKey())) {
ProjectConfig config = projectConfigFactory.read(md);
if (!deleteLabel(config, rsrc.getLabelType().getName())) {
throw new ResourceNotFoundException(IdString.fromDecoded(rsrc.getLabelType().getName()));
}
if (input.commitMessage != null) {
md.setMessage(Strings.emptyToNull(input.commitMessage.trim()));
} else {
md.setMessage("Delete label");
}
config.commit(md);
}
projectCache.evictAndReindex(rsrc.getProject().getProjectState().getProject());
return Response.none();
}
Aggregations