OC-2746: Changes from comments: new method to construct base url server

This commit is contained in:
masensio 2014-01-28 14:41:38 +01:00
parent 36d4f3d465
commit d963d702fb
6 changed files with 24 additions and 19 deletions

@ -1 +1 @@
Subproject commit 7b5d6cdef791cd27a573fcaa9c8214970753843c
Subproject commit b4d67521b24bbd517cc1c91b37715ad650688bc3

View file

@ -934,7 +934,7 @@ public class FileDataStorageManager {
return shareExists(ProviderTableMeta.OCSHARES_PATH, path);
}
public void cleanShare() {
public void cleanShares() {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
@ -952,5 +952,13 @@ public class FileDataStorageManager {
Log_OC.e(TAG, "Exception in cleanShareFile" + e.getMessage());
}
}
}
public void saveFiles(ArrayList<OCFile> sharedFiles) {
if (sharedFiles != null) {
cleanShares();
}
}
}

View file

@ -39,24 +39,22 @@ public class GetSharesOperation extends RemoteOperation {
private static final String TAG = GetSharesOperation.class.getSimpleName();
private String mUrlServer;
protected FileDataStorageManager mStorageManager;
public GetSharesOperation(String urlServer, FileDataStorageManager storageManager) {
mUrlServer = urlServer;
public GetSharesOperation(FileDataStorageManager storageManager) {
mStorageManager = storageManager;
}
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
GetRemoteSharesOperation operation = new GetRemoteSharesOperation(mUrlServer);
GetRemoteSharesOperation operation = new GetRemoteSharesOperation(client.getBaseUri().toString());
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {
// Clean Share data in filelist table
mStorageManager.cleanShare();
mStorageManager.cleanShares();
// Update DB with the response
Log_OC.d(TAG, "Share list size = " + result.getData().size());

View file

@ -70,7 +70,7 @@ public class OAuth2GetAccessToken extends RemoteOperation {
nameValuePairs[3] = new NameValuePair(OAuth2Constants.KEY_CLIENT_ID, mClientId);
//nameValuePairs[4] = new NameValuePair(OAuth2Constants.KEY_SCOPE, mOAuth2ParsedAuthorizationResponse.get(OAuth2Constants.KEY_SCOPE));
postMethod = new PostMethod(client.getBaseUri().toString());
postMethod = new PostMethod(client.getWebdavUri().toString());
postMethod.setRequestBody(nameValuePairs);
int status = client.executeMethod(postMethod);
@ -99,16 +99,16 @@ public class OAuth2GetAccessToken extends RemoteOperation {
postMethod.releaseConnection(); // let the connection available for other methods
if (result.isSuccess()) {
Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getBaseUri() + ": " + result.getLogMessage());
Log_OC.i(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
} else if (result.getException() != null) {
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getBaseUri() + ": " + result.getLogMessage(), result.getException());
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage(), result.getException());
} else if (result.getCode() == ResultCode.OAUTH2_ERROR) {
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getBaseUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + ((mResultTokenMap != null) ? mResultTokenMap.get(OAuth2Constants.KEY_ERROR) : "NULL"));
} else {
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getBaseUri() + ": " + result.getLogMessage());
Log_OC.e(TAG, "OAuth2 TOKEN REQUEST with auth code " + mOAuth2ParsedAuthorizationResponse.get("code") + " to " + client.getWebdavUri() + ": " + result.getLogMessage());
}
}

View file

@ -90,15 +90,15 @@ public class UpdateOCVersionOperation extends RemoteOperation {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
}
}
Log_OC.i(TAG, "Check for update of ownCloud server version at " + client.getBaseUri() + ": " + result.getLogMessage());
Log_OC.i(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage());
} catch (JSONException e) {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getBaseUri() + ": " + result.getLogMessage(), e);
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e);
} catch (Exception e) {
result = new RemoteOperationResult(e);
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getBaseUri() + ": " + result.getLogMessage(), e);
Log_OC.e(TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e);
} finally {
if (get != null)

View file

@ -73,6 +73,8 @@ import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.GetSharesOperation;
import com.owncloud.android.lib.accounts.OwnCloudAccount;
import com.owncloud.android.lib.network.OwnCloudClient;
import com.owncloud.android.lib.network.OwnCloudClientFactory;
import com.owncloud.android.lib.operations.common.OnRemoteOperationListener;
import com.owncloud.android.lib.operations.common.RemoteOperation;
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
@ -1519,10 +1521,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
private void startGetShares() {
// Get shared files/folders
AccountManager accountMngr = AccountManager.get(this);
String urlServer = accountMngr.getUserData(getAccount(), OwnCloudAccount.Constants.KEY_OC_BASE_URL);
RemoteOperation getShares = new GetSharesOperation(urlServer, mStorageManager);
RemoteOperation getShares = new GetSharesOperation(mStorageManager);
getShares.execute(getAccount(), this, this, mHandler, this);
}