1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Reviewed names and types of parameters

This commit is contained in:
David A. Velasco 2014-02-17 14:36:45 +01:00
parent 7fe393b28e
commit 689fbe0ce1
11 changed files with 60 additions and 61 deletions

View File

@ -50,16 +50,16 @@ public class RemoveRemoteShareOperation extends RemoteOperation {
private static final String TAG = RemoveRemoteShareOperation.class.getSimpleName(); private static final String TAG = RemoveRemoteShareOperation.class.getSimpleName();
private int mIdShare; private int mRemoteShareId;
/** /**
* Constructor * Constructor
* *
* @param idShare Share ID * @param remoteShareId Share ID
*/ */
public RemoveRemoteShareOperation(int idShare) { public RemoveRemoteShareOperation(int remoteShareId) {
mIdShare = idShare; mRemoteShareId = remoteShareId;
} }
@ -71,9 +71,9 @@ public class RemoveRemoteShareOperation extends RemoteOperation {
DeleteMethod delete = null; DeleteMethod delete = null;
try { try {
String id = "/" + String.valueOf(mIdShare); String id = "/" + String.valueOf(mRemoteShareId);
delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH + id);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH + id);
status = client.executeMethod(delete); status = client.executeMethod(delete);

View File

@ -60,7 +60,7 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
FileChannel channel = null; FileChannel channel = null;
RandomAccessFile raf = null; RandomAccessFile raf = null;
try { try {
File file = new File(mStoragePath); File file = new File(mLocalPath);
raf = new RandomAccessFile(file, "r"); raf = new RandomAccessFile(file, "r");
channel = raf.getChannel(); channel = raf.getChannel();
mEntity = new ChunkFromFileChannelRequestEntity(channel, mMimeType, CHUNK_SIZE, file); mEntity = new ChunkFromFileChannelRequestEntity(channel, mMimeType, CHUNK_SIZE, file);
@ -82,7 +82,7 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
mPutMethod.setRequestEntity(mEntity); mPutMethod.setRequestEntity(mEntity);
status = client.executeMethod(mPutMethod); status = client.executeMethod(mPutMethod);
client.exhaustResponse(mPutMethod.getResponseBodyAsStream()); client.exhaustResponse(mPutMethod.getResponseBodyAsStream());
Log.d(TAG, "Upload of " + mStoragePath + " to " + mRemotePath + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status); Log.d(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status);
if (!isSuccess(status)) if (!isSuccess(status))
break; break;
} }

View File

@ -65,11 +65,11 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
private GetMethod mGet; private GetMethod mGet;
private String mRemotePath; private String mRemotePath;
private String mDownloadFolderPath; private String mLocalFolderPath;
public DownloadRemoteFileOperation(String remotePath, String downloadFolderPath) { public DownloadRemoteFileOperation(String remotePath, String localFolderPath) {
mRemotePath = remotePath; mRemotePath = remotePath;
mDownloadFolderPath = downloadFolderPath; mLocalFolderPath = localFolderPath;
} }
@Override @Override
@ -157,7 +157,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
} }
private String getTmpPath() { private String getTmpPath() {
return mDownloadFolderPath + mRemotePath; return mLocalFolderPath + mRemotePath;
} }
public void addDatatransferProgressListener (OnDatatransferProgressListener listener) { public void addDatatransferProgressListener (OnDatatransferProgressListener listener) {

View File

@ -56,12 +56,12 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
/** /**
* Full constructor. Success of the operation will depend upon the value of successIfAbsent. * Full constructor. Success of the operation will depend upon the value of successIfAbsent.
* *
* @param path Path to append to the URL owned by the client instance. * @param remotePath Path to append to the URL owned by the client instance.
* @param context Android application context. * @param context Android application context.
* @param successIfAbsent When 'true', the operation finishes in success if the path does NOT exist in the remote server (HTTP 404). * @param successIfAbsent When 'true', the operation finishes in success if the path does NOT exist in the remote server (HTTP 404).
*/ */
public ExistenceCheckRemoteOperation(String path, Context context, boolean successIfAbsent) { public ExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent) {
mPath = (path != null) ? path : ""; mPath = (remotePath != null) ? remotePath : "";
mContext = context; mContext = context;
mSuccessIfAbsent = successIfAbsent; mSuccessIfAbsent = successIfAbsent;
} }

View File

@ -126,24 +126,24 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
* Read the data retrieved from the server about the contents of the target folder * 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 * @param remoteData Full response got from the server with the data of the target
* folder and its direct children. * folder and its direct children.
* @param client Client instance to the remote server where the data were * @param client Client instance to the remote server where the data were
* retrieved. * retrieved.
* @return * @return
*/ */
private void readData(MultiStatus dataInServer, OwnCloudClient client) { private void readData(MultiStatus remoteData, OwnCloudClient client) {
mFolderAndFiles = new ArrayList<Object>(); mFolderAndFiles = new ArrayList<Object>();
// parse data from remote folder // parse data from remote folder
WebdavEntry we = new WebdavEntry(dataInServer.getResponses()[0], client.getWebdavUri().getPath()); WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getWebdavUri().getPath());
mFolderAndFiles.add(fillOCFile(we)); mFolderAndFiles.add(fillOCFile(we));
// loop to update every child // loop to update every child
RemoteFile remoteFile = null; RemoteFile remoteFile = null;
for (int i = 1; i < dataInServer.getResponses().length; ++i) { for (int i = 1; i < remoteData.getResponses().length; ++i) {
/// new OCFile instance with the data from the server /// new OCFile instance with the data from the server
we = new WebdavEntry(dataInServer.getResponses()[i], client.getWebdavUri().getPath()); we = new WebdavEntry(remoteData.getResponses()[i], client.getWebdavUri().getPath());
remoteFile = fillOCFile(we); remoteFile = fillOCFile(we);
mFolderAndFiles.add(remoteFile); mFolderAndFiles.add(remoteFile);
} }

View File

@ -54,7 +54,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
public class UploadRemoteFileOperation extends RemoteOperation { public class UploadRemoteFileOperation extends RemoteOperation {
protected String mStoragePath; protected String mLocalPath;
protected String mRemotePath; protected String mRemotePath;
protected String mMimeType; protected String mMimeType;
protected PutMethod mPutMethod = null; protected PutMethod mPutMethod = null;
@ -64,8 +64,8 @@ public class UploadRemoteFileOperation extends RemoteOperation {
protected RequestEntity mEntity = null; protected RequestEntity mEntity = null;
public UploadRemoteFileOperation(String storagePath, String remotePath, String mimeType) { public UploadRemoteFileOperation(String localPath, String remotePath, String mimeType) {
mStoragePath = storagePath; mLocalPath = localPath;
mRemotePath = remotePath; mRemotePath = remotePath;
mMimeType = mimeType; mMimeType = mimeType;
} }
@ -106,7 +106,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
protected int uploadFile(OwnCloudClient client) throws HttpException, IOException, OperationCancelledException { protected int uploadFile(OwnCloudClient client) throws HttpException, IOException, OperationCancelledException {
int status = -1; int status = -1;
try { try {
File f = new File(mStoragePath); File f = new File(mLocalPath);
mEntity = new FileRequestEntity(f, mMimeType); mEntity = new FileRequestEntity(f, mMimeType);
synchronized (mDataTransferListeners) { synchronized (mDataTransferListeners) {
((ProgressiveDataTransferer)mEntity).addDatatransferProgressListeners(mDataTransferListeners); ((ProgressiveDataTransferer)mEntity).addDatatransferProgressListeners(mDataTransferListeners);

View File

@ -57,7 +57,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
private ArrayList<OCShare> mShares; // List of shares for result, one share in this case private ArrayList<OCShare> mShares; // List of shares for result, one share in this case
private String mPath; private String mRemoteFilePath;
private ShareType mShareType; private ShareType mShareType;
private String mShareWith; private String mShareWith;
private boolean mPublicUpload; private boolean mPublicUpload;
@ -66,26 +66,26 @@ public class CreateRemoteShareOperation extends RemoteOperation {
/** /**
* Constructor * Constructor
* @param path Full path of the file/folder being shared. Mandatory argument * @param remoteFilePath Full path of the file/folder being shared. Mandatory argument
* @param shareType 0 = user, 1 = group, 3 = Public link. Mandatory argument * @param shareType 0 = user, 1 = group, 3 = Public link. Mandatory argument
* @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1 * @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1
* @param publicUpload If false (default) public cannot upload to a public shared folder. * @param publicUpload If false (default) public cannot upload to a public shared folder.
* If true public can upload to a shared folder. Only available for public link shares * If true public can upload to a shared folder. Only available for public link shares
* @param password Password to protect a public link share. Only available for public link shares * @param password Password to protect a public link share. Only available for public link shares
* @param permissions 1 - Read only Default for public shares * @param permissions 1 - Read only Default for public shares
* 2 - Update * 2 - Update
* 4 - Create * 4 - Create
* 8 - Delete * 8 - Delete
* 16- Re-share * 16- Re-share
* 31- All above Default for private shares * 31- All above Default for private shares
* For user or group shares. * For user or group shares.
* To obtain combinations, add the desired values together. * To obtain combinations, add the desired values together.
* For instance, for Re-Share, delete, read, update, add 16+8+2+1 = 27. * For instance, for Re-Share, delete, read, update, add 16+8+2+1 = 27.
*/ */
public CreateRemoteShareOperation(String path, ShareType shareType, String shareWith, boolean publicUpload, public CreateRemoteShareOperation(String remoteFilePath, ShareType shareType, String shareWith, boolean publicUpload,
String password, int permissions) { String password, int permissions) {
mPath = path; mRemoteFilePath = remoteFilePath;
mShareType = shareType; mShareType = shareType;
mShareWith = shareWith; mShareWith = shareWith;
mPublicUpload = publicUpload; mPublicUpload = publicUpload;
@ -102,11 +102,11 @@ public class CreateRemoteShareOperation extends RemoteOperation {
try { try {
// Post Method // Post Method
post = new PostMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); post = new PostMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH);
post.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); // necessary for special characters post.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); // necessary for special characters
post.addParameter(PARAM_PATH, mPath); post.addParameter(PARAM_PATH, mRemoteFilePath);
post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue())); post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue()));
post.addParameter(PARAM_SHARE_WITH, mShareWith); post.addParameter(PARAM_SHARE_WITH, mShareWith);
post.addParameter(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload)); post.addParameter(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload));

View File

@ -58,21 +58,21 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation {
private ArrayList<OCShare> mShares; // List of shares for result, one share in this case private ArrayList<OCShare> mShares; // List of shares for result, one share in this case
private String mPath; private String mRemoteFilePath;
private boolean mReshares; private boolean mReshares;
private boolean mSubfiles; private boolean mSubfiles;
/** /**
* Constructor * Constructor
* *
* @param path Path to file or folder * @param remoteFilePath Path to file or folder
* @param reshares If set to false (default), only shares from the current user are returned * @param reshares If set to false (default), only shares from the current user are returned
* If set to true, all shares from the given file are returned * If set to true, all shares from the given file are returned
* @param subfiles If set to false (default), lists only the folder being shared * @param subfiles If set to false (default), lists only the folder being shared
* If set to true, all shared files within the folder are returned. * If set to true, all shared files within the folder are returned.
*/ */
public GetRemoteSharesForFileOperation(String path, boolean reshares, boolean subfiles) { public GetRemoteSharesForFileOperation(String remoteFilePath, boolean reshares, boolean subfiles) {
mPath = path; mRemoteFilePath = remoteFilePath;
mReshares = reshares; mReshares = reshares;
mSubfiles = subfiles; mSubfiles = subfiles;
} }
@ -86,12 +86,12 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation {
try { try {
// Get Method // Get Method
get = new GetMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH);
// Add Parameters to Get Method // Add Parameters to Get Method
get.setQueryString(new NameValuePair[] { get.setQueryString(new NameValuePair[] {
new NameValuePair(PARAM_PATH, mPath), new NameValuePair(PARAM_PATH, mRemoteFilePath),
new NameValuePair(PARAM_RESHARES, String.valueOf(mReshares)), new NameValuePair(PARAM_RESHARES, String.valueOf(mReshares)),
new NameValuePair(PARAM_SUBFILES, String.valueOf(mSubfiles)) new NameValuePair(PARAM_SUBFILES, String.valueOf(mSubfiles))
}); });

View File

@ -66,8 +66,8 @@ public class GetRemoteSharesOperation extends RemoteOperation {
// Get the response // Get the response
try{ try{
get = new GetMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE); Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH);
status = client.executeMethod(get); status = client.executeMethod(get);
if(isSuccess(status)) { if(isSuccess(status)) {
Log.d(TAG, "Obtain RESPONSE"); Log.d(TAG, "Obtain RESPONSE");

View File

@ -34,6 +34,6 @@ package com.owncloud.android.lib.resources.shares;
public class ShareUtils { public class ShareUtils {
// OCS Route // OCS Route
public static final String SHAREAPI_ROUTE ="/ocs/v1.php/apps/files_sharing/api/v1/shares"; public static final String SHARING_API_PATH ="/ocs/v1.php/apps/files_sharing/api/v1/shares";
} }

View File

@ -33,7 +33,6 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.common.accounts.AccountUtils;
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.operations.RemoteOperationResult.ResultCode;
import android.content.Context; import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;