Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2025 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android;
Expand Down Expand Up @@ -265,7 +266,7 @@ public void after() {

private void removeOnClient(OwnCloudClient client) {
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
assertTrue(result.getLogMessage(), result.isSuccess());
assertTrue(result.getLogMessage(context), result.isSuccess());

for (Object object : result.getData()) {
RemoteFile remoteFile = (RemoteFile) object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
* SPDX-FileCopyrightText: 2014 Jorge Antonio Diaz-Benito Soriano <jorge.diazbenitosoriano@gmail.com>
* SPDX-FileCopyrightText: 2014-2016 Juan Carlos González Cabrero <malkomich@gmail.com>
* SPDX-FileCopyrightText: 2014 jabarros <jabarros@solidgear.es>
* SPDX-FileCopyrightText: 2025 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.common.operations;

import android.accounts.Account;
import android.accounts.AccountsException;
import android.content.Context;
import android.os.Build;
import android.system.ErrnoException;
import android.system.OsConstants;

import androidx.annotation.NonNull;

import com.nextcloud.common.OkHttpMethodBase;
import com.owncloud.android.lib.R;
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
import com.owncloud.android.lib.common.network.CertificateCombinedException;
import com.owncloud.android.lib.common.utils.Log_OC;
Expand Down Expand Up @@ -576,6 +581,8 @@ private CertificateCombinedException getCertificateCombinedException(Exception e
return result;
}

// use getLogMessage(Context)
@Deprecated
public String getLogMessage() {

if (mException != null) {
Expand Down Expand Up @@ -670,6 +677,100 @@ public String getLogMessage() {

}

public String getLogMessage(@NonNull Context context) {

if (mException != null) {
if (mException instanceof OperationCancelledException) {
return context.getString(R.string.operation_cancelled);

} else if (mException instanceof SocketException) {
return context.getString(R.string.socket_exception);

} else if (mException instanceof SocketTimeoutException) {
return context.getString(R.string.socket_timeout_exception);

} else if (mException instanceof ConnectTimeoutException) {
return context.getString(R.string.connect_timeout_exception);

} else if (mException instanceof MalformedURLException) {
return context.getString(R.string.malformed_url_exception);

} else if (mException instanceof UnknownHostException) {
return context.getString(R.string.unknown_host_exception);

} else if (mException instanceof CertificateCombinedException) {
if (((CertificateCombinedException) mException).isRecoverable()) {
return context.getString(R.string.ssl_recoverable_exception);
} else {
return context.getString(R.string.ssl_exception);
}

} else if (mException instanceof SSLException) {
return context.getString(R.string.ssl_exception);

} else if (mException instanceof DavException) {
return context.getString(R.string.unexpected_webdav_exception);

} else if (mException instanceof HttpException) {
return context.getString(R.string.http_violation);

} else if (mException instanceof IOException) {
return context.getString(R.string.unrecovered_transport_exception);

} else if (mException instanceof AccountNotFoundException) {
Account failedAccount = ((AccountNotFoundException) mException).getFailedAccount();
return mException.getMessage() + " (" +
(failedAccount != null ? failedAccount.name : "NULL") + ")";

} else if (mException instanceof AccountsException) {
return context.getString(R.string.exception_using_account);

} else if (mException instanceof JSONException) {
return context.getString(R.string.json_exception);

} else {
return context.getString(R.string.unexpected_exception);
}
}

if (mCode == ResultCode.INSTANCE_NOT_CONFIGURED) {
return context.getString(R.string.instance_not_configured);

} else if (mCode == ResultCode.NO_NETWORK_CONNECTION) {
return context.getString(R.string.no_network_connection);

} else if (mCode == ResultCode.BAD_OC_VERSION) {
return context.getString(R.string.bad_oc_version);

} else if (mCode == ResultCode.LOCAL_STORAGE_FULL) {
return context.getString(R.string.local_storage_full);

} else if (mCode == ResultCode.LOCAL_STORAGE_NOT_MOVED) {
return context.getString(R.string.local_storage_not_moved);

} else if (mCode == ResultCode.ACCOUNT_NOT_NEW) {
return context.getString(R.string.account_not_new);

} else if (mCode == ResultCode.ACCOUNT_NOT_THE_SAME) {
return context.getString(R.string.account_not_the_same);

} else if (mCode == ResultCode.INVALID_CHARACTER_IN_NAME) {
return context.getString(R.string.invalid_character_in_name);

} else if (mCode == ResultCode.FILE_NOT_FOUND) {
return context.getString(R.string.file_not_found);

} else if (mCode == ResultCode.SYNC_CONFLICT) {
return context.getString(R.string.sync_conflict);

} else if (mCode == ResultCode.LOCKED) {
return context.getString(R.string.file_locked);
}

return context.getString(R.string.operation_finished_http_code, mHttpCode, isSuccess() ? "success" : "fail");
}


public boolean isServerFail() {
return (mHttpCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
Expand Down
27 changes: 27 additions & 0 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
~
~ SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
~ SPDX-FileCopyrightText: 2015 ownCloud Inc.
~ SPDX-FileCopyrightText: 2025 TSI-mc <surinder.kumar@t-systems.com>
~ SPDX-License-Identifier: MIT
-->
<resources>
Expand All @@ -13,4 +14,30 @@
<string name="notification_title_select_client_cert">Select client certificate</string>
<string name="notification_message_select_client_cert">Select client certificate for %1$s:%2$d</string>
<string name="operation_cancelled_by_the_caller">Operation cancelled by the caller</string>
<string name="operation_cancelled">Operation cancelled by the caller</string>
<string name="socket_exception">Socket exception</string>
<string name="socket_timeout_exception">Socket timeout exception</string>
<string name="connect_timeout_exception">Connect timeout exception</string>
<string name="malformed_url_exception">Malformed URL exception</string>
<string name="unknown_host_exception">Unknown host exception</string>
<string name="ssl_recoverable_exception">SSL recoverable exception</string>
<string name="ssl_exception">SSL exception</string>
<string name="unexpected_webdav_exception">Unexpected WebDAV exception</string>
<string name="http_violation">HTTP violation</string>
<string name="unrecovered_transport_exception">Unrecovered transport exception</string>
<string name="exception_using_account">Exception while using account</string>
<string name="json_exception">JSON exception</string>
<string name="unexpected_exception">Unexpected exception</string>
<string name="instance_not_configured">The Nextcloud server is not configured!</string>
<string name="no_network_connection">No network connection</string>
<string name="bad_oc_version">No valid Nextcloud version was found at the server</string>
<string name="local_storage_full">Local storage full</string>
<string name="local_storage_not_moved">Error while moving file to final directory</string>
<string name="account_not_new">Account already existing when creating a new one</string>
<string name="account_not_the_same">Authenticated with a different account than the one updating</string>
<string name="invalid_character_in_name">The file name contains a forbidden character</string>
<string name="file_not_found">Local file does not exist</string>
<string name="sync_conflict">Synchronization conflict</string>
<string name="file_locked">File is currently locked by another user or process</string>
<string name="operation_finished_http_code">Operation finished with HTTP status code %1$d (%2$s)</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2015 ownCloud Inc.
* SPDX-FileCopyrightText: 2015 David A. Velasco <dvelasco@solidgear.es>
* SPDX-FileCopyrightText: 2025 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: MIT
*/
package com.owncloud.android.lib.sampleclient;
Expand Down Expand Up @@ -195,7 +196,7 @@ private void startLocalDeletion() {
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
if (!result.isSuccess()) {
Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
Log.e(TAG, result.getLogMessage(), result.getException());
Log.e(TAG, result.getLogMessage(this), result.getException());

} else if (operation instanceof ReadFolderRemoteOperation) {
onSuccessfulRefresh((ReadFolderRemoteOperation) operation, result);
Expand Down
Loading