Author: ygrego Date: 2015-03-12 09:51:30 +0000 (Thu, 12 Mar 2015) New Revision: 943 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/943 Log: Reimplementation of method "isObjectSupported" and verify in each method of creation object: if the object is supported by the terminal. Modified: oipf/js/impl/OipfObjectFactory.js Modified: oipf/js/impl/OipfObjectFactory.js =================================================================== --- oipf/js/impl/OipfObjectFactory.js 2015-03-12 09:10:44 UTC (rev 942) +++ oipf/js/impl/OipfObjectFactory.js 2015-03-12 09:51:30 UTC (rev 943) @@ -1,23 +1,5 @@ -var channelConfig_type = "channelCongig"; //Not a DAE MIME Type -var videoBroadcast_dae_mime_type = "video/broadcast"; -var notifSocket_dae_mime_type = "application/notifsocket"; -var applicationManager_dae_mime_type = "application/oipfApplicationManager"; -var capabilities_dae_mime_type = "application/oipfCapabilities"; -var codManager_dae_mime_type = "application/oipfCodManager"; -var configuration_dae_mime_type = "application/oipfConfiguration"; -var downloadManager_dae_mime_type = "application/oipfDownloadManager"; -var downloadTrigger_dae_mime_type = "application/oipfDownloadTrigger"; -var drmAgent_dae_mime_type = "application/oipfDrmAgent"; -var gatewayInfo_dae_mime_type = "application/oipfGatewayInfo"; -var communicationServices_dae_mime_type = "application/oipfCommunicationServices"; -var mdtf_dae_mime_type = "application/oipfMDTF"; -var parentalControlManager_dae_mime_type = "application/oipfParentalControlManager"; -var recordingScheduler_dae_mime_type = "application/oipfRecordingScheduler"; -var remoteControlFunction_dae_mime_type = "application/oipfRemoteControlFunction"; -var remoteManagement_dae_mime_type = "application/oipfRemoteManagement"; -var searchManager_dae_mime_type = "application/oipfSearchManager"; -var statusView_dae_mime_type = "application/oipfStatusView"; + /*! * \class OipfObjectFactory * \brief Provide access to components of a terminal supporting OIFP specification. @@ -139,10 +121,30 @@ * */ isObjectSupported: function(mimeType) { - var mimeTypeCopy = mimeType; - var pattern = /(application\/oipf)(\w+)/; + + var mimeType_method = { + "application/notifsocket" : "createNotifSocketObject", + "application/oipfApplicationManager" : "createApplicationManagerObject", + "application/oipfCapabilities" : "createCapabilitiesObject", + "application/oipfCodManager" : "createCodManagerObject", + "application/oipfCommunicationServices" : "createCommunicationServicesObject", + "application/oipfConfiguration" : "createConfigurationObject", + "application/oipfDownloadManager" : "createDownloadManagerObject", + "application/oipfDownloadTrigger" : "createDownloadTriggerObject", + "application/oipfDrmAgent" : "createDrmAgentObject", + "application/oipfGatewayInfo" : "createGatewayInfoObject", + "application/oipfMDTF" : "createMDTFObject", + "application/oipfParentalControlManager" : "createParentalControlManagerObject", + "application/oipfRecordingScheduler" : "createRecordingSchedulerObject", + "application/oipfRemoteControlFunction" : "createRemoteControlFunctionObject", + "application/oipfRemoteManagement" : "createRemoteManagementObject", + "application/oipfSearchManager" : "createSearchManagerObject", + "application/oipfStatusView" : "createStatusViewObject", + "video/broadcast" : "createVideoBroadcastObject", + "video/mpeg" : "createVideoMpegObject" + }; - return this[mimeTypeCopy.replace(pattern, 'create$2Object')]; + return this[mimeType_method[mimeType]]; }, /*! @@ -173,10 +175,14 @@ * allocationMethod property SHALL be set to DYNAMIC_ALLOCATION . */ createVideoBroadcastObject: function(requiredCapabilities) { + + console.log("[INFO] createVideoBroadcastObject() of OipfObjectFactory class called."); + if (this.isObjectSupported("video/broadcast")) { + return new VideoBroadcastObject(requiredCapabilities); + } else { + throw new TypeError("This object type is not supported."); + } - console.log("[INFO] createVideoBroadcastObject() of OipfObjectFactory class called."); - return new VideoBroadcastObject(requiredCapabilities); - }, /* @@ -193,10 +199,12 @@ * implements the interface for the specified object. */ createSearchManagerObject: function() { - - console.log("[INFO] createSearchManagerObject() of OipfObjectFactory class called."); - return this.searchManagerObject; - + if (this.isObjectSupported(SEARCH_MANAGER_DAE_MIME_TYPE)) { + console.log("[INFO] createSearchManagerObject() of OipfObjectFactory class called."); + return this.searchManagerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, /* @@ -213,9 +221,12 @@ * implements the interface for the specified object. */ createApplicationManagerObject: function() { - - console.log("[INFO] createApplicationManagerObject() of OipfObjectFactory class called."); - return this.applicationManagerObject; + if (this.isObjectSupported(APPLICATION_MANAGER_DAE_MIME_TYPE)) { + console.log("[INFO] createApplicationManagerObject() of OipfObjectFactory class called."); + return this.applicationManagerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, /* @@ -232,149 +243,320 @@ * implements the interface for the specified object. */ createCapabilitiesObject: function() { - - console.log("[INFO] createCapabilitiesObject() of OipfObjectFactory class called."); - return this.capabilitiesObject; + if (this.isObjectSupported(CAPABILITIES_DAE_MIME_TYPE)) { + console.log("[INFO] createCapabilitiesObject() of OipfObjectFactory class called."); + return this.capabilitiesObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createChannelConfig: function() { - - console.log("[INFO] createChannelConfigObject() of OipfObjectFactory class called."); - return this.channelConfig; + if (this.isObjectSupported(CHANNEL_CONFIG_TYPE)) { + console.log("[INFO] createChannelConfigObject() of OipfObjectFactory class called."); + return this.channelConfig; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createCodManagerObject: function() { - - console.log("[INFO] createCodManagerObject() of OipfObjectFactory class called."); - return this.codManagerObject; + if (this.isObjectSupported(COD_MANAGER_DAE_MIME_TYPE)) { + console.log("[INFO] createCodManagerObject() of OipfObjectFactory class called."); + return this.codManagerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createConfigurationObject: function() { - - console.log("[INFO] createConfigurationObject() of OipfObjectFactory class called."); - return this.configurationObject; + if (this.isObjectSupported(CONFIGURATION_DAE_MIME_TYPE)) { + console.log("[INFO] createConfigurationObject() of OipfObjectFactory class called."); + return this.configurationObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createDownloadManagerObject: function() { - - console.log("[INFO] createDownloadManagerObject() of OipfObjectFactory class called."); - return this.downloadManagerObject; + if (this.isObjectSupported(DOWNLOAD_MANAGER_DAE_MIME_TYPE)) { + console.log("[INFO] createDownloadManagerObject() of OipfObjectFactory class called."); + return this.downloadManagerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createDownloadTriggerObject: function() { - - console.log("[INFO] createDownloadTriggerObject() of OipfObjectFactory class called."); - return this.downloadTriggerObject; + if (this.isObjectSupported(DOWNLOAD_TRIGGER_DAE_MIME_TYPE)) { + console.log("[INFO] createDownloadTriggerObject() of OipfObjectFactory class called."); + return this.downloadTriggerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createDrmAgentObject: function() { - - console.log("[INFO] createDrmAgentObject() of OipfObjectFactory class called."); - return this.drmAgentObject; + if (this.isObjectSupported(DRM_AGENT_DAE_MIME_TYPE)) { + console.log("[INFO] createDrmAgentObject() of OipfObjectFactory class called."); + return this.drmAgentObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createGatewayInfoObject: function() { - - console.log("[INFO] createGatewayInfoObject() of OipfObjectFactory class called."); - return this.gatewayInfoObject; + if (this.isObjectSupported(GATEWAY_INFO_DAE_MIME_TYPE)) { + console.log("[INFO] createGatewayInfoObject() of OipfObjectFactory class called."); + return this.gatewayInfoObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createIMSObject: function() { - - console.log("[INFO] createIMSObject() of OipfObjectFactory class called."); - return this.imsObject; + if (this.isObjectSupported(COMMUNICATION_SERVICES_DAE_MIME_TYPE)) { + console.log("[INFO] createIMSObject() of OipfObjectFactory class called."); + return this.imsObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createMDTFObject: function() { - - console.log("[INFO] createMDTFObject() of OipfObjectFactory class called."); - return this.mdtfObject; + if (this.isObjectSupported(MDTF_DAE_MIME_TYPE)) { + console.log("[INFO] createMDTFObject() of OipfObjectFactory class called."); + return this.mdtfObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createNotifSocketObject: function() { - - console.log("[INFO] createNotifSocketObject() of OipfObjectFactory class called."); - return this.notifSocketObject; + if (this.isObjectSupported(NotifSocketObject)) { + console.log("[INFO] createNotifSocketObject() of OipfObjectFactory class called."); + return this.notifSocketObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ - createParentalControlManagerObject: function() { - - console.log("[INFO] createParentalControlManangerObject() of OipfObjectFactory class called."); - return this.parentalControlManagerObject; + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ + createParentalControlManagerObject: function(PARENTAL_CONTROL_MANAGER_DAE_MIME_TYPE) { + if (this.isObjectSupported("video/broadcast")) { + console.log("[INFO] createParentalControlManangerObject() of OipfObjectFactory class called."); + return this.parentalControlManagerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createRecordingSchedulerObject: function() { - - console.log("[INFO] createRecordingSchedulerObject() of OipfObjectFactory class called."); - return this.recordingSchedulerObject; + if (this.isObjectSupported(RECORDING_SCHEDULER_DAE_MIME_TYPE)) { + console.log("[INFO] createRecordingSchedulerObject() of OipfObjectFactory class called."); + return this.recordingSchedulerObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createRemoteControlFunctionObject: function() { - - console.log("[INFO] createRemoteControlFunctionObject() of OipfObjectFactory class called."); - return this.remoteControlFunctionObject; + if (this.isObjectSupported(REMOTE_CONTROL_FUNCTION_DAE_MIME_TYPE)) { + console.log("[INFO] createRemoteControlFunctionObject() of OipfObjectFactory class called."); + return this.remoteControlFunctionObject; + } else { + throw new TypeError("This object type is not supported."); + } }, - /*! - * \class - * \brief - */ + /* + * Description + * If the object type is supported, each of these methods SHALL return an instance of the + * corresponding embedded object. This may be a new instance or existing instance. For + * example, the object will likely be a global singleton object and calls to this method may + * return the same instance. + * Since objects do not claim scarce resources when they are instantiated, instantiation + * SHALL never fail if the object type is supported. If the method name to create the object is + * not supported, the OITF SHALL throw an error with the name property set to the value + * " TypeError ". + * If the object is supported, the method SHALL return a JavaScript Object which + * implements the interface for the specified object. + */ createRemoteManagementObject: function() { - - console.log("[INFO] createRemoteManagementObject() of OipfObjectFactory class called."); - return this.remoteManagementObject; + if (this.isObjectSupported(REMOTE_MANAGEMENT_DAE_MIME_TYPE)) { + console.log("[INFO] createRemoteManagementObject() of OipfObjectFactory class called."); + return this.remoteManagementObject; + } else { + throw new TypeError("This object type is not supported."); + } }, /*! @@ -405,10 +587,12 @@ * allocationMethod property SHALL be set to DYNAMIC_ALLOCATION . */ createStatusViewObject: function() { - - console.log("[INFO] createStatusViewObject() of OipfObjectFactory class called."); - return new StatusViewObject(); - + if (this.isObjectSupported(STATUS_VIEW_DAE_MIME_TYPE)) { + console.log("[INFO] createStatusViewObject() of OipfObjectFactory class called."); + return new StatusViewObject(); + } else { + throw new TypeError("This object type is not supported."); + } }, /*! @@ -439,9 +623,11 @@ * allocationMethod property SHALL be set to DYNAMIC_ALLOCATION . */ createVideoMpegObject: function() { - - console.log("[INFO] createVideoMpegObject() of OipfObjectFactory class called."); - return new VideoMpegObject(); - + if (this.isObjectSupported("video/mpeg")) { + console.log("[INFO] createVideoMpegObject() of OipfObjectFactory class called."); + return new VideoMpegObject(); + } else { + throw new TypeError("This object type is not supported."); + } } });
participants (1)
-
ygregoï¼ users.nuiton.org