Fix error for commits with SSH signatures

Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com>
Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
Rene Pfeuffer
2024-03-06 13:23:55 +01:00
parent 1a6e202384
commit 01bd18b714
2 changed files with 6 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Internal server error for commits with SSH signatures

View File

@@ -24,6 +24,7 @@
package sonia.scm.api.v2.resources;
import com.google.common.base.Strings;
import de.otto.edison.hal.Embedded;
import de.otto.edison.hal.Links;
import jakarta.inject.Inject;
@@ -51,9 +52,11 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.google.common.base.Strings.emptyToNull;
import static de.otto.edison.hal.Embedded.embeddedBuilder;
import static de.otto.edison.hal.Link.link;
import static de.otto.edison.hal.Links.linkingTo;
import static java.util.Optional.ofNullable;
@Mapper
public abstract class DefaultChangesetToChangesetDtoMapper extends HalAppenderMapper implements InstantAttributeMapper, ChangesetToChangesetDtoMapper {
@@ -88,7 +91,7 @@ public abstract class DefaultChangesetToChangesetDtoMapper extends HalAppenderMa
@ObjectFactory
SignatureDto createDto(Signature signature) {
final Optional<RawGpgKey> key = publicKeyStore.findById(signature.getKeyId());
Optional<RawGpgKey> key = ofNullable(emptyToNull(signature.getKeyId())).flatMap(publicKeyStore::findById);
if (signature.getType().equals("gpg") && key.isPresent()) {
final Links.Builder linkBuilder =
linkingTo()