Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit bec5643

Browse files
committed
Include services implementation so that can be used by library users
1 parent cf06126 commit bec5643

File tree

12 files changed

+285
-6
lines changed

12 files changed

+285
-6
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileService.kt renamed to owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* THE SOFTWARE.
2222
*
2323
*/
24-
package com.owncloud.android.lib.resources.files
24+
package com.owncloud.android.lib.resources.files.services
2525

2626
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2727
import com.owncloud.android.lib.resources.Service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author Abel García de Prada
5+
* Copyright (C) 2020 ownCloud GmbH.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2,
9+
* as published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.owncloud.android.lib.resources.files.services.implementation
21+
22+
import com.owncloud.android.lib.common.OwnCloudClient
23+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
24+
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
25+
import com.owncloud.android.lib.resources.files.services.FileService
26+
27+
class OCFileService(override val client: OwnCloudClient) :
28+
FileService {
29+
override fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> =
30+
CheckPathExistenceRemoteOperation(
31+
remotePath = path,
32+
isUserLogged = isUserLogged
33+
).execute(client)
34+
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt renamed to owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/services/ShareService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
package com.owncloud.android.lib.resources.shares
21+
package com.owncloud.android.lib.resources.shares.services
2222

2323
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2424
import com.owncloud.android.lib.resources.Service
25+
import com.owncloud.android.lib.resources.shares.ShareParserResult
26+
import com.owncloud.android.lib.resources.shares.ShareType
2527

2628
interface ShareService : Service {
2729
fun getShares(

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt renamed to owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/services/ShareeService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
package com.owncloud.android.lib.resources.shares
21+
package com.owncloud.android.lib.resources.shares.services
2222

2323
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2424
import com.owncloud.android.lib.resources.Service
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author David González Verdugo
5+
*
6+
* Copyright (C) 2020 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
* <p>
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.lib.resources.shares.services.implementation
22+
23+
import com.owncloud.android.lib.common.OwnCloudClient
24+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
25+
import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation
26+
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation
27+
import com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation
28+
import com.owncloud.android.lib.resources.shares.ShareParserResult
29+
import com.owncloud.android.lib.resources.shares.ShareType
30+
import com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation
31+
import com.owncloud.android.lib.resources.shares.services.ShareService
32+
33+
class OCShareService(override val client: OwnCloudClient) :
34+
ShareService {
35+
override fun getShares(
36+
remoteFilePath: String,
37+
reshares: Boolean,
38+
subfiles: Boolean
39+
): RemoteOperationResult<ShareParserResult> = GetRemoteSharesForFileOperation(
40+
remoteFilePath,
41+
reshares,
42+
subfiles
43+
).execute(client)
44+
45+
override fun insertShare(
46+
remoteFilePath: String,
47+
shareType: ShareType,
48+
shareWith: String,
49+
permissions: Int,
50+
name: String,
51+
password: String,
52+
expirationDate: Long,
53+
publicUpload: Boolean
54+
): RemoteOperationResult<ShareParserResult> =
55+
CreateRemoteShareOperation(
56+
remoteFilePath,
57+
shareType,
58+
shareWith,
59+
permissions
60+
).apply {
61+
this.name = name
62+
this.password = password
63+
this.expirationDateInMillis = expirationDate
64+
this.publicUpload = publicUpload
65+
this.retrieveShareDetails = true
66+
}.execute(client)
67+
68+
override fun updateShare(
69+
remoteId: Long,
70+
name: String,
71+
password: String?,
72+
expirationDate: Long,
73+
permissions: Int,
74+
publicUpload: Boolean
75+
): RemoteOperationResult<ShareParserResult> =
76+
UpdateRemoteShareOperation(
77+
remoteId
78+
).apply {
79+
this.name = name
80+
this.password = password
81+
this.expirationDateInMillis = expirationDate
82+
this.permissions = permissions
83+
this.publicUpload = publicUpload
84+
this.retrieveShareDetails = true
85+
}.execute(client)
86+
87+
override fun deleteShare(remoteId: Long): RemoteOperationResult<ShareParserResult> =
88+
RemoveRemoteShareOperation(
89+
remoteId
90+
).execute(client)
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author David González Verdugo
5+
*
6+
* Copyright (C) 2020 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
* <p>
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.lib.resources.shares.services.implementation
22+
23+
import com.owncloud.android.lib.common.OwnCloudClient
24+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
25+
import com.owncloud.android.lib.resources.shares.GetRemoteShareesOperation
26+
import com.owncloud.android.lib.resources.shares.services.ShareeService
27+
import org.json.JSONObject
28+
import java.util.ArrayList
29+
30+
class OCShareeService(override val client: OwnCloudClient) :
31+
ShareeService {
32+
override fun getSharees(
33+
searchString: String,
34+
page: Int,
35+
perPage: Int
36+
): RemoteOperationResult<ArrayList<JSONObject>> =
37+
GetRemoteShareesOperation(
38+
searchString,
39+
page,
40+
perPage
41+
).execute(client)
42+
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt renamed to owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/services/CapabilityService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
package com.owncloud.android.lib.resources.status
21+
package com.owncloud.android.lib.resources.status.services
2222

2323
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2424
import com.owncloud.android.lib.resources.Service
25+
import com.owncloud.android.lib.resources.status.RemoteCapability
2526

2627
interface CapabilityService: Service {
2728
fun getCapabilities() : RemoteOperationResult<RemoteCapability>

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/ServerInfoService.kt renamed to owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/services/ServerInfoService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* THE SOFTWARE.
2222
*
2323
*/
24-
package com.owncloud.android.lib.resources.status
24+
package com.owncloud.android.lib.resources.status.services
2525

2626
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2727
import com.owncloud.android.lib.resources.status.OwnCloudVersion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author David González Verdugo
5+
*
6+
* Copyright (C) 2020 ownCloud GmbH.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.owncloud.android.lib.resources.status.services.implementation
22+
23+
import com.owncloud.android.lib.common.OwnCloudClient
24+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
25+
import com.owncloud.android.lib.resources.status.services.CapabilityService
26+
import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation
27+
import com.owncloud.android.lib.resources.status.RemoteCapability
28+
29+
class OCCapabilityService(override val client: OwnCloudClient) :
30+
CapabilityService {
31+
override fun getCapabilities(): RemoteOperationResult<RemoteCapability> =
32+
GetRemoteCapabilitiesOperation().execute(client)
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* ownCloud Android client application
3+
*
4+
* @author Abel García de Prada
5+
* Copyright (C) 2020 ownCloud GmbH.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2,
9+
* as published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.owncloud.android.lib.resources.status.services.implementation
21+
22+
import android.net.Uri
23+
import com.owncloud.android.lib.common.OwnCloudClient
24+
import com.owncloud.android.lib.common.operations.RemoteOperationResult
25+
import com.owncloud.android.lib.resources.status.services.ServerInfoService
26+
import com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation
27+
import com.owncloud.android.lib.resources.status.GetRemoteStatusOperation
28+
import com.owncloud.android.lib.resources.status.OwnCloudVersion
29+
30+
class OCServerInfoService : ServerInfoService {
31+
override fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> =
32+
CheckPathExistenceRemoteOperation(
33+
remotePath = path,
34+
isUserLogged = true
35+
).execute(createClientFromPath(path))
36+
37+
override fun getRemoteStatus(path: String): RemoteOperationResult<OwnCloudVersion> =
38+
GetRemoteStatusOperation().execute(createClientFromPath(path))
39+
40+
private fun createClientFromPath(path: String): OwnCloudClient {
41+
return OwnCloudClient(Uri.parse(path))
42+
}
43+
}

0 commit comments

Comments
 (0)