@Test(expected = DecisionTableParseException.class) public void testValidateFileWithInvalidContent() throws IOException { this.service = getServiceWithValidationOverride(null); File tempFile = File.createTempFile("emptyxls", null); try (FileOutputStream tempFOS = new FileOutputStream(tempFile)) { IOUtils.write("birdplane!", tempFOS); tempFOS.flush(); service.validate(tempFile); } }
void validate(final File tempFile) { Workbook workbook = null; try { workbook = WorkbookFactory.create(tempFile); } catch (IOException e) { throw new DecisionTableParseException("DecisionTableParseException: Failed to open Excel stream, " + "please check that the content is xls97 format.", e); } catch (Throwable e) { throw new DecisionTableParseException("DecisionTableParseException: " + e.getMessage(), e); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { throw ExceptionUtilities.handleException(e); } } } }
DecisionTableXLSServiceImpl extends KieService<DecisionTableXLSContent> implements DecisionTableXLSService,
                   ExtendedDecisionTableXLSService { void validate(final File tempFile) { Workbook workbook = null; try { workbook = WorkbookFactory.create(tempFile); } catch (IOException e) { throw new DecisionTableParseException("DecisionTableParseException: Failed to open Excel stream, " + "please check that the content is xls97 format.", e); } catch (Throwable e) { throw new DecisionTableParseException("DecisionTableParseException: " + e.getMessage(), e); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { throw ExceptionUtilities.handleException(e); } } } } }
DecisionTableXLSServiceImpl extends KieService<DecisionTableXLSContent> implements DecisionTableXLSService,
                   ExtendedDecisionTableXLSService { void validate(final File tempFile) { Workbook workbook = null; try { workbook = WorkbookFactory.create(tempFile); } catch (IOException e) { throw new DecisionTableParseException("DecisionTableParseException: Failed to open Excel stream, " + "please check that the content is xls97 format.", e); } catch (Throwable e) { throw new DecisionTableParseException("DecisionTableParseException: " + e.getMessage(), e); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { throw ExceptionUtilities.handleException(e); } } } } DecisionTableXLSServiceImpl(); @Inject  DecisionTableXLSServiceImpl(@Named("ioStrategy") final IOService ioService,
                                       final CopyService copyService,
                                       final DeleteService deleteService,
                                       final RenameService renameService,
                                       final Event<ResourceOpenedEvent> resourceOpenedEvent,
                                       final DecisionTableXLSConversionService conversionService,
                                       final GenericValidator genericValidator,
                                       final CommentedOptionFactory commentedOptionFactory,
                                       final AuthenticationService authenticationService); }
DecisionTableXLSServiceImpl extends KieService<DecisionTableXLSContent> implements DecisionTableXLSService,
                   ExtendedDecisionTableXLSService { void validate(final File tempFile) { Workbook workbook = null; try { workbook = WorkbookFactory.create(tempFile); } catch (IOException e) { throw new DecisionTableParseException("DecisionTableParseException: Failed to open Excel stream, " + "please check that the content is xls97 format.", e); } catch (Throwable e) { throw new DecisionTableParseException("DecisionTableParseException: " + e.getMessage(), e); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { throw ExceptionUtilities.handleException(e); } } } } DecisionTableXLSServiceImpl(); @Inject  DecisionTableXLSServiceImpl(@Named("ioStrategy") final IOService ioService,
                                       final CopyService copyService,
                                       final DeleteService deleteService,
                                       final RenameService renameService,
                                       final Event<ResourceOpenedEvent> resourceOpenedEvent,
                                       final DecisionTableXLSConversionService conversionService,
                                       final GenericValidator genericValidator,
                                       final CommentedOptionFactory commentedOptionFactory,
                                       final AuthenticationService authenticationService); @Override DecisionTableXLSContent loadContent(final Path path); @Override InputStream load(final Path path,
                            final String sessionId); @Override Path create(final Path resource,
                       final InputStream content,
                       final String sessionId,
                       final String comment); @Override Path save(final Path resource,
                     final InputStream content,
                     final String sessionId,
                     final String comment); @Override String getSource(final Path path); @Override void delete(final Path path,
                       final String comment); @Override Path rename(final Path path,
                       final String newName,
                       final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final Path targetDirectory,
                     final String comment); @Override ConversionResult convert(final Path path); @Override List<ValidationMessage> validate(final Path path,
                                            final Path resource); }
DecisionTableXLSServiceImpl extends KieService<DecisionTableXLSContent> implements DecisionTableXLSService,
                   ExtendedDecisionTableXLSService { void validate(final File tempFile) { Workbook workbook = null; try { workbook = WorkbookFactory.create(tempFile); } catch (IOException e) { throw new DecisionTableParseException("DecisionTableParseException: Failed to open Excel stream, " + "please check that the content is xls97 format.", e); } catch (Throwable e) { throw new DecisionTableParseException("DecisionTableParseException: " + e.getMessage(), e); } finally { if (workbook != null) { try { workbook.close(); } catch (IOException e) { throw ExceptionUtilities.handleException(e); } } } } DecisionTableXLSServiceImpl(); @Inject  DecisionTableXLSServiceImpl(@Named("ioStrategy") final IOService ioService,
                                       final CopyService copyService,
                                       final DeleteService deleteService,
                                       final RenameService renameService,
                                       final Event<ResourceOpenedEvent> resourceOpenedEvent,
                                       final DecisionTableXLSConversionService conversionService,
                                       final GenericValidator genericValidator,
                                       final CommentedOptionFactory commentedOptionFactory,
                                       final AuthenticationService authenticationService); @Override DecisionTableXLSContent loadContent(final Path path); @Override InputStream load(final Path path,
                            final String sessionId); @Override Path create(final Path resource,
                       final InputStream content,
                       final String sessionId,
                       final String comment); @Override Path save(final Path resource,
                     final InputStream content,
                     final String sessionId,
                     final String comment); @Override String getSource(final Path path); @Override void delete(final Path path,
                       final String comment); @Override Path rename(final Path path,
                       final String newName,
                       final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final Path targetDirectory,
                     final String comment); @Override ConversionResult convert(final Path path); @Override List<ValidationMessage> validate(final Path path,
                                            final Path resource);  }