Examples of ItemStreamException


Examples of org.springframework.batch.item.ItemStreamException

  public void close() throws ItemStreamException {
    if (dataStoreReader != null) {
      try {
        dataStoreReader.close();
      } catch (IOException e) {
        throw new ItemStreamException("Error while closing item reader", e);
      } finally {
        dataStoreReader = null;
      }
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

      if (!(++position < toPosition)) {
        break;
      }
    }
    if (position < toPosition) {
      throw new ItemStreamException("Expected to restore to position " + toPosition
          + " but was only able to read to position " + position);
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

  public void open(ExecutionContext executionContext) throws ItemStreamException {
    if (executionContext.containsKey(EXPECTED)) {
      localState.open(executionContext.getInt(EXPECTED), executionContext.getInt(ACTUAL));
      if (!waitForResults()) {
        throw new ItemStreamException("Timed out waiting for back log on open");
      }
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

    try {
      if (!restarted) {
        if (!append) {
          if (file.exists()) {
            if (!overwriteOutputFile) {
              throw new ItemStreamException("File already exists: [" + file.getAbsolutePath() + "]");
            }
            if (!file.delete()) {
              throw new IOException("Could not delete file: " + file);
            }
          }

          if (file.getParent() != null) {
            new File(file.getParent()).mkdirs();
          }
          if (!createNewFile(file)) {
            throw new ItemStreamException("Output file was not created: [" + file.getAbsolutePath() + "]");
          }
        }
        else {
          if (!file.exists()) {
            if (file.getParent() != null) {
              new File(file.getParent()).mkdirs();
            }
            if (!createNewFile(file)) {
              throw new ItemStreamException("Output file was not created: [" + file.getAbsolutePath()
                  + "]");
            }
          }
        }
      }
    }
    catch (IOException ioe) {
      throw new ItemStreamException("Unable to create file: [" + file.getAbsolutePath() + "]", ioe);
    }

    if (!file.canWrite()) {
      throw new ItemStreamException("File is not writable: [" + file.getAbsolutePath() + "]");
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

          footerCallback.writeFooter(state.outputBufferedWriter);
          state.outputBufferedWriter.flush();
        }
      }
      catch (IOException e) {
        throw new ItemStreamException("Failed to write footer before closing", e);
      }
      finally {
        state.close();
        if (state.linesWritten == 0 && shouldDeleteIfEmpty) {
          try {
            resource.getFile().delete();
          }
          catch (IOException e) {
            throw new ItemStreamException("Failed to delete empty file on close", e);
          }
        }
        state = null;
      }
    }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

    }
    try {
      outputState.initializeBufferedWriter();
    }
    catch (IOException ioe) {
      throw new ItemStreamException("Failed to initialize writer", ioe);
    }
    if (outputState.lastMarkedByteOffsetPosition == 0 && !outputState.appending) {
      if (headerCallback != null) {
        try {
          headerCallback.writeHeader(outputState.outputBufferedWriter);
          outputState.write(lineSeparator);
        }
        catch (IOException e) {
          throw new ItemStreamException("Could not write headers.  The file may be corrupt.", e);
        }
      }
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

   */
  @Override
  public void update(ExecutionContext executionContext) {
    super.update(executionContext);
    if (state == null) {
      throw new ItemStreamException("ItemStream not open or already closed.");
    }

    Assert.notNull(executionContext, "ExecutionContext must not be null");

    if (saveState) {

      try {
        executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), state.position());
      }
      catch (IOException e) {
        throw new ItemStreamException("ItemStream does not return current position properly", e);
      }

      executionContext.putLong(getExecutionContextKey(WRITTEN_STATISTICS_NAME), state.linesWritten);
    }
  }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

      File file;
      try {
        file = resource.getFile();
      }
      catch (IOException e) {
        throw new ItemStreamException("Could not convert resource to file: [" + resource + "]", e);
      }
      Assert.state(!file.exists() || file.canWrite(), "Resource is not writable: [" + resource + "]");
      state = new OutputState();
      state.setDeleteIfExists(shouldDeleteIfExists);
      state.setAppendAllowed(append);
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

        if (outputBufferedWriter != null) {
          outputBufferedWriter.close();
        }
      }
      catch (IOException ioe) {
        throw new ItemStreamException("Unable to close the the ItemWriter", ioe);
      }
      finally {
        if (!transactional) {
          closeStream();
        }
View Full Code Here

Examples of org.springframework.batch.item.ItemStreamException

        if (fileChannel != null) {
          fileChannel.close();
        }
      }
      catch (IOException ioe) {
        throw new ItemStreamException("Unable to close the the ItemWriter", ioe);
      }
      finally {
        try {
          if (os != null) {
            os.close();
          }
        }
        catch (IOException ioe) {
          throw new ItemStreamException("Unable to close the the ItemWriter", ioe);
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.