-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GITFLOW]merging 'hotfix-1.70.1' into 'master'
- Loading branch information
Showing
47 changed files
with
478 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
sormas-api/src/main/java/de/symeda/sormas/api/sormastosormas/SormasToSormasI18nMessage.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
...api/src/main/java/de/symeda/sormas/api/sormastosormas/SormasToSormasI18nMessageError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* SORMAS® - Surveillance Outbreak Response Management & Analysis System | ||
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.symeda.sormas.api.sormastosormas; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @author Alex Vidrean | ||
* @since 25-Jun-21 | ||
*/ | ||
public abstract class SormasToSormasI18nMessageError extends Exception { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
public SormasToSormasI18nMessageError(String message) { | ||
super(message); | ||
} | ||
|
||
public SormasToSormasI18nMessageError() { | ||
} | ||
|
||
public abstract String getI18nTag(); | ||
|
||
public abstract Object[] getArgs(); | ||
|
||
protected abstract String getHumanMessageUnsafe() throws Exception; | ||
|
||
public String getHumanMessage() { | ||
try { | ||
return getHumanMessageUnsafe(); | ||
} catch (Exception e) { | ||
String error = | ||
String.format("Formatting the human readable message failed. I18nTag: %s, arguments: %s", getI18nTag(), Arrays.toString(getArgs())); | ||
logger.error(error); | ||
return error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 70 additions & 69 deletions
139
.../src/main/java/de/symeda/sormas/api/sormastosormas/validation/ValidationErrorMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,90 @@ | ||
/* | ||
* SORMAS® - Surveillance Outbreak Response Management & Analysis System | ||
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) | ||
* | ||
* Copyright © 2016-2022 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.symeda.sormas.api.sormastosormas.validation; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import de.symeda.sormas.api.i18n.I18nProperties; | ||
import de.symeda.sormas.api.sormastosormas.SormasToSormasI18nMessage; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class ValidationErrorMessage implements SormasToSormasI18nMessage, Serializable { | ||
|
||
private static final long serialVersionUID = 1693893611287329737L; | ||
|
||
private String i18nTag; | ||
|
||
private Object[] args; | ||
|
||
public ValidationErrorMessage() { | ||
|
||
} | ||
|
||
public ValidationErrorMessage(String i18nProperty, Object... args) { | ||
this.i18nTag = i18nProperty; | ||
this.args = args; | ||
} | ||
|
||
public void setI18nTag(String i18nTag) { | ||
this.i18nTag = i18nTag; | ||
} | ||
|
||
@Override | ||
public String getI18nTag() { | ||
return i18nTag; | ||
} | ||
|
||
public void setArgs(Object[] args) { | ||
this.args = args; | ||
} | ||
|
||
@Override | ||
public Object[] getArgs() { | ||
return args; | ||
} | ||
|
||
@JsonIgnore | ||
@Override | ||
public String getHumanMessage() { | ||
if (ArrayUtils.isNotEmpty(args)) { | ||
return I18nProperties.getValidationError(i18nTag, args); | ||
} else { | ||
return I18nProperties.getValidationError(i18nTag); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ValidationErrorMessage that = (ValidationErrorMessage) o; | ||
return Objects.equals(i18nTag, that.i18nTag) && Arrays.equals(args, that.args); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(i18nTag); | ||
result = 31 * result + Arrays.hashCode(args); | ||
return result; | ||
} | ||
} | ||
import org.apache.commons.lang3.ArrayUtils; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
import de.symeda.sormas.api.i18n.I18nProperties; | ||
import de.symeda.sormas.api.sormastosormas.SormasToSormasI18nMessageError; | ||
|
||
public class ValidationErrorMessage extends SormasToSormasI18nMessageError implements Serializable { | ||
|
||
private static final long serialVersionUID = 1693893611287329737L; | ||
|
||
private String i18nTag; | ||
|
||
private Object[] args; | ||
|
||
public ValidationErrorMessage() { | ||
|
||
} | ||
|
||
public ValidationErrorMessage(String i18nProperty, Object... args) { | ||
this.i18nTag = i18nProperty; | ||
this.args = args; | ||
} | ||
|
||
public void setI18nTag(String i18nTag) { | ||
this.i18nTag = i18nTag; | ||
} | ||
|
||
@Override | ||
public String getI18nTag() { | ||
return i18nTag; | ||
} | ||
|
||
public void setArgs(Object[] args) { | ||
this.args = args; | ||
} | ||
|
||
@Override | ||
public Object[] getArgs() { | ||
return args; | ||
} | ||
|
||
@JsonIgnore | ||
@Override | ||
protected String getHumanMessageUnsafe() { | ||
if (ArrayUtils.isNotEmpty(args)) { | ||
return I18nProperties.getValidationError(i18nTag, args); | ||
} else { | ||
return I18nProperties.getValidationError(i18nTag); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
ValidationErrorMessage that = (ValidationErrorMessage) o; | ||
return Objects.equals(i18nTag, that.i18nTag) && Arrays.equals(args, that.args); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(i18nTag); | ||
result = 31 * result + Arrays.hashCode(args); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.