Class: ServerProjectProvider

ServerProjectProvider()

new ServerProjectProvider()

This ServerProjectProvider class is responsible for handling the corresponding plugin js to interact with the native ServerProjectProvider class.corresponding JS methods are written under this class which are used by the end user in application script. This ServerProjectProvider downloads assets from the given server url. Project and variant data are first looked in the cache. If the specified version is found, the cached data will be returned without reaching the server. If download assets needs to be stored in the customised path,You should call useCacheProvider() method.

Methods

cancelLoadAllVariants(successCallback, errorCallback)

This method cancels loadAllVariants for all projects. Already downloaded data will not be deleted. Cancel is not an immediate operation. When cancel is complete, loadAllVariantsForProject of the errorCallback will be fired with operation cancel error.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
var mServerProjectProvider;
var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                         mServerProjectProvider = provider;
                            mServerProjectProvider.loadAllVariantsForProject(function(result){
                            },function(error){
                                alert("loadAllVariantsForProject error:: "+JSON.stringify(error));
                            },loadAllVariantsCallback,getVariantOptions);
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);

loadAllVariantsCallback = function(){
};

var cancelAllVariants = function(){
mServerProjectProvider.cancelLoadAllVariants(function(result){
                            },function(error){
                                alert("cancelLoadAllVariants error:: "+JSON.stringify(error));
     });
};

getHighestVersion(successCallback, errorCallback, completeListener, highestVersionOptions)

To get the highest version for the given project in server.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
completeListener function CallBack consists of highest server project version available for a given projectName.
highestVersionOptions Object A JSON object contains the options to get the highest server version for the given project.
Properties
Name Type Attributes Description
projectName String <optional>
Name of the project.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception. completeListener - It will returns highest server project version for a given projectName.
Example
var OnDeviceExtraction = kfxCordova.kfxEngine.createOnDeviceExtraction();

var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
  var region = OnDeviceExtraction.getRegions();
  var idType = OnDeviceExtraction.getIDTypes();
  var parameters = {
           region: region.US,    //region.ASIA,region.CANADA,etc.
           IDType: idType.ID
  };
  OnDeviceExtraction.getProjectName(function(projectName){
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.getHighestVersion(function(result){
                            },function(error){
                                alert("getHighestVersion error:: "+JSON.stringify(error));
                            },getHighestVersionCallback,{projectName:projectName});
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);
                                    },function(error){
                                      alert(JSON.stringify(error));
                                    }, parameters);

getHighestVersionCallback = function(result){
               alert("get Highest Version:: "+result.version);
};

getProject(successCallback, errorCallback, completeListener, getProjectOptions)

To get path to the project data for the given project and version.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
completeListener function The callBack consists of path to specified project files.
getProjectOptions Object A JSON object contains the options of the ServerProjectProvider.
Properties
Name Type Attributes Description
projectName String <optional>
Name of the project.
version Number <optional>
The version of the project to retrieve
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - Error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception. completeListener - It will returns specified project file path.
Example
var OnDeviceExtraction = kfxCordova.kfxEngine.createOnDeviceExtraction();
var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
  var region = OnDeviceExtraction.getRegions();
  var idType = OnDeviceExtraction.getIDTypes();
  var parameters = {
           region: region.US,    //region.ASIA,region.CANADA,etc.
           IDType: idType.ID
  };
  OnDeviceExtraction.getProjectName(function(projectName){
   var getProjectOptions={
     projectName:projectName,
     version:1
   };
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.getProject(function(result){
                            },function(error){
                                alert("getProject error:: "+JSON.stringify(error));
                            },getProjectCallback,getProjectOptions);
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);
                                    },function(error){
                                      alert(JSON.stringify(error));
                                    }, parameters);

    getProjectCallback = function(result){
          alert("get Project path:: "+result.path);
    };

getVariant(successCallback, errorCallback, completeListener, getVariantOptions)

To get the path to specified variant files.
Parameters:
Name Type Attributes Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
completeListener function The callBack consists of path to specified variant files.
getVariantOptions Object A JSON object contains the options of the ServerProjectProvider.
Properties
Name Type Attributes Description
projectName String <optional>
Name of the project.
variantName String <optional>
VariantFileName for which the path has to be retrieved.
getProjectOptions.version Number <optional>
The version of the project to retrieve
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception. completeListener - It will returns specified variant file path.
Example
var OnDeviceExtraction = kfxCordova.kfxEngine.createOnDeviceExtraction();


var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
  var region = OnDeviceExtraction.getRegions();
  var idType = OnDeviceExtraction.getIDTypes();
  var parameters = {
           region: region.US,    //region.ASIA,region.CANADA,etc.
           IDType: idType.ID
  };
  OnDeviceExtraction.getProjectName(function(projectName){
   var getVariantOptions={
     projectName:projectName,
     variantName:'variantName',  // CA3
     version:'versionNumber'     // 1
   };
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.getVariant(function(result){
                            },function(error){
                                alert("getVariant error:: "+JSON.stringify(error));
                            },getVariantCallback,getVariantOptions);
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);
                                    },function(error){
                                      alert(JSON.stringify(error));
                                    }, parameters);

getVariantCallback = function(result){
               alert("get Variant path:: "+result.path);
};

loadAllVariantsForProject(successCallback, errorCallback, completeListener, getVariantOptions)

Use this method to Download all variants for given project.It checks the latest available version on server. If the latest server and cached version are the same, it will go through variant list and download only missing variants.
Parameters:
Name Type Attributes Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
completeListener function The callBack consists of path to specified variant files.
getVariantOptions Object A JSON object contains the options of the ServerProjectProvider.
Properties
Name Type Attributes Description
projectName String <optional>
Name of the project.
variantName String <optional>
VariantFileName for which the path has to be retrieved.
getProjectOptions.version Number <optional>
The version of the project to retrieve
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException and Exception.If cancels the operation then it will returns the operation cancel error. completeListener - After completes the downloaded then this method will returns success callback.
Example
var OnDeviceExtraction = kfxCordova.kfxEngine.createOnDeviceExtraction();

var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
  var region = OnDeviceExtraction.getRegions();
  var idType = OnDeviceExtraction.getIDTypes();
  var parameters = {
           region: region.US,    //region.ASIA,region.CANADA,etc.
           IDType: idType.ID
  };
  OnDeviceExtraction.getProjectName(function(projectName){
  var loadAllVariantsOptions={
    projectName:projectName
  };
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.loadAllVariantsForProject(function(result){
                            },function(error){
                                alert("loadAllVariantsForProject error:: "+JSON.stringify(error));
                            },loadAllVariantsCallback,getVariantOptions);
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);
                                    },function(error){
                                      alert(JSON.stringify(error));
                                    }, parameters);


loadAllVariantsCallback = function(result){
               alert("Download completed");
};

setRequestTimeout(successCallback, errorCallback, timeoutOptions)

Allows to customize request timeout for HTTP server requests.
Parameters:
Name Type Attributes Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
timeoutOptions Object A JSON object contains the options to set the timeout to the server request.
highestVersionOptions.duration int <optional>
duration which is used to set the timeout for server requests.The default timeout value is 10 secs.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
var timeoutOptions={
    duration:10
};


var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.setRequestTimeout(function(result){
                            },function(error){
                                alert("setRequestTimeout error:: "+JSON.stringify(error));
                            },timeoutOptions);
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);

useCacheProvider(successCallback, errorCallback)

Use this method to creates serverProjectProvider object using bundleCacheProvider, before calling this method you must create bundleCacheProvider object otherwise it will returns error callback.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - It will returns success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception and if bundleCacheProvider has not been created before calling this method then will gets callback error.
Example
var mBundleCacheProvider;
 var serverUrl = "";  //Initializes the serverProjectProvider object with server URL.
kfxCordova.kfxEngine.createBundleCacheProvider(function(provider){
                 mBundleCacheProvider = provider;
                kfxCordova.kfxEngine.createServerProjectProvider(function(provider){
                            provider.useCacheProvider(function(result){
                            },function(error){
                                alert("useCacheProvider error:: "+JSON.stringify(error));
                            });
                },function(error){
                        alert("createServerProjectProvider error::"+JSON.stringify(error));
                },serverUrl);
           },function(error){
                         alert("createBundleCacheProvider error::"+JSON.stringify(error));
           });