From: Witold Choinkowski Date: Fri, 2 Jan 2015 14:41:28 +0000 (+0100) Subject: [Archive] add InvalidAccessError exception X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~526 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13864b4a047a93d98bc90aaa018f7c2e290626ac;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Archive] add InvalidAccessError exception Change-Id: Ia0bdaccfbafdde7f06986ef9f9162254be3c6549 Signed-off-by: Witold Choinkowski --- diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js index d57b27d3..722bddde 100644 --- a/src/archive/archive_api.js +++ b/src/archive/archive_api.js @@ -133,6 +133,12 @@ function propertyFactory_(that, name, value, flags, options) { ); } +function checkMode(mode, access) +{ if(access.indexOf(mode) == -1) { + throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_ACCESS_ERR, 'Not allowed operation'); + } +} + /** * Enumeration for the compression level. * @enum {string} @@ -282,6 +288,7 @@ function ArchiveFile(data) { } } + checkMode(this.mode, ["w","rw", "a"]); bridge.async({ cmd: 'ArchiveFile_add', args: { @@ -336,6 +343,7 @@ function ArchiveFile(data) { throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, "destinationDirectory should be virtual path or file."); + checkMode(this.mode, ["r","rw"]); bridge.async({ cmd: 'ArchiveFile_extractAll', args: { @@ -383,6 +391,7 @@ function ArchiveFile(data) { ]), opId = getNextOpId(); + checkMode(this.mode, ["r","rw"]); bridge.async({ cmd: 'ArchiveFile_getEntries', args: { @@ -421,6 +430,7 @@ function ArchiveFile(data) { ]), opId = getNextOpId(); + checkMode(this.mode, ["r","rw"]); bridge.async({ cmd: 'ArchiveFile_getEntryByName', args: {