// Path: common/dataobjects/src/main/java/com/sastix/cms/common/content/exceptions/ResourceNotFound.java
// @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = Constants.RESOURCE_NOT_FOUND)
// public class ResourceNotFound extends GeneralResourceException {
// 
//     /**
//      * Serial Version UID.
//      */
//     private static final long serialVersionUID = 6032702930609853039L;
// 
//     /**
//      * Constructor that allows a specific error message to be specified.
//      *
//      * @param message detail message.
//      */
//     public ResourceNotFound(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: common/dataobjects/src/main/java/com/sastix/cms/common/exception/CommonException.java
// public class CommonException extends RestClientException {
// 
//     /**
//      * Serial Version UID.
//      */
//     private static final long serialVersionUID = -7037833658038044223L;
// 
//     /**
//      * Constructor that allows a specific error message to be specified.
//      *
//      * @param message detail message.
//      */
//     public CommonException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Creates a {@code CommonException} with the specified
//      * detail message and cause.
//      *
//      * @param message the detail message
//      * @param cause   the cause
//      */
//     public CommonException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import com.sastix.cms.common.content.exceptions.ResourceNotFound;
import com.sastix.cms.common.exception.CommonException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/*
 * Copyright(c) 2016 the original author or authors.
 *
 * 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.
 */

package com.sastix.cms.common.services.web;




@Slf4j
@ControllerAdvice
public class ExceptionHandlingController {

    @ExceptionHandler({CommonException.class})
    public void handleBadRequests(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
// Path: common/dataobjects/src/main/java/com/sastix/cms/common/content/exceptions/ResourceNotFound.java
// @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = Constants.RESOURCE_NOT_FOUND)
// public class ResourceNotFound extends GeneralResourceException {
// 
//     /**
//      * Serial Version UID.
//      */
//     private static final long serialVersionUID = 6032702930609853039L;
// 
//     /**
//      * Constructor that allows a specific error message to be specified.
//      *
//      * @param message detail message.
//      */
//     public ResourceNotFound(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: common/dataobjects/src/main/java/com/sastix/cms/common/exception/CommonException.java
// public class CommonException extends RestClientException {
// 
//     /**
//      * Serial Version UID.
//      */
//     private static final long serialVersionUID = -7037833658038044223L;
// 
//     /**
//      * Constructor that allows a specific error message to be specified.
//      *
//      * @param message detail message.
//      */
//     public CommonException(String message) {
//         super(message);
//     }
// 
//     /**
//      * Creates a {@code CommonException} with the specified
//      * detail message and cause.
//      *
//      * @param message the detail message
//      * @param cause   the cause
//      */
//     public CommonException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: common/services/src/main/java/com/sastix/cms/common/services/web/ExceptionHandlingController.java
import com.sastix.cms.common.content.exceptions.ResourceNotFound;
import com.sastix.cms.common.exception.CommonException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
 * Copyright(c) 2016 the original author or authors.
 *
 * 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.
 */

package com.sastix.cms.common.services.web;




@Slf4j
@ControllerAdvice
public class ExceptionHandlingController {

    @ExceptionHandler({CommonException.class})
    public void handleBadRequests(HttpServletRequest request, HttpServletResponse response, Exception e) throws IOException {
        log.error("Bad request: {} from {}, Exception: {} {}",