/*
 * CS3283/4 dataModifier.js
 * This acts as a facade class for modifying and update data for storage facade
 *
 */

import dataAdd from './dataAdd';
import dataDelete from './dataDelete';
import dataUpdate from './dataUpdate';
import exceptions from '../exceptions';

export default class dataModifier {
  static constructor() {}

  static deleteAllEntities() {
    dataDelete.deleteAllEntities();
  }

  static createNewFile(organizationId, filePath, folderId) {
    if (typeof Promise === 'function') {
      return new Promise((resolve, reject) => {
        dataAdd.createNewFile(organizationId, filePath, folderId)
          .then((fileId) => {
            console.log('DATAMODIFIER');
            console.log(fileId);
            resolve(fileId);
          }).catch(sqlErr => sqlErr);
      });
    } else {
      throw new exceptions.PromiseFunctionNotDefined();
    }
  }

  static createNewFolder(organizationId, folderPath, folderId) {
    if (typeof Promise === 'function') {
      return new Promise((resolve, reject) => {
        dataAdd.createNewFolder(organizationId, folderPath, folderId)
          .then(data => true)
          .catch(sqlErr => sqlErr);
      });
    } else {
      throw new exceptions.PromiseFunctionNotDefined();
    }
  }

  static saveFile(fileId, file) {
    if (typeof Promise === 'function') {
      return new Promise((resolve, reject) => {
        resolve(dataUpdate.saveFile(fileId, file)
          .then(() => true))
          .catch(sqlError => sqlError);
      });
    } else {
      throw new exceptions.PromiseFunctionNotDefined();
    }
  }

  static deleteFile(fileId) {
    if (typeof Promise === 'function') {
      return new Promise((resolve, reject) => {
        resolve(dataDelete.deleteFile(fileId)
          .then(() => true))
          .catch(sqlError => sqlError);
      });
    } else {
      throw new exceptions.PromiseFunctionNotDefined();
    }
  }

}

@@ -1912,10 +1912,341 @@
  %7D%0A  %7D%0A%0A
+  static deleteFolder(folderId) %7B%0A    if (typeof Promise === 'function') %7B%0A      return new Promise((resolve, reject) =%3E %7B%0A        resolve(dataDelete.deleteFolder(folderId)%0A          .then(() =%3E true))%0A          .catch(sqlError =%3E sqlError);%0A      %7D);%0A    %7D else %7B%0A      throw new exceptions.PromiseFunctionNotDefined();%0A    %7D%0A  %7D%0A
 %7D%0A

Add deleteFolder implementation into dataModifier.js