Ver código fonte

test fullTextSearch

marinofaggiana 5 anos atrás
pai
commit
3c8de43aaa

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -962,7 +962,7 @@ typedef enum {
 
 #pragma mark - Fulltextsearch
 
-- (void)fullTextSearch:(NSString *)serverPath providers:(NSString *)providers text:(NSString *)text page:(NSInteger)page options:(NSString *)options size:(NSInteger)size onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
+- (void)fullTextSearch:(NSString *)serverPath data:(NSString *)data onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
 #pragma mark - Trash
 

+ 2 - 12
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -3077,22 +3077,12 @@
 
 #pragma mark - Fulltextsearch
 
-- (void)fullTextSearch:(NSString *)serverPath providers:(NSString *)providers text:(NSString *)text page:(NSInteger)page options:(NSString *)options size:(NSInteger)size onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
-    
-    serverPath = [serverPath stringByAppendingString:k_url_fulltextsearch];
-    serverPath = [NSString stringWithFormat:@"?providers:%@", providers];
-    serverPath = [NSString stringWithFormat:@"?search:%@", text];
-    serverPath = [NSString stringWithFormat:@"?page:%ld", (long) page];
-    serverPath = [NSString stringWithFormat:@"?options:%@", options];
-    serverPath = [NSString stringWithFormat:@"?size:%ld", (long) size];
-    serverPath = [serverPath stringByAppendingString:@"?format=json"];
+- (void)fullTextSearch:(NSString *)serverPath data:(NSString *)data onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer))successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
-    serverPath = [serverPath encodeString:NSUTF8StringEncoding];
-
     OCWebDAVClient *request = [[OCWebDAVClient alloc] init];
     request = [self getRequestWithCredentials:request];
     
-    [request fullTextSearch:serverPath onCommunication:sharedOCComunication success:^(NSHTTPURLResponse * _Nonnull operation, id  _Nonnull response) {
+    [request fullTextSearch:serverPath data:data onCommunication:sharedOCComunication success:^(NSHTTPURLResponse * _Nonnull operation, id  _Nonnull response) {
     
         NSData *responseData = (NSData*) response;
         

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCFrameworkConstants.h

@@ -84,7 +84,7 @@
 #define k_url_insert_assets_to_richdocuments @"apps/richdocuments/assets"
 
 //Url for fulltextsearch
-#define k_url_fulltextsearch @"apps/apps/fulltextsearch/v1/remote"
+#define k_url_fulltextsearch @"index.php/apps/fulltextsearch/v1/remote"
 
 //Version of the server that have share API
 #define k_version_support_shared [NSArray arrayWithObjects:  @"5", @"0", @"27", nil]

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.h

@@ -676,7 +676,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 #pragma mark - Fulltextsearch
 
-- (void)fullTextSearch:(NSString *)serverPath onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response))success failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure;
+- (void)fullTextSearch:(NSString *)serverPath data:(NSString *)data onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response))success failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure;
 
 #pragma mark - Trash
 

+ 3 - 2
iOSClient/Library/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -1289,7 +1289,7 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
 
 #pragma mark - Fulltextsearch
 
-- (void)fullTextSearch:(NSString *)serverPath onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response))success failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure {
+- (void)fullTextSearch:(NSString *)serverPath data:(NSString *)data onCommunication:(OCCommunication *)sharedOCCommunication success:(void(^)(NSHTTPURLResponse *operation, id response))success failure:(void(^)(NSHTTPURLResponse *operation, id  _Nullable responseObject, NSError *error))failure {
     
     NSParameterAssert(success);
     
@@ -1297,7 +1297,8 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil timeout:k_timeout_webdav];
     [request setValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
-    
+    [request setHTTPBody:[data dataUsingEncoding:NSUTF8StringEncoding]];
+
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];
     

+ 6 - 1
iOSClient/Main/CCMain.m

@@ -1316,6 +1316,12 @@
        
         if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
             
+            /*
+            [[OCNetworking sharedManager] fullTextSearchWithAccount:appDelegate.activeAccount text:_searchFileName page:1 completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
+                NSLog(@"x");
+            }];
+            */
+            
             _searchResultMetadatas = [[NSMutableArray alloc] initWithArray:metadatas];
             [self insertMetadatasWithAccount:appDelegate.activeAccount serverUrl:_serverUrl metadataFolder:nil metadatas:_searchResultMetadatas];
             
@@ -1863,7 +1869,6 @@
 
 - (void)readShareWithAccount:(NSString *)account openWindow:(BOOL)openWindow metadata:(tableMetadata *)metadata
 {
-    //[[OCNetworking sharedManager] readShareWithAccount:account completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
     [[OCNetworking sharedManager] readShareWithAccount:account path:@"/" completion:^(NSString *account, NSArray *items, NSString *message, NSInteger errorCode) {
         
         [_hud hideHud];

+ 8 - 2
iOSClient/Networking/OCNetworking.m

@@ -2346,13 +2346,19 @@
         completion(account, nil, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
     }
     
-    NSString *options = [NSString stringWithFormat:@"\"files_within_dir\": \"\", \"files_local\": \"\", \"files_extension\": \"\""];
+    // Create JSON
+    NSMutableDictionary *dataDic = [NSMutableDictionary new];
+    [dataDic setValue:@"files" forKey:@"providers"];
+    [dataDic setValue:text forKey:@"search"];
+    [dataDic setValue:[NSNumber numberWithInteger:page] forKey:@"page"];
+    [dataDic setValue:[NSNumber numberWithInt:20] forKey:@"size"];
+    NSString *data = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil] encoding:NSUTF8StringEncoding];
     
     OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
     
     [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
     [communication setUserAgent:[CCUtility getUserAgent]];
-    [communication fullTextSearch:[tableAccount.url stringByAppendingString:@"/"] providers:@"files" text:text page:page options:options size:20 onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
+    [communication fullTextSearch:[tableAccount.url stringByAppendingString:@"/"] data:data onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
         
         completion(account, items, nil, 0);