mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-19 04:13:07 +00:00
Refactor parameter user_agent out of RemoteOperation and children
This commit is contained in:
@@ -75,7 +75,6 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
|
||||
}
|
||||
mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
|
||||
mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
|
||||
mPutMethod.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
((ChunkFromFileChannelRequestEntity)mEntity).setOffset(offset);
|
||||
mPutMethod.setRequestEntity(mEntity);
|
||||
status = client.executeMethod(mPutMethod);
|
||||
|
||||
@@ -78,8 +78,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
result = createFolder(client);
|
||||
if (!result.isSuccess() && mCreateFullPath &&
|
||||
RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) {
|
||||
result = createParentFolder(FileUtils.getParentPath(mRemotePath), client,
|
||||
getUserAgent());
|
||||
result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
|
||||
if (result.isSuccess()) {
|
||||
result = createFolder(client); // second (and last) try
|
||||
}
|
||||
@@ -98,7 +97,6 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
MkColMethod mkcol = null;
|
||||
try {
|
||||
mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
mkcol.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
|
||||
result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
|
||||
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
|
||||
@@ -115,11 +113,10 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
return result;
|
||||
}
|
||||
|
||||
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client,
|
||||
String userAgent) {
|
||||
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) {
|
||||
RemoteOperation operation = new CreateRemoteFolderOperation(parentPath,
|
||||
mCreateFullPath);
|
||||
return operation.execute(client, userAgent);
|
||||
return operation.execute(client);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
||||
int status = -1;
|
||||
boolean savedFile = false;
|
||||
mGet = new GetMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
mGet.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
Iterator<OnDatatransferProgressListener> it = null;
|
||||
|
||||
FileOutputStream fos = null;
|
||||
|
||||
@@ -77,7 +77,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
|
||||
HeadMethod head = null;
|
||||
try {
|
||||
head = new HeadMethod(client.getWebdavUri() + WebdavUtils.encodePath(mPath));
|
||||
head.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(head, TIMEOUT, TIMEOUT);
|
||||
client.exhaustResponse(head.getResponseBodyAsStream());
|
||||
boolean success = (status == HttpStatus.SC_OK && !mSuccessIfAbsent) ||
|
||||
|
||||
@@ -113,7 +113,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {
|
||||
client.getWebdavUri() + WebdavUtils.encodePath(mTargetRemotePath),
|
||||
mOverwrite
|
||||
);
|
||||
move.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(move, MOVE_READ_TIMEOUT, MOVE_CONNECTION_TIMEOUT);
|
||||
|
||||
/// process response
|
||||
|
||||
@@ -79,7 +79,6 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
||||
propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||
WebdavUtils.getFilePropSet(), // PropFind Properties
|
||||
DavConstants.DEPTH_0);
|
||||
propfind.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status;
|
||||
status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
|
||||
query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||
WebdavUtils.getAllPropSet(), // PropFind Properties
|
||||
DavConstants.DEPTH_1);
|
||||
query.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(query);
|
||||
|
||||
// check and process response
|
||||
|
||||
@@ -68,7 +68,6 @@ public class RemoveRemoteFileOperation extends RemoteOperation {
|
||||
|
||||
try {
|
||||
delete = new DeleteMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||
delete.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT);
|
||||
|
||||
delete.getResponseBodyAsString(); // exhaust the response, although not interesting
|
||||
|
||||
@@ -107,7 +107,6 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
||||
move = new LocalMoveMethod( client.getWebdavUri() +
|
||||
WebdavUtils.encodePath(mOldRemotePath),
|
||||
client.getWebdavUri() + WebdavUtils.encodePath(mNewRemotePath));
|
||||
move.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT);
|
||||
|
||||
move.getResponseBodyAsString(); // exhaust response, although not interesting
|
||||
|
||||
@@ -82,7 +82,6 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
||||
} else {
|
||||
mPutMethod = new PutMethod(client.getWebdavUri() +
|
||||
WebdavUtils.encodePath(mRemotePath));
|
||||
mPutMethod.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
|
||||
post.setRequestHeader( "Content-Type",
|
||||
"application/x-www-form-urlencoded; charset=utf-8"); // necessary for special characters
|
||||
post.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
post.addParameter(PARAM_PATH, mRemoteFilePath);
|
||||
post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue()));
|
||||
|
||||
@@ -86,7 +86,6 @@ public class GetRemoteSharesForFileOperation extends RemoteOperation {
|
||||
try {
|
||||
// Get Method
|
||||
get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
// Add Parameters to Get Method
|
||||
get.setQueryString(new NameValuePair[] {
|
||||
|
||||
@@ -67,7 +67,6 @@ public class GetRemoteSharesOperation extends RemoteOperation {
|
||||
try{
|
||||
get = new GetMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
status = client.executeMethod(get);
|
||||
if(isSuccess(status)) {
|
||||
String response = get.getResponseBodyAsString();
|
||||
|
||||
@@ -72,7 +72,6 @@ public class RemoveRemoteShareOperation extends RemoteOperation {
|
||||
delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH + id);
|
||||
|
||||
delete.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
delete.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
status = client.executeMethod(delete);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.net.ConnectivityManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -77,10 +78,10 @@ public class GetRemoteStatusOperation extends RemoteOperation {
|
||||
String baseUrlSt = client.getBaseUri().toString();
|
||||
try {
|
||||
get = new GetMethod(baseUrlSt + AccountUtils.STATUS_PATH);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
|
||||
HttpParams params = get.getParams().getDefaultParams();
|
||||
params.setParameter(HttpMethodParams.USER_AGENT, getUserAgent());
|
||||
params.setParameter(HttpMethodParams.USER_AGENT,
|
||||
OwnCloudClientManagerFactory.getUserAgent());
|
||||
get.getParams().setDefaults(params);
|
||||
|
||||
client.setFollowRedirects(false);
|
||||
|
||||
@@ -79,7 +79,6 @@ public class GetRemoteUserNameOperation extends RemoteOperation {
|
||||
try {
|
||||
get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
||||
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
get.addRequestHeader(USER_AGENT_HEADER, getUserAgent());
|
||||
status = client.executeMethod(get);
|
||||
if(isSuccess(status)) {
|
||||
String response = get.getResponseBodyAsString();
|
||||
|
||||
Reference in New Issue
Block a user