Commit 42e4e3d8 authored by Noel Alonso's avatar Noel Alonso
Browse files

Merge branch 'feature-atlasExceptions' into 'dev'

Feature atlas exceptions

See merge request redmic-project/server/library/exceptions!9
parents fb013005 29cc5080
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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>

+25 −2
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ 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),
	ES_DELETE_ITEM_REFERENCED_ERROR(Constants.ES_DELETE_ITEM_REFERENCED_ERROR),
	ES_PARENT_NOT_EXIST_ERROR(Constants.ES_PARENT_NOT_EXIST_ERROR),
	
	// DTOs
	DTO_NOT_VALID(Constants.DTO_NOT_VALID),
@@ -102,6 +105,7 @@ public enum ExceptionType implements ExceptionTypeItfc {
	
	INTERNAL_EXCEPTION(Constants.INTERNAL_EXCEPTION),
	RESOURCE_NOT_FOUND(Constants.RESOURCE_NOT_FOUND),
	URL_EXCEPTION(Constants.URL_EXCEPTION),
	
	// Data
	DT_INCCORRECT_INTERVAL(Constants.DT_INCCORRECT_INTERVAL),
@@ -131,7 +135,15 @@ public enum ExceptionType implements ExceptionTypeItfc {
	
	REPORT_ERROR(Constants.REPORT_ERROR),
	
	NO_CONTENT(Constants.NO_CONTENT);
	NO_CONTENT(Constants.NO_CONTENT),
	
	// Settings
	
	SELECTION_CHANGE_NOT_ALLOWED(Constants.SELECTION_CHANGE_NOT_ALLOWED),
	SETTINGS_TO_CLONE_NOT_FOUND_EXCEPTION(Constants.SETTINGS_TO_CLONE_NOT_FOUND_EXCEPTION),
	SETTINGS_TO_SAVE_NOT_FOUND_EXCEPTION(Constants.SETTINGS_TO_SAVE_NOT_FOUND_EXCEPTION),
	SETTINGS_CHANGE_FORBIDDEN(Constants.SETTINGS_CHANGE_FORBIDDEN_EXCEPTION),
	DELETE_SETTINGS_NOT_ALLOWED(Constants.DELETE_SETTINGS_NOT_ALLOWED);
	
	// @formatter:on

@@ -212,6 +224,9 @@ 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",
			ES_DELETE_ITEM_REFERENCED_ERROR="ESDeleteItemReferencedError",
			ES_PARENT_NOT_EXIST_ERROR = "ESParentNotExistError",
			
			// DTOs
			DTO_NOT_VALID = "DTONotValidException",
@@ -239,6 +254,7 @@ public enum ExceptionType implements ExceptionTypeItfc {
			
			INTERNAL_EXCEPTION = "InternalException",
			RESOURCE_NOT_FOUND = "ResourceNotFound",
			URL_EXCEPTION = "URLException",
			
			// Data
			DT_INCCORRECT_INTERVAL = "IncorrectInterval",
@@ -268,7 +284,14 @@ public enum ExceptionType implements ExceptionTypeItfc {
			
			REPORT_ERROR = "ReportError",
		
			NO_CONTENT = "NoContentException";
			NO_CONTENT = "NoContentException",
		
			// Settings
			SELECTION_CHANGE_NOT_ALLOWED = "SelectionChangeNotAllowedException",
			SETTINGS_TO_CLONE_NOT_FOUND_EXCEPTION = "SettingsToCloneNotFoundException",
			SETTINGS_TO_SAVE_NOT_FOUND_EXCEPTION = "SettingsToSaveNotFoundException",
			SETTINGS_CHANGE_FORBIDDEN_EXCEPTION = "SettingsChangeForbiddenException",
			DELETE_SETTINGS_NOT_ALLOWED = "DeleteSettingsNotAllowedException";
		// @formatter:on
	}

+37 −0
Original line number Diff line number Diff line
package es.redmic.exception.common;

/*-
 * #%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%
 */

public abstract class RequestForbiddenException extends BaseException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public RequestForbiddenException(ExceptionTypeItfc code) {
		this(code, null);
	}

	public RequestForbiddenException(ExceptionTypeItfc code, Exception e) {
		super(code, e);
	}
}
+43 −0
Original line number Diff line number Diff line
package es.redmic.exception.custom;

/*-
 * #%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.ExceptionType;
import es.redmic.exception.common.NotFoundException;

public class URLException extends NotFoundException {

	private static final long serialVersionUID = 6714485190161856195L;

	public URLException(Exception e, String url) {

		super(ExceptionType.URL_EXCEPTION, e);
		setFieldErrors(Arrays.asList(url));
	}

	public URLException(String url) {

		super(ExceptionType.URL_EXCEPTION);
		setFieldErrors(Arrays.asList(url));
	}
}
+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 ESDeleteItemReferencedException extends BadRequestException {

	private static final long serialVersionUID = 1L;

	public ESDeleteItemReferencedException(String field, String value) {

		super(ExceptionType.ES_DELETE_ITEM_REFERENCED_ERROR);
		setFieldErrors(Arrays.asList(field, value));
	}
}
Loading