// Path: step10_simple_app_with_cxf-spring-boot-starter/src/main/java/de/jonashackt/tutorial/common/CustomIds.java
// public enum CustomIds {
// 
// 	EVERYTHING_FINE("01", "The Weather-Call was successfully processed by the backend."),
// 	NON_XML_COMPLIANT("71", "XML-Scheme-validiation failed."),
// 	COMPLETE_USELESS_XML("72", "Syntactically incorrect XML."),
// 	SOMETHING_ELSE_WENT_TERRIBLY_WRONG("99", "Backend processing failed.");
// 
// 	private String id;
// 	private String message;
// 
// 	private CustomIds(String id, String text) {
// 		this.id = id;
// 		this.message = text;
// 	}
// 	
// 	public String getMessage() {
// 		return message;
// 	}
// 	
// 	public String getId() {
// 		return id;
// 	}
// 	
// }


import de.codecentric.cxf.common.FaultType;
import de.codecentric.cxf.xmlvalidation.CustomFaultBuilder;
import de.codecentric.namespace.weatherservice.exception.WeatherException;
import de.jonashackt.tutorial.common.CustomIds;
import org.springframework.stereotype.Component;
package de.jonashackt.tutorial.xmlvalidation;


@Component
public class WeatherFaultBuilder implements CustomFaultBuilder {

	private de.codecentric.namespace.weatherservice.exception.ObjectFactory objectFactoryDatatypes = new de.codecentric.namespace.weatherservice.exception.ObjectFactory();

	@Override
	public String createCustomFaultMessage(FaultType faultType) {
		if(FaultType.SCHEME_VALIDATION_ERROR.equals(faultType)) {
			return CustomIds.NON_XML_COMPLIANT.getMessage();
		}
		else if(FaultType.SYNTACTICALLY_INCORRECT_XML_ERROR.equals(faultType)) {
			return CustomIds.COMPLETE_USELESS_XML.getMessage();
		}
		else {
			return CustomIds.SOMETHING_ELSE_WENT_TERRIBLY_WRONG.getMessage();
		}
	}

	@Override
	public WeatherException createCustomFaultDetail(String originalFaultMessage, FaultType faultType) {
		// Build SOAP-Fault detail <datatypes:WeatherException>
		WeatherException weatherException = objectFactoryDatatypes.createWeatherException();
		weatherException.setBigBusinessErrorCausingMoneyLoss(true);
		setIdBasedUponFaultContent(faultType, weatherException);
		weatherException.setExceptionDetails(originalFaultMessage);
		weatherException.setUuid("ExtremeRandomNumber");
		return weatherException;
	}

	private void setIdBasedUponFaultContent(FaultType faultType, WeatherException weatherException) {
// Path: step10_simple_app_with_cxf-spring-boot-starter/src/main/java/de/jonashackt/tutorial/common/CustomIds.java
// public enum CustomIds {
// 
// 	EVERYTHING_FINE("01", "The Weather-Call was successfully processed by the backend."),
// 	NON_XML_COMPLIANT("71", "XML-Scheme-validiation failed."),
// 	COMPLETE_USELESS_XML("72", "Syntactically incorrect XML."),
// 	SOMETHING_ELSE_WENT_TERRIBLY_WRONG("99", "Backend processing failed.");
// 
// 	private String id;
// 	private String message;
// 
// 	private CustomIds(String id, String text) {
// 		this.id = id;
// 		this.message = text;
// 	}
// 	
// 	public String getMessage() {
// 		return message;
// 	}
// 	
// 	public String getId() {
// 		return id;
// 	}
// 	
// }


// Path: step10_simple_app_with_cxf-spring-boot-starter/src/main/java/de/jonashackt/tutorial/xmlvalidation/WeatherFaultBuilder.java
import de.codecentric.cxf.common.FaultType;
import de.codecentric.cxf.xmlvalidation.CustomFaultBuilder;
import de.codecentric.namespace.weatherservice.exception.WeatherException;
import de.jonashackt.tutorial.common.CustomIds;
import org.springframework.stereotype.Component;

package de.jonashackt.tutorial.xmlvalidation;


@Component
public class WeatherFaultBuilder implements CustomFaultBuilder {

	private de.codecentric.namespace.weatherservice.exception.ObjectFactory objectFactoryDatatypes = new de.codecentric.namespace.weatherservice.exception.ObjectFactory();

	@Override
	public String createCustomFaultMessage(FaultType faultType) {
		if(FaultType.SCHEME_VALIDATION_ERROR.equals(faultType)) {
			return CustomIds.NON_XML_COMPLIANT.getMessage();
		}
		else if(FaultType.SYNTACTICALLY_INCORRECT_XML_ERROR.equals(faultType)) {
			return CustomIds.COMPLETE_USELESS_XML.getMessage();
		}
		else {
			return CustomIds.SOMETHING_ELSE_WENT_TERRIBLY_WRONG.getMessage();
		}
	}

	@Override
	public WeatherException createCustomFaultDetail(String originalFaultMessage, FaultType faultType) {
		// Build SOAP-Fault detail <datatypes:WeatherException>
		WeatherException weatherException = objectFactoryDatatypes.createWeatherException();
		weatherException.setBigBusinessErrorCausingMoneyLoss(true);
		setIdBasedUponFaultContent(faultType, weatherException);
		weatherException.setExceptionDetails(originalFaultMessage);
		weatherException.setUuid("ExtremeRandomNumber");
		return weatherException;
	}

	private void setIdBasedUponFaultContent(FaultType faultType, WeatherException weatherException) {
		if(FaultType.SCHEME_VALIDATION_ERROR.equals(faultType)) {