static void assertHeadersAreEqual(final FileItemHeaders fileItemHeaders, final Map<String, List<String>> headersFromPart){ int i = 0; final Iterator<String> headerNamesIterator = fileItemHeaders.getHeaderNames(); while (headerNamesIterator.hasNext()){ i++; String headerName = headerNamesIterator.next(); List<String> headerValues = Lists.newArrayList(fileItemHeaders.getHeaders(headerName)); List<String> headerValues1 = headersFromPart.get(headerName); if (log.isDebugEnabled()){ log.debug("Commons io header values for '" + headerName + "': " + (headerValues != null ? Joiner.on(",").join(headerValues) : "null")); log.debug("Nio multipart header values for '" + headerName + "': " + (headerValues1 != null ? Joiner.on(",").join(headerValues1) : "null")); } Assert.assertEquals(headerValues, headerValues1); } Assert.assertEquals(i, headersFromPart.size()); }
void dumpFileIterator(final FileItemIterator fileItemIterator){ int partIndex = 0; try { log.info("-- COMMONS FILE UPLOAD --"); while (fileItemIterator.hasNext()) { log.info("-- Part " + partIndex++); FileItemStream fileItemStream = fileItemIterator.next(); FileItemHeaders fileItemHeaders = fileItemStream.getHeaders(); Iterator<String> headerNames = fileItemHeaders.getHeaderNames(); while(headerNames.hasNext()){ String headerName = headerNames.next(); log.info("Header: " + headerName+ ": " + Joiner.on(',').join(fileItemHeaders.getHeaders(headerName))); } log.info("Body:\n" + IOUtils.toString(fileItemStream.openStream())); } log.info("-- ------------------- --"); }catch (Exception e){ log.error("Error dumping the FileItemIterator", e); } }
@Override public FileItemHeaders getHeaders() { throw new UnsupportedOperationException(); }
@Override public void setHeaders(FileItemHeaders headers) { throw new UnsupportedOperationException(); }
@Override public FileItemHeaders getHeaders() { return null; }
@Override public void setHeaders(FileItemHeaders fileItemHeaders) { }
public FileItemHeaders getHeaders() { return null; }
public void setHeaders(FileItemHeaders headers) { }
@Override public void setHeaders(FileItemHeaders headers) { throw new RuntimeException("Invalid operation on FormFileItem"); }
@Override public void setHeaders(FileItemHeaders headers) { throw new RuntimeException("Invalid operation on BodyFileItem"); }
@Override protected String getFileName(FileItemHeaders headers) { return getFileName(headers.getHeader(CONTENT_DISPOSITION)); }
/** * {@inheritDoc} */ @Override public FileItemHeaders getHeaders( ) { return _item.getHeaders( ); }
/** * {@inheritDoc} */ @Override public void setHeaders( FileItemHeaders headers ) { _item.setHeaders( headers ); }
@Override public FileItemHeaders getHeaders() { System.out.println("getHeaders"); return null; }
@Override public void setHeaders(FileItemHeaders arg0) { System.out.println("setHeaders"); }
@Override public void setHeaders(FileItemHeaders arg0) { }
@Override public FileItemHeaders getHeaders() { return headers; }
@Override public void setHeaders(FileItemHeaders pHeaders) { headers = pHeaders; }
/** * Returns the file item headers. * @return The file items headers. */ public FileItemHeaders getHeaders() { return headers; }
/** * Sets the file item headers. * @param pHeaders The file items headers. */ public void setHeaders(FileItemHeaders pHeaders) { headers = pHeaders; }
/** * Returns the file item headers. * * @return The file items headers. */ @Override public FileItemHeaders getHeaders() { return headers; }
/** * Sets the file item headers. * * @param pHeaders The file items headers. */ @Override public void setHeaders(FileItemHeaders pHeaders) { headers = pHeaders; }