List of usage examples for org.springframework.batch.item ReaderNotOpenException ReaderNotOpenException
public ReaderNotOpenException(String message)
From source file:org.hoteia.qalingo.app.crmsync.job.customer.CustomerItemReader.java
public CommonProcessIndicatorItemWrapper<Customer, Customer> read() throws DataAccessException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); }//from w w w .j a v a2 s . c o m Customer key = null; synchronized (lock) { if (keysIterator.hasNext()) { key = keysIterator.next(); } } // logger.debug("Retrieved key from list: " + key); if (key == null) { return null; } Customer result = null; // try { // result = xxxxDAO.getxxxById(xxxxId); // // } catch (Exception e) { // logger.error("", e); // throw new ReaderNotOpenException("Fail to load"); // } return new CommonProcessIndicatorItemWrapper<Customer, Customer>(key, result); }
From source file:org.hoteia.qalingo.app.cmssync.job.cmscontent.CmsContentItemReader.java
public CommonProcessIndicatorItemWrapper<CmsContent, CmsContent> read() throws DataAccessException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); }/*from ww w . jav a2 s. c o m*/ CmsContent key = null; synchronized (lock) { if (keysIterator.hasNext()) { key = keysIterator.next(); } } // logger.debug("Retrieved key from list: " + key); if (key == null) { return null; } CmsContent result = null; // try { // result = xxxxDAO.getxxxById(xxxxId); // // } catch (Exception e) { // logger.error("", e); // throw new ReaderNotOpenException("Fail to load"); // } return new CommonProcessIndicatorItemWrapper<CmsContent, CmsContent>(key, result); }
From source file:org.hoteia.qalingo.app.erpsync.job.stock.StockItemReader.java
public CommonProcessIndicatorItemWrapper<ProductSkuStock, ProductSkuStock> read() throws DataAccessException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); }/* ww w.j a va2 s . c o m*/ ProductSkuStock key = null; synchronized (lock) { if (keysIterator.hasNext()) { key = keysIterator.next(); } } // logger.debug("Retrieved key from list: " + key); if (key == null) { return null; } ProductSkuStock result = null; // try { // result = xxxxDAO.getxxxxById(xxxxId); // // } catch (Exception e) { // logger.error("", e); // throw new ReaderNotOpenException("Fail to load"); // } return new CommonProcessIndicatorItemWrapper<ProductSkuStock, ProductSkuStock>(key, result); }
From source file:org.hoteia.qalingo.app.business.job.email.AbstractEmailItemReader.java
public CommonProcessIndicatorItemWrapper<Long, Email> read() throws DataAccessException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); }//from www .jav a2s . co m Long key = null; synchronized (lock) { if (keysIterator.hasNext()) { key = keysIterator.next(); } } logger.debug("Retrieved key from list: " + key); if (key == null) { return null; } Email result = null; try { result = emailService.getEmailById(key); } catch (Exception e) { logger.error("Fail to load", e); throw new ReaderNotOpenException("Fail to load"); } return new CommonProcessIndicatorItemWrapper<Long, Email>(key, result); }
From source file:lcn.module.batch.web.guide.support.StagingItemReader.java
/** * BATCH_STAGING? value? ?//www . j a v a 2 s.c om * @return ProcessIndicatorItemWrapper : */ public ProcessIndicatorItemWrapper<T> read() throws DataAccessException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); } Long id = null; synchronized (lock) { if (keys.hasNext()) { id = keys.next(); } } logger.debug("Retrieved key from list: " + id); if (id == null) { return null; } @SuppressWarnings("unchecked") T result = (T) jdbcTemplate.queryForObject("SELECT VALUE FROM BATCH_STAGING WHERE ID=?", new ParameterizedRowMapper<Object>() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { byte[] blob = rs.getBytes(1); return SerializationUtils.deserialize(blob); } }, id); return new ProcessIndicatorItemWrapper<T>(id, result); }
From source file:fr.acxio.tools.agia.alfresco.HibernateNodeReader.java
public ProcessIndicatorItemWrapper<Node> read() throws NodeDaoException { if (!initialized) { throw new ReaderNotOpenException("Reader must be open before it can be used."); }//from ww w.j a v a 2 s . c o m Long id = null; synchronized (lock) { if (keys.hasNext()) { id = keys.next(); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Retrieved key from list: " + id); } if (id == null) { return null; } return new ProcessIndicatorItemWrapper<Node>(id, nodeDao.findById(id)); }
From source file:org.jasig.ssp.util.importer.job.csv.FlatFileItemReaderNewLine.java
/** * @return next line (skip comments).getCurrentResource */// w w w .j a va2 s . c o m private String readLine() { if (reader == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } String line = null; try { line = this.reader.readLine(); if (line == null) { return null; } lineCount++; while (isComment(line)) { line = reader.readLine(); if (line == null) { return null; } lineCount++; } while (isIncomplete(line)) { line = line + "\n" + reader.readLine(); } line = applyRecordSeparatorPolicy(line); } catch (IOException e) { // Prevent IOException from recurring indefinitely // if client keeps catching and re-calling noInput = true; throw new NonTransientFlatFileException("Unable to read from resource: [" + resource + "]", e, line, lineCount); } return line; }
From source file:org.springframework.batch.item.database.AbstractCursorItemReader.java
/** * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */// w w w . j av a2 s .c o m @Override protected T doRead() throws Exception { if (rs == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } try { if (!rs.next()) { return null; } int currentRow = getCurrentItemCount(); T item = readCursor(rs, currentRow); verifyCursorPosition(currentRow); return item; } catch (SQLException se) { throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se); } }
From source file:org.springframework.batch.item.file.FlatFileItemReader.java
/** * @return next line (skip comments).getCurrentResource *//* www . j a v a 2 s. c o m*/ private String readLine() { if (reader == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } String line = null; try { line = this.reader.readLine(); if (line == null) { return null; } lineCount++; while (isComment(line)) { line = reader.readLine(); if (line == null) { return null; } lineCount++; } line = applyRecordSeparatorPolicy(line); } catch (IOException e) { // Prevent IOException from recurring indefinitely // if client keeps catching and re-calling noInput = true; throw new NonTransientFlatFileException("Unable to read from resource: [" + resource + "]", e, line, lineCount); } return line; }
From source file:org.springframework.batch.item.file.RegexFileItemReader.java
/** * @return next line (skip comments).getCurrentResource *//*from www .j a va 2 s. c om*/ private String readLine() { if (reader == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } String line = null; try { while (1 == 1) { boolean readed = readBuffer(); if (!readed) { return null; } String bufferString = String.valueOf(buffer); Matcher matcher = pattern.matcher(bufferString); boolean found = matcher.find(offsetLastEnd); if (found) { offsetLastStart = matcher.start(); offsetLastEnd = matcher.end(); line = bufferString.substring(offsetLastStart, offsetLastEnd); lineCount++; break; } else { readBufferNeeded = true; if (offsetLastEnd != 0) { int restLen = currentBufferSize - offsetLastEnd; // move to beggining of buffer chunk after last item found copy(buffer, offsetLastEnd, currentBufferSize - offsetLastEnd, 0); Arrays.fill(buffer, restLen, buffer.length, (char) 0); // new buffer's length will contain this chunk currentBufferSize = bufferSize + restLen; offsetBuffer = restLen; offsetLastEnd = 0; } else { // if can't find any item in current buffer then read next block // and add to first one (remove previous block if needed) offsetBuffer = bufferSize; if (currentBufferSize == bufferSize) { // first block stays, read next one after first // blocks: 1 -> 12 currentBufferSize = 2 * bufferSize; } else { // copy second block to beginning, make room to next one, forget first // blocks: 12 -> 23 copy(buffer, bufferSize, bufferSize, 0); offsetBuffer = bufferSize; currentBufferSize = 2 * bufferSize; } } } } if (line == null) { return null; } } catch (IOException e) { // Prevent IOException from recurring indefinitely // if client keeps catching and re-calling noInput = true; throw new NonTransientFlatFileException("Unable to read from resource: [" + resource + "]", e, line, lineCount); } return line; }