Fix up code to work with java5. See #286
This commit is contained in:
parent
ced80f3ae2
commit
5219a59597
|
@ -93,7 +93,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
return tmpFile;
|
return tmpFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(ChannelBuffer buffer) throws IOException {
|
public void setContent(ChannelBuffer buffer) throws IOException {
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
throw new NullPointerException("buffer");
|
throw new NullPointerException("buffer");
|
||||||
|
@ -123,7 +122,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContent(ChannelBuffer buffer, boolean last)
|
public void addContent(ChannelBuffer buffer, boolean last)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
|
@ -166,7 +164,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(File file) throws IOException {
|
public void setContent(File file) throws IOException {
|
||||||
if (this.file != null) {
|
if (this.file != null) {
|
||||||
delete();
|
delete();
|
||||||
|
@ -177,7 +174,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(InputStream inputStream) throws IOException {
|
public void setContent(InputStream inputStream) throws IOException {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
throw new NullPointerException("inputStream");
|
throw new NullPointerException("inputStream");
|
||||||
|
@ -208,7 +204,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
if (! isRenamed) {
|
if (! isRenamed) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
@ -217,7 +212,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] get() throws IOException {
|
public byte[] get() throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
|
@ -225,7 +219,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
return readFrom(file);
|
return readFrom(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChannelBuffer() throws IOException {
|
public ChannelBuffer getChannelBuffer() throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return ChannelBuffers.EMPTY_BUFFER;
|
return ChannelBuffers.EMPTY_BUFFER;
|
||||||
|
@ -234,7 +227,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
return ChannelBuffers.wrappedBuffer(array);
|
return ChannelBuffers.wrappedBuffer(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChunk(int length) throws IOException {
|
public ChannelBuffer getChunk(int length) throws IOException {
|
||||||
if (file == null || length == 0) {
|
if (file == null || length == 0) {
|
||||||
return ChannelBuffers.EMPTY_BUFFER;
|
return ChannelBuffers.EMPTY_BUFFER;
|
||||||
|
@ -265,30 +257,26 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString() throws IOException {
|
public String getString() throws IOException {
|
||||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString(Charset encoding) throws IOException {
|
public String getString(Charset encoding) throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
byte[] array = readFrom(file);
|
byte[] array = readFrom(file);
|
||||||
return new String(array, HttpCodecUtil.DEFAULT_CHARSET);
|
return new String(array, HttpCodecUtil.DEFAULT_CHARSET.name());
|
||||||
}
|
}
|
||||||
byte[] array = readFrom(file);
|
byte[] array = readFrom(file);
|
||||||
return new String(array, encoding);
|
return new String(array, encoding.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInMemory() {
|
public boolean isInMemory() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renameTo(File dest) throws IOException {
|
public boolean renameTo(File dest) throws IOException {
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
throw new NullPointerException("dest");
|
throw new NullPointerException("dest");
|
||||||
|
@ -339,7 +327,6 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getFile() throws IOException {
|
public File getFile() throws IOException {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,22 +67,18 @@ public abstract class AbstractHttpData implements HttpData {
|
||||||
definedSize = size;
|
definedSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
return completed;
|
return completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Charset getCharset() {
|
public Charset getCharset() {
|
||||||
return charset;
|
return charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCharset(Charset charset) {
|
public void setCharset(Charset charset) {
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
throw new NullPointerException("charset");
|
throw new NullPointerException("charset");
|
||||||
|
@ -90,7 +86,6 @@ public abstract class AbstractHttpData implements HttpData {
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long length() {
|
public long length() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
super(name, charset, size);
|
super(name, charset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(ChannelBuffer buffer) throws IOException {
|
public void setContent(ChannelBuffer buffer) throws IOException {
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
throw new NullPointerException("buffer");
|
throw new NullPointerException("buffer");
|
||||||
|
@ -55,7 +54,6 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(InputStream inputStream) throws IOException {
|
public void setContent(InputStream inputStream) throws IOException {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
throw new NullPointerException("inputStream");
|
throw new NullPointerException("inputStream");
|
||||||
|
@ -77,7 +75,6 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContent(ChannelBuffer buffer, boolean last)
|
public void addContent(ChannelBuffer buffer, boolean last)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (buffer != null) {
|
if (buffer != null) {
|
||||||
|
@ -103,7 +100,6 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(File file) throws IOException {
|
public void setContent(File file) throws IOException {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
throw new NullPointerException("file");
|
throw new NullPointerException("file");
|
||||||
|
@ -128,12 +124,10 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] get() {
|
public byte[] get() {
|
||||||
if (channelBuffer == null) {
|
if (channelBuffer == null) {
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
|
@ -143,12 +137,10 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString() {
|
public String getString() {
|
||||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString(Charset encoding) {
|
public String getString(Charset encoding) {
|
||||||
if (channelBuffer == null) {
|
if (channelBuffer == null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -164,12 +156,10 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
* to a Disk (or another implementation) FileUpload
|
* to a Disk (or another implementation) FileUpload
|
||||||
* @return the attached ChannelBuffer containing the actual bytes
|
* @return the attached ChannelBuffer containing the actual bytes
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChannelBuffer() {
|
public ChannelBuffer getChannelBuffer() {
|
||||||
return channelBuffer;
|
return channelBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChunk(int length) throws IOException {
|
public ChannelBuffer getChunk(int length) throws IOException {
|
||||||
if (channelBuffer == null || length == 0 || channelBuffer.readableBytes() == 0) {
|
if (channelBuffer == null || length == 0 || channelBuffer.readableBytes() == 0) {
|
||||||
chunkPosition = 0;
|
chunkPosition = 0;
|
||||||
|
@ -189,12 +179,10 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInMemory() {
|
public boolean isInMemory() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renameTo(File dest) throws IOException {
|
public boolean renameTo(File dest) throws IOException {
|
||||||
if (dest == null) {
|
if (dest == null) {
|
||||||
throw new NullPointerException("dest");
|
throw new NullPointerException("dest");
|
||||||
|
@ -219,7 +207,6 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||||
return written == length;
|
return written == length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getFile() throws IOException {
|
public File getFile() throws IOException {
|
||||||
throw new IOException("Not represented by a file");
|
throw new IOException("Not represented by a file");
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Attribute createAttribute(HttpRequest request, String name) {
|
public Attribute createAttribute(HttpRequest request, String name) {
|
||||||
if (useDisk) {
|
if (useDisk) {
|
||||||
Attribute attribute = new DiskAttribute(name);
|
Attribute attribute = new DiskAttribute(name);
|
||||||
|
@ -106,7 +105,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
return new MemoryAttribute(name);
|
return new MemoryAttribute(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Attribute createAttribute(HttpRequest request, String name, String value) {
|
public Attribute createAttribute(HttpRequest request, String name, String value) {
|
||||||
if (useDisk) {
|
if (useDisk) {
|
||||||
Attribute attribute;
|
Attribute attribute;
|
||||||
|
@ -132,7 +130,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileUpload createFileUpload(HttpRequest request, String name, String filename,
|
public FileUpload createFileUpload(HttpRequest request, String name, String filename,
|
||||||
String contentType, String contentTransferEncoding, Charset charset,
|
String contentType, String contentTransferEncoding, Charset charset,
|
||||||
long size) {
|
long size) {
|
||||||
|
@ -153,7 +150,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
contentTransferEncoding, charset, size);
|
contentTransferEncoding, charset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data) {
|
public void removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data) {
|
||||||
if (data instanceof HttpData) {
|
if (data instanceof HttpData) {
|
||||||
List<HttpData> fileToDelete = getList(request);
|
List<HttpData> fileToDelete = getList(request);
|
||||||
|
@ -161,7 +157,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanRequestHttpDatas(HttpRequest request) {
|
public void cleanRequestHttpDatas(HttpRequest request) {
|
||||||
List<HttpData> fileToDelete = requestFileDeleteMap.remove(request);
|
List<HttpData> fileToDelete = requestFileDeleteMap.remove(request);
|
||||||
if (fileToDelete != null) {
|
if (fileToDelete != null) {
|
||||||
|
@ -172,7 +167,6 @@ public class DefaultHttpDataFactory implements HttpDataFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanAllHttpDatas() {
|
public void cleanAllHttpDatas() {
|
||||||
for (HttpRequest request : requestFileDeleteMap.keySet()) {
|
for (HttpRequest request : requestFileDeleteMap.keySet()) {
|
||||||
List<HttpData> fileToDelete = requestFileDeleteMap.get(request);
|
List<HttpData> fileToDelete = requestFileDeleteMap.get(request);
|
||||||
|
|
|
@ -52,23 +52,20 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return HttpDataType.Attribute;
|
return HttpDataType.Attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() throws IOException {
|
public String getValue() throws IOException {
|
||||||
byte [] bytes = get();
|
byte [] bytes = get();
|
||||||
return new String(bytes, charset);
|
return new String(bytes, charset.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(String value) throws IOException {
|
public void setValue(String value) throws IOException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException("value");
|
throw new NullPointerException("value");
|
||||||
}
|
}
|
||||||
byte [] bytes = value.getBytes(charset);
|
byte [] bytes = value.getBytes(charset.name());
|
||||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(bytes);
|
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(bytes);
|
||||||
if (definedSize > 0) {
|
if (definedSize > 0) {
|
||||||
definedSize = buffer.readableBytes();
|
definedSize = buffer.readableBytes();
|
||||||
|
@ -98,7 +95,6 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||||
return getName().equalsIgnoreCase(attribute.getName());
|
return getName().equalsIgnoreCase(attribute.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData arg0) {
|
||||||
if (!(arg0 instanceof Attribute)) {
|
if (!(arg0 instanceof Attribute)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
|
|
|
@ -44,17 +44,14 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||||
setContentTransferEncoding(contentTransferEncoding);
|
setContentTransferEncoding(contentTransferEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return HttpDataType.FileUpload;
|
return HttpDataType.FileUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFilename(String filename) {
|
public void setFilename(String filename) {
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
throw new NullPointerException("filename");
|
throw new NullPointerException("filename");
|
||||||
|
@ -76,7 +73,6 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||||
return getName().equalsIgnoreCase(attribute.getName());
|
return getName().equalsIgnoreCase(attribute.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData arg0) {
|
||||||
if (!(arg0 instanceof FileUpload)) {
|
if (!(arg0 instanceof FileUpload)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
|
@ -95,7 +91,6 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentType(String contentType) {
|
public void setContentType(String contentType) {
|
||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
throw new NullPointerException("contentType");
|
throw new NullPointerException("contentType");
|
||||||
|
@ -103,17 +98,14 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentTransferEncoding() {
|
public String getContentTransferEncoding() {
|
||||||
return contentTransferEncoding;
|
return contentTransferEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentTransferEncoding(String contentTransferEncoding) {
|
public void setContentTransferEncoding(String contentTransferEncoding) {
|
||||||
this.contentTransferEncoding = contentTransferEncoding;
|
this.contentTransferEncoding = contentTransferEncoding;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,4 +57,4 @@ public interface FileUpload extends HttpData {
|
||||||
* @return the Content-Transfer-Encoding
|
* @return the Content-Transfer-Encoding
|
||||||
*/
|
*/
|
||||||
String getContentTransferEncoding();
|
String getContentTransferEncoding();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,156 +26,156 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||||
* Extended interface for InterfaceHttpData
|
* Extended interface for InterfaceHttpData
|
||||||
*/
|
*/
|
||||||
public interface HttpData extends InterfaceHttpData {
|
public interface HttpData extends InterfaceHttpData {
|
||||||
/**
|
/**
|
||||||
* Set the content from the ChannelBuffer (erase any previous data)
|
* Set the content from the ChannelBuffer (erase any previous data)
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param buffer
|
||||||
* must be not null
|
* must be not null
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
void setContent(ChannelBuffer buffer) throws IOException;
|
void setContent(ChannelBuffer buffer) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the content from the ChannelBuffer
|
* Add the content from the ChannelBuffer
|
||||||
*
|
*
|
||||||
* @param buffer
|
* @param buffer
|
||||||
* must be not null except if last is set to False
|
* must be not null except if last is set to False
|
||||||
* @param last
|
* @param last
|
||||||
* True of the buffer is the last one
|
* True of the buffer is the last one
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
void addContent(ChannelBuffer buffer, boolean last) throws IOException;
|
void addContent(ChannelBuffer buffer, boolean last) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the content from the file (erase any previous data)
|
* Set the content from the file (erase any previous data)
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* must be not null
|
* must be not null
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
void setContent(File file) throws IOException;
|
void setContent(File file) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the content from the inputStream (erase any previous data)
|
* Set the content from the inputStream (erase any previous data)
|
||||||
*
|
*
|
||||||
* @param inputStream
|
* @param inputStream
|
||||||
* must be not null
|
* must be not null
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
void setContent(InputStream inputStream) throws IOException;
|
void setContent(InputStream inputStream) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return True if the InterfaceHttpData is completed (all data are stored)
|
* @return True if the InterfaceHttpData is completed (all data are stored)
|
||||||
*/
|
*/
|
||||||
boolean isCompleted();
|
boolean isCompleted();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size in byte of the InterfaceHttpData
|
* Returns the size in byte of the InterfaceHttpData
|
||||||
*
|
*
|
||||||
* @return the size of the InterfaceHttpData
|
* @return the size of the InterfaceHttpData
|
||||||
*/
|
*/
|
||||||
long length();
|
long length();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the underlying storage for a file item, including deleting any
|
* Deletes the underlying storage for a file item, including deleting any
|
||||||
* associated temporary disk file.
|
* associated temporary disk file.
|
||||||
*/
|
*/
|
||||||
void delete();
|
void delete();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contents of the file item as an array of bytes.
|
* Returns the contents of the file item as an array of bytes.
|
||||||
*
|
*
|
||||||
* @return the contents of the file item as an array of bytes.
|
* @return the contents of the file item as an array of bytes.
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
byte[] get() throws IOException;
|
byte[] get() throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the content of the file item as a ChannelBuffer
|
* Returns the content of the file item as a ChannelBuffer
|
||||||
*
|
*
|
||||||
* @return the content of the file item as a ChannelBuffer
|
* @return the content of the file item as a ChannelBuffer
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ChannelBuffer getChannelBuffer() throws IOException;
|
ChannelBuffer getChannelBuffer() throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a ChannelBuffer for the content from the current position with at
|
* Returns a ChannelBuffer for the content from the current position with at
|
||||||
* most length read bytes, increasing the current position of the Bytes
|
* most length read bytes, increasing the current position of the Bytes
|
||||||
* read. Once it arrives at the end, it returns an EMPTY_BUFFER and it
|
* read. Once it arrives at the end, it returns an EMPTY_BUFFER and it
|
||||||
* resets the current position to 0.
|
* resets the current position to 0.
|
||||||
*
|
*
|
||||||
* @param length
|
* @param length
|
||||||
* @return a ChannelBuffer for the content from the current position or an
|
* @return a ChannelBuffer for the content from the current position or an
|
||||||
* EMPTY_BUFFER if there is no more data to return
|
* EMPTY_BUFFER if there is no more data to return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ChannelBuffer getChunk(int length) throws IOException;
|
ChannelBuffer getChunk(int length) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contents of the file item as a String, using the default
|
* Returns the contents of the file item as a String, using the default
|
||||||
* character encoding.
|
* character encoding.
|
||||||
*
|
*
|
||||||
* @return the contents of the file item as a String, using the default
|
* @return the contents of the file item as a String, using the default
|
||||||
* character encoding.
|
* character encoding.
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
String getString() throws IOException;
|
String getString() throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contents of the file item as a String, using the specified
|
* Returns the contents of the file item as a String, using the specified
|
||||||
* charset.
|
* charset.
|
||||||
*
|
*
|
||||||
* @param encoding
|
* @param encoding
|
||||||
* the charset to use
|
* the charset to use
|
||||||
* @return the contents of the file item as a String, using the specified
|
* @return the contents of the file item as a String, using the specified
|
||||||
* charset.
|
* charset.
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
String getString(Charset encoding) throws IOException;
|
String getString(Charset encoding) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Charset passed by the browser if defined
|
* Set the Charset passed by the browser if defined
|
||||||
*
|
*
|
||||||
* @param charset
|
* @param charset
|
||||||
* Charset to set - must be not null
|
* Charset to set - must be not null
|
||||||
*/
|
*/
|
||||||
void setCharset(Charset charset);
|
void setCharset(Charset charset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Charset passed by the browser or null if not defined.
|
* Returns the Charset passed by the browser or null if not defined.
|
||||||
*
|
*
|
||||||
* @return the Charset passed by the browser or null if not defined.
|
* @return the Charset passed by the browser or null if not defined.
|
||||||
*/
|
*/
|
||||||
Charset getCharset();
|
Charset getCharset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience method to write an uploaded item to disk. If a previous one
|
* A convenience method to write an uploaded item to disk. If a previous one
|
||||||
* exists, it will be deleted. Once this method is called, if successful,
|
* exists, it will be deleted. Once this method is called, if successful,
|
||||||
* the new file will be out of the cleaner of the factory that creates the
|
* the new file will be out of the cleaner of the factory that creates the
|
||||||
* original InterfaceHttpData object.
|
* original InterfaceHttpData object.
|
||||||
*
|
*
|
||||||
* @param dest
|
* @param dest
|
||||||
* destination file - must be not null
|
* destination file - must be not null
|
||||||
* @return True if the write is successful
|
* @return True if the write is successful
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
boolean renameTo(File dest) throws IOException;
|
boolean renameTo(File dest) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a hint as to whether or not the file contents will be read from
|
* Provides a hint as to whether or not the file contents will be read from
|
||||||
* memory.
|
* memory.
|
||||||
*
|
*
|
||||||
* @return True if the file contents is in memory.
|
* @return True if the file contents is in memory.
|
||||||
*/
|
*/
|
||||||
boolean isInMemory();
|
boolean isInMemory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the associated File if this data is represented in a file
|
* @return the associated File if this data is represented in a file
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
* if this data is not represented by a file
|
* if this data is not represented by a file
|
||||||
*/
|
*/
|
||||||
File getFile() throws IOException;
|
File getFile() throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ package org.jboss.netty.handler.codec.http;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to enable creation of InterfaceHttpData objects
|
* Interface to enable creation of InterfaceHttpData objects
|
||||||
*/
|
*/
|
||||||
|
@ -77,4 +75,4 @@ public interface HttpDataFactory {
|
||||||
* Remove all InterfaceHttpData from virtual File storage from clean list for all requests
|
* Remove all InterfaceHttpData from virtual File storage from clean list for all requests
|
||||||
*/
|
*/
|
||||||
void cleanAllHttpDatas();
|
void cleanAllHttpDatas();
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,7 +855,6 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||||
return new DefaultHttpChunk(buffer);
|
return new DefaultHttpChunk(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
//NO since the user can want to reuse (broadcast for instance) cleanFiles();
|
//NO since the user can want to reuse (broadcast for instance) cleanFiles();
|
||||||
}
|
}
|
||||||
|
@ -867,7 +866,6 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||||
* @return the next available HttpChunk
|
* @return the next available HttpChunk
|
||||||
* @throws ErrorDataEncoderException if the encoding is in error
|
* @throws ErrorDataEncoderException if the encoding is in error
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public HttpChunk nextChunk() throws ErrorDataEncoderException {
|
public HttpChunk nextChunk() throws ErrorDataEncoderException {
|
||||||
if (isLastChunk) {
|
if (isLastChunk) {
|
||||||
isLastChunkSent = true;
|
isLastChunkSent = true;
|
||||||
|
@ -937,7 +935,6 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||||
return new DefaultHttpChunk(buffer);
|
return new DefaultHttpChunk(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEndOfInput() throws Exception {
|
public boolean isEndOfInput() throws Exception {
|
||||||
return isLastChunkSent;
|
return isLastChunkSent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
||||||
public class InternalAttribute implements InterfaceHttpData {
|
public class InternalAttribute implements InterfaceHttpData {
|
||||||
protected List<String> value = new ArrayList<String>();
|
protected List<String> value = new ArrayList<String>();
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return HttpDataType.InternalAttribute;
|
return HttpDataType.InternalAttribute;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +68,6 @@ public class InternalAttribute implements InterfaceHttpData {
|
||||||
return getName().equalsIgnoreCase(attribute.getName());
|
return getName().equalsIgnoreCase(attribute.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData arg0) {
|
||||||
if (!(arg0 instanceof InternalAttribute)) {
|
if (!(arg0 instanceof InternalAttribute)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
|
@ -98,7 +96,6 @@ public class InternalAttribute implements InterfaceHttpData {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "InternalAttribute";
|
return "InternalAttribute";
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,22 +41,19 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return HttpDataType.Attribute;
|
return HttpDataType.Attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return getChannelBuffer().toString(charset);
|
return getChannelBuffer().toString(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(String value) throws IOException {
|
public void setValue(String value) throws IOException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException("value");
|
throw new NullPointerException("value");
|
||||||
}
|
}
|
||||||
byte [] bytes = value.getBytes(charset);
|
byte [] bytes = value.getBytes(charset.name());
|
||||||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(bytes);
|
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(bytes);
|
||||||
if (definedSize > 0) {
|
if (definedSize > 0) {
|
||||||
definedSize = buffer.readableBytes();
|
definedSize = buffer.readableBytes();
|
||||||
|
@ -87,7 +84,6 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
|
||||||
return getName().equalsIgnoreCase(attribute.getName());
|
return getName().equalsIgnoreCase(attribute.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData arg0) {
|
||||||
if (!(arg0 instanceof Attribute)) {
|
if (!(arg0 instanceof Attribute)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
|
|
|
@ -38,17 +38,14 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||||
setContentTransferEncoding(contentTransferEncoding);
|
setContentTransferEncoding(contentTransferEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return HttpDataType.FileUpload;
|
return HttpDataType.FileUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFilename(String filename) {
|
public void setFilename(String filename) {
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
throw new NullPointerException("filename");
|
throw new NullPointerException("filename");
|
||||||
|
@ -70,7 +67,6 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||||
return getName().equalsIgnoreCase(attribute.getName());
|
return getName().equalsIgnoreCase(attribute.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData arg0) {
|
||||||
if (!(arg0 instanceof FileUpload)) {
|
if (!(arg0 instanceof FileUpload)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
|
@ -89,7 +85,6 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentType(String contentType) {
|
public void setContentType(String contentType) {
|
||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
throw new NullPointerException("contentType");
|
throw new NullPointerException("contentType");
|
||||||
|
@ -97,17 +92,14 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentTransferEncoding() {
|
public String getContentTransferEncoding() {
|
||||||
return contentTransferEncoding;
|
return contentTransferEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentTransferEncoding(String contentTransferEncoding) {
|
public void setContentTransferEncoding(String contentTransferEncoding) {
|
||||||
this.contentTransferEncoding = contentTransferEncoding;
|
this.contentTransferEncoding = contentTransferEncoding;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ public class MixedAttribute implements Attribute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContent(ChannelBuffer buffer, boolean last) throws IOException {
|
public void addContent(ChannelBuffer buffer, boolean last) throws IOException {
|
||||||
if (attribute instanceof MemoryAttribute) {
|
if (attribute instanceof MemoryAttribute) {
|
||||||
if (attribute.length() + buffer.readableBytes() > limitSize) {
|
if (attribute.length() + buffer.readableBytes() > limitSize) {
|
||||||
|
@ -73,62 +72,50 @@ public class MixedAttribute implements Attribute {
|
||||||
attribute.addContent(buffer, last);
|
attribute.addContent(buffer, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
attribute.delete();
|
attribute.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] get() throws IOException {
|
public byte[] get() throws IOException {
|
||||||
return attribute.get();
|
return attribute.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChannelBuffer() throws IOException {
|
public ChannelBuffer getChannelBuffer() throws IOException {
|
||||||
return attribute.getChannelBuffer();
|
return attribute.getChannelBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Charset getCharset() {
|
public Charset getCharset() {
|
||||||
return attribute.getCharset();
|
return attribute.getCharset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString() throws IOException {
|
public String getString() throws IOException {
|
||||||
return attribute.getString();
|
return attribute.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString(Charset encoding) throws IOException {
|
public String getString(Charset encoding) throws IOException {
|
||||||
return attribute.getString(encoding);
|
return attribute.getString(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
return attribute.isCompleted();
|
return attribute.isCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInMemory() {
|
public boolean isInMemory() {
|
||||||
return attribute.isInMemory();
|
return attribute.isInMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long length() {
|
public long length() {
|
||||||
return attribute.length();
|
return attribute.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renameTo(File dest) throws IOException {
|
public boolean renameTo(File dest) throws IOException {
|
||||||
return attribute.renameTo(dest);
|
return attribute.renameTo(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCharset(Charset charset) {
|
public void setCharset(Charset charset) {
|
||||||
attribute.setCharset(charset);
|
attribute.setCharset(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(ChannelBuffer buffer) throws IOException {
|
public void setContent(ChannelBuffer buffer) throws IOException {
|
||||||
if (buffer.readableBytes() > limitSize) {
|
if (buffer.readableBytes() > limitSize) {
|
||||||
if (attribute instanceof MemoryAttribute) {
|
if (attribute instanceof MemoryAttribute) {
|
||||||
|
@ -139,7 +126,6 @@ public class MixedAttribute implements Attribute {
|
||||||
attribute.setContent(buffer);
|
attribute.setContent(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(File file) throws IOException {
|
public void setContent(File file) throws IOException {
|
||||||
if (file.length() > limitSize) {
|
if (file.length() > limitSize) {
|
||||||
if (attribute instanceof MemoryAttribute) {
|
if (attribute instanceof MemoryAttribute) {
|
||||||
|
@ -150,7 +136,6 @@ public class MixedAttribute implements Attribute {
|
||||||
attribute.setContent(file);
|
attribute.setContent(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(InputStream inputStream) throws IOException {
|
public void setContent(InputStream inputStream) throws IOException {
|
||||||
if (attribute instanceof MemoryAttribute) {
|
if (attribute instanceof MemoryAttribute) {
|
||||||
// change to Disk even if we don't know the size
|
// change to Disk even if we don't know the size
|
||||||
|
@ -159,17 +144,14 @@ public class MixedAttribute implements Attribute {
|
||||||
attribute.setContent(inputStream);
|
attribute.setContent(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return attribute.getHttpDataType();
|
return attribute.getHttpDataType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return attribute.getName();
|
return attribute.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData o) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
return attribute.compareTo(o);
|
return attribute.compareTo(o);
|
||||||
}
|
}
|
||||||
|
@ -179,22 +161,18 @@ public class MixedAttribute implements Attribute {
|
||||||
return "Mixed: " + attribute.toString();
|
return "Mixed: " + attribute.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() throws IOException {
|
public String getValue() throws IOException {
|
||||||
return attribute.getValue();
|
return attribute.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(String value) throws IOException {
|
public void setValue(String value) throws IOException {
|
||||||
attribute.setValue(value);
|
attribute.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChunk(int length) throws IOException {
|
public ChannelBuffer getChunk(int length) throws IOException {
|
||||||
return attribute.getChunk(length);
|
return attribute.getChunk(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getFile() throws IOException {
|
public File getFile() throws IOException {
|
||||||
return attribute.getFile();
|
return attribute.getFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class MixedFileUpload implements FileUpload {
|
||||||
definedSize = size;
|
definedSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContent(ChannelBuffer buffer, boolean last)
|
public void addContent(ChannelBuffer buffer, boolean last)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (fileUpload instanceof MemoryFileUpload) {
|
if (fileUpload instanceof MemoryFileUpload) {
|
||||||
|
@ -66,77 +65,62 @@ public class MixedFileUpload implements FileUpload {
|
||||||
fileUpload.addContent(buffer, last);
|
fileUpload.addContent(buffer, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
fileUpload.delete();
|
fileUpload.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] get() throws IOException {
|
public byte[] get() throws IOException {
|
||||||
return fileUpload.get();
|
return fileUpload.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChannelBuffer() throws IOException {
|
public ChannelBuffer getChannelBuffer() throws IOException {
|
||||||
return fileUpload.getChannelBuffer();
|
return fileUpload.getChannelBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Charset getCharset() {
|
public Charset getCharset() {
|
||||||
return fileUpload.getCharset();
|
return fileUpload.getCharset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return fileUpload.getContentType();
|
return fileUpload.getContentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getContentTransferEncoding() {
|
public String getContentTransferEncoding() {
|
||||||
return fileUpload.getContentTransferEncoding();
|
return fileUpload.getContentTransferEncoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFilename() {
|
public String getFilename() {
|
||||||
return fileUpload.getFilename();
|
return fileUpload.getFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString() throws IOException {
|
public String getString() throws IOException {
|
||||||
return fileUpload.getString();
|
return fileUpload.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString(Charset encoding) throws IOException {
|
public String getString(Charset encoding) throws IOException {
|
||||||
return fileUpload.getString(encoding);
|
return fileUpload.getString(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
return fileUpload.isCompleted();
|
return fileUpload.isCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInMemory() {
|
public boolean isInMemory() {
|
||||||
return fileUpload.isInMemory();
|
return fileUpload.isInMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long length() {
|
public long length() {
|
||||||
return fileUpload.length();
|
return fileUpload.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renameTo(File dest) throws IOException {
|
public boolean renameTo(File dest) throws IOException {
|
||||||
return fileUpload.renameTo(dest);
|
return fileUpload.renameTo(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCharset(Charset charset) {
|
public void setCharset(Charset charset) {
|
||||||
fileUpload.setCharset(charset);
|
fileUpload.setCharset(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(ChannelBuffer buffer) throws IOException {
|
public void setContent(ChannelBuffer buffer) throws IOException {
|
||||||
if (buffer.readableBytes() > limitSize) {
|
if (buffer.readableBytes() > limitSize) {
|
||||||
if (fileUpload instanceof MemoryFileUpload) {
|
if (fileUpload instanceof MemoryFileUpload) {
|
||||||
|
@ -151,7 +135,6 @@ public class MixedFileUpload implements FileUpload {
|
||||||
fileUpload.setContent(buffer);
|
fileUpload.setContent(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(File file) throws IOException {
|
public void setContent(File file) throws IOException {
|
||||||
if (file.length() > limitSize) {
|
if (file.length() > limitSize) {
|
||||||
if (fileUpload instanceof MemoryFileUpload) {
|
if (fileUpload instanceof MemoryFileUpload) {
|
||||||
|
@ -166,7 +149,6 @@ public class MixedFileUpload implements FileUpload {
|
||||||
fileUpload.setContent(file);
|
fileUpload.setContent(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(InputStream inputStream) throws IOException {
|
public void setContent(InputStream inputStream) throws IOException {
|
||||||
if (fileUpload instanceof MemoryFileUpload) {
|
if (fileUpload instanceof MemoryFileUpload) {
|
||||||
// change to Disk
|
// change to Disk
|
||||||
|
@ -179,32 +161,26 @@ public class MixedFileUpload implements FileUpload {
|
||||||
fileUpload.setContent(inputStream);
|
fileUpload.setContent(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentType(String contentType) {
|
public void setContentType(String contentType) {
|
||||||
fileUpload.setContentType(contentType);
|
fileUpload.setContentType(contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContentTransferEncoding(String contentTransferEncoding) {
|
public void setContentTransferEncoding(String contentTransferEncoding) {
|
||||||
fileUpload.setContentTransferEncoding(contentTransferEncoding);
|
fileUpload.setContentTransferEncoding(contentTransferEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFilename(String filename) {
|
public void setFilename(String filename) {
|
||||||
fileUpload.setFilename(filename);
|
fileUpload.setFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpDataType getHttpDataType() {
|
public HttpDataType getHttpDataType() {
|
||||||
return fileUpload.getHttpDataType();
|
return fileUpload.getHttpDataType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fileUpload.getName();
|
return fileUpload.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(InterfaceHttpData o) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
return fileUpload.compareTo(o);
|
return fileUpload.compareTo(o);
|
||||||
}
|
}
|
||||||
|
@ -214,12 +190,10 @@ public class MixedFileUpload implements FileUpload {
|
||||||
return "Mixed: " + fileUpload.toString();
|
return "Mixed: " + fileUpload.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelBuffer getChunk(int length) throws IOException {
|
public ChannelBuffer getChunk(int length) throws IOException {
|
||||||
return fileUpload.getChunk(length);
|
return fileUpload.getChunk(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public File getFile() throws IOException {
|
public File getFile() throws IOException {
|
||||||
return fileUpload.getFile();
|
return fileUpload.getFile();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user