use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class VastParserExtractor method performVastUnwrap.
private void performVastUnwrap(String vast) {
if (!vast.contains("VAST version")) {
final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.VAST_SCHEMA_ERROR.toString());
mListener.onResult(createExtractorFailureResult(adException));
return;
}
mVastWrapperCount++;
// A new response has come back, either from the initial VAST request or a wrapper request.
// Parse the response.
AdResponseParserVast adResponseParserVast;
try {
adResponseParserVast = new AdResponseParserVast(vast);
} catch (VastParseError e) {
LogUtil.error(TAG, "AdResponseParserVast creation failed: " + Log.getStackTraceString(e));
final AdException adException = new AdException(AdException.INTERNAL_ERROR, e.getMessage());
mListener.onResult(createExtractorFailureResult(adException));
return;
}
// Check if this is the response from the initial request or from unwrapping a wrapper
if (mRootVastParser == null) {
// If mRootVastParser doesn't exist then it is the initial VAST request
LogUtil.debug(TAG, "Initial VAST Request");
mRootVastParser = adResponseParserVast;
} else {
// Otherwise, this is the result of unwrapping a Wrapper.
LogUtil.debug(TAG, "Unwrapping VAST Wrapper");
mLatestVastWrapperParser.setWrapper(adResponseParserVast);
}
mLatestVastWrapperParser = adResponseParserVast;
// Check if this response is a wrapper
String vastUrl = mLatestVastWrapperParser.getVastUrl();
if (!TextUtils.isEmpty(vastUrl)) {
if (mVastWrapperCount >= WRAPPER_NESTING_LIMIT) {
final AdException adException = new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.WRAPPER_LIMIT_REACH_ERROR.toString());
final VastExtractorResult extractorFailureResult = createExtractorFailureResult(adException);
mListener.onResult(extractorFailureResult);
mVastWrapperCount = 0;
return;
}
mAsyncVastLoader.loadVast(vastUrl, mResponseHandler);
} else {
final AdResponseParserBase[] parserArray = { mRootVastParser, mLatestVastWrapperParser };
mListener.onResult(new VastExtractorResult(parserArray));
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class CreativeFactory method attemptVastCreative.
private void attemptVastCreative() {
VideoCreativeModel videoCreativeModel = (VideoCreativeModel) mCreativeModel;
String mediaUrl = videoCreativeModel.getMediaUrl();
if (Utils.isBlank(mediaUrl) || mediaUrl.equals("invalid media file")) {
mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, VASTErrorCodes.NO_SUPPORTED_MEDIA_ERROR.toString()));
return;
}
// get the tracking url for all event types & do the registration here.
for (VideoAdEvent.Event videoEvent : VideoAdEvent.Event.values()) {
videoCreativeModel.registerVideoEvent(videoEvent, videoCreativeModel.getVideoEventUrls().get(videoEvent));
}
VideoCreative newCreative;
try {
if (mCreativeModel.getAdConfiguration().isRewarded()) {
newCreative = new RewardedVideoCreative(mContextReference.get(), videoCreativeModel, mOmAdSessionManager, mInterstitialManager);
} else {
newCreative = new VideoCreative(mContextReference.get(), videoCreativeModel, mOmAdSessionManager, mInterstitialManager);
}
newCreative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
mCreative = newCreative;
markWorkStart(VAST_TIMEOUT);
newCreative.load();
} catch (Exception exception) {
LogUtil.error(TAG, "VideoCreative creation failed: " + Log.getStackTraceString(exception));
mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, "VideoCreative creation failed: " + exception.getMessage()));
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class CreativeFactory method start.
public void start() {
try {
AdConfiguration.AdUnitIdentifierType adUnitIdentifierType = mCreativeModel.getAdConfiguration().getAdUnitIdentifierType();
switch(adUnitIdentifierType) {
case BANNER:
case INTERSTITIAL:
attemptAuidCreative();
break;
case VAST:
attemptVastCreative();
break;
default:
String msg = "Unable to start creativeFactory. adConfig.adUnitIdentifierType doesn't match supported types" + "adConfig.adUnitIdentifierType: " + adUnitIdentifierType;
LogUtil.error(TAG, msg);
AdException adException = new AdException(AdException.INTERNAL_ERROR, msg);
mListener.onFailure(adException);
break;
}
} catch (Exception exception) {
String message = "Creative Factory failed: " + exception.getMessage();
LogUtil.error(TAG, message + Log.getStackTraceString(exception));
AdException adException = new AdException(AdException.INTERNAL_ERROR, message);
mListener.onFailure(adException);
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class CreativeFactory method attemptAuidCreative.
private void attemptAuidCreative() throws Exception {
mCreative = new HTMLCreative(mContextReference.get(), mCreativeModel, mOmAdSessionManager, mInterstitialManager);
mCreative.setResolutionListener(new CreativeFactoryCreativeResolutionListener(this));
ArrayList<String> riUrls = new ArrayList<>();
ArrayList<String> rcUrls = new ArrayList<>();
// This needs to be more generalized and allow for multiple click urls
if (!mCreativeModel.isRequireImpressionUrl() || Utils.isNotBlank(mCreativeModel.getImpressionUrl())) {
if (!TextUtils.isEmpty(mCreativeModel.getImpressionUrl())) {
riUrls.add(mCreativeModel.getImpressionUrl());
mCreativeModel.registerTrackingEvent(TrackingEvent.Events.IMPRESSION, riUrls);
}
//
if (!TextUtils.isEmpty(mCreativeModel.getClickUrl())) {
rcUrls.add(mCreativeModel.getClickUrl());
mCreativeModel.registerTrackingEvent(TrackingEvent.Events.CLICK, rcUrls);
}
} else {
mListener.onFailure(new AdException(AdException.INTERNAL_ERROR, "Tracking info not found"));
}
markWorkStart(BANNER_TIMEOUT);
mCreative.load();
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class Transaction method startCreativeFactories.
public void startCreativeFactories() {
try {
// Initialize list of CreativeFactories
mCreativeFactories.clear();
for (CreativeModel creativeModel : mCreativeModels) {
CreativeFactory creativeFactory = new CreativeFactory(mContextReference.get(), creativeModel, new CreativeFactoryListener(this), mOmAdSessionManager, mInterstitialManager);
mCreativeFactories.add(creativeFactory);
}
// Start first CreativeFactory, if any
// On success, the CreativeFactoryListener will start the next CreativeFactory
mCreativeFactoryIterator = mCreativeFactories.iterator();
startNextCreativeFactory();
} catch (AdException e) {
mListener.onTransactionFailure(e, mLoaderIdentifier);
}
}
Aggregations