Package org.springframework.batch.item

Examples of org.springframework.batch.item.UnexpectedInputException


  public void init(StepExecution stepExecution) {
    // this.stepExecution = stepExecution;
    Sip sip = new Sip(guid, URI.create(uri));
    List<File> items = sip.getItems();
    if (items.isEmpty()) {
      throw new UnexpectedInputException("SIP has no item");
    }
    iterator = sip.getItems().iterator();

    batchIngestTracker.init(guid);
  }
View Full Code Here


        try {
          // write item
          writer.write(items);
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
    });
    writer.close();

    // create new writer from saved restart data and continue writing
    writer = createItemWriter();
    writer.open(executionContext);
    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
      @Override
      public Void doInTransaction(TransactionStatus status) {
        try {
          writer.write(items);
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
View Full Code Here

        try {
          // write item
          writer.write(itemsMultiByte);
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
    });
    writer.close();

    // create new writer from saved restart data and continue writing
    writer = createItemWriter();
    writer.setEncoding(encoding);
    writer.open(executionContext);
    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
      @Override
      public Void doInTransaction(TransactionStatus status) {
        try {
          writer.write(itemsMultiByte);
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
View Full Code Here

            writer.write(items);
          }
          catch (Exception e) {
            throw new IllegalStateException("Could not write data", e);
          }
          throw new UnexpectedInputException("Could not write data");
        }
      });
    }
    catch (UnexpectedInputException e) {
      // expected
    }
    writer.close();
    String outputFile = getOutputFileContent();
    assertEquals("<root></root>", outputFile);

    // create new writer from saved restart data and continue writing
    writer = createItemWriter();
    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
      @Override
      public Void doInTransaction(TransactionStatus status) {
        writer.open(executionContext);
        try {
          writer.write(items);
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
View Full Code Here

        try {
          writer.write(Collections.singletonList(TEST_STRING));
          assertEquals(expectedInTransaction, readLine());
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }

        return null;
      }
    });
View Full Code Here

          writer.write(Arrays.asList(new String[] { "testLine1", "testLine2", "testLine3" }));
          // write more lines
          writer.write(Arrays.asList(new String[] { "testLine4", "testLine5" }));
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
    });
    // close template
    writer.close();

    // init with correct data
    writer.open(executionContext);

    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
      @Override
      public Void doInTransaction(TransactionStatus status) {
        try {
          // write more lines
          writer.write(Arrays.asList(new String[] { "testLine6", "testLine7", "testLine8" }));
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
View Full Code Here

          writer.write(Arrays.asList(new String[] { "téstLine1", "téstLine2", "téstLine3" }));
          // write more lines
          writer.write(Arrays.asList(new String[] { "téstLine4", "téstLine5" }));
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
    });
    // close template
    writer.close();

    // init with correct data
    writer.open(executionContext);

    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Void>() {
      @Override
      public Void doInTransaction(TransactionStatus status) {
        try {
          // write more lines
          writer.write(Arrays.asList(new String[] { "téstLine6", "téstLine7", "téstLine8" }));
        }
        catch (Exception e) {
          throw new UnexpectedInputException("Could not write data", e);
        }
        // get restart data
        writer.update(executionContext);
        return null;
      }
View Full Code Here

      if (item instanceof Message) {
        try {
          return !((Message) item).getJMSRedelivered();
        }
        catch (JMSException e) {
          throw new UnexpectedInputException("Could not extract message ID", e);
        }
      }
    }
    return false;
  }
View Full Code Here

      if (item instanceof Message) {
        try {
          return ((Message) item).getJMSMessageID();
        }
        catch (JMSException e) {
          throw new UnexpectedInputException("Could not extract message ID", e);
        }
      }
    }
    if (items.length == 0) {
      throw new IllegalArgumentException(
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.UnexpectedInputException

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.