From: David A. Velasco Date: Mon, 2 Dec 2013 12:44:08 +0000 (+0100) Subject: Merge branch 'develop' into sni_support_based_on_network_implementation_built_in X-Git-Tag: oc-android-1.5.5~113^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/04e2434affd5a7fd187f955abc25fa3dc2de183b?hp=732cfcede8aba59f60a473019003d8ffc538ebb8 Merge branch 'develop' into sni_support_based_on_network_implementation_built_in --- diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java new file mode 100644 index 00000000..b8ab2b0c --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/DeleteFileTest.java @@ -0,0 +1,57 @@ +package com.owncloud.android.oc_framework_test_project.test; + +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +public class DeleteFileTest extends ActivityInstrumentationTestCase2 { + + /* Folder data to delete. */ + private final String mFolderPath = "/folderToDelete"; + + /* File to delete. */ + private final String mFilePath = "fileToDelete.png"; + + private TestActivity mActivity; + + public DeleteFileTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Remove Folder + */ + public void testRemoveFolder() { + + RemoteOperationResult result = mActivity.removeFile(mFolderPath); + assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND); + } + + /** + * Test Remove File + */ + public void testRemoveFile() { + + RemoteOperationResult result = mActivity.removeFile(mFilePath); + assertTrue(result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND); + } + + /** + * Restore initial conditions + */ + public void testRestoreInitialConditions() { + RemoteOperationResult result = mActivity.createFolder(mFolderPath, true); + assertTrue(result.isSuccess()); + + } +} diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/ReadFolderTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/ReadFolderTest.java new file mode 100644 index 00000000..c3399158 --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/ReadFolderTest.java @@ -0,0 +1,46 @@ +package com.owncloud.android.oc_framework_test_project.test; + + +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +/** + * Class to test Read Folder Operation + * @author masensio + * + */ + +public class ReadFolderTest extends ActivityInstrumentationTestCase2 { + + + /* Folder data to read. This folder must exist on the account */ + private final String mRemoteFolderPath = "/folderToRead"; + + + private TestActivity mActivity; + + public ReadFolderTest() { + super(TestActivity.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Read Folder + */ + public void testReadFolder() { + + RemoteOperationResult result = mActivity.readFile(mRemoteFolderPath); + assertTrue(result.getData().size() > 1); + assertTrue(result.getData().size() == 4); + assertTrue(result.isSuccess()); + } + +} diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java index fe30550b..e21c6ff8 100644 --- a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java @@ -6,6 +6,12 @@ import com.owncloud.android.oc_framework_test_project.TestActivity; import android.test.ActivityInstrumentationTestCase2; +/** + * Class to test Rename File Operation + * @author masensio + * + */ + public class RenameFileTest extends ActivityInstrumentationTestCase2 { /* Folder data to rename. This folder must exist on the account */ diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index 7687bb2f..db38ea5c 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -4,6 +4,8 @@ import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation; +import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFolderOperation; +import com.owncloud.android.oc_framework.operations.remote.RemoveRemoteFileOperation; import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; import android.net.Uri; @@ -44,8 +46,8 @@ public class TestActivity extends Activity { /** * Access to the library method to Create a Folder - * @param remotePath - * @param createFullPath + * @param remotePath Full path to the new directory to create in the remote server. + * @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet. * * @return */ @@ -75,4 +77,32 @@ public class TestActivity extends Activity { return result; } + /** + * Access to the library method to Remove a File or Folder + * + * @param remotePath Remote path of the file or folder in the server. + * @return + */ + public RemoteOperationResult removeFile(String remotePath) { + + RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); + RemoteOperationResult result = removeOperation.execute(mClient); + + return result; + } + + /** + * Access to the library method to Read a Folder (PROPFIND DEPTH 1) + * @param remotePath + * + * @return + */ + public RemoteOperationResult readFile(String remotePath) { + + ReadRemoteFolderOperation readOperation= new ReadRemoteFolderOperation(remotePath); + RemoteOperationResult result = readOperation.execute(mClient); + + return result; + } + } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java b/oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java index 37698d68..7d9df09b 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java @@ -1,4 +1,3 @@ -package com.owncloud.android.oc_framework.network; /* ownCloud Android client application * Copyright (C) 2012 ownCloud Inc. * @@ -17,6 +16,7 @@ package com.owncloud.android.oc_framework.network; */ +package com.owncloud.android.oc_framework.network; import java.util.Map; diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteFile.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteFile.java new file mode 100644 index 00000000..07f45b7b --- /dev/null +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteFile.java @@ -0,0 +1,170 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.operations; + +import java.io.Serializable; + +import android.os.Parcel; +import android.os.Parcelable; + +import com.owncloud.android.oc_framework.utils.FileUtils; + +/** + * Contains the data of a Remote File from a WebDavEntry + * + * @author masensio + */ + +public class RemoteFile implements Parcelable, Serializable { + + /** Generated - should be refreshed every time the class changes!! */ + private static final long serialVersionUID = 7256606476031992757L; + + private String mRemotePath; + private String mMimeType; + private long mLength; + private long mCreationTimestamp; + private long mModifiedTimestamp; + private String mEtag; + + /** + * Getters and Setters + */ + + public String getRemotePath() { + return mRemotePath; + } + + public void setRemotePath(String remotePath) { + this.mRemotePath = remotePath; + } + + public String getMimeType() { + return mMimeType; + } + + public void setMimeType(String mimeType) { + this.mMimeType = mimeType; + } + + public long getLength() { + return mLength; + } + + public void setLength(long length) { + this.mLength = length; + } + + public long getCreationTimestamp() { + return mCreationTimestamp; + } + + public void setCreationTimestamp(long creationTimestamp) { + this.mCreationTimestamp = creationTimestamp; + } + + public long getModifiedTimestamp() { + return mModifiedTimestamp; + } + + public void setModifiedTimestamp(long modifiedTimestamp) { + this.mModifiedTimestamp = modifiedTimestamp; + } + + public String getEtag() { + return mEtag; + } + + public void setEtag(String etag) { + this.mEtag = etag; + } + + /** + * Create new {@link RemoteFile} with given path. + * + * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'. + * + * @param path The remote path of the file. + */ + public RemoteFile(String path) { + resetData(); + if (path == null || path.length() <= 0 || !path.startsWith(FileUtils.PATH_SEPARATOR)) { + throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path); + } + mRemotePath = path; + } + + /** + * Used internally. Reset all file properties + */ + private void resetData() { + mRemotePath = null; + mMimeType = null; + mLength = 0; + mCreationTimestamp = 0; + mModifiedTimestamp = 0; + mEtag = null; + } + + /** + * Parcelable Methods + */ + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @Override + public RemoteFile createFromParcel(Parcel source) { + return new RemoteFile(source); + } + + @Override + public RemoteFile[] newArray(int size) { + return new RemoteFile[size]; + } + }; + + + /** + * Reconstruct from parcel + * + * @param source The source parcel + */ + private RemoteFile(Parcel source) { + mRemotePath = source.readString(); + mMimeType = source.readString(); + mLength = source.readLong(); + mCreationTimestamp = source.readLong(); + mModifiedTimestamp = source.readLong(); + mEtag = source.readString(); + } + + @Override + public int describeContents() { + return this.hashCode(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mRemotePath); + dest.writeString(mMimeType); + dest.writeLong(mLength); + dest.writeLong(mCreationTimestamp); + dest.writeLong(mModifiedTimestamp); + dest.writeString(mEtag); + } + + +} diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java index f26988cc..666e3129 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.SocketException; import java.net.SocketTimeoutException; import java.net.UnknownHostException; +import java.util.ArrayList; import javax.net.ssl.SSLException; @@ -51,10 +52,8 @@ import android.util.Log; */ public class RemoteOperationResult implements Serializable { - /** Generated - should be refreshed every time the class changes!! */ - private static final long serialVersionUID = -4415103901492836870L; - - + /** Generated - should be refreshed every time the class changes!! */ + private static final long serialVersionUID = -2469951225222759283L; private static final String TAG = "RemoteOperationResult"; @@ -99,9 +98,12 @@ public class RemoteOperationResult implements Serializable { private ResultCode mCode = ResultCode.UNKNOWN_ERROR; private String mRedirectedLocation; + private ArrayList mFiles; + public RemoteOperationResult(ResultCode code) { mCode = code; mSuccess = (code == ResultCode.OK || code == ResultCode.OK_SSL || code == ResultCode.OK_NO_SSL); + mFiles = null; } private RemoteOperationResult(boolean success, int httpCode) { @@ -196,6 +198,15 @@ public class RemoteOperationResult implements Serializable { } + + public void setData(ArrayList files){ + mFiles = files; + } + + public ArrayList getData(){ + return mFiles; + } + public boolean isSuccess() { return mSuccess; } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java index 0974d08b..4e756da7 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java @@ -1,3 +1,20 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.operations.remote; import org.apache.commons.httpclient.HttpStatus; diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/ReadRemoteFolderOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/ReadRemoteFolderOperation.java new file mode 100644 index 00000000..b0a8bd54 --- /dev/null +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/ReadRemoteFolderOperation.java @@ -0,0 +1,162 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.operations.remote; + +import java.util.ArrayList; + +import org.apache.http.HttpStatus; +import org.apache.jackrabbit.webdav.DavConstants; +import org.apache.jackrabbit.webdav.MultiStatus; +import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; + +import android.util.Log; + +import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.network.webdav.WebdavEntry; +import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; +import com.owncloud.android.oc_framework.operations.RemoteFile; +import com.owncloud.android.oc_framework.operations.RemoteOperation; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; + +/** + * Remote operation performing the read of remote file or folder in the ownCloud server. + * + * @author David A. Velasco + * @author masensio + */ + +public class ReadRemoteFolderOperation extends RemoteOperation { + + private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName(); + + private String mRemotePath; + private ArrayList mFolderAndFiles; + + /** + * Constructor + * + * @param remotePath Remote path of the file. + */ + public ReadRemoteFolderOperation(String remotePath) { + mRemotePath = remotePath; + } + + /** + * Performs the read operation. + * + * @param client Client object to communicate with the remote ownCloud server. + */ + @Override + protected RemoteOperationResult run(WebdavClient client) { + RemoteOperationResult result = null; + PropFindMethod query = null; + + try { + // remote request + query = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath), + DavConstants.PROPFIND_ALL_PROP, + DavConstants.DEPTH_1); + int status = client.executeMethod(query); + + // check and process response + if (isMultiStatus(status)) { + // get data from remote folder + MultiStatus dataInServer = query.getResponseBodyAsMultiStatus(); + readData(dataInServer, client); + + // Result of the operation + result = new RemoteOperationResult(true, status, query.getResponseHeaders()); + // Add data to the result + if (result.isSuccess()) { + result.setData(mFolderAndFiles); + } + } else { + // synchronization failed + client.exhaustResponse(query.getResponseBodyAsStream()); + result = new RemoteOperationResult(false, status, query.getResponseHeaders()); + } + + } catch (Exception e) { + result = new RemoteOperationResult(e); + + + } finally { + if (query != null) + query.releaseConnection(); // let the connection available for other methods + if (result.isSuccess()) { + Log.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); + } else { + if (result.isException()) { + Log.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(), result.getException()); + } else { + Log.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); + } + } + + } + return result; + } + + public boolean isMultiStatus(int status) { + return (status == HttpStatus.SC_MULTI_STATUS); + } + + /** + * Read the data retrieved from the server about the contents of the target folder + * + * + * @param dataInServer Full response got from the server with the data of the target + * folder and its direct children. + * @param client Client instance to the remote server where the data were + * retrieved. + * @return + */ + private void readData(MultiStatus dataInServer, WebdavClient client) { + mFolderAndFiles = new ArrayList(); + + // parse data from remote folder + WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getBaseUri().getPath()); + mFolderAndFiles.add(fillOCFile(we)); + + // loop to update every child + RemoteFile remoteFile = null; + for (int i = 1; i < dataInServer.getResponses().length; ++i) { + /// new OCFile instance with the data from the server + we = new WebdavEntry(dataInServer.getResponses()[i], client.getBaseUri().getPath()); + remoteFile = fillOCFile(we); + mFolderAndFiles.add(remoteFile); + } + + } + + /** + * Creates and populates a new {@link RemoteFile} object with the data read from the server. + * + * @param we WebDAV entry read from the server for a WebDAV resource (remote file or folder). + * @return New OCFile instance representing the remote resource described by we. + */ + private RemoteFile fillOCFile(WebdavEntry we) { + RemoteFile file = new RemoteFile(we.decodedPath()); + file.setCreationTimestamp(we.createTimestamp()); + file.setLength(we.contentLength()); + file.setMimeType(we.contentType()); + file.setModifiedTimestamp(we.modifiedTimestamp()); + file.setEtag(we.etag()); + return file; + } +} diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RemoveRemoteFileOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RemoveRemoteFileOperation.java new file mode 100644 index 00000000..f083acb4 --- /dev/null +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RemoveRemoteFileOperation.java @@ -0,0 +1,83 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.operations.remote; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; + +import android.util.Log; + +import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; +import com.owncloud.android.oc_framework.operations.RemoteOperation; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; + +/** + * Remote operation performing the removal of a remote file or folder in the ownCloud server. + * + * @author David A. Velasco + * @author masensio + */ +public class RemoveRemoteFileOperation extends RemoteOperation { + private static final String TAG = RemoveRemoteFileOperation.class.getSimpleName(); + + private static final int REMOVE_READ_TIMEOUT = 10000; + private static final int REMOVE_CONNECTION_TIMEOUT = 5000; + + private String mRemotePath; + + /** + * Constructor + * + * @param remotePath RemotePath of the remote file or folder to remove from the server + */ + public RemoveRemoteFileOperation(String remotePath) { + mRemotePath = remotePath; + } + + /** + * Performs the rename operation. + * + * @param client Client object to communicate with the remote ownCloud server. + */ + @Override + protected RemoteOperationResult run(WebdavClient client) { + RemoteOperationResult result = null; + DeleteMethod delete = null; + + try { + delete = new DeleteMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath)); + int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT); + + delete.getResponseBodyAsString(); // exhaust the response, although not interesting + result = new RemoteOperationResult((delete.succeeded() || status == HttpStatus.SC_NOT_FOUND), status, delete.getResponseHeaders()); + Log.i(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage()); + + } catch (Exception e) { + result = new RemoteOperationResult(e); + Log.e(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage(), e); + + } finally { + if (delete != null) + delete.releaseConnection(); + } + + return result; + } + +} diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java index ad6fffc8..b1714ae7 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java @@ -1,3 +1,20 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.operations.remote; import java.io.File; diff --git a/oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java b/oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java index 8fb01dce..a7674e4f 100644 --- a/oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java +++ b/oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java @@ -1,3 +1,20 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * 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 com.owncloud.android.oc_framework.utils; import java.io.File; diff --git a/res/values-cs-rCZ/strings.xml b/res/values-cs-rCZ/strings.xml index df2dd56a..f4d717f0 100644 --- a/res/values-cs-rCZ/strings.xml +++ b/res/values-cs-rCZ/strings.xml @@ -24,8 +24,11 @@ Zobrazuje zaznamenané logy Smazat historii Nápověda + Doporučit příteli Odezva Imprint + Zkusit %1$s na vašem smartphonu! + Chtěl bych vás pozvat k používání %1$s na vašem smartphonu.\nKe stažení zde: %2$s Zkontrolovat server Adresa serveru Uživatelské jméno @@ -92,6 +95,7 @@ Některé místní soubory byly zapomenuty %1$d souborů z adresáře %2$s nelze zkopírovat do Od verze 1.3.16 jsou soubory odeslané z tohoto zařízení, pro ochranu proti ztrátě dat při synchronizaci z více účtů, nahrány do místní složky %1$s.\n\nVšechny soubory odeslané předchozími verzemi byly kvůli této změně přesunuty do složky %2$s. Bohužel chyba zabránila dokončení této operace při synchronizaci účtu. Můžete nyní ponechat soubory ve stávajícím stavu a smazat odkaz na %3$s nebo přesunout soubory do adresáře %1$s a zachovat odkazy na %4$s.\n\nNásleduje seznam místních souborů a jejich odkazů na vzdálené soubory v %5$s. + Složka %1$s již neexistuje. Přesunout vše Všechny soubory byly přesunuty Některé soubory nebylo možno přesunout @@ -117,6 +121,7 @@ Nepodporovaný kodek Multimediální soubor nelze přečíst Multimediální soubor není správně kódován + Příliš mnoho času bylo zkoušeno přehrání Multimediální soubor nelze proudově odesílat Multimediální soubor nemůže být přehrán s výchozím přehrávačem Chyba zabezpečení při pokusu o přehrání %1$s @@ -131,12 +136,15 @@ Spojení navázáno Zkouším spojení... Neplatné nastavení serveru + Účet pro stejného uživatele a server již v zařízení existuje + Zadaný uživatel neodpovídá uživateli tohoto účtu Nastala neznámá chyba Nelze najít hostitele Instance serveru nenalezena Serveru trvalo příliš dlouho odpovědět Neplatné URL Inicializace SSL selhala + Nemohu ověřit SSL identitu serveru Nerozpoznaná verze serveru Nemohu navázat spojení Zabezpečené spojení navázáno @@ -144,7 +152,12 @@ Neúspěšné přihlášení Přístup zamítnut autorizačním serverem Neočekávaný stav; prosím vložte znovu URL adresu serveru + Vaše přihlášení vypršelo. Přihlašte se, prosím, znovu Zadejte prosím aktuální heslo + Vaše přihlášení vypršelo. Přihlašte se, prosím, znovu + Připojuji se k přihlašovacímu serveru... + Server nepodporuje tuto přihlašovací metodu. + %1$s nepodporuje více účtů. Udržovat soubor aktuální Přejmenovat Odstranit @@ -162,9 +175,11 @@ Vzdálený soubor nemohl být zkontrolován Obsah souboru je již synchronizován Adresář nelze vytvořit + Zakázané znaky: / \\ < > : \" | ? * Počkejte chvíli Neočekávaný problém - zkuste zvolit soubor jinou aplikací Žádný soubor nebyl vybrán + Přihlásit se s oAuth2. Připojuji se k oAuth2 serveru... Identitu stránky nelze ověřit - Certifikát serveru je nedůvěryhodný @@ -204,6 +219,7 @@ Náhled obrázku Obrázek nemůže být zobrazen %1$s nelze zkopírovat do místního adresáře %2$s + Selhalo Okamžité odeslání\" Selhaná okamžitá odeslání Souhrn všech selhaných okamžitých odeslání vybrat vše diff --git a/res/values-de-rDE/strings.xml b/res/values-de-rDE/strings.xml index 1a8f2ca6..50597463 100644 --- a/res/values-de-rDE/strings.xml +++ b/res/values-de-rDE/strings.xml @@ -175,6 +175,7 @@ Die entfernte Datei konnte nicht überprüft werden Dateiinhalte bereits synchronisiert Das Verzeichnis konnte nicht erstellt werden. + Verbotene Zeichen: / \\ < > : \" | ? * Bitte warten Sie einen Moment. Ein unerwartetes Problem ist aufgetreten. Bitte versuchen Sie, die Datei in einer anderen App zu öffnen. Es wurde keine Datei ausgewählt. @@ -218,6 +219,7 @@ Bildvorschau Dieses Bild kann nicht angezeigt werden %1$s konnte nicht in den lokalen %2$s Ordner kopiert werden + Sofort-Upload fehlgeschlagen Sofortige Uploads fehlgeschlagen Zusammenfassung aller fehlgeschlagenen Uploads Alle auswählen diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 84787722..e1d851e4 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -175,6 +175,7 @@ Die entfernte Datei konnte nicht überprüft werden Dateiinhalte bereits synchronisiert Das Verzeichnis konnte nicht erstellt werden. + Verbotene Zeichen: / \\ < > : \" | ? * Bitte warte einen Moment. Ein unerwartetes Problem ist aufgetreten. Bitte versuche, die Datei in einer anderen App zu öffnen Es wurde keine Datei ausgewählt. @@ -218,6 +219,7 @@ Bildvorschau Dieses Bild kann nicht angezeigt werden %1$s konnte nicht in den lokalen %2$s Ordner kopiert werden + Sofort-Upload fehlgeschlagen SofortUpload fehlgeschlagen Übersicht aller fehlgeschlagenen SofortUploads Alles auswählen diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 0837a49a..f747b1ba 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -2,6 +2,7 @@ %1$s Εφαρμογή για Android έκδοση %1$s + Ανανέωση λογαριασμού Μεταφόρτωση Περιεχόμενο από άλλες εφαρμογές Αρχεία @@ -17,10 +18,17 @@ Προστατέψτε την εφαρμογή Ενεργοποιήστε την άμεση μεταφόρτωση Άμεση μεταφόρτωση των φωτογραφιών που τραβάει η φωτογρ. μηχανή + Ενεργοποίηση Καταγραφής Ιστορικού + Χρησιμοποιείται για την καταγραφή προβλημάτων + Ιστορικό Καταγραφής + Εδώ μπορείτε να δείτε το καταγεγραμμένο ιστορικό Διαγραφή Ιστορικού Βοήθεια + Προτείνετε σε ένα φίλο Σχόλια Αποτύπωμα + Δοκιμάστε %1$s στο κινητό σας! + Θέλω να σας προσκαλέσω να χρησιμοποιήσετε το %1$s στο κινητό σας!\nΚατεβάστε το εδώ: %2$s Έλεγχος Διακομιστή Διεύθυνση εξυπηρέτη Όνομα χρήστη @@ -74,6 +82,7 @@ %1$s αρχεία λήφθηκαν με επιτυχία Το κατέβασμα απέτυχε Η λήψη του %1$s δεν μπόρεσε να ολοκληρωθεί με επιτυχία + Δεν έχει κατέβει ακόμα Επιλογή λογαριασμού Ο συγχρονισμός απέτυχε Ο συγχρονισμός του %1$s δεν μπόρεσε να ολοκληρωθεί @@ -84,6 +93,8 @@ Τα περιεχόμενα των %1$d αρχείων δεν μπόρεσαν να συγχρονιστούν (%2$d διενέξεις) Ορισμένα τοπικά αρχεία ξεχάστηκαν %1$d αρχεια απο τον %2$s χωρο αποθηκευσης δεν μπορουν να αντιγραφθουν σε + Από την έκδοση 1.3.16 και μετά, αρχεία που μεταφορτώνονται από αυτήν τη συσκευή αντιγράφονται στον τοπικό φάκελο %1$s για να αποτραπεί η απώλεια δεδομένων όταν ένα αρχείο είναι συγχρονισμένο με πολλαπλούς λογαριασμούς.\nΛόγω αυτής της αλλαγής, όλα τα αρχεία που μεταφορτώθηκαν με προηγούμενες εκδόσεις αυτής της εφαρμογής αντιγράφηκαν στο φάκελο %2$s. Ωστόσο, ένα σφάλμα εμπόδισε την ολοκλήρωση αυτής της επιχείρησης κατά το συγχρονισμό του λογαριασμού. Μπορείτε είτε να αφήσετε τα αρχεία όπως είναι και να καταργήσετε τη σύνδεση με%3$s ή να μετακινήσετε τα αρχεία στον κατάλογο %1$s και να διατηρήσετε τη σύνδεση με %4$s.\n\nΑπαριθμημένα πιο κάτω είναι το(α) τοπικό(ά) αρχείο(α) και το(α) απομακρυσμένο(α) αρχείο(α) στο %5$s με το(α) οποίο(α) συνδέονταν. + Ο φάκελος %1$s δεν υπάρχει πια Μετακινηση ολων Ολα τα αρχεια μετακινηθηκαν Μερικα αρχεια δεν μπορεσαν να μετακινηθουν @@ -101,8 +112,13 @@ Το PIN της εφαρμογής αποθηκεύτηκε Δεν βρέθηκε αρχείο πολυμέσων Δεν δόθηκε λογαριασμός + Το αρχείο δεν βρίσκεται σε έγκυρο λογαριασμό + Αυτή η μορφή κωδικοποιήσης πολυμέσων δεν υποστηρίζεται Το αρχείο πολυμέσων δεν μπόρεσε να διαβαστεί Το αρχείο πολυμέσων δεν είναι σωστά κοδικοποιημένο + Λήξη χρόνου κατά την προσπάθεια αναπαραγωγής + Το αρχείο πολυμέσων δεν μπορεί να μεταδοθεί + Το αρχείο πολυμέσων δεν μπορεί να αναπαραχθεί με την παρεχόμενη εφαρμογή αναπαραγωγής πολυμέσων Κουμπί αναπαραγωγής ή παύσης Προσπάθεια σύνδεσης... Δεν υπάρχει σύνδεση στο δίκτυο @@ -110,18 +126,28 @@ Επετεύχθη σύνδεση Έλεγχος σύνδεσης... Λανθασμένες ρυθμίσεις + Ένας λογαριασμός για τον ίδιο χρήστη και διακομιστή υπάρχει ήδη στη συσκευή + Ο χρήστης που εισάγατε δεν ταιριάζει με το χρήστη αυτού του λογαριασμού Παρουσιάστηκε άγνωστο σφάλμα Δεν βρέθηκε υπολογιστής Δεν βρέθηκε στιγμιότυπο server σας Ο εξυπηρετητής αργεί πολύ να απαντήσει Κακώς διατυπωμένο URL Η αρχικοποίηση του SLL απέτυχε + Αδυναμία επιβεβαίωσης την ταυτότητα SSL του διακομιστή Μη αναγνωρίσιμη έκδοση διακομιστή server σας Δεν ήταν δυνατή η σύνδεση Επιτεύχθηκε ασφαλής σύνδεση Λάθος όνομα χρήστη ή κωδικός Η πιστοποίηση απέτυχε + Ο διακομιστής πιστοποίησης αρνήθηκε την πρόσβαση + Απρόοπτη κατάσταση - παρακαλώ εισάγετε τη διεύθυνση URL του διακομιστή ξανά + Η εξουσιοδότησή σας έληξε. Παρακαλώ εξουσιοδοτείστε ξανά Παρακαλώ είσάγετε τον τρέχοντα κωδικό + Η συνεδρία σας έληξε. Παρακαλώ συνδεθείτε ξανά + Σύνδεση με το διακομιστή πιστοποίησης σε εξέλιξη... + Ο διακομιστής δεν υποστηρίζει αυτή τη μέθοδο πιστοποίησης + Ο %1$s δεν υποστηρίζει πολλαπλούς λογαριασμούς Διατήρηση αρχείου ενημερωμένo Μετονομασία Αφαίρεση @@ -139,9 +165,12 @@ Αδυναμία ελέγχου του απομακρυσμένου αρχείου Τα περιεχόμενα του αρχείου έχουν ήδη συγχρονιστεί Ο κατάλογος δεν ήταν δυνατόν να δημιουργηθεί + Μη-επιτρεπόμενοι χαρακτήρες: / \\ < > : \" | ? * Παρακαλούμε περιμένετε Απροσδόκητο σφάλμα, δοκιμάστε με άλλη εφαρμογή Δεν επιλέχθηκαν αρχεία + Σύνδεση με oAuth2 + Σύνδεση με το διακομιστή oAuth2 σε εξέλιξη... Η ταυτότητα της σελίδας δεν μπορεί να εγκριθεί - Το πιστοποιητικό του διακομιστή δεν είναι αξιόπιστο - Το πιστοποιητικό του διακομιστή έχει λήξει @@ -181,6 +210,10 @@ Αυτή η εικόνε δεν μπόρεσε να προβληθεί %1$s δεν μπορεσε να αντιγραφθεί στον %2$s τοπικο καταλόγο επιλογή όλων + επανάληψη για όλα τα επιλεγμένα + διαγραφή όλων των επιλεγμένων από τη λίστα προς μεταφόρτωση + επανάληψη προσπάθειας μεταφόρτωσης της εικόνας: Φόρτωση περισσότερων εικόνων Μήνυμα Αποτυχίας: + Παρακαλώ ελέγξτε τις ρυθμίσεις του διακομιστή σας, ίσως έχετε υπερβεί τη διαθέσιμη μερίδα σας. diff --git a/res/values-et-rEE/strings.xml b/res/values-et-rEE/strings.xml index 41a7c31e..3a07fcdb 100644 --- a/res/values-et-rEE/strings.xml +++ b/res/values-et-rEE/strings.xml @@ -175,6 +175,7 @@ Mujaloleva faili kontrollimine ebaõnnestus Faili sisu on juba sünkroniseeritud Kausta loomine ebaõnnestus + Keelatud sümbolid: / \\ < > : \" | ? * Oota hetk Ootamatu tõrge ; palun kasuta faili valimiseks mõnda teist rakendust Ühtegi faili pole valitud @@ -218,6 +219,7 @@ Pildi eelvaade Seda pilti ei saa näidata %1$s ei suudetud kopeerida kohalikku kataloogi failina %2$s + Ebaõnnestunud kohene üleslaadimine Ebaõnnestunud kohesed üleslaadimised Kõikide ebaõnnestunud üleslaadimiste kokkuvõte vali kõik diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml new file mode 100644 index 00000000..c757504a --- /dev/null +++ b/res/values-fr-rCA/strings.xml @@ -0,0 +1,2 @@ + + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 65f07234..40d759f5 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -175,6 +175,7 @@ Le fichier distant n\'a pu être vérifié Le contenu des fichiers est déjà synchronisé Création du répertoire impossible + Caractères interdits : / \\ < > : \" | ? * Veuillez patienter Problème inattendu ; veuillez essayer une autre app pour la sélection du fichier Aucun fichier sélectionné @@ -218,6 +219,7 @@ Prévisualisation de l\'image Cette image ne peut pas être affichée %1$s n\'a pas pu être copié vers le dossier local suivant %2$s + Échec du téléversement instantané Téléchargements instantanés échoués Résumé de tous les téléchargements instantanés échoués Tous sélectionner diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index 2c223c36..fe9e7d0f 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -175,6 +175,7 @@ Non foi posíbel comprobar o ficheiro remoto Os contidos do ficheiro xa están sincronizados Non foi posíbel crear o directorio + Caracteres non permitidos: / \\ < > : \" | ? * Agarde un chisco Produciuse un erro non agardado. Seleccione o ficheiro con outro aplicativo diferente Non se escolleu ningún ficheiro @@ -218,6 +219,7 @@ Vista previa da imaxe Esta imaxe non pode ser amosada Non foi posíbel copiar %1$s no directorio local %2$s + produciuse un fallo de EnvíoInstantáneo Envíos instantáneos fallados Resumo de todos os envíos instantáneos fallados seleccionar todo diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 58bdc131..2242f74e 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -175,6 +175,7 @@ Il file remoto non può essere controllato Contenuti del file già sincronizzati La cartella non può essere creata + Caratteri proibiti: / \\ < > : \" | ? * Attendi Problema inatteso; prova un\'altra applicazione per selezionare il file Non è stato selezionato alcun file @@ -218,6 +219,7 @@ Anteprima dell\'immagine Questa immagine non può essere mostrata %1$s non può essere copiato nella cartella locale %2$s + Caricamento istantaneo non riuscito Caricamenti istantanei non riusciti Riepilogo dei caricamenti istantanei non riusciti seleziona tutto diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 362a5fb5..17616d61 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -94,6 +94,7 @@ Vsebine %1$d datotek ni bilo mogoče uskladiti (zaznanih je %2$d sporov) Nekatere krajevne datoteke so spregledane Skupno %1$d datotek iz mape %2$s ni mogoče kopirati v + Od različice 1.3.16 dalje so datoteke, poslane iz te naprave, kopirane v krajevno mapo %1$s. S tem je preprečena izguba podatkov, kadar poteka usklajevanje ene datoteke z več računi.\n\nZaradi te spremembe so vse datoteke, poslane pred namestitvijo te različice programa, kopirane v mapo %2$s. Med usklajevanjem računov je prišlo do napake, ki je preprečila končanje tega opravila. Datoteke lahko pustite nespremenjene in odstranite povezavo do %3$s ali jih premaknete v mapo %1$s in ohranite povezavo do %4$s.\n\nNavedene so krajevne in oddaljene datoteke in mesto %5$s, kje so bile povezane. Mapa %1$s ne obstaja več Premakni vse Vse datoteke so uspešno premaknjene na novo mesto @@ -126,6 +127,7 @@ Prišlo je do varnostne napake med predvajanjem %1$s Prišlo je do napake vhoda med predvajanjem %1$s Prišlo je do nepričakovane napake med predvajanjem %1$s + Vrni nazaj Gumb za predvajanje in premor Gumb za hitro predvajanje naprej Poskus prijave … @@ -135,6 +137,7 @@ Preizkušanje povezave ... Napačno oblikovane nastavitve strežnika Na napravi račun za istega uporabnika in strežnik že obstaja + Vpisan uporabnik ni lastnik tega računa Prišlo je do neznane napake! Gostitelja ni mogoče najti Primerka strežnika ni mogoče najti @@ -153,6 +156,7 @@ Vnesite trenutno geslo Seja je potekla. Ponovno je treba vzpostaviti povezavo. Poteka povezovanje z overitvenim strežnikom ... + Strežnik ne podpira tega načina overitve %1$s ne omogoča podpore več računom Datoteka naj bo posodobljena Preimenuj @@ -215,9 +219,15 @@ Predogled slike Te slike ni mogoče prikazati Datoteke %1$s ni mogoče kopirati v krajevno mapo %2$s. + Spodletelo takojšnje pošiljanje + Spodletela takojšnja pošiljanja + Povzetek vseh spodletelih takojšnjih pošiljanj izberi vse vse izbrane poskusi znova + izbriši izbrane iz vrste za pošiljanje + poskusi poslati sliko: Naloži več slik + ne pošlji takoj, saj je povezava v omrežje ni dejavna Sporočilo o napaki: Preverite nastavitve strežnika. Morda je presežena vrednost količinske omejitve. diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index f5271339..9b4a1366 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -175,6 +175,7 @@ Fjärrfilen kunde inte kontrolleras Filinnehåll redan synkroniserat Mapp kunde inte skapas + Förbjudna tecken är: / \\ < > : \" | ? * Var god vänta Oväntat problem; prova annat program för aktuell fil Ingen fil vald @@ -218,6 +219,7 @@ Förhandsvisa bild Denna bild kan inte visas %1$s kunde inte kopieras till %2$s lokal mapp + Fel vid direktuppladdning\" Misslyckades vid direktuppladdning Sammanfattning av alla misslyckade uppladdningar välj alla diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index fb55e933..042709a1 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -434,7 +434,7 @@ public class FileDataStorageManager { } updateFolderSize(file.getParentId()); } - if (removeLocalCopy && file.isDown()) { + if (removeLocalCopy && file.isDown() && file.getStoragePath() != null) { boolean success = new File(file.getStoragePath()).delete(); if (!removeDBData && success) { // maybe unnecessary, but should be checked TODO remove if unnecessary diff --git a/src/com/owncloud/android/operations/RemoveFileOperation.java b/src/com/owncloud/android/operations/RemoveFileOperation.java index 34926afb..0ab8ac3c 100644 --- a/src/com/owncloud/android/operations/RemoveFileOperation.java +++ b/src/com/owncloud/android/operations/RemoveFileOperation.java @@ -17,16 +17,13 @@ package com.owncloud.android.operations; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; - import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; import com.owncloud.android.oc_framework.operations.RemoteOperation; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; -import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; -import com.owncloud.android.utils.Log_OC; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.operations.remote.RemoveRemoteFileOperation; /** @@ -36,10 +33,7 @@ import com.owncloud.android.utils.Log_OC; */ public class RemoveFileOperation extends RemoteOperation { - private static final String TAG = RemoveFileOperation.class.getSimpleName(); - - private static final int REMOVE_READ_TIMEOUT = 10000; - private static final int REMOVE_CONNECTION_TIMEOUT = 5000; + // private static final String TAG = RemoveFileOperation.class.getSimpleName(); OCFile mFileToRemove; boolean mDeleteLocalCopy; @@ -69,7 +63,6 @@ public class RemoveFileOperation extends RemoteOperation { return mFileToRemove; } - /** * Performs the remove operation * @@ -78,25 +71,14 @@ public class RemoveFileOperation extends RemoteOperation { @Override protected RemoteOperationResult run(WebdavClient client) { RemoteOperationResult result = null; - DeleteMethod delete = null; - try { - delete = new DeleteMethod(client.getBaseUri() + WebdavUtils.encodePath(mFileToRemove.getRemotePath())); - int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT); - if (delete.succeeded() || status == HttpStatus.SC_NOT_FOUND) { - mDataStorageManager.removeFile(mFileToRemove, true, mDeleteLocalCopy); - } - delete.getResponseBodyAsString(); // exhaust the response, although not interesting - result = new RemoteOperationResult((delete.succeeded() || status == HttpStatus.SC_NOT_FOUND), status, delete.getResponseHeaders()); - Log_OC.i(TAG, "Remove " + mFileToRemove.getRemotePath() + ": " + result.getLogMessage()); - - } catch (Exception e) { - result = new RemoteOperationResult(e); - Log_OC.e(TAG, "Remove " + mFileToRemove.getRemotePath() + ": " + result.getLogMessage(), e); - - } finally { - if (delete != null) - delete.releaseConnection(); + + RemoveRemoteFileOperation operation = new RemoveRemoteFileOperation(mFileToRemove.getRemotePath()); + result = operation.execute(client); + + if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) { + mDataStorageManager.removeFile(mFileToRemove, true, mDeleteLocalCopy); } + return result; } diff --git a/src/com/owncloud/android/operations/RenameFileOperation.java b/src/com/owncloud/android/operations/RenameFileOperation.java index 9aa573ab..be6cdcce 100644 --- a/src/com/owncloud/android/operations/RenameFileOperation.java +++ b/src/com/owncloud/android/operations/RenameFileOperation.java @@ -20,7 +20,6 @@ package com.owncloud.android.operations; import java.io.File; import java.io.IOException; -import org.apache.commons.httpclient.HttpException; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 780fd42c..e93736c4 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -23,6 +23,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,7 +31,6 @@ import java.util.Vector; import org.apache.http.HttpStatus; import org.apache.jackrabbit.webdav.DavConstants; -import org.apache.jackrabbit.webdav.MultiStatus; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; import android.accounts.Account; @@ -45,6 +45,8 @@ import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; import com.owncloud.android.oc_framework.operations.RemoteOperation; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.operations.remote.ReadRemoteFolderOperation; +import com.owncloud.android.oc_framework.operations.RemoteFile; import com.owncloud.android.syncadapter.FileSyncService; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.Log_OC; @@ -241,59 +243,25 @@ public class SynchronizeFolderOperation extends RemoteOperation { private RemoteOperationResult fetchAndSyncRemoteFolder(WebdavClient client) { - RemoteOperationResult result = null; - String remotePath = null; - PropFindMethod query = null; - try { - remotePath = mLocalFolder.getRemotePath(); - Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath); - - // remote request - query = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(remotePath), - DavConstants.PROPFIND_ALL_PROP, - DavConstants.DEPTH_1); - int status = client.executeMethod(query); - - // check and process response - if (isMultiStatus(status)) { - synchronizeData(query.getResponseBodyAsMultiStatus(), client); - if (mConflictsFound > 0 || mFailsInFavouritesFound > 0) { - result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); // should be different result, but will do the job - } else { - result = new RemoteOperationResult(true, status, query.getResponseHeaders()); - } - - } else { - // synchronization failed - client.exhaustResponse(query.getResponseBodyAsStream()); - if (status == HttpStatus.SC_NOT_FOUND) { - removeLocalFolder(); - } - result = new RemoteOperationResult(false, status, query.getResponseHeaders()); - } - - } catch (Exception e) { - result = new RemoteOperationResult(e); - - - } finally { - if (query != null) - query.releaseConnection(); // let the connection available for other methods - if (result.isSuccess()) { - Log_OC.i(TAG, "Synchronized " + mAccount.name + remotePath + ": " + result.getLogMessage()); - } else { - if (result.isException()) { - Log_OC.e(TAG, "Synchronized " + mAccount.name + remotePath + ": " + result.getLogMessage(), result.getException()); - } else { - Log_OC.e(TAG, "Synchronized " + mAccount.name + remotePath + ": " + result.getLogMessage()); - } + String remotePath = mLocalFolder.getRemotePath(); + ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath); + RemoteOperationResult result = operation.execute(client); + Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath); + + if (result.isSuccess()) { + synchronizeData(result.getData(), client); + if (mConflictsFound > 0 || mFailsInFavouritesFound > 0) { + result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); // should be different result, but will do the job } - + } else { + if (result.getCode() == ResultCode.FILE_NOT_FOUND) + removeLocalFolder(); } + return result; } - + private void removeLocalFolder() { if (mStorageManager.fileExists(mLocalFolder.getFileId())) { String currentSavePath = FileStorageUtils.getSavePath(mAccount.name); @@ -307,26 +275,25 @@ public class SynchronizeFolderOperation extends RemoteOperation { * with the current data in the local database. * * Grants that mChildren is updated with fresh data after execution. - * - * @param dataInServer Full response got from the server with the data of the target - * folder and its direct children. + * + * @param folderAndFiles Remote folder and children files in Folder + * * @param client Client instance to the remote server where the data were * retrieved. * @return 'True' when any change was made in the local data, 'false' otherwise. */ - private void synchronizeData(MultiStatus dataInServer, WebdavClient client) { + private void synchronizeData(ArrayList folderAndFiles, WebdavClient client) { // get 'fresh data' from the database mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath()); // parse data from remote folder - WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getBaseUri().getPath()); - OCFile remoteFolder = fillOCFile(we); + OCFile remoteFolder = fillOCFile(folderAndFiles.get(0)); remoteFolder.setParentId(mLocalFolder.getParentId()); remoteFolder.setFileId(mLocalFolder.getFileId()); Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath() + " changed - starting update of local data "); - List updatedFiles = new Vector(dataInServer.getResponses().length - 1); + List updatedFiles = new Vector(folderAndFiles.size() - 1); List filesToSyncContents = new Vector(); // get current data about local contents of the folder to synchronize @@ -338,10 +305,9 @@ public class SynchronizeFolderOperation extends RemoteOperation { // loop to update every child OCFile remoteFile = null, localFile = null; - for (int i = 1; i < dataInServer.getResponses().length; ++i) { + for (int i=1; i