#include "JSFilesystemManager.h"
-
-#include <dpl/log/log.h>
-
#include <Commons/Exception.h>
#include "EventResolve.h"
#include "IManager.h"
#include <WidgetDB/WidgetDBMgr.h>
#include <WidgetDB/IWidgetDB.h>
#include <TimeTracer.h>
-
+#include <ArgumentValidator.h>
+#include <JSWebAPIError.h>
+#include <JSWebAPIException.h>
+#include <JSUtil.h>
#include "JSFile.h"
#include "FilesystemUtils.h"
#include "Converter.h"
#include "ResponseDispatcher.h"
#include "FilesystemAsyncCallbackManager.h"
#include "FilesystemListenerManager.h"
+#include <Logger.h>
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis;
+
namespace {
const char* PLUGIN_NAME = "FileSystemManager";
const char* PROPERTY_MAXPATHLENGTH = "maxPathLength";
{
if (Validator(ctx).isCallback(arg)) {
return arg;
- } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
+ } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
ThrowMsg(ConversionException, "Not a function nor JS null.");
}
return NULL;
int widgetId = WrtAccessSingleton::Instance().getWidgetId();
WidgetDB::Api::IWidgetDBPtr widgetDB = WidgetDB::Api::getWidgetDB(widgetId);
- LogDebug(widgetDB->getWidgetInstallationPath());
+ LoggerD(widgetDB->getWidgetInstallationPath());
std::string wgtpackage = "wgt-package";
std::string wgtprivate = "wgt-private";
std::string wgtprivatetemp = "wgt-private-tmp";
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_GET_STORAGE);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ // argument validation with new validator
+ try {
+ ArgumentValidator validator(context, argc, argv);
+ validator.toString(0, false);
+ validator.toFunction(1, false);
+ validator.toFunction(2, true);
+ }
+ catch (const BasePlatformException &err) {
+ return JSWebAPIException::throwException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("");
+ return JSWebAPIException::throwException(context, exception, err);
+ }
+
if (argc < 2) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
+
+
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-
+
try {
JSValueRef onSuccess = getFunction(globalContext, argv[1]);
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_LIST_STORAGE);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ // argument validation with new validator
+ try {
+ ArgumentValidator validator(context, argc, argv);
+ validator.toFunction(0, false);
+ validator.toFunction(1, true);
+ }
+ catch (const BasePlatformException &err) {
+ return JSWebAPIException::throwException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("");
+ return JSWebAPIException::throwException(context, exception, err);
+ }
if (argc < 1) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ // argument validation with new validator
+ try {
+ ArgumentValidator validator(context, argc, argv);
+ validator.toFunction(0, false);
+ validator.toFunction(1, true);
+ }
+ catch (const BasePlatformException &err) {
+ LogDebug("Exception");
+ return JSWebAPIException::throwException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("");
+ return JSWebAPIException::throwException(context, exception, err);
+ }
+
+
if (argc < 1) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "TYPE_MISMATCH_ERROR");
}
-
JSContextRef globalContext = privateObject->getContext();
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ LogDebug("a");
+
+ // argument validation with new validator
+ try {
+ ArgumentValidator validator(context, argc, argv);
+ validator.toLong(0, false);
+ }
+ catch (const BasePlatformException &err) {
+ return JSWebAPIException::throwException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("");
+ return JSWebAPIException::throwException(context, exception, err);
+ }
+
if (argc < 1) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
try {
long id = static_cast<long>(converter->toLong(argv[0]));
- LogDebug("id:" << id);
+ LoggerD("id:" << id);
if (id >= 0) {
JSValueRef* exception)
{
- LogDebug("<<<");
+ LoggerD("<<<");
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ // argument validation with new validator
+ try {
+ ArgumentValidator validator(context, argc, argv);
+ validator.toString(0, false);
+ validator.toFunction(1, false);
+ validator.toFunction(2, true);
+ validator.toString(3, true);
+ }
+ catch (const BasePlatformException &err) {
+ return JSWebAPIException::throwException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("");
+ return JSWebAPIException::throwException(context, exception, err);
+ }
if (argc < 2) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
}
+ LogDebug("resolve");
+
+
+
+
JSContextRef globalContext = privateObject->getContext();
ConverterPtr converter = ConverterFactory::getConverter(globalContext);
size_t index = 0;
- JSValueRef reserveArguments[4];
JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-
-
-
+ JSValueRef reserveArguments[4];
try {
for (index = 0; index < 4; index++) {
if (index < argc)
reserveArguments[index] = argv[index];
else
- reserveArguments[index] = JSValueMakeUndefined(context);
+ reserveArguments[index] = JSValueMakeUndefined(context);
}
+
JSValueRef onSuccess = getFunction(globalContext, reserveArguments[1]);
JSValueRef onError = NULL;
std::string virtualPath;
path = Utils::fromVirtualPath(globalContext, converter->toString(reserveArguments[0]));
virtualPath = converter->toString(reserveArguments[0]);
- LogDebug("virtualPath:[" << virtualPath << "]");
+ LoggerD("virtualPath:[" << virtualPath << "]");
int permissions = PERM_READ | PERM_WRITE;
if (argc > 3) {
std::string perms = converter->toString(reserveArguments[3]);
- LogDebug("perms:[" << perms << "]");
+ LoggerD("perms:[" << perms << "]");
if (("r" != perms) && ("rw" != perms) && ("w" != perms) && ("a" != perms)) {
return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid permission");
} else if ("r" == perms) {