Package com.github.dandelion.datatables.core.exception

Examples of com.github.dandelion.datatables.core.exception.ExportException


    String exportFormat = htmlTable.getTableConfiguration().getCurrentExportFormat();
    ExportConf exportConf = htmlTable.getTableConfiguration().getExportConfiguration().get(exportFormat);

    String exportClassName = exportConf.getExportClass();
    if (exportClassName == null) {
      throw new ExportException("No export class has been configured for the '" + exportFormat
          + "' format. Please configure it before exporting.");
    }
    logger.debug("Selected export class: {}", exportClassName);

    // Check that the class can be instantiated
    if (!ClassUtils.isPresent(exportClassName)) {
      StringBuilder sb = new StringBuilder("Unable to export in the ");
      sb.append(exportFormat);
      sb.append(" format because either the export class '");
      sb.append(exportClassName);
      sb.append("' or some other librairies ");
      sb.append(" imported in the export class is not present in the classpath.");
      sb.append("Did you forget to add a dependency?");
      throw new ExportException(sb.toString());
    }

    // Instantiates the export class and processes the export
    Class<?> exportClass = null;
    Object obj = null;
    try {
      exportClass = ClassUtils.getClass(exportClassName);
      obj = ClassUtils.getNewInstance(exportClass);
    } catch (ClassNotFoundException e) {
      throw new ExportException("Unable to load the class '" + exportClassName + "'", e);
    } catch (InstantiationException e) {
      throw new ExportException("Unable to instanciate the class '" + exportClassName + "'", e);
    } catch (IllegalAccessException e) {
      throw new ExportException("Unable to access the class '" + exportClassName + "'", e);
    }

    ((DatatablesExport) obj).initExport(htmlTable);
    ((DatatablesExport) obj).processExport(stream);
View Full Code Here


    } catch (XMLStreamException e) {
      StringBuilder sb = new StringBuilder("Something went wrong during the XML generation of the table '");
      sb.append(table.getOriginalId());
      sb.append("' and with the following export configuration: ");
      sb.append(exportConf.toString());
      throw new ExportException(sb.toString(), e);
    }
    finally {
      try {
        writer.close();
      } catch (XMLStreamException e) {
        StringBuilder sb = new StringBuilder("Something went wrong during the XML generation of the table '");
        sb.append(table.getOriginalId());
        sb.append("' and with the following export configuration: ");
        sb.append(exportConf.toString());
        throw new ExportException(sb.toString(), e);
      }
    }
  }
View Full Code Here

    } catch (IOException e) {
      StringBuilder sb = new StringBuilder("Something went wrong during the CSV generation of the table '");
      sb.append(table.getOriginalId());
      sb.append("' and with the following export configuration: ");
      sb.append(exportConf.toString());
      throw new ExportException(sb.toString(), e);
    }
  }
View Full Code Here

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    String exportClass = exportConf.getExportClass();

    // Check whether the class can be instantiated
    if (!ClassUtils.isPresent(exportClass)) {
      throw new ExportException("Unable to export in " + exportConf.getFormat()
          + " format because the export class cannot be found. Did you forget to add an extra dependency?");
    }

    Class<?> klass = null;
    DatatablesExport export = null;
    try {
      klass = ClassUtils.getClass(exportClass);
      export = (DatatablesExport) ClassUtils.getNewInstance(klass);
    } catch (ClassNotFoundException e) {
      throw new ExportException("Unable to load the class '" + exportClass + "'", e);
    } catch (InstantiationException e) {
      throw new ExportException("Unable to instanciate the class '" + exportClass + "'", e);
    } catch (IllegalAccessException e) {
      throw new ExportException("Unable to access the class '" + exportClass + "'", e);
    }
   
    export.initExport(table);
    export.processExport(stream);
       
    try {
      writeToResponse(response, stream, exportConf.getFileName() + "." + exportConf.getFileExtension(),
          exportConf.getMimeType());
    } catch (IOException e) {
      throw new ExportException(
          "Unable to write to response using the " + exportClass.getClass().getSimpleName(), e);
    }
  }
View Full Code Here

    } catch (DocumentException e) {
      StringBuilder sb = new StringBuilder("Something went wrong during the PDF generation of the table '");
      sb.append(table.getOriginalId());
      sb.append("' and with the following export configuration: ");
      sb.append(exportConf.toString());
      throw new ExportException(sb.toString(), e);
    } finally {
      document.close();
    }
  }
View Full Code Here

    } catch (IOException e) {
      StringBuilder sb = new StringBuilder("Something went wrong during the XLS generation of the table '");
      sb.append(table.getOriginalId());
      sb.append("' and with the following export configuration: ");
      sb.append(exportConf.toString());
      throw new ExportException(sb.toString(), e);
    }
  }
View Full Code Here

    } catch (IOException e) {
      StringBuilder sb = new StringBuilder("Something went wrong during the XLSX generation of the table '");
      sb.append(table.getOriginalId());
      sb.append("' and with the following export configuration: ");
      sb.append(exportConf.toString());
      throw new ExportException(sb.toString(), e);
    }
  }
View Full Code Here

TOP

Related Classes of com.github.dandelion.datatables.core.exception.ExportException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.