Merge pull request #279 from bsinno/fix_negative_max_assignments

Fix negative max assignments of softwareModuleTypes
This commit is contained in:
Kai Zimmermann
2016-08-31 08:55:44 +02:00
committed by GitHub
10 changed files with 126 additions and 21 deletions

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.exception;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
import org.eclipse.hawkbit.exception.SpServerError;
/**
* the {@link ConstraintViolationException} is thrown when an entity is tried to
* be saved which has constraint violations
*/
public class ConstraintViolationException extends AbstractServerRtException {
private static final long serialVersionUID = 1L;
private static final String MESSAGE_FORMATTER_SEPARATOR = " ";
/**
* Constructor for {@link ConstraintViolationException}
*
* @param ex
* the javax.validation.ConstraintViolationException which is
* thrown
*/
public ConstraintViolationException(final javax.validation.ConstraintViolationException ex) {
super(getExceptionMessage(ex), SpServerError.SP_REPO_CONSTRAINT_VIOLATION);
}
/**
* Uses the information of
* {@link javax.validation.ConstraintViolationException} to provide a proper
* error message for {@link ConstraintViolationException}
*
* @param ex
* javax.validation.ConstraintViolationException which is thrown
* @return message String with proper error information
*/
public static String getExceptionMessage(final javax.validation.ConstraintViolationException ex) {
return ex
.getConstraintViolations().stream().map(violation -> violation.getPropertyPath()
+ MESSAGE_FORMATTER_SEPARATOR + violation.getMessage() + ".")
.collect(Collectors.joining(MESSAGE_FORMATTER_SEPARATOR));
}
}

View File

@@ -8,15 +8,12 @@
*/
package org.eclipse.hawkbit.repository.exception;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
import org.eclipse.hawkbit.exception.SpServerError;
/**
* the {@link EntityAlreadyExistsException} is thrown when a entity is tried to
* the {@link EntityAlreadyExistsException} is thrown when an entity is tried to
* be saved which already exists or which violates unique key constraints.
*
*
*
*/
public class EntityAlreadyExistsException extends AbstractServerRtException {