diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java index adc19df0a..3960fb3c2 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java @@ -24,6 +24,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.exception.ConstraintViolationException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.LocalArtifact; @@ -43,6 +44,9 @@ public final class MgmtSoftwareModuleMapper { private static SoftwareModuleType getSoftwareModuleTypeFromKeyString(final String type, final SoftwareManagement softwareManagement) { + if (type == null) { + throw new ConstraintViolationException("type cannot be null"); + } final SoftwareModuleType smType = softwareManagement.findSoftwareModuleTypeByKey(type.trim()); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ConstraintViolationException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ConstraintViolationException.java index f7a7660cf..021d91526 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ConstraintViolationException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ConstraintViolationException.java @@ -31,7 +31,18 @@ public class ConstraintViolationException extends AbstractServerRtException { * thrown */ public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) { - super(getExceptionMessage(ex), SpServerError.SP_REPO_CONSTRAINT_VIOLATION); + this(getExceptionMessage(ex)); + } + + /** + * Creates a new {@link ConstraintViolationException} with the error code + * {@link SpServerError#SP_REPO_CONSTRAINT_VIOLATION}. + * + * @param msgText + * the message text for this exception + */ + public ConstraintViolationException(final String msgText) { + super(msgText, SpServerError.SP_REPO_CONSTRAINT_VIOLATION); } /**