X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/b0ab3ce0872d2702e82b5979dddaa5a897be340b..2be23eaec586972a5ff86c4f9c34d95188231821:/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java?ds=inline
diff --git a/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java b/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java
deleted file mode 100644
index b7ab2613..00000000
--- a/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package eu.alefzero.webdav;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.httpclient.methods.RequestEntity;
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
-
-import android.util.Log;
-
-
-/**
- * A RequestEntity that represents a PIECE of a file.
- *
- * @author David A. Velasco
- */
-public class ChunkFromFileChannelRequestEntity implements RequestEntity {
-
- private static final String TAG = ChunkFromFileChannelRequestEntity.class.getSimpleName();
-
- //private final File mFile;
- private final FileChannel mChannel;
- private final String mContentType;
- private final long mSize;
- private long mOffset;
- Set mListeners = new HashSet();
- private ByteBuffer mBuffer = ByteBuffer.allocate(4096);
-
- public ChunkFromFileChannelRequestEntity(final FileChannel channel, final String contentType, long size) {
- super();
- if (channel == null) {
- throw new IllegalArgumentException("File may not be null");
- }
- if (size <= 0) {
- throw new IllegalArgumentException("Size must be greater than zero");
- }
- mChannel = channel;
- mContentType = contentType;
- mSize = size;
- mOffset = 0;
- }
-
- public void setOffset(long offset) {
- mOffset = offset;
- }
-
- public long getContentLength() {
- try {
- return Math.min(mSize, mChannel.size() - mChannel.position());
- } catch (IOException e) {
- return mSize;
- }
- }
-
- public String getContentType() {
- return mContentType;
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public void addOnDatatransferProgressListener(OnDatatransferProgressListener listener) {
- mListeners.add(listener);
- }
-
- public void addOnDatatransferProgressListeners(Collection listeners) {
- mListeners.addAll(listeners);
- }
-
- public void removeOnDatatransferProgressListener(OnDatatransferProgressListener listener) {
- mListeners.remove(listener);
- }
-
-
- public void writeRequest(final OutputStream out) throws IOException {
- int readCount = 0;
- Iterator it = null;
-
- try {
- mChannel.position(mOffset);
- while (mChannel.position() < mOffset + mSize && mChannel.position() < mChannel.size()) {
- readCount = mChannel.read(mBuffer);
- out.write(mBuffer.array(), 0, readCount);
- mBuffer.clear();
- it = mListeners.iterator();
- while (it.hasNext()) {
- it.next().onTransferProgress(readCount);
- }
- }
-
- } catch (IOException io) {
- Log.e(TAG, io.getMessage());
- throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);
-
- }
- }
-
-}
\ No newline at end of file