Loading pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ <groupId>es.redmic.lib</groupId> <artifactId>exceptions</artifactId> <packaging>jar</packaging> <version>0.9.0</version> <version>0.9.0-feature-atlasExceptions</version> <name>Exceptions</name> <description>Exceptions utils and management</description> Loading src/main/java/es/redmic/exception/common/ExceptionType.java +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public enum ExceptionType implements ExceptionTypeItfc { ES_QUERY_ERROR(Constants.ES_QUERY_ERROR), ES_INSERT_DOCUMENT(Constants.ES_INSERT_DOCUMENT), ES_CREATE_MAPPING_ERROR(Constants.ES_CREATE_MAPPING_ERROR), ES_DELETE_ITEM_WITH_CHILDREN_ERROR(Constants.ES_DELETE_ITEM_WITH_CHILDREN_ERROR), // DTOs DTO_NOT_VALID(Constants.DTO_NOT_VALID), Loading Loading @@ -212,6 +213,7 @@ public enum ExceptionType implements ExceptionTypeItfc { ES_QUERY_ERROR = "ESQueryError", ES_INSERT_DOCUMENT = "ESInsertError", ES_CREATE_MAPPING_ERROR = "ESCreateMappingError", ES_DELETE_ITEM_WITH_CHILDREN_ERROR = "ESDeleteItemWithChildrenError", // DTOs DTO_NOT_VALID = "DTONotValidException", Loading src/main/java/es/redmic/exception/elasticsearch/ESDeleteItemWithChildrenException.java 0 → 100644 +37 −0 Original line number Diff line number Diff line package es.redmic.exception.elasticsearch; /*- * #%L * Exceptions * %% * Copyright (C) 2019 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.util.Arrays; import es.redmic.exception.common.BadRequestException; import es.redmic.exception.common.ExceptionType; public class ESDeleteItemWithChildrenException extends BadRequestException { private static final long serialVersionUID = 1L; public ESDeleteItemWithChildrenException(String field, String value) { super(ExceptionType.ES_DELETE_ITEM_WITH_CHILDREN_ERROR); setFieldErrors(Arrays.asList(field, value)); } } src/main/java/es/redmic/exception/factory/ExceptionFactory.java +22 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import es.redmic.exception.common.InternalException; import es.redmic.exception.data.DeleteItemException; import es.redmic.exception.data.ItemAlreadyExistException; import es.redmic.exception.data.ItemNotFoundException; import es.redmic.exception.elasticsearch.ESDeleteItemWithChildrenException; import es.redmic.exception.elasticsearch.ESInsertException; import es.redmic.exception.elasticsearch.ESUpdateException; Loading @@ -44,19 +45,23 @@ public class ExceptionFactory { return new ItemAlreadyExistException(); if (exceptionType.equals(ExceptionType.ITEM_NOT_FOUND.name()) && (arguments != null && arguments.size() == 1)) // TODO: sacar errores del map return new ItemNotFoundException("a", "b"); return new ItemNotFoundException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.DELETE_ITEM_EXCEPTION.name()) && (arguments == null || arguments.size() == 0)) return new DeleteItemException(); if (exceptionType.equals(ExceptionType.ES_INSERT_DOCUMENT.name()) && (arguments != null && arguments.size() == 4)) return new ESInsertException("a", "b"); && (arguments != null && arguments.size() > 0)) return new ESInsertException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.ES_UPDATE_DOCUMENT.name()) && (arguments != null)) return new ESUpdateException("a"); if (exceptionType.equals(ExceptionType.ES_UPDATE_DOCUMENT.name()) && (arguments != null && arguments.size() > 0)) return new ESUpdateException(getKeysFromMap(arguments)); if (exceptionType.equals(ExceptionType.ES_DELETE_ITEM_WITH_CHILDREN_ERROR.name()) && (arguments != null && arguments.size() > 0)) return new ESDeleteItemWithChildrenException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.INTERNAL_EXCEPTION.name()) && (arguments == null)) return new InternalException(ExceptionType.INTERNAL_EXCEPTION); Loading @@ -65,4 +70,15 @@ public class ExceptionFactory { return new InternalException(ExceptionType.INTERNAL_EXCEPTION); } // TODO: Construir argumentos del tipo [campo: valor (restricción que incumple)] private static String getKeysFromMap(Map<String, String> arguments) { return String.join(",", arguments.keySet()); } private static String getValuesFromMap(Map<String, String> arguments) { return String.join(",", arguments.values()); } } src/main/resources/i18n/messages_en_EN.properties +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ ESTermQueryError=Error. Term {0} with value {1} is not as expected. ESQueryError=Error. Query is erroneous. ESInsertError=Error. Register with field {0} and value {1} already exists. ESCreateMappingError=Error. Mapping for index {0} could not be created. ESDeleteItemWithChildrenError=Error. Unable to delete the item with field {0} with value {1}. Has children and it is not possible to remove it. #Layer LayerNotFound=Layer {0} does not exist in service {1} Loading Loading
pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ <groupId>es.redmic.lib</groupId> <artifactId>exceptions</artifactId> <packaging>jar</packaging> <version>0.9.0</version> <version>0.9.0-feature-atlasExceptions</version> <name>Exceptions</name> <description>Exceptions utils and management</description> Loading
src/main/java/es/redmic/exception/common/ExceptionType.java +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public enum ExceptionType implements ExceptionTypeItfc { ES_QUERY_ERROR(Constants.ES_QUERY_ERROR), ES_INSERT_DOCUMENT(Constants.ES_INSERT_DOCUMENT), ES_CREATE_MAPPING_ERROR(Constants.ES_CREATE_MAPPING_ERROR), ES_DELETE_ITEM_WITH_CHILDREN_ERROR(Constants.ES_DELETE_ITEM_WITH_CHILDREN_ERROR), // DTOs DTO_NOT_VALID(Constants.DTO_NOT_VALID), Loading Loading @@ -212,6 +213,7 @@ public enum ExceptionType implements ExceptionTypeItfc { ES_QUERY_ERROR = "ESQueryError", ES_INSERT_DOCUMENT = "ESInsertError", ES_CREATE_MAPPING_ERROR = "ESCreateMappingError", ES_DELETE_ITEM_WITH_CHILDREN_ERROR = "ESDeleteItemWithChildrenError", // DTOs DTO_NOT_VALID = "DTONotValidException", Loading
src/main/java/es/redmic/exception/elasticsearch/ESDeleteItemWithChildrenException.java 0 → 100644 +37 −0 Original line number Diff line number Diff line package es.redmic.exception.elasticsearch; /*- * #%L * Exceptions * %% * Copyright (C) 2019 REDMIC Project / Server * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.util.Arrays; import es.redmic.exception.common.BadRequestException; import es.redmic.exception.common.ExceptionType; public class ESDeleteItemWithChildrenException extends BadRequestException { private static final long serialVersionUID = 1L; public ESDeleteItemWithChildrenException(String field, String value) { super(ExceptionType.ES_DELETE_ITEM_WITH_CHILDREN_ERROR); setFieldErrors(Arrays.asList(field, value)); } }
src/main/java/es/redmic/exception/factory/ExceptionFactory.java +22 −6 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import es.redmic.exception.common.InternalException; import es.redmic.exception.data.DeleteItemException; import es.redmic.exception.data.ItemAlreadyExistException; import es.redmic.exception.data.ItemNotFoundException; import es.redmic.exception.elasticsearch.ESDeleteItemWithChildrenException; import es.redmic.exception.elasticsearch.ESInsertException; import es.redmic.exception.elasticsearch.ESUpdateException; Loading @@ -44,19 +45,23 @@ public class ExceptionFactory { return new ItemAlreadyExistException(); if (exceptionType.equals(ExceptionType.ITEM_NOT_FOUND.name()) && (arguments != null && arguments.size() == 1)) // TODO: sacar errores del map return new ItemNotFoundException("a", "b"); return new ItemNotFoundException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.DELETE_ITEM_EXCEPTION.name()) && (arguments == null || arguments.size() == 0)) return new DeleteItemException(); if (exceptionType.equals(ExceptionType.ES_INSERT_DOCUMENT.name()) && (arguments != null && arguments.size() == 4)) return new ESInsertException("a", "b"); && (arguments != null && arguments.size() > 0)) return new ESInsertException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.ES_UPDATE_DOCUMENT.name()) && (arguments != null)) return new ESUpdateException("a"); if (exceptionType.equals(ExceptionType.ES_UPDATE_DOCUMENT.name()) && (arguments != null && arguments.size() > 0)) return new ESUpdateException(getKeysFromMap(arguments)); if (exceptionType.equals(ExceptionType.ES_DELETE_ITEM_WITH_CHILDREN_ERROR.name()) && (arguments != null && arguments.size() > 0)) return new ESDeleteItemWithChildrenException(getKeysFromMap(arguments), getValuesFromMap(arguments)); if (exceptionType.equals(ExceptionType.INTERNAL_EXCEPTION.name()) && (arguments == null)) return new InternalException(ExceptionType.INTERNAL_EXCEPTION); Loading @@ -65,4 +70,15 @@ public class ExceptionFactory { return new InternalException(ExceptionType.INTERNAL_EXCEPTION); } // TODO: Construir argumentos del tipo [campo: valor (restricción que incumple)] private static String getKeysFromMap(Map<String, String> arguments) { return String.join(",", arguments.keySet()); } private static String getValuesFromMap(Map<String, String> arguments) { return String.join(",", arguments.values()); } }
src/main/resources/i18n/messages_en_EN.properties +1 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ ESTermQueryError=Error. Term {0} with value {1} is not as expected. ESQueryError=Error. Query is erroneous. ESInsertError=Error. Register with field {0} and value {1} already exists. ESCreateMappingError=Error. Mapping for index {0} could not be created. ESDeleteItemWithChildrenError=Error. Unable to delete the item with field {0} with value {1}. Has children and it is not possible to remove it. #Layer LayerNotFound=Layer {0} does not exist in service {1} Loading