Update change log and spec for wrt-plugins-tizen_0.4.70
[platform/framework/web/wrt-plugins-tizen.git] / src / Content / JSContentManager.cpp
index 41140e0..a52042e 100755 (executable)
 // limitations under the License.
 //
 
-
 #include <cassert>
 #include <memory>
-#include <dpl/log/log.h>
 #include <CommonsJavaScript/Utils.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSPendingOperation.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <JSTizenExceptionFactory.h>
-#include <JSTizenException.h>
 #include <SecurityExceptions.h>
 #include <CallbackUserData.h>
 #include <MultiCallbackUserData.h>
 #include <GlobalContextManager.h>
 #include <FilterConverter.h>
-#include <JSWebAPIError.h>
+#include <JSWebAPIErrorFactory.h>
 #include <ArgumentValidator.h>
 #include <TimeTracer.h>
+#include <Security.h>
 
 #include "JSUtil.h"
 #include "ContentFactory.h"
 #include "JSVideo.h"
 #include "JSAudio.h"
 #include "ContentConverter.h"
-#include "plugin_config.h"
+#include "plugin_config_impl.h"
 #include "ContentAsyncCallbackManager.h"
 #include "ContentListener.h"
 #include "ContentVideo.h"
 #include "ContentImage.h"
 #include "ContentFilterConverter.h"
 #include "ContentUtility.h"
-#include "JSWebAPIException.h"
-
+#include <Logger.h>
 
 using namespace DeviceAPI::Common;
 using namespace DeviceAPI::Tizen;
@@ -116,14 +112,13 @@ JSValueRef JSMediacontentManager::getFolders(
                             const JSValueRef arguments[],
                             JSValueRef* exception )
 {
-    LogDebug("JSContentManagerManager::getFolders entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if (!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIError::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
@@ -146,11 +141,11 @@ JSValueRef JSMediacontentManager::getFolders(
             cbm->setOnError(errorCallbackObj);
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
         DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     Try
@@ -167,28 +162,28 @@ JSValueRef JSMediacontentManager::getFolders(
     }
     Catch(WrtDeviceApis::Commons::UnsupportedException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::ConversionException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::NotFoundException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -206,19 +201,17 @@ JSValueRef JSMediacontentManager::findItems(
                             const JSValueRef arguments[],
                             JSValueRef* exception )
 {
-    LogDebug("JSContentManagerManager::find entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if(!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIError::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_FIND_ITEMS);
-
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_FIND_ITEMS);
 
     JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
 
@@ -266,8 +259,8 @@ JSValueRef JSMediacontentManager::findItems(
         sortModeObj= argValidator.toObject(4,true);
 
         // count
-        if(argumentCount >= 6){        
-//            if(!JSValueIsNull(context, arguments[5]) && !JSValueIsUndefined(context, arguments[5])){
+        if(argumentCount >= 6){
+            if(!JSValueIsNull(context, arguments[5])){
                 long count = argValidator.toLong(5, true, 0);
                 if( count >= 0L ){
                     dplEvent->setLimit(count);
@@ -275,7 +268,7 @@ JSValueRef JSMediacontentManager::findItems(
                 else{
                     throw InvalidValuesException( "count should be positive.");
                 }
-//            }
+            }
         }
         if(argumentCount >= 7){
             // offset
@@ -288,11 +281,11 @@ JSValueRef JSMediacontentManager::findItems(
             }
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
-        DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        DeviceAPI::Common::UnknownException err("Unknown Error in find().");
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     Try
@@ -312,28 +305,28 @@ JSValueRef JSMediacontentManager::findItems(
     }
     Catch(WrtDeviceApis::Commons::UnsupportedException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::ConversionException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::NotFoundException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -349,18 +342,16 @@ JSValueRef JSMediacontentManager::updateItemsBatch(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("JSContentManagerManager::updateItemsBatch entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if(!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIError::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH);
 
     JSCallbackManagerPtr cbm(NULL);
     MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
@@ -386,20 +377,17 @@ JSValueRef JSMediacontentManager::updateItemsBatch(JSContextRef context,
         if(successCallbackObj){
             cbm->setOnSuccess(successCallbackObj);
         }
-        else{
-            throw TypeMismatchException("SuccessCallback type mismatched.");
-        }
 
         JSObjectRef errorCallbackObj = argValidator.toFunction(2,true);
         if(errorCallbackObj){
             cbm->setOnError(errorCallbackObj);
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
-        DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        DeviceAPI::Common::UnknownException err("Unknown Error in updateBatch().");
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     Try
@@ -417,28 +405,28 @@ JSValueRef JSMediacontentManager::updateItemsBatch(JSContextRef context,
     }
     Catch(WrtDeviceApis::Commons::UnsupportedException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::ConversionException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::NotFoundException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -455,18 +443,17 @@ JSValueRef JSMediacontentManager::updateItem(
                         const JSValueRef arguments[],
                         JSValueRef* exception)
 {
-    LogDebug("JSContentManagerManager::updateItem entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if (!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIError::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_UPDATE_ITEM);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_UPDATE_ITEM);
 
     Try
     {
@@ -494,28 +481,53 @@ JSValueRef JSMediacontentManager::updateItem(
         IEventUpdateMediaPtr dplEvent(new IEventUpdateMedia());
 
         if(JSValueIsObjectOfClass(context, arguments[0], JSImage::getClassRef())){
-            JSValueRef geoValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
-            JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
-            double latitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "latitude"));
-            double longitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "longitude"));
-
             MediacontentImagePtr imgPtr = JSImage::getImageObject(arg);
-            imgPtr->setImageLatitude(latitude);
-            imgPtr->setImageLongitude(longitude);
+            JSValueRef geoValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
+            if(!(JSValueIsNull(context, geoValRef) || JSValueIsUndefined(context, geoValRef))){
+                JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
+                double latitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "latitude"));
+                double longitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "longitude"));
+                if(ContentUtility::checkLocation(latitude, latitude)){
+                    imgPtr->setImageLatitude(latitude);
+                    imgPtr->setImageLongitude(longitude);
+                }
+                else{
+                    ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "geolocation value is not valid.");
+                }
+            }
+            else
+            {
+                imgPtr->setImageLatitude(DEFAULT_GEOLOCATION);
+                imgPtr->setImageLongitude(DEFAULT_GEOLOCATION);
+            }
         }
         else if(JSValueIsObjectOfClass(context, arguments[0], JSVideo::getClassRef())){
-            JSValueRef geoValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
-            JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
-
-            double latitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "latitude"));
-
-            double longitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "longitude"));
-
             MediacontentVideoPtr vedioPtr = JSVideo::getVideoObject(arg);
-            vedioPtr->setVideoLatitude(latitude);
-            vedioPtr->setVideoLongitude(longitude);
+            JSValueRef geoValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "geolocation");
+            if(!(JSValueIsNull(context, geoValRef) || JSValueIsUndefined(context, geoValRef))){
+                JSObjectRef geoObjRef = JSUtil::JSValueToObject(context, geoValRef);
+                double latitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "latitude"));
+                double longitude = JSUtil::JSValueToDouble(context, JSUtil::getProperty(context, geoObjRef, "longitude"));
+                if(ContentUtility::checkLocation(latitude, latitude)){
+                    vedioPtr->setVideoLatitude(latitude);
+                    vedioPtr->setVideoLongitude(longitude);
+                }
+                else{
+                    ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "geolocation value is not valid.");
+                }
+            }
+            else
+            {
+                vedioPtr->setVideoLatitude(DEFAULT_GEOLOCATION);
+                vedioPtr->setVideoLongitude(DEFAULT_GEOLOCATION);
+            }
         }
 
+        JSValueRef nameValRef = JSUtil::getProperty(context , JSUtil::JSValueToObject(context, arguments[0]), "name");
+        if((JSValueIsNull(context, nameValRef) || JSValueIsUndefined(context, nameValRef)) ||
+            JSUtil::JSValueToString(context, nameValRef) == ""){
+            ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "name is not valid.");
+        }
         event = JSMedia::getMediaObject(arg);
         dplEvent->setMediaItem(event);
 
@@ -528,28 +540,28 @@ JSValueRef JSMediacontentManager::updateItem(
     }
     Catch(WrtDeviceApis::Commons::UnsupportedException)
     {
-    LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+    return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException)
     {
-    LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+    return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::ConversionException)
     {
-    LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+    return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::NotFoundException)
     {
-    LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+    LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+    return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-    LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+    return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -562,12 +574,12 @@ static void _scanCompletedCallback(std::string err_msg, std::string path, void *
     if(cb != NULL){
             if(err_msg.empty() ){
                         Converter converter(cb->getContext());
-                        JSValueRef jsPath = converter.toJSValueRef(path);
+                        JSValueRef jsPath = converter.toJSValueRef(ContentUtility::convertPathToUri(path));
                         cb->callSuccessCallback(jsPath);
             }
             else{
                         DeviceAPI::Common::UnknownException err(err_msg.c_str());
-                        JSObjectRef errorObject = JSWebAPIError::makeJSWebAPIError(cb->getContext(),err);
+                        JSObjectRef errorObject = JSWebAPIErrorFactory::makeErrorObject(cb->getContext(),err);
                         cb->callErrorCallback(errorObject);
             }
             delete cb;
@@ -582,18 +594,16 @@ JSValueRef JSMediacontentManager::scanFile(
                         const JSValueRef arguments[],
                         JSValueRef* exception)
 {
-    LogDebug("JSContentManagerManager::scanFile entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if(!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SCAN_FILE);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SCAN_FILE);
 
     string path;
     CallbackUserData *callback = NULL;
@@ -619,11 +629,11 @@ JSValueRef JSMediacontentManager::scanFile(
             callback->setErrorCallback(errorCallbackObj);
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
-        DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        DeviceAPI::Common::UnknownException err("Unknown Error in scanFile().");
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
     Try
@@ -633,28 +643,28 @@ JSValueRef JSMediacontentManager::scanFile(
     }
     Catch(WrtDeviceApis::Commons::UnsupportedException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::ConversionException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::NotFoundException)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+        LoggerW("Exception: "<<_rethrown_exception.GetMessage());
+        return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -670,18 +680,16 @@ JSValueRef JSMediacontentManager::setChangeListener(
                         const JSValueRef arguments[],
                         JSValueRef* exception)
 {
-    LogDebug("JSContentManagerManager::setChangeListener entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
 
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if(!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SET_CHANGE_LISTENER);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SET_CHANGE_LISTENER);
 
     try{
         ArgumentValidator argValidator(context, argumentCount, arguments);
@@ -694,11 +702,11 @@ JSValueRef JSMediacontentManager::setChangeListener(
             throw DeviceAPI::Common::UnknownException( "Unknown exception is occured by platfrom");
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
-        DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        DeviceAPI::Common::UnknownException err("Unknown Error in setChangeListener().");
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -713,17 +721,15 @@ JSValueRef JSMediacontentManager::unsetChangeListener(
                         const JSValueRef arguments[],
                         JSValueRef* exception)
 {
-    LogDebug("JSContentManagerManager::unsetChangeListener entered");
-       TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
-    MediacontentManagerPrivObject *privateObject;
-    privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+    TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+    MediacontentManagerPriv *privateObject;
+    privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(thisObject));
     if(!privateObject) {
         DeviceAPI::Common::UnknownException err("Content's private object is NULL.");
-        return JSWebAPIException::throwException(context, exception, err);
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
-    AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SET_CHANGE_LISTENER);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SET_CHANGE_LISTENER);
 
     try{
         // perform
@@ -733,11 +739,11 @@ JSValueRef JSMediacontentManager::unsetChangeListener(
             throw DeviceAPI::Common::UnknownException( "Unknown exception is occured by platfrom");
         }
     }catch(const BasePlatformException &err){
-        return JSWebAPIException::throwException(context,exception,err);
+        return JSWebAPIErrorFactory::postException(context,exception,err);
     }
     catch(...){
-        DeviceAPI::Common::UnknownException err("Unknown Error in ContentManager.getDirectories().");
-        return JSWebAPIException::throwException(context, exception, err);
+        DeviceAPI::Common::UnknownException err("Unknown Error in unsetChangeListener().");
+        return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
        TIME_TRACER_ITEM_END(__FUNCTION__, 0);
@@ -759,13 +765,11 @@ const JSClassDefinition* JSMediacontentManager::getClassInfo()
 
 void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object)
 {
-    LogDebug("JSContentManager  initialize entered");
-    MediacontentManagerPrivObject *privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(object));
+    MediacontentManagerPriv *privateObject = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(object));
     if (NULL == privateObject)
     {
-        LogDebug("Create ContenttManagerPrivObject");
         IMediacontentManagerPtr contentManager = MediacontentFactory::getInstance().createMediacontentManagerObject();
-        privateObject = new MediacontentManagerPrivObject(context, contentManager);
+        privateObject = new MediacontentManagerPriv(context, contentManager);
         if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject)))
         {
             delete privateObject;
@@ -776,11 +780,9 @@ void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object)
 
 void JSMediacontentManager::finalize(JSObjectRef object)
 {
-    LogDebug("Entered");
-    MediacontentManagerPrivObject* priv = static_cast<MediacontentManagerPrivObject*> (JSObjectGetPrivate(object));
+    MediacontentManagerPriv* priv = static_cast<MediacontentManagerPriv*> (JSObjectGetPrivate(object));
     if(priv != NULL)
     {
-        LogDebug("Deleting coordinates object");
         delete priv;
         JSObjectSetPrivate(object, NULL);
         priv = NULL;
@@ -793,7 +795,7 @@ IMediacontentManagerPtr JSMediacontentManager::getContentManagerPrivObject(
                         const JSObjectRef object,
                         JSValueRef* exception)
 {
-    MediacontentManagerPrivObject *priv = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(object));
+    MediacontentManagerPriv *priv = static_cast<MediacontentManagerPriv*>(JSObjectGetPrivate(object));
     if (priv)
     {
         return priv->getObject();