use of org.netbeans.modules.schema2beans.ValidateException in project Payara by payara.
the class MappingGenerator method getSunCmpMappings.
/**
* Loads sun-cmp-mapping.xml into memory as SunCmpMappings
* @param cmpMappingFile a file of sun-cmp-mappings.xml
* @return a SunCmpMappings object
* @throws IOException
* @throws Schema2BeansException
*/
private SunCmpMappings getSunCmpMappings(File cmpMappingFile) throws IOException, Schema2BeansException, GeneratorException {
InputStream is = null;
BufferedInputStream iasMapping = null;
SunCmpMappings sunCmpMapping = null;
if (cmpMappingFile.length() == 0) {
throw JDOCodeGeneratorHelper.createGeneratorException("CMG.BeansFileSizeIsZero", // NOI18N
bundle);
}
try {
is = new FileInputStream(cmpMappingFile);
iasMapping = new BufferedInputStream(is);
sunCmpMapping = SunCmpMappings.createGraph(iasMapping);
} catch (IOException ex) {
throw ex;
} finally {
if (is != null) {
try {
is.close();
} catch (Exception ex) {
if (logger.isLoggable(Logger.FINE))
logger.fine(ex.toString());
}
}
if (iasMapping != null) {
try {
iasMapping.close();
} catch (Exception ex) {
if (logger.isLoggable(Logger.FINE))
logger.fine(ex.toString());
}
}
}
try {
sunCmpMapping.validate();
} catch (ValidateException ex) {
throw JDOCodeGeneratorHelper.createGeneratorException("CMG.InvalidSunCmpMappingsFile", bundle, // NOI18N
ex);
}
return sunCmpMapping;
}
Aggregations