Commit c3973fd7 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer 🎼
Browse files

Remove get client async task n

parent 6fa0ac9a
Pipeline #17256 passed with stage
in 2 minutes and 1 second
...@@ -12,21 +12,16 @@ import android.content.Context; ...@@ -12,21 +12,16 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.models.SyncedFolder;
import foundation.e.drive.models.SyncedFileState; import foundation.e.drive.models.SyncedFileState;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
* source: https://developer.android.com/training/data-storage/sqlite.html#java * source: https://developer.android.com/training/data-storage/sqlite.html#java
* https://vogella.developpez.com/tutoriels/android/utilisation-base-donnees-sqlite/ * https://vogella.developpez.com/tutoriels/android/utilisation-base-donnees-sqlite/
*
*/ */
public final class DbHelper extends SQLiteOpenHelper { public final class DbHelper extends SQLiteOpenHelper {
final private static String TAG = DbHelper.class.getSimpleName(); //Tag for log final private static String TAG = DbHelper.class.getSimpleName(); //Tag for log
private static final int DATABASE_VERSION = 19; //20/09/2018 private static final int DATABASE_VERSION = 19; //20/09/2018
......
...@@ -59,5 +59,4 @@ class SyncedFileStateContract implements BaseColumns{ ...@@ -59,5 +59,4 @@ class SyncedFileStateContract implements BaseColumns{
static final String UPDATE_SETTINGS_DATA_TO_VERSION_19 = "UPDATE "+TABLE_NAME+ static final String UPDATE_SETTINGS_DATA_TO_VERSION_19 = "UPDATE "+TABLE_NAME+
" SET "+IS_MEDIA_TYPE+" = 0 WHERE "+REMOTE_PATH+" LIKE \"/Devices/%\";"; " SET "+IS_MEDIA_TYPE+" = 0 WHERE "+REMOTE_PATH+" LIKE \"/Devices/%\";";
} }
...@@ -13,12 +13,9 @@ import android.content.Context; ...@@ -13,12 +13,9 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.SQLException; import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import foundation.e.drive.models.SyncedFileState; import foundation.e.drive.models.SyncedFileState;
import static foundation.e.drive.database.SyncedFileStateContract.TABLE_NAME; import static foundation.e.drive.database.SyncedFileStateContract.TABLE_NAME;
import static foundation.e.drive.database.SyncedFileStateContract.FILE_NAME; import static foundation.e.drive.database.SyncedFileStateContract.FILE_NAME;
...@@ -29,7 +26,6 @@ import static foundation.e.drive.database.SyncedFileStateContract.LOCAL_PATH; ...@@ -29,7 +26,6 @@ import static foundation.e.drive.database.SyncedFileStateContract.LOCAL_PATH;
import static foundation.e.drive.database.SyncedFileStateContract.REMOTE_PATH; import static foundation.e.drive.database.SyncedFileStateContract.REMOTE_PATH;
import static foundation.e.drive.database.SyncedFileStateContract.SYNCEDFOLDER_ID; import static foundation.e.drive.database.SyncedFileStateContract.SYNCEDFOLDER_ID;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
* Offers Query to CRUD operation for SyncedFIleState Object * Offers Query to CRUD operation for SyncedFIleState Object
......
...@@ -16,7 +16,6 @@ import android.database.sqlite.SQLiteDatabase; ...@@ -16,7 +16,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.models.SyncedFolder;
import static foundation.e.drive.database.SyncedFolderContract.CATEGORIE_LABEL; import static foundation.e.drive.database.SyncedFolderContract.CATEGORIE_LABEL;
import static foundation.e.drive.database.SyncedFolderContract.ENABLED; import static foundation.e.drive.database.SyncedFolderContract.ENABLED;
...@@ -191,6 +190,5 @@ class SyncedFolderDAO { ...@@ -191,6 +190,5 @@ class SyncedFolderDAO {
.setId(cursor.getInt(0) ) .setId(cursor.getInt(0) )
.setLastEtag(cursor.getString( 4 ) ) .setLastEtag(cursor.getString( 4 ) )
.setLastModified(cursor.getLong( 5 ) ); .setLastModified(cursor.getLong( 5 ) );
} }
} }
...@@ -11,7 +11,6 @@ package foundation.e.drive.fileFilters; ...@@ -11,7 +11,6 @@ package foundation.e.drive.fileFilters;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
* FileFilter for application Settings * FileFilter for application Settings
...@@ -22,6 +21,5 @@ class AppSettingsFileFilter implements FileFilter { ...@@ -22,6 +21,5 @@ class AppSettingsFileFilter implements FileFilter {
return pathname.isFile() return pathname.isFile()
|| (pathname.isDirectory() || (pathname.isDirectory()
&& !pathname.getName().toLowerCase().contains("cache")); && !pathname.getName().toLowerCase().contains("cache"));
} }
} }
...@@ -10,7 +10,6 @@ package foundation.e.drive.fileFilters; ...@@ -10,7 +10,6 @@ package foundation.e.drive.fileFilters;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.AppConstants;
/** /**
......
...@@ -13,7 +13,6 @@ import android.app.job.JobService; ...@@ -13,7 +13,6 @@ import android.app.job.JobService;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.util.Log; import android.util.Log;
import foundation.e.drive.receivers.ScreenOffReceiver; import foundation.e.drive.receivers.ScreenOffReceiver;
import foundation.e.drive.services.ObserverService; import foundation.e.drive.services.ObserverService;
import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.CommonUtils;
...@@ -40,7 +39,6 @@ public class ScannerJob extends JobService { ...@@ -40,7 +39,6 @@ public class ScannerJob extends JobService {
} }
/** /**
*
* @param params * @param params
* @return default return... ? * @return default return... ?
*/ */
......
...@@ -15,7 +15,6 @@ package foundation.e.drive.models; ...@@ -15,7 +15,6 @@ package foundation.e.drive.models;
public class SyncedFileState { public class SyncedFileState {
protected SyncedFileState(){}; //@ToRemove. Test Only. It's to allow to make a mock SyncedFileState Class in test. protected SyncedFileState(){}; //@ToRemove. Test Only. It's to allow to make a mock SyncedFileState Class in test.
private int id; private int id;
private String name; //name of the file private String name; //name of the file
...@@ -126,5 +125,4 @@ public class SyncedFileState { ...@@ -126,5 +125,4 @@ public class SyncedFileState {
+"\nSyncedFolderId: "+this.syncedFolderId +"\nSyncedFolderId: "+this.syncedFolderId
+"\nisMediaType: "+this.isMediaType; +"\nisMediaType: "+this.isMediaType;
} }
} }
...@@ -16,7 +16,6 @@ import android.os.Parcelable; ...@@ -16,7 +16,6 @@ import android.os.Parcelable;
* This class encapsulates the representation of a synced or syncable folder. * This class encapsulates the representation of a synced or syncable folder.
* It stores data about remote and local real folder. * It stores data about remote and local real folder.
*/ */
public class SyncedFolder implements Parcelable { public class SyncedFolder implements Parcelable {
private int id; private int id;
private String libelle; private String libelle;
......
...@@ -27,8 +27,4 @@ public interface ComparableOperation { ...@@ -27,8 +27,4 @@ public interface ComparableOperation {
* @return RemoteOperation this instance * @return RemoteOperation this instance
*/ */
public RemoteOperation toRemoteOperation(); public RemoteOperation toRemoteOperation();
} }
...@@ -10,14 +10,11 @@ package foundation.e.drive.operations; ...@@ -10,14 +10,11 @@ package foundation.e.drive.operations;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation; import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import java.io.File; import java.io.File;
import foundation.e.drive.database.DbHelper; import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.models.SyncedFolder;
......
...@@ -30,11 +30,9 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException; ...@@ -30,11 +30,9 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.common.utils.Log_OC;
import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.GetMethod;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -49,7 +47,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -49,7 +47,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author masensio * @author masensio
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
*/ */
class DownloadFileRemoteOperation extends RemoteOperation { class DownloadFileRemoteOperation extends RemoteOperation {
private static final String TAG = DownloadFileRemoteOperation.class.getSimpleName(); private static final String TAG = DownloadFileRemoteOperation.class.getSimpleName();
...@@ -57,11 +54,9 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -57,11 +54,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
private long mModificationTimestamp = 0; private long mModificationTimestamp = 0;
private String mEtag = ""; private String mEtag = "";
private GetMethod mGet; private GetMethod mGet;
private final String mRemotePath; private final String mRemotePath;
private final String mLocalFolderPath; private final String mLocalFolderPath;
/** /**
* Constructor * Constructor
* @param remotePath Path of file on the server * @param remotePath Path of file on the server
...@@ -90,7 +85,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -90,7 +85,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
Log_OC.e(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + Log_OC.e(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " +
result.getLogMessage(), e); result.getLogMessage(), e);
} }
return result; return result;
} }
...@@ -125,7 +119,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -125,7 +119,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
fos.write(bytes, 0, readResult); fos.write(bytes, 0, readResult);
transferred += readResult; transferred += readResult;
} }
// Check if the file is completed // Check if the file is completed
// if transfer-encoding: chunked we cannot check if the file is complete // if transfer-encoding: chunked we cannot check if the file is complete
...@@ -135,7 +128,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -135,7 +128,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
if (transferEncodingHeader != null) { if (transferEncodingHeader != null) {
transferEncoding = transferEncodingHeader.getValue().equals("chunked"); transferEncoding = transferEncodingHeader.getValue().equals("chunked");
} }
if (transferred == totalToTransfer || transferEncoding) { if (transferred == totalToTransfer || transferEncoding) {
savedFile = true; savedFile = true;
Header modificationTime = mGet.getResponseHeader("Last-Modified"); Header modificationTime = mGet.getResponseHeader("Last-Modified");
...@@ -153,16 +145,13 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -153,16 +145,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
if (mEtag.length() == 0) { if (mEtag.length() == 0) {
Log_OC.e(TAG, "Could not read eTag from response downloading " + mRemotePath); Log_OC.e(TAG, "Could not read eTag from response downloading " + mRemotePath);
} }
} else { } else {
client.exhaustResponse(mGet.getResponseBodyAsStream()); client.exhaustResponse(mGet.getResponseBodyAsStream());
// TODO some kind of error control! // TODO some kind of error control!
} }
} else { } else {
client.exhaustResponse(mGet.getResponseBodyAsStream()); client.exhaustResponse(mGet.getResponseBodyAsStream());
} }
} catch (Exception e) { } catch (Exception e) {
Log_OC.e(TAG, e.getMessage()); Log_OC.e(TAG, e.getMessage());
} finally { } finally {
......
...@@ -10,21 +10,17 @@ package foundation.e.drive.operations; ...@@ -10,21 +10,17 @@ package foundation.e.drive.operations;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.LightReadFolderRemoteOperation; import com.owncloud.android.lib.resources.files.LightReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile; import com.owncloud.android.lib.resources.files.model.RemoteFile;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import foundation.e.drive.database.DbHelper; import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.models.SyncedFolder;
import static org.apache.jackrabbit.webdav.DavConstants.DEPTH_1; import static org.apache.jackrabbit.webdav.DavConstants.DEPTH_1;
/** /**
...@@ -32,7 +28,6 @@ import static org.apache.jackrabbit.webdav.DavConstants.DEPTH_1; ...@@ -32,7 +28,6 @@ import static org.apache.jackrabbit.webdav.DavConstants.DEPTH_1;
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
* Created by Vincent on 04/05/2018. * Created by Vincent on 04/05/2018.
*/ */
public class ListFileRemoteOperation extends RemoteOperation { public class ListFileRemoteOperation extends RemoteOperation {
private final String TAG = ListFileRemoteOperation.class.getSimpleName(); private final String TAG = ListFileRemoteOperation.class.getSimpleName();
......
...@@ -10,7 +10,6 @@ package foundation.e.drive.operations; ...@@ -10,7 +10,6 @@ package foundation.e.drive.operations;
import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation; import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
import foundation.e.drive.models.SyncedFileState; import foundation.e.drive.models.SyncedFileState;
/** /**
......
...@@ -12,7 +12,6 @@ import android.content.Context; ...@@ -12,7 +12,6 @@ import android.content.Context;
import android.util.Log; import android.util.Log;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.UserInfo; import com.owncloud.android.lib.common.UserInfo;
import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperation;
...@@ -22,7 +21,6 @@ import com.owncloud.android.lib.resources.files.FileUtils; ...@@ -22,7 +21,6 @@ import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation; import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import foundation.e.drive.database.DbHelper; import foundation.e.drive.database.DbHelper;
import foundation.e.drive.models.SyncedFileState; import foundation.e.drive.models.SyncedFileState;
import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.CommonUtils;
...@@ -34,16 +32,13 @@ import foundation.e.drive.utils.CommonUtils; ...@@ -34,16 +32,13 @@ import foundation.e.drive.utils.CommonUtils;
public class UploadFileOperation extends RemoteOperation implements ComparableOperation{ public class UploadFileOperation extends RemoteOperation implements ComparableOperation{
private final static String TAG = UploadFileOperation.class.getSimpleName(); private final static String TAG = UploadFileOperation.class.getSimpleName();
private int restartCounter =0; private int restartCounter =0;
private long previousLastModified; //get to restore real value if all trials fails private long previousLastModified; //get to restore real value if all trials fails
private boolean checkEtag; private boolean checkEtag;
private String mTargetPath; private String mTargetPath;
private final File mFile; private final File mFile;
private final Context mContext; private final Context mContext;
private SyncedFileState mSyncedState; private SyncedFileState mSyncedState;
private long availableQuota = -1; private long availableQuota = -1;
@Override @Override
...@@ -78,7 +73,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp ...@@ -78,7 +73,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
"", "",
0, 0,
syncedFolderId, syncedFolderIsMediaType); syncedFolderId, syncedFolderIsMediaType);
} }
Log.v(TAG, ""+mSyncedState.getLocalLastModified() ); Log.v(TAG, ""+mSyncedState.getLocalLastModified() );
this.previousLastModified = mSyncedState.getLocalLastModified(); this.previousLastModified = mSyncedState.getLocalLastModified();
...@@ -138,8 +132,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp ...@@ -138,8 +132,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
UploadFileRemoteOperation uploadOperation = buildUploadOperation(); UploadFileRemoteOperation uploadOperation = buildUploadOperation();
// Execute UploadFileOperation // Execute UploadFileOperation
RemoteOperationResult uploadResult = uploadOperation.execute( client ); RemoteOperationResult uploadResult = uploadOperation.execute( client );
ResultCode mResultCode; ResultCode mResultCode;
...@@ -169,18 +161,14 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp ...@@ -169,18 +161,14 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
mustRestart = false; mustRestart = false;
mSyncedState.setLocalLastModified( this.previousLastModified); mSyncedState.setLocalLastModified( this.previousLastModified);
} }
}catch(Exception e){ }catch(Exception e){
Log.e(TAG, e.toString() ); Log.e(TAG, e.toString() );
mSyncedState.setLocalLastModified( this.previousLastModified); mSyncedState.setLocalLastModified( this.previousLastModified);
mustRestart = false; mustRestart = false;
} }
}else if(uploadResult.getCode() == ResultCode.QUOTA_EXCEEDED){ }else if(uploadResult.getCode() == ResultCode.QUOTA_EXCEEDED){
mResultCode = ResultCode.QUOTA_EXCEEDED; mResultCode = ResultCode.QUOTA_EXCEEDED;
mustRestart = false; mustRestart = false;
}else{ }else{
//Upload failed //Upload failed
Log.e(TAG, "UploadFileRemoteOperation for : " + mFile.getName() + " failed => code: " + uploadResult.getCode()); Log.e(TAG, "UploadFileRemoteOperation for : " + mFile.getName() + " failed => code: " + uploadResult.getCode());
...@@ -249,8 +237,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp ...@@ -249,8 +237,6 @@ public class UploadFileOperation extends RemoteOperation implements ComparableOp
} }
} }
/** /**
* Return the file that should be uploading * Return the file that should be uploading
* @return File given to this operation * @return File given to this operation
......
...@@ -15,7 +15,6 @@ import android.net.Uri; ...@@ -15,7 +15,6 @@ import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
/** /**
* *
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
......
...@@ -12,14 +12,11 @@ import android.content.BroadcastReceiver; ...@@ -12,14 +12,11 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import foundation.e.drive.utils.JobUtils; import foundation.e.drive.utils.JobUtils;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
*/ */
public class BatteryStateReceiver extends BroadcastReceiver { public class BatteryStateReceiver extends BroadcastReceiver {
private final static String TAG = BatteryStateReceiver.class.getSimpleName(); private final static String TAG = BatteryStateReceiver.class.getSimpleName();
...@@ -32,16 +29,13 @@ public class BatteryStateReceiver extends BroadcastReceiver { ...@@ -32,16 +29,13 @@ public class BatteryStateReceiver extends BroadcastReceiver {
Log.e(TAG, "intent Action is null"); Log.e(TAG, "inte