diff --git a/JaspersoftSDK.podspec b/JaspersoftSDK.podspec index 5ac2b5c..0fc1af1 100644 --- a/JaspersoftSDK.podspec +++ b/JaspersoftSDK.podspec @@ -49,6 +49,7 @@ Pod::Spec.new do |s| #import "JSConstants.h" #import "JSUtils.h" + #import "NSString+JSURLEncodings.h" #define _AFNETWORKING_PIN_SSL_CERTIFICATES_ #if __IPHONE_OS_VERSION_MIN_REQUIRED diff --git a/JaspersoftSDK.xcodeproj/project.pbxproj b/JaspersoftSDK.xcodeproj/project.pbxproj index 8c9f361..50d9ad0 100644 --- a/JaspersoftSDK.xcodeproj/project.pbxproj +++ b/JaspersoftSDK.xcodeproj/project.pbxproj @@ -140,6 +140,8 @@ BD0A8F061C7F646A00C63F44 /* JSMapping.h in Headers */ = {isa = PBXBuildFile; fileRef = BD0A8F041C7F646A00C63F44 /* JSMapping.h */; }; BD0A8F071C7F646A00C63F44 /* JSMapping.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0A8F051C7F646A00C63F44 /* JSMapping.m */; }; BD194F891C75D50100C99DA9 /* JSObjectMappingsProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = BD194F881C75D50100C99DA9 /* JSObjectMappingsProtocol.h */; }; + BD991C5A1CF76B5B00859145 /* NSString+JSURLEncodings.h in Headers */ = {isa = PBXBuildFile; fileRef = BD991C581CF76B5B00859145 /* NSString+JSURLEncodings.h */; }; + BD991C5B1CF76B5B00859145 /* NSString+JSURLEncodings.m in Sources */ = {isa = PBXBuildFile; fileRef = BD991C591CF76B5B00859145 /* NSString+JSURLEncodings.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -272,6 +274,8 @@ BD0A8F041C7F646A00C63F44 /* JSMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMapping.h; sourceTree = ""; }; BD0A8F051C7F646A00C63F44 /* JSMapping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSMapping.m; sourceTree = ""; }; BD194F881C75D50100C99DA9 /* JSObjectMappingsProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectMappingsProtocol.h; sourceTree = ""; }; + BD991C581CF76B5B00859145 /* NSString+JSURLEncodings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+JSURLEncodings.h"; sourceTree = ""; }; + BD991C591CF76B5B00859145 /* NSString+JSURLEncodings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+JSURLEncodings.m"; sourceTree = ""; }; F5758F3D174E301800C355C1 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; F5758F40174E302800C355C1 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; F5758F42174E302E00C355C1 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; @@ -485,6 +489,8 @@ 0849FCE81C2C1D7D008F1064 /* JSUtils.m */, A1478E5FF766BDE05BFDB838 /* JSDateFormatterFactory.h */, A1478F2F9E43E7F32310F7FB /* JSDateFormatterFactory.m */, + BD991C581CF76B5B00859145 /* NSString+JSURLEncodings.h */, + BD991C591CF76B5B00859145 /* NSString+JSURLEncodings.m */, ); path = JSHelper; sourceTree = ""; @@ -589,6 +595,7 @@ 0849FCD71C2B0A93008F1064 /* KeychainItemWrapper.h in Headers */, 0849FCCF1C2B0A92008F1064 /* JSRESTBase+JSRESTResource.h in Headers */, 0849FC951C2B0A91008F1064 /* JSExportExecutionRequest.h in Headers */, + BD991C5A1CF76B5B00859145 /* NSString+JSURLEncodings.h in Headers */, 0899C4451C2D8FEE00CFBD91 /* JSErrorBuilder.h in Headers */, 0849FCAE1C2B0A91008F1064 /* JSReportParameter.h in Headers */, 0849FCDD1C2B0A93008F1064 /* JSSecurity.h in Headers */, @@ -755,6 +762,7 @@ 0849FCEE1C2C1D7D008F1064 /* JSUtils.m in Sources */, 0849FCCC1C2B0A92008F1064 /* JSRequest.m in Sources */, 0849FCA31C2B0A91008F1064 /* JSOperationResult.m in Sources */, + BD991C5B1CF76B5B00859145 /* NSString+JSURLEncodings.m in Sources */, 0849FCB71C2B0A91008F1064 /* JSResourceReportUnit.m in Sources */, 0849FCAD1C2B0A91008F1064 /* JSReportOutputResource.m in Sources */, 0849FCAF1C2B0A91008F1064 /* JSReportParameter.m in Sources */, diff --git a/Sources/JSHelper/JSErrorBuilder.h b/Sources/JSHelper/JSErrorBuilder.h index 2c2a399..da583de 100644 --- a/Sources/JSHelper/JSErrorBuilder.h +++ b/Sources/JSHelper/JSErrorBuilder.h @@ -1,7 +1,36 @@ +/* + * TIBCO JasperMobile for iOS + * Copyright © 2005-2016 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + + // -// Created by Aleksandr Dakhno on 10/16/15. +// JSErrorBuilder.h +// TIBCO JasperMobile // +/** + @author Aleksandr Dakhno odahno@tibco.com + @since 2.3 + */ + #import #import "JSConstants.h" diff --git a/Sources/JSHelper/JSErrorBuilder.m b/Sources/JSHelper/JSErrorBuilder.m index 061f276..2bc4dde 100644 --- a/Sources/JSHelper/JSErrorBuilder.m +++ b/Sources/JSHelper/JSErrorBuilder.m @@ -1,5 +1,29 @@ +/* + * TIBCO JasperMobile for iOS + * Copyright © 2005-2016 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + + // -// Created by Aleksandr Dakhno on 10/16/15. +// JSErrorBuilder.m +// TIBCO JasperMobile // #import "JSErrorBuilder.h" diff --git a/Sources/JSHelper/JSHelper.h b/Sources/JSHelper/JSHelper.h index ebadb46..c4a4e39 100644 --- a/Sources/JSHelper/JSHelper.h +++ b/Sources/JSHelper/JSHelper.h @@ -31,4 +31,5 @@ #import "JSUtils.h" #import "JSConstants.h" #import "JSErrorBuilder.h" -#import "JSDateFormatterFactory.h" \ No newline at end of file +#import "JSDateFormatterFactory.h" +#import "NSString+JSURLEncodings.h" diff --git a/Sources/JSHelper/NSString+JSURLEncodings.h b/Sources/JSHelper/NSString+JSURLEncodings.h new file mode 100644 index 0000000..d78b698 --- /dev/null +++ b/Sources/JSHelper/NSString+JSURLEncodings.h @@ -0,0 +1,41 @@ +/* + * TIBCO JasperMobile for iOS + * Copyright © 2005-2016 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + + +// +// NSString(JSURLEncodings).h +// TIBCO JasperMobile +// + +/** + @author Alexey Gubarev ogubarie@tibco.com + @since 2.5 + */ + +#import + +@interface NSString(JSURLEncodings) + +- (nonnull NSString *)hostEncodedString; + +- (nonnull NSString *)queryEncodedString; +@end diff --git a/Sources/JSHelper/NSString+JSURLEncodings.m b/Sources/JSHelper/NSString+JSURLEncodings.m new file mode 100644 index 0000000..1860269 --- /dev/null +++ b/Sources/JSHelper/NSString+JSURLEncodings.m @@ -0,0 +1,50 @@ +/* + * TIBCO JasperMobile for iOS + * Copyright © 2005-2016 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-ios + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + + +// +// NSString(JSURLEncodings).m +// TIBCO JasperMobile +// + +#import "NSString+JSURLEncodings.h" + +@implementation NSString(JSURLEncodings) + +- (nonnull NSString *)hostEncodedString { + NSArray *components = [self componentsSeparatedByString:@"/"]; + NSMutableArray *encodedComponentsArray = [NSMutableArray array]; + for (NSString *component in components) { + [encodedComponentsArray addObject:[component encodedStringWithCharSet:[NSCharacterSet URLHostAllowedCharacterSet]]]; + } + return [encodedComponentsArray componentsJoinedByString:@"/"]; +} + +- (nonnull NSString *)queryEncodedString { + return [self encodedStringWithCharSet:[NSCharacterSet URLQueryAllowedCharacterSet]]; +} + +- (NSString *)encodedStringWithCharSet:(NSCharacterSet *)characterSet { + return [self stringByAddingPercentEncodingWithAllowedCharacters:characterSet]; +} + +@end diff --git a/Sources/JSRestClient/JSRESTBase+JSRESTDashboard.m b/Sources/JSRestClient/JSRESTBase+JSRESTDashboard.m index 126d783..eac1f38 100644 --- a/Sources/JSRestClient/JSRESTBase+JSRESTDashboard.m +++ b/Sources/JSRestClient/JSRESTBase+JSRESTDashboard.m @@ -33,14 +33,13 @@ #import "JSInputControlDescriptor.h" #import "JSReportParameter.h" - @implementation JSRESTBase (JSRESTDashboard) #pragma mark - Components - (void)fetchDashboardComponentsWithURI:(NSString *)dashboardURI completion:(nullable JSRequestCompletionBlock)block { - NSString *fullURL = [NSString stringWithFormat:@"%@%@_files/%@", kJS_REST_RESOURCES_URI, dashboardURI, @"components"]; + NSString *fullURL = [NSString stringWithFormat:@"%@%@_files/%@", kJS_REST_RESOURCES_URI, dashboardURI.hostEncodedString, @"components"]; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.objectMapping = [JSMapping mappingWithObjectMapping:[JSDashboardComponent objectMappingForServerProfile:self.serverProfile] keyPath:nil]; request.restVersion = JSRESTVersion_2; @@ -134,12 +133,12 @@ - (NSString *)constructFullURIWithDashboardURI:(NSString *)uri inputControls:(NSArray *)dependencies initialValuesOnly:(BOOL)initialValuesOnly { - NSString *fullReportsUri = [NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (uri ?: @""), kJS_REST_INPUT_CONTROLS_URI]; + NSString *fullReportsUri = [NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (uri.hostEncodedString ?: @""), kJS_REST_INPUT_CONTROLS_URI]; if (dependencies && dependencies.count) { NSMutableString *dependenciesUriPart = [[NSMutableString alloc] initWithString:@"/"]; for (NSString *dependency in dependencies) { - [dependenciesUriPart appendFormat:@"%@;", dependency]; + [dependenciesUriPart appendFormat:@"%@;", dependency.hostEncodedString]; } fullReportsUri = [fullReportsUri stringByAppendingString:dependenciesUriPart]; } diff --git a/Sources/JSRestClient/JSRESTBase+JSRESTReport.m b/Sources/JSRestClient/JSRESTBase+JSRESTReport.m index c7c4877..589ffbe 100644 --- a/Sources/JSRestClient/JSRESTBase+JSRESTReport.m +++ b/Sources/JSRestClient/JSRESTBase+JSRESTReport.m @@ -41,27 +41,16 @@ #import "AFURLRequestSerialization.h" #import "JSReportComponent.h" -// Report query used for setting output format (i.e PDF, HTML, etc.) -// and path for images (current dir) when exporting report in HTML -static NSString * const _baseReportQueryImagesParam = @"IMAGES_URI"; -static NSString * const _baseReportQueryOutputFormatParam = @"RUN_OUTPUT_FORMAT"; - @interface JSRESTBase (PrivateAPI) - (void) addReportParametersToRequest:(JSRequest *)request withSelectedValues:(NSArray *)selectedValues; - (NSString *)fullReportExecutionUri:(NSString *)requestId; -- (NSString *)fullDownloadReportFileUri:(NSString *)uuid; - -- (NSString *)fullRunReportUri:(NSString *)uri; - - (NSString *)fullReportsUriForIC:(NSString *)uri withInputControls:(NSArray *)dependencies initialValuesOnly:(BOOL)initialValuesOnly; - (NSString *)fullExportExecutionUri:(NSString *)requestId; -- (NSDictionary *)runReportQueryParams:(NSString *)format; - - (NSString *)encodeAttachmentsPrefix:(NSString *)exportOutput; @end @@ -69,7 +58,7 @@ @implementation JSRESTBase (JSRESTReportOptions) - (void)inputControlsForReport:(NSString *)reportUri selectedValues:(NSArray *)selectedValues completionBlock:(JSRequestCompletionBlock)block { - JSRequest *request = [[JSRequest alloc] initWithUri:[NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (reportUri ?: @""), kJS_REST_INPUT_CONTROLS_URI]]; + JSRequest *request = [[JSRequest alloc] initWithUri:[NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (reportUri.hostEncodedString ?: @""), kJS_REST_INPUT_CONTROLS_URI]]; request.objectMapping = [JSMapping mappingWithObjectMapping:[JSInputControlDescriptor objectMappingForServerProfile:self.serverProfile] keyPath:@"inputControl"]; request.restVersion = JSRESTVersion_2; request.method = ([selectedValues count]) ? JSRequestHTTPMethodPOST : JSRequestHTTPMethodGET; @@ -90,7 +79,7 @@ - (void)updatedInputControlsValues:(NSString *)reportUri ids:(NSArray *)dependencies initialValuesOnly:(BOOL)initialValuesOnly { - NSString *fullReportsUri = [NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (uri ?: @""), kJS_REST_INPUT_CONTROLS_URI]; + NSString *fullReportsUri = [NSString stringWithFormat:@"%@%@%@", kJS_REST_REPORTS_URI, (uri.hostEncodedString ?: @""), kJS_REST_INPUT_CONTROLS_URI]; if (dependencies && dependencies.count) { NSMutableString *dependenciesUriPart = [[NSMutableString alloc] initWithString:@"/"]; for (NSString *dependency in dependencies) { - [dependenciesUriPart appendFormat:@"%@;", dependency]; + [dependenciesUriPart appendFormat:@"%@;", dependency.hostEncodedString]; } fullReportsUri = [fullReportsUri stringByAppendingString:dependenciesUriPart]; } @@ -425,11 +404,6 @@ - (NSString *)fullExportExecutionUri:(NSString *)requestId { return [NSString stringWithFormat:@"%@/%@%@", kJS_REST_REPORT_EXECUTION_URI, requestId, kJS_REST_EXPORT_EXECUTION_URI]; } -- (NSDictionary *)runReportQueryParams:(NSString *)format { - return [NSDictionary dictionaryWithObjectsAndKeys:@"./", _baseReportQueryImagesParam, - format, _baseReportQueryOutputFormatParam, nil]; -} - - (NSString *)encodeAttachmentsPrefix:(NSString *)exportOutput { NSRange prefixRange = [exportOutput rangeOfString:@"attachmentsPrefix="]; @@ -438,8 +412,7 @@ - (NSString *)encodeAttachmentsPrefix:(NSString *)exportOutput { NSRange valueRange = NSMakeRange(location, exportOutput.length - location); NSString *value = [exportOutput substringWithRange:valueRange]; if (value.length) { - value = [self encodeString:value]; - exportOutput = [exportOutput stringByReplacingCharactersInRange:valueRange withString:value]; + exportOutput = [exportOutput stringByReplacingCharactersInRange:valueRange withString:value.queryEncodedString]; } } diff --git a/Sources/JSRestClient/JSRESTBase+JSRESTResource.m b/Sources/JSRestClient/JSRESTBase+JSRESTResource.m index affcf0c..558c7b7 100644 --- a/Sources/JSRestClient/JSRESTBase+JSRESTResource.m +++ b/Sources/JSRestClient/JSRESTBase+JSRESTResource.m @@ -52,7 +52,7 @@ @implementation JSRESTBase(JSRESTResource) #pragma mark Public methods for REST V2 resources API - (void)modifyResource:(nonnull JSResourceLookup *)resource completionBlock:(nullable JSRequestCompletionBlock)block { - JSRequest *request = [[JSRequest alloc] initWithUri:[self fullResourcesUri:resource.uri]]; + JSRequest *request = [[JSRequest alloc] initWithUri:[self fullResourceUri:resource.uri]]; request.restVersion = JSRESTVersion_2; request.method = JSRequestHTTPMethodPATCH; request.completionBlock = block; @@ -80,7 +80,7 @@ - (void)resourceLookupForURI:(NSString *)resourceURI { NSString *uri = kJS_REST_RESOURCES_URI; if (resourceURI && ![resourceURI isEqualToString:@"/"]) { - uri = [uri stringByAppendingString:resourceURI]; + uri = [uri stringByAppendingString:resourceURI.hostEncodedString]; } JSRequest *request = [[JSRequest alloc] initWithUri:uri]; request.restVersion = JSRESTVersion_2; @@ -146,20 +146,14 @@ - (void)resourceLookups:(NSString *)folderUri - (NSString *)generateThumbnailImageUrl:(NSString *)resourceURI { - NSString *restURI = kJS_REST_SERVICES_V2_URI; - NSString *thumbnailURI = kJS_REST_RESOURCE_THUMBNAIL_URI; - return [NSString stringWithFormat:@"%@/%@%@%@?defaultAllowed=false", self.serverProfile.serverUrl, restURI, thumbnailURI, resourceURI]; + return [NSString stringWithFormat:@"%@/%@%@%@?defaultAllowed=false", self.serverProfile.serverUrl, kJS_REST_SERVICES_V2_URI, kJS_REST_RESOURCE_THUMBNAIL_URI, resourceURI.hostEncodedString]; } #pragma mark - #pragma mark Private methods -- (NSString *)fullResourcesUri:(NSString *)uri { - return [NSString stringWithFormat:@"%@%@", kJS_REST_RESOURCES_URI, (uri ?: @"")]; -} - - (NSString *)fullResourceUri:(NSString *)uri { - return [NSString stringWithFormat:@"%@%@", kJS_REST_RESOURCE_URI, (uri ?: @"")]; + return [NSString stringWithFormat:@"%@%@", kJS_REST_RESOURCE_URI, (uri.hostEncodedString ?: @"")]; } @end diff --git a/Sources/JSRestClient/JSRESTBase+JSSchedule.m b/Sources/JSRestClient/JSRESTBase+JSSchedule.m index 0f92904..3027707 100644 --- a/Sources/JSRestClient/JSRESTBase+JSSchedule.m +++ b/Sources/JSRestClient/JSRESTBase+JSSchedule.m @@ -49,7 +49,7 @@ - (void)fetchSchedulesWithSearchParameters:(JSScheduleSearchParameters *)paramet @throw wrongActionxception; } - NSString *fullURL = [NSString stringWithFormat:@"%@", @"/jobs"]; + NSString *fullURL = @"/jobs"; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.restVersion = JSRESTVersion_2; request.method = JSRequestHTTPMethodGET; @@ -92,7 +92,7 @@ - (void)fetchSchedulesForResourceWithURI:(NSString *)resourceURI completion:(JSR - (void)fetchScheduleMetadataWithId:(NSInteger)scheduleId completion:(JSRequestCompletionBlock)completion { - NSString *fullURL = [NSString stringWithFormat:@"%@/%@", @"/jobs", @(scheduleId)]; + NSString *fullURL = [NSString stringWithFormat:@"/jobs/%@", @(scheduleId)]; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.objectMapping = [JSMapping mappingWithObjectMapping:[JSScheduleMetadata objectMappingForServerProfile:self.serverProfile] keyPath:nil]; @@ -109,7 +109,7 @@ - (void)fetchScheduleMetadataWithId:(NSInteger)scheduleId completion:(JSRequestC - (void)createScheduleWithData:(JSScheduleMetadata *)data completion:(JSRequestCompletionBlock)completion { - NSString *fullURL = [NSString stringWithFormat:@"%@", @"/jobs"]; + NSString *fullURL = @"/jobs"; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.objectMapping = [JSMapping mappingWithObjectMapping:[JSScheduleMetadata objectMappingForServerProfile:self.serverProfile] keyPath:nil]; @@ -128,7 +128,7 @@ - (void)createScheduleWithData:(JSScheduleMetadata *)data completion:(JSRequestC - (void)updateSchedule:(JSScheduleMetadata *)schedule completion:(JSRequestCompletionBlock)completion { - NSString *fullURL = [NSString stringWithFormat:@"%@/%@", @"/jobs", @(schedule.jobIdentifier)]; + NSString *fullURL = [NSString stringWithFormat:@"/jobs/%@", @(schedule.jobIdentifier)]; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.objectMapping = [JSMapping mappingWithObjectMapping:[JSScheduleMetadata objectMappingForServerProfile:self.serverProfile] keyPath:nil]; @@ -145,7 +145,7 @@ - (void)updateSchedule:(JSScheduleMetadata *)schedule completion:(JSRequestCompl - (void)deleteScheduleWithId:(NSInteger)identifier completion:(JSRequestCompletionBlock)completion { - NSString *fullURL = [NSString stringWithFormat:@"%@/%@", @"/jobs", @(identifier)]; + NSString *fullURL = [NSString stringWithFormat:@"/jobs/%@", @(identifier)]; JSRequest *request = [[JSRequest alloc] initWithUri:fullURL]; request.restVersion = JSRESTVersion_2; request.method = JSRequestHTTPMethodDELETE; diff --git a/Sources/JSRestClient/JSRESTBase.h b/Sources/JSRestClient/JSRESTBase.h index 462b28a..f498a8f 100644 --- a/Sources/JSRestClient/JSRESTBase.h +++ b/Sources/JSRestClient/JSRESTBase.h @@ -124,12 +124,4 @@ extern NSString * const _Nonnull kJSRequestResponceType; - (void)updateCookiesWithCookies:(NSArray * __nullable)cookies; -/** - Returns a percent-escaped string. - @param string The string to be percent-escaped - - @return The percent-escaped string - @since 2.5 - */ -- (nonnull NSString *)encodeString:(nonnull NSString *)string; @end diff --git a/Sources/JSRestClient/JSRESTBase.m b/Sources/JSRestClient/JSRESTBase.m index ff8dbd6..72d05fc 100644 --- a/Sources/JSRestClient/JSRESTBase.m +++ b/Sources/JSRestClient/JSRESTBase.m @@ -527,14 +527,4 @@ - (JSOperationResult *) operationResultForSerializationError:(NSError *)serializ return result; } -// TODO: refactor, find better way to make URL encoded string -- (NSString *)encodeString:(NSString *)string { - if (string.length) { - NSString *charactersToEncoding = @":#[]@!$&'()*+,;=/?"; - CFStringRef encodedValue = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef) string, NULL, (CFStringRef) charactersToEncoding, kCFStringEncodingUTF8); - string = CFBridgingRelease(encodedValue); - } - - return string; -} @end diff --git a/Support/JaspersoftSDK-Prefix.pch b/Support/JaspersoftSDK-Prefix.pch index 142f5d8..bbb35e2 100644 --- a/Support/JaspersoftSDK-Prefix.pch +++ b/Support/JaspersoftSDK-Prefix.pch @@ -8,4 +8,5 @@ #import #import "JSConstants.h" #import "JSUtils.h" + #import "NSString+JSURLEncodings.h" #endif