Search in sources :

Example 1 with ActionNotResolvedException

use of org.prebid.mobile.rendering.utils.url.ActionNotResolvedException in project prebid-mobile-android by prebid.

the class DeepLinkPlusActionTest method performActionWithInvalidPrimaryUrlAndFallbackDeepLinkPlusUrl_ThrowException.

@Test
public void performActionWithInvalidPrimaryUrlAndFallbackDeepLinkPlusUrl_ThrowException() {
    Uri invalidFallbackDeepLink = Uri.parse(INVALID_NESTED_DEEPLINK_IN_FALLBACK_URL);
    String expectedMessage = "Deeplink+ URL had another Deeplink+ URL as the 'fallbackUrl'.";
    String actualMessage = "";
    try {
        mDeepLinkPlusAction.performAction(mMockContext, mMockUrlHandler, invalidFallbackDeepLink);
    } catch (ActionNotResolvedException e) {
        actualMessage = e.getMessage();
    }
    assertEquals(expectedMessage, actualMessage);
}
Also used : ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException) Uri(android.net.Uri) Test(org.junit.Test)

Example 2 with ActionNotResolvedException

use of org.prebid.mobile.rendering.utils.url.ActionNotResolvedException in project prebid-mobile-android by prebid.

the class DeepLinkPlusActionTest method performActionWithInvalidPrimaryUrlAndEmptyFallback_ThrowException.

@Test
public void performActionWithInvalidPrimaryUrlAndEmptyFallback_ThrowException() {
    Uri emptyFallbackDeepLink = Uri.parse(NO_FALLBACK_DEEPLINK_EXAMPLE);
    String expectedMessage = "Unable to handle 'primaryUrl' for Deeplink+ and 'fallbackUrl' was missing.";
    String actualMessage = "";
    try {
        mDeepLinkPlusAction.performAction(mMockContext, mMockUrlHandler, emptyFallbackDeepLink);
    } catch (ActionNotResolvedException e) {
        actualMessage = e.getMessage();
    }
    assertEquals(expectedMessage, actualMessage);
}
Also used : ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException) Uri(android.net.Uri) Test(org.junit.Test)

Example 3 with ActionNotResolvedException

use of org.prebid.mobile.rendering.utils.url.ActionNotResolvedException in project prebid-mobile-android by prebid.

the class MraidInternalBrowserAction method performAction.

@Override
public void performAction(Context context, UrlHandler urlHandler, Uri uri) throws ActionNotResolvedException {
    BaseJSInterface baseJSInterface = mJSInterfaceWeakReference.get();
    if (baseJSInterface == null) {
        throw new ActionNotResolvedException("Action can't be handled. BaseJSInterface is null");
    }
    handleInternalBrowserAction(context, baseJSInterface, uri.toString());
}
Also used : BaseJSInterface(org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface) ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException)

Example 4 with ActionNotResolvedException

use of org.prebid.mobile.rendering.utils.url.ActionNotResolvedException in project prebid-mobile-android by prebid.

the class ExternalViewerUtils method launchApplicationUrl.

public static void launchApplicationUrl(Context context, Uri uri) throws ActionNotResolvedException {
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    if (!isActivityCallable(context, intent)) {
        throw new ActionNotResolvedException("launchApplicationUrl: Failure. No activity was found to handle action for " + uri);
    }
    launchApplicationIntent(context, intent);
}
Also used : ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException) Intent(android.content.Intent)

Example 5 with ActionNotResolvedException

use of org.prebid.mobile.rendering.utils.url.ActionNotResolvedException in project prebid-mobile-android by prebid.

the class DeepLinkPlusAction method performAction.

@Override
public void performAction(Context context, UrlHandler urlHandler, Uri uri) throws ActionNotResolvedException {
    if (!HOST_NAVIGATE.equalsIgnoreCase(uri.getHost())) {
        throw new ActionNotResolvedException("Deeplink+ URL did not have 'navigate' as the host.");
    }
    final String primaryUrl;
    final List<String> primaryTrackingUrls;
    final String fallbackUrl;
    final List<String> fallbackTrackingUrls;
    try {
        primaryUrl = uri.getQueryParameter(QUERY_PRIMARY_URL);
        primaryTrackingUrls = uri.getQueryParameters(QUERY_PRIMARY_TRACKING_URL);
        fallbackUrl = uri.getQueryParameter(QUERY_FALLBACK_URL);
        fallbackTrackingUrls = uri.getQueryParameters(QUERY_FALLBACK_TRACKING_URL);
    } catch (UnsupportedOperationException e) {
        // UnsupportedOperationException (see https://developer.android.com/reference/android/net/Uri.html#getQueryParameter(java.lang.String)
        throw new ActionNotResolvedException("Deeplink+ URL was not a hierarchical URI.");
    }
    if (primaryUrl == null) {
        throw new ActionNotResolvedException("Deeplink+ did not have 'primaryUrl' query param.");
    }
    final Uri primaryUri = Uri.parse(primaryUrl);
    if (shouldOverrideUrlLoading(primaryUri)) {
        // Nested Deeplink+ URLs are not allowed
        throw new ActionNotResolvedException("Deeplink+ had another Deeplink+ as the 'primaryUrl'.");
    }
    // 2. Attempt to handle the primary URL
    try {
        ExternalViewerUtils.launchApplicationUrl(context, primaryUri);
        TrackingManager.getInstance().fireEventTrackingURLs(primaryTrackingUrls);
        return;
    } catch (ActionNotResolvedException e) {
        LogUtil.debug(TAG, "performAction(): Primary URL failed. Attempting to process fallback URL");
    }
    // 3. Attempt to handle the fallback URL
    if (fallbackUrl == null) {
        throw new ActionNotResolvedException("Unable to handle 'primaryUrl' for Deeplink+ and 'fallbackUrl' was missing.");
    }
    if (shouldOverrideUrlLoading(Uri.parse(fallbackUrl))) {
        // Nested Deeplink+ URLs are not allowed
        throw new ActionNotResolvedException("Deeplink+ URL had another Deeplink+ URL as the 'fallbackUrl'.");
    }
    // UrlAction.handleUrl already verified this comes from a user interaction
    urlHandler.handleUrl(context, fallbackUrl, fallbackTrackingUrls, true);
}
Also used : ActionNotResolvedException(org.prebid.mobile.rendering.utils.url.ActionNotResolvedException) Uri(android.net.Uri)

Aggregations

ActionNotResolvedException (org.prebid.mobile.rendering.utils.url.ActionNotResolvedException)5 Uri (android.net.Uri)3 Test (org.junit.Test)2 Intent (android.content.Intent)1 BaseJSInterface (org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface)1