Manos Chorianopoulos

fix db select errors

...@@ -709,6 +709,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -709,6 +709,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
709 } 709 }
710 @catch (NSException *exception) { 710 @catch (NSException *exception) {
711 NSLog(@"SELECT accessToken error: %@", exception.reason); 711 NSLog(@"SELECT accessToken error: %@", exception.reason);
712 + accessToken = @"";
712 } 713 }
713 @finally { 714 @finally {
714 // NSLog(@"Finally condition"); 715 // NSLog(@"Finally condition");
...@@ -724,36 +725,81 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -724,36 +725,81 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
724 }; 725 };
725 726
726 - (NSString*)getRefreshToken { 727 - (NSString*)getRefreshToken {
727 - NSString *refreshToken = [NSString alloc]; 728 +// NSString *refreshToken = [NSString alloc];
729 + NSString *refreshToken = @"";
728 if ([_db tableExists:@"requestVariables"] == YES) { 730 if ([_db tableExists:@"requestVariables"] == YES) {
729 - FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; 731 + @try {
730 - while ([refreshTokenSet next]) { 732 + FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
731 - refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue]; 733 + while ([refreshTokenSet next]) {
734 + refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
735 + }
732 } 736 }
737 + @catch (NSException *exception) {
738 + NSLog(@"SELECT refreshToken error: %@", exception.reason);
739 + refreshToken = @"";
740 + }
741 + @finally {
742 +// NSLog(@"Finally condition");
743 + }
744 +
745 +// FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
746 +// while ([refreshTokenSet next]) {
747 +// refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
748 +// }
733 return refreshToken; 749 return refreshToken;
734 } 750 }
735 return @""; 751 return @"";
736 } 752 }
737 753
738 - (NSString*)getClientId { 754 - (NSString*)getClientId {
739 - NSString *clientId = [NSString alloc]; 755 +// NSString *clientId = [NSString alloc];
756 + NSString *clientId = @"";
740 if ([_db tableExists:@"requestVariables"] == YES) { 757 if ([_db tableExists:@"requestVariables"] == YES) {
741 - FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"]; 758 + @try {
742 - while ([clientIdSet next]) { 759 + FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
743 - clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue]; 760 + while ([clientIdSet next]) {
761 + clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
762 + }
744 } 763 }
764 + @catch (NSException *exception) {
765 + NSLog(@"SELECT clientId error: %@", exception.reason);
766 + clientId = @"";
767 + }
768 + @finally {
769 +// NSLog(@"Finally condition");
770 + }
771 +
772 +// FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
773 +// while ([clientIdSet next]) {
774 +// clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
775 +// }
745 return clientId; 776 return clientId;
746 } 777 }
747 return @""; 778 return @"";
748 } 779 }
749 780
750 - (NSString*)getClientSecret { 781 - (NSString*)getClientSecret {
751 - NSString *clientSecret = [NSString alloc]; 782 +// NSString *clientSecret = [NSString alloc];
783 + NSString *clientSecret = @"";
752 if ([_db tableExists:@"requestVariables"] == YES) { 784 if ([_db tableExists:@"requestVariables"] == YES) {
753 - FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"]; 785 + @try {
754 - while ([clientSecretSet next]) { 786 + FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
755 - clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue]; 787 + while ([clientSecretSet next]) {
788 + clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
789 + }
790 + }
791 + @catch (NSException *exception) {
792 + NSLog(@"SELECT clientSecret error: %@", exception.reason);
793 + clientSecret = @"";
756 } 794 }
795 + @finally {
796 +// NSLog(@"Finally condition");
797 + }
798 +
799 +// FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
800 +// while ([clientSecretSet next]) {
801 +// clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
802 +// }
757 return clientSecret; 803 return clientSecret;
758 } 804 }
759 return @""; 805 return @"";
......