Search in sources :

Example 1 with ValidateException

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;
}
Also used : ValidateException(org.netbeans.modules.schema2beans.ValidateException) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) SunCmpMappings(com.sun.jdo.api.persistence.mapping.ejb.beans.SunCmpMappings) FileInputStream(java.io.FileInputStream) ModelException(com.sun.jdo.api.persistence.model.ModelException) ConversionException(com.sun.jdo.api.persistence.mapping.ejb.ConversionException) ValidateException(org.netbeans.modules.schema2beans.ValidateException) SQLException(java.sql.SQLException) DBException(org.netbeans.modules.dbschema.DBException) Schema2BeansException(org.netbeans.modules.schema2beans.Schema2BeansException) IOException(java.io.IOException) GeneratorException(com.sun.jdo.spi.persistence.support.ejb.codegen.GeneratorException)

Aggregations

ConversionException (com.sun.jdo.api.persistence.mapping.ejb.ConversionException)1 SunCmpMappings (com.sun.jdo.api.persistence.mapping.ejb.beans.SunCmpMappings)1 ModelException (com.sun.jdo.api.persistence.model.ModelException)1 GeneratorException (com.sun.jdo.spi.persistence.support.ejb.codegen.GeneratorException)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 SQLException (java.sql.SQLException)1 DBException (org.netbeans.modules.dbschema.DBException)1 Schema2BeansException (org.netbeans.modules.schema2beans.Schema2BeansException)1 ValidateException (org.netbeans.modules.schema2beans.ValidateException)1