1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
* Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.platform.xml;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import org.xml.sax.SAXParseException;
import org.eclipse.persistence.exceptions.EclipseLinkException;
import org.eclipse.persistence.exceptions.i18n.ExceptionMessageGenerator;
public class XMLPlatformException extends EclipseLinkException {
public static final int XML_PLATFORM_CLASS_NOT_FOUND = 27001;
public static final int XML_PLATFORM_COULD_NOT_INSTANTIATE = 27002;
public static final int XML_PLATFORM_COULD_NOT_CREATE_DOCUMENT = 27003;
public static final int XML_PLATFORM_INVALID_XPATH = 27004;
public static final int XML_PLATFORM_VALIDATION_EXCEPTION = 27005;
public static final int XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA = 27006;
public static final int XML_PLATFORM_PARSE_EXCEPTION = 27101;
public static final int XML_PLATFORM_PARSER_FILE_NOT_FOUND_EXCEPTION = 27102;
public static final int XML_PLATFORM_PARSER_SAX_PARSE_EXCEPTION = 27103;
public static final int XML_PLATFORM_TRANSFORM_EXCEPTION = 27201;
public static final int XML_PLATFORM_INVALID_TYPE = 27202;
protected XMLPlatformException(String message) {
super(message);
}
public static XMLPlatformException xmlPlatformClassNotFound(String xmlPlatformClassName, Exception nestedException) {
Object[] args = { xmlPlatformClassName };
int errorCode = XML_PLATFORM_CLASS_NOT_FOUND;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformCouldNotInstantiate(String xmlPlatformClassName, Exception nestedException) {
Object[] args = { xmlPlatformClassName };
int errorCode = XML_PLATFORM_COULD_NOT_INSTANTIATE;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformCouldNotCreateDocument(Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_COULD_NOT_CREATE_DOCUMENT;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
return exception;
}
public static XMLPlatformException xmlPlatformInvalidXPath(Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_INVALID_XPATH;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformValidationException(Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_VALIDATION_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
/**
* Takes an error messsage string
*/
public static XMLPlatformException xmlPlatformValidationException(String errorMessage) {
int errorCode = XML_PLATFORM_VALIDATION_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(errorMessage);
exception.setErrorCode(errorCode);
return exception;
}
/**
* Handles an invalid type setting in a schema reference.
*
* @see org.eclipse.persistence.platform.xml.XMLSchemaReference#getType()
*/
public static XMLPlatformException xmlPlatformInvalidTypeException(int type) {
Object[] args = { Integer.valueOf(type) };
int errorCode = XML_PLATFORM_INVALID_TYPE;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
return exception;
}
public static XMLPlatformException xmlPlatformParseException(Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_PARSE_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformFileNotFoundException(File file, IOException nestedException) {
Object[] args = { file.getAbsolutePath() };
int errorCode = XML_PLATFORM_PARSER_FILE_NOT_FOUND_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformSAXParseException(SAXParseException nestedException) {
Object[] args = { Integer.valueOf(nestedException.getLineNumber()), nestedException.getSystemId(), nestedException.getMessage() };
int errorCode = XML_PLATFORM_PARSER_SAX_PARSE_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformErrorResolvingXMLSchema(URL url, Exception nestedException) {
Object[] args = { url };
int errorCode = XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformErrorResolvingXMLSchemas(Object[] schemas, Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
public static XMLPlatformException xmlPlatformTransformException(Exception nestedException) {
Object[] args = { };
int errorCode = XML_PLATFORM_TRANSFORM_EXCEPTION;
XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args));
exception.setErrorCode(errorCode);
exception.setInternalException(nestedException);
return exception;
}
}
|