Merge branch 'develop' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core into feature/video_molecule

This commit is contained in:
Pfeil, Scott Robert 2021-02-11 17:22:06 -05:00
commit b80ee45496
9 changed files with 103 additions and 64 deletions

View File

@ -946,6 +946,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@ -1007,6 +1008,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;

View File

@ -395,7 +395,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
} else {
[MVMCoreDispatchUtility performBlockInBackground:^{
// Cannot linkaway, show error.
MVMCoreErrorObject *error = error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeLinkAway]];
MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodeLinkawayFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_%@",NSStringFromClass([delegateObject.actionDelegate class]),KeyActionTypeLinkAway]];
[self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject];
}];
}

View File

@ -110,34 +110,32 @@
- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
NSURL *url = nil;
if (requestParameters.alternateBaseURL) {
url = requestParameters.alternateBaseURL;
} else {
url = [MVMCoreSessionObject sharedGlobal].baseURL;
}
NSURL *url = requestParameters.URL;
if (!url) {
url = [NSURL URLWithString:URLProdPostpayBase];
if (requestParameters.alternateBaseURL) {
url = requestParameters.alternateBaseURL;
} else {
url = [MVMCoreSessionObject sharedGlobal].baseURL ?: [NSURL URLWithString:URLProdPostpayBase];
}
// Appends the context root.
if (requestParameters.contextRoot) {
url = [url URLByAppendingPathComponent:requestParameters.contextRoot];
} else if ([MVMCoreSessionObject sharedGlobal].contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (requestParameters.pageType) {
url = [url URLByAppendingPathComponent:requestParameters.pageType];
}
// This has changed since the initial agreement. Seems server always needs page type now.
/* else if (requestParameters.modules) {
url = [url URLByAppendingPathComponent:KeyModuleMap];
}*/
}
// Appends the context root.
if (requestParameters.contextRoot) {
url = [url URLByAppendingPathComponent:requestParameters.contextRoot];
} else if ([MVMCoreSessionObject sharedGlobal].contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (requestParameters.pageType) {
url = [url URLByAppendingPathComponent:requestParameters.pageType];
}
// This has changed since the initial agreement. Seems server always needs page type now.
/* else if (requestParameters.modules) {
url = [url URLByAppendingPathComponent:KeyModuleMap];
}*/
// Adds modules needed to the request parameters.
if (requestParameters.modules.count > 0) {
[requestParameters addRequestParameters:@{KeyModuleList:requestParameters.modules}];

View File

@ -191,29 +191,32 @@
// Never use the cache.
completionHandler(nil,nil);
} else if (requestParameters.pageType.length != 0 && requestParameters.modules.count > 0) {
} else {
NSArray *modules = [requestParameters allModules];
if (requestParameters.pageType.length != 0 && modules.count > 0) {
// Check cache function for page json is already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
// Check cache function for page json is already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
// Check cache function for modules already in the cache.
NSDictionary *pageDictionary = jsonDictionary;
[[MVMCoreCache sharedCache] fetchJSONForModules:requestParameters.modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(pageDictionary,jsonDictionary);
// Check cache function for modules already in the cache.
NSDictionary *pageDictionary = jsonDictionary;
[[MVMCoreCache sharedCache] fetchJSONForModules:modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(pageDictionary,jsonDictionary);
}];
}];
}];
} else if (requestParameters.pageType.length != 0) {
} else if (requestParameters.pageType.length != 0) {
// Check cache function if page json is already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(jsonDictionary,nil);
}];
} else if (requestParameters.modules.count > 0) {
// Check cache function if modules already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForModules:requestParameters.modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(nil,jsonDictionary);
}];
// Check cache function if page json is already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(jsonDictionary,nil);
}];
} else if (modules > 0) {
// Check cache function if modules already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForModules:modules completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
completionHandler(nil,jsonDictionary);
}];
}
}
}
@ -239,16 +242,21 @@
// Check if the page was found in the cache.
BOOL pageNotInCache = loadObject.operation.requestParameters.pageType && !loadObject.pageDataFromCache;
// Check all modules were found in the cache
// Check all required modules were found in the cache
NSMutableArray *modulesNotInCache = [NSMutableArray array];
for (NSString *module in loadObject.operation.requestParameters.modules) {
NSMutableArray *requiredModules = [NSMutableArray arrayWithArray:loadObject.operation.requestParameters.modules];
for (NSString *module in [loadObject.operation.requestParameters allModules]) {
if (![loadObject.modulesJSON objectForKey:module]) {
// Missing a module.
[modulesNotInCache addObject:module];
} else {
// Received a required module.
[requiredModules removeObject:module];
}
}
MVMCoreRequestParameters *requestParametersForServer = nil;
if (pageNotInCache || modulesNotInCache.count > 0) {
if (pageNotInCache || requiredModules.count > 0) {
// We are missing data, will need to go to server.
requestParametersForServer = [loadObject.operation.requestParameters copy];

View File

@ -29,16 +29,23 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// request parameters
@property (nullable, strong, nonatomic) NSString *pageType;
@property (nullable, strong, nonatomic) NSArray *modules;
@property (nullable, strong, nonatomic) NSArray<NSString *> *optionalModules;
@property (nullable, strong, nonatomic) NSArray<NSString *> *modules;
@property (nullable, strong, nonatomic) NSDictionary *parameters;
@property (nullable, strong, nonatomic) NSData *imageData;
// adding parent pageType for freebee
@property (nullable, strong, nonatomic) NSString *parentPageType;
// Context root for server
/// App context to use when building the url. For ex: baseURL/appContext/pageType
@property (nullable, strong, nonatomic) NSString *contextRoot;
/// Base URL to use when building the url. For ex: baseURL/appContext/pageType
@property (nullable, strong, nonatomic) NSURL *alternateBaseURL;
/// Entire URL to use instead of building the url
@property (nullable, strong, nonatomic) NSURL *URL;
// A flag for if you do not want to try loading any actual view controller. (Unless there is an error screen)
@property (assign, nonatomic) BOOL noViewControllerToLoad;
@ -82,9 +89,6 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// If the request was created with an action map.
@property (nullable, strong, nonatomic) NSDictionary *actionMap;
// only used when the base url is not the same as mf
@property (nullable, strong, nonatomic) NSURL *alternateBaseURL;
@property (nullable, strong, nonatomic) NSNumber *customTimeoutTime;
// Will open support panel at the end of the load.
@ -117,4 +121,7 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// Sets the load style based on the server sent presentationStyle
- (void)setMFLoadStyleBasedOnPresentationStyle:(nonnull NSString *)presentationStyle;
/// Returns optional and required modules
- (nullable NSArray<NSString *> *)allModules;
@end

View File

@ -33,7 +33,8 @@
- (nullable instancetype)initWithPageType:(nonnull NSString *)pageType extraParameters:(nullable NSDictionary *)extraParameters {
if (self = [self initWithExtraParameters:extraParameters]) {
self.pageType = pageType;
self.modules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] allModulesForPageType:pageType];
self.optionalModules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] modulesOptionalForPageType:pageType];
self.modules = [[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] modulesRequiredForPageType:pageType];
}
return self;
}
@ -66,6 +67,14 @@
if (self = [self initWithPageType:[actionMap stringForKey:KeyPageType] additionalModules:[actionMap array:KeyModuleList] extraParameters:[actionMap dict:KeyExtraParameters]]) {
self.contextRoot = [actionMap string:KeyContextRoot];
NSString *alternateBase = [actionMap string:@"baseURL"];
if (alternateBase) {
self.alternateBaseURL = [NSURL URLWithString:alternateBase];
}
NSString *url = [actionMap string:@"URL"];
if (url) {
self.URL = [NSURL URLWithString:url];
}
self.actionMap = actionMap;
self.customTimeoutTime = [actionMap optionalNumberForKey:@"customTimeoutTime"];
self.openSupportPanel = [actionMap boolForKey:KeyOpenSupport];
@ -108,12 +117,18 @@
}
}
- (nullable NSArray *)allModules {
NSMutableSet *set = [NSMutableSet setWithArray:self.optionalModules];
[set addObjectsFromArray:self.modules];
return [set allObjects];
}
- (id)copyWithZone:(nullable NSZone *)zone {
MVMCoreRequestParameters *copyObject = [[MVMCoreRequestParameters alloc] init];
copyObject.pageType = [self.pageType copy];
copyObject.parentPageType = self.parentPageType;
copyObject.optionalModules = [self.optionalModules copy];
copyObject.modules = [self.modules copy];
copyObject.parameters = [self.parameters copy];
copyObject.contextRoot = [self.contextRoot copy];
@ -136,6 +151,7 @@
copyObject.imageData = self.imageData;
copyObject.customTimeoutTime = self.customTimeoutTime;
copyObject.backgroundRequest = self.backgroundRequest;
copyObject.URL = self.URL;
return copyObject;
}

View File

@ -12,12 +12,18 @@ public protocol ActionModelProtocol: ModelProtocol {
var actionType: String { get }
var extraParameters: JSONValueDictionary? { get set }
var analyticsData: JSONValueDictionary? { get set }
var accessibilityIdentifier: String? { get set }
}
public extension ActionModelProtocol {
var actionType: String {
get { return Self.identifier }
get { Self.identifier }
}
var accessibilityIdentifier: String? {
get { nil }
set { }
}
static var categoryCodingKey: String {

View File

@ -15,6 +15,9 @@
public static var identifier: String = "openPage"
public var actionType: String = ActionOpenPageModel.identifier
public var pageType: String
public var baseURL: String?
public var appContext: String?
public var URL: String?
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
public var presentationStyle: String?

View File

@ -69,16 +69,16 @@
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request {
NSDictionary *cannedResponse = nil;
if(_jsonDictionary) {
if (_jsonDictionary) {
BOOL matchesQuery = NO;
for(NSString *urlKey in _sortedKeys) {
for (NSString *urlKey in _sortedKeys) {
NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithString:urlKey];
if([urlComponents.path isEqualToString:request.pageType]) {
if ([urlComponents.path isEqualToString:request.pageType]) {
matchesQuery = YES;
if(urlComponents.query) {
for(NSURLQueryItem *item in urlComponents.queryItems) {
if (urlComponents.query) {
for (NSURLQueryItem *item in urlComponents.queryItems) {
NSString *requestVal = [request.parameters stringForKey:item.name];
if(!requestVal || ![requestVal isEqualToString:item.value]) {
if (!requestVal || ![requestVal isEqualToString:item.value]) {
matchesQuery = NO;
break;
}
@ -88,7 +88,7 @@
cannedResponse = _jsonDictionary[urlKey];
// keep searching to see if there is a more exact match on parameters
}
if(matchesQuery) {
if (matchesQuery) {
cannedResponse = _jsonDictionary[urlKey];
// found a request parameters match, accept as the best result and break out
break;
@ -101,7 +101,6 @@
cannedResponse = [self getHardCodedResponseForPageType:request.pageType];
}
return cannedResponse;
}