77 */
88package com .owncloud .android .lib .resources .e2ee ;
99
10- import com .owncloud .android .lib .common .OwnCloudClient ;
10+ import com .nextcloud .common .NextcloudClient ;
11+ import com .nextcloud .operations .GetMethod ;
1112import com .owncloud .android .lib .common .operations .RemoteOperation ;
1213import com .owncloud .android .lib .common .operations .RemoteOperationResult ;
1314import com .owncloud .android .lib .common .utils .Log_OC ;
1415
15- import org .apache .commons .httpclient .Header ;
1616import org .apache .commons .httpclient .HttpStatus ;
17- import org .apache .commons .httpclient .methods .GetMethod ;
1817import org .json .JSONObject ;
1918
2019
2524public class GetMetadataRemoteOperation extends RemoteOperation <MetadataResponse > {
2625
2726 private static final String TAG = GetMetadataRemoteOperation .class .getSimpleName ();
28- private static final int SYNC_READ_TIMEOUT = 40000 ;
29- private static final int SYNC_CONNECTION_TIMEOUT = 5000 ;
3027 private static final String METADATA_V1_URL = "/ocs/v2.php/apps/end_to_end_encryption/api/v1/meta-data/" ;
3128 private static final String METADATA_V2_URL = "/ocs/v2.php/apps/end_to_end_encryption/api/v2/meta-data/" ;
3229
@@ -49,32 +46,29 @@ public GetMetadataRemoteOperation(long fileId) {
4946 * @param client Client object
5047 */
5148 @ Override
52- protected RemoteOperationResult <MetadataResponse > run (OwnCloudClient client ) {
53- GetMethod getMethod = null ;
49+ public RemoteOperationResult <MetadataResponse > run (NextcloudClient client ) {
50+ com . nextcloud . operations . GetMethod getMethod = null ;
5451 RemoteOperationResult <MetadataResponse > result ;
5552
5653 try {
5754 // remote request
58- getMethod = new GetMethod (client .getBaseUri () + METADATA_V2_URL + fileId + JSON_FORMAT );
59- getMethod .addRequestHeader (OCS_API_HEADER , OCS_API_HEADER_VALUE );
55+ getMethod = new com .nextcloud .operations .GetMethod (client .getBaseUri () + METADATA_V2_URL + fileId + JSON_FORMAT , true );
6056
61- int status = client .executeMethod (getMethod , SYNC_READ_TIMEOUT , SYNC_CONNECTION_TIMEOUT );
57+ int status = client .execute (getMethod );
6258
6359 if (status == HttpStatus .SC_NOT_FOUND || status == HttpStatus .SC_INTERNAL_SERVER_ERROR ) {
6460 // retry with v1
65- getMethod = new GetMethod (client .getBaseUri () + METADATA_V1_URL + fileId + JSON_FORMAT );
66- getMethod .addRequestHeader (OCS_API_HEADER , OCS_API_HEADER_VALUE );
61+ getMethod = new GetMethod (client .getBaseUri () + METADATA_V1_URL + fileId + JSON_FORMAT , true );
6762
68- status = client .executeMethod (getMethod , SYNC_READ_TIMEOUT , SYNC_CONNECTION_TIMEOUT );
63+ status = client .execute (getMethod );
6964 }
7065
7166 if (status == HttpStatus .SC_OK ) {
7267 String response = getMethod .getResponseBodyAsString ();
73- Header signatureHeader = getMethod .getResponseHeader (HEADER_SIGNATURE );
68+ String signature = getMethod .getResponseHeader (HEADER_SIGNATURE );
7469
75- String signature = "" ;
76- if (signatureHeader != null ) {
77- signature = signatureHeader .getValue ();
70+ if (signature == null ) {
71+ signature = "" ;
7872 }
7973
8074 // Parse the response
@@ -90,7 +84,6 @@ protected RemoteOperationResult<MetadataResponse> run(OwnCloudClient client) {
9084 result .setResultData (metadataResponse );
9185 } else {
9286 result = new RemoteOperationResult <>(false , getMethod );
93- client .exhaustResponse (getMethod .getResponseBodyAsStream ());
9487 }
9588 } catch (Exception e ) {
9689 result = new RemoteOperationResult <>(e );
0 commit comments