[Archive] add InvalidAccessError exception
authorWitold Choinkowski <w.choinkowsk@samsung.com>
Fri, 2 Jan 2015 14:41:28 +0000 (15:41 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 2 Feb 2015 09:28:56 +0000 (18:28 +0900)
Change-Id: Ia0bdaccfbafdde7f06986ef9f9162254be3c6549
Signed-off-by: Witold Choinkowski <w.choinkowsk@samsung.com>
src/archive/archive_api.js

index d57b27d36086904cbdee15f95ed73ebbf6cb6f27..722bddde332fa041b0fe63432baf43494afe83c5 100644 (file)
@@ -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: {