Skip to content

Commit

Permalink
feat(FEC-8872): add provider check for entry status import and conver…
Browse files Browse the repository at this point in the history
…ting (#107)

Added a check in OVP provider to check status 0 or 1 from the multiRequest response and throw a specific new sub error 2002 of error 7002
  • Loading branch information
RoyBregman authored Apr 13, 2020
1 parent 38b7bc3 commit 04d677f
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/entities/media-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export default class MediaEntry {
* @type {number}
*/
dvrStatus: number;
/**
* @member - media status
* @type {number}
*/
status: number;
/**
* @member - media poster
* @type {string | Array<Object>}
Expand Down
1 change: 1 addition & 0 deletions src/k-provider/ovp/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class OVPProviderParser {
mediaEntry.metadata.description = entry.description || '';
mediaEntry.metadata.name = entry.name || '';
mediaEntry.metadata.tags = entry.tags || '';
mediaEntry.status = entry.status;

mediaEntry.type = OVPProviderParser._getEntryType(entry.entryType, entry.type);
if (mediaEntry.type === MediaEntry.Type.LIVE) {
Expand Down
15 changes: 15 additions & 0 deletions src/k-provider/ovp/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import getLogger from '../../util/logger';
import OVPConfiguration from './config';
import OVPProviderParser from './provider-parser';
import KalturaMediaEntry from './response-types/kaltura-media-entry';
import OVPMediaEntryLoader from './loaders/media-entry-loader';
import OVPSessionLoader from './loaders/session-loader';
import OVPDataLoaderManager from './loaders/data-loader-manager';
Expand Down Expand Up @@ -120,6 +121,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
}
const mediaEntry = OVPProviderParser.getMediaEntry(this.isAnonymous ? '' : this.ks, this.partnerId, this.uiConfId, response);
Object.assign(mediaConfig.sources, this._getSourcesObject(mediaEntry));
this._verifyMediaStatus(mediaEntry);
this._verifyHasSources(mediaConfig.sources);
}
}
Expand All @@ -128,6 +130,19 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
return mediaConfig;
}

/**
* Checks media is ready for playback (not being imported or converted)
* @param {MediaEntry} mediaEntry - the media entry info
* @returns {void}
*/
_verifyMediaStatus(mediaEntry: MediaEntry) {
if ([KalturaMediaEntry.EntryStatus.IMPORT, KalturaMediaEntry.EntryStatus.PRECONVERT].includes(mediaEntry.status)) {
throw new Error(Error.Severity.CRITICAL, Error.Category.SERVICE, Error.Code.MEDIA_STATUS_NOT_READY, {
messages: `Status of entry id ${mediaEntry.id} is ${mediaEntry.status} and is still being imported or converted`,
data: {status}
});
}
}
/**
* Gets the backend playlist config.
* @param {ProviderPlaylistInfoObject} playlistInfo - ovp playlist info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
const FIELDS =
'id,referenceId,name,description,thumbnailUrl,dataUrl,duration,msDuration,flavorParamsIds,mediaType,type,tags,dvrStatus,externalSourceType';
'id,referenceId,name,description,thumbnailUrl,dataUrl,duration,msDuration,flavorParamsIds,mediaType,type,tags,dvrStatus,externalSourceType,status';

export default class BaseEntryResponseProfile {
static Type: {[type: string]: number} = {
Expand Down
7 changes: 7 additions & 0 deletions src/k-provider/ovp/response-types/kaltura-media-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export default class KalturaMediaEntry {
*/
tags: string;

/**
* @member - Entry status
* @type {number}
*/
status: number;

/**
* @constructor
* @param {Object} entry The json response
Expand All @@ -128,6 +134,7 @@ export default class KalturaMediaEntry {
this.flavorParamsIds = entry.flavorParamsIds;
this.duration = entry.duration;
this.poster = entry.thumbnailUrl;
this.status = entry.status;
this.dvrStatus = entry.dvrStatus;
this.tags = entry.tags;
}
Expand Down
6 changes: 6 additions & 0 deletions src/util/error/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ const Code: CodeType = {
*/
BLOCK_ACTION: 2001,

/**
* The server responded with status import or pre convert
*/
MEDIA_STATUS_NOT_READY: 2002,

/**
* The provider is missing mandatory parameter/s
*/

MISSING_MANDATORY_PARAMS: 3000,

/**
Expand Down
Loading

0 comments on commit 04d677f

Please sign in to comment.