<commit_before>define(function (require) {
  require("jquery");
  require('json2');
  var Utils = require('core/Utils');
  var Connector = require('core/Connector');
  
  var storage = window.sessionStorage;
  storage.clear();
  
  function get_all(class_id) {
    var objects_string = storage.getItem(class_id);
    if (!objects_string) {
      return null;
    }
    var objects = JSON.parse(objects_string);
    if (!objects) {
      return null;
    }
    return objects;
  }
  
  function get_one(class_id, object_id) {
    var objects = get_all(class_id);
    if (!objects) {
      return null;
    }
    var object = objects[object_id];
    return !object ? null : object;
  }
  
  function set_all(class_id, objects) {
    console.assert(Utils.is_object(objects), objects);
    if (!Utils.is_object(objects)) {
      console.error("'objects' argument is not [Object].");
      console.dir(objects);
      return;
    }
    storage.setItem(class_id, JSON.stringify(objects));
  }
  
  function set_one(class_id, object_id, object) {
    console.assert(Utils.is_object(object), object);
    if (!Utils.is_object(object)) {
      console.error("'object' argument is not [Object].");
      console.dir(object);
      return;
    }
    var objects = get_all(class_id);
    if (!objects) {
      objects = {};
    }
    objects[object_id] = object;
    set_all(class_id, objects);
  }
  
  function remove_all(class_id) {
    storage.removeItem(class_id);
  }
  
  function remove_one(class_id, object_id) {
    var objects = get_all(class_id);
    if (!objects) {
      return;
    }
    delete objects[object_id];
    set_all(objects);
  }
  
  var Storage = {
    create: function(class_id, object, files) {
      var url = 'api/' + class_id;
      return Connector.post(url, object, files, "json");
    },
    read: function(class_id, object_id) {
      var url = 'api/' + class_id + (!object_id ? '' : '/' + object_id);
      var dfd = new $.Deferred;
      Connector.get(url, "json")
      .done(function (response, text_status, jqXHR) {
        var data = null;
        if (jqXHR.status == 304) {
          data = !object_id ? get_all(class_id) : get_one(class_id, object_id);
        } else {
          data = response;
        }
        if (!object_id) {
          set_all(class_id, data);
        } else {
          set_one(class_id, object_id, data);
        }
        dfd.resolve(data);
      })
      .fail(function (jqXHR, text_status, error_thrown) {
        dfd.reject(jqXHR, text_status, error_thrown);
      });
      return dfd.promise();
    },
    update: function(class_id, object_id, object, files) {
      var url = 'api/' + class_id + '/' + object_id;
      return Connector.update(url, object, files, "json");
    },
    delete: function(class_id, object_id) {
      var url = 'api/' + class_id + '/' + object_id;
      return Connector.delete(url, "json");
    }
  };
  
  return Storage;
});
<commit_msg>Modified Storage.js when HTTP response status 410 in create/update/delete.<commit_after>define(function (require) {
  require("jquery");
  require('json2');
  var Utils = require('core/Utils');
  var Connector = require('core/Connector');
  
  var storage = window.sessionStorage;
  storage.clear();
  
  function get_all(class_id) {
    var objects_string = storage.getItem(class_id);
    if (!objects_string) {
      return null;
    }
    var objects = JSON.parse(objects_string);
    if (!objects) {
      return null;
    }
    return objects;
  }
  
  function get_one(class_id, object_id) {
    var objects = get_all(class_id);
    if (!objects) {
      return null;
    }
    var object = objects[object_id];
    return !object ? null : object;
  }
  
  function set_all(class_id, objects) {
    console.assert(Utils.is_object(objects), objects);
    if (!Utils.is_object(objects)) {
      console.error("'objects' argument is not [Object].");
      console.dir(objects);
      return;
    }
    storage.setItem(class_id, JSON.stringify(objects));
  }
  
  function set_one(class_id, object_id, object) {
    console.assert(Utils.is_object(object), object);
    if (!Utils.is_object(object)) {
      console.error("'object' argument is not [Object].");
      console.dir(object);
      return;
    }
    var objects = get_all(class_id);
    if (!objects) {
      objects = {};
    }
    objects[object_id] = object;
    set_all(class_id, objects);
  }
  
  function remove_all(class_id) {
    storage.removeItem(class_id);
  }
  
  function remove_one(class_id, object_id) {
    var objects = get_all(class_id);
    if (!objects) {
      return;
    }
    delete objects[object_id];
    set_all(objects);
  }
  
  var Storage = {
    create: function(class_id, object, files) {
      var url = 'api/' + class_id;
      var dfd = new $.Deferred;
      Connector.post(url, object, files, "json")
      .done(function (response, text_status, jqXHR) {
        dfd.resolve(response, text_status, jqXHR);
      })
      .fail(function (jqXHR, text_status, error_thrown) {
        if (jqXHR.status == 410) {
          remove_all(class_id);
        }
        dfd.reject(jqXHR, text_status, error_thrown);
      });
      return dfd.promise();
    },
    read: function(class_id, object_id) {
      var url = 'api/' + class_id + (!object_id ? '' : '/' + object_id);
      var dfd = new $.Deferred;
      Connector.get(url, "json")
      .done(function (response, text_status, jqXHR) {
        var data = null;
        if (jqXHR.status == 304) {
          data = !object_id ? get_all(class_id) : get_one(class_id, object_id);
        } else {
          data = response;
        }
        if (!object_id) {
          set_all(class_id, data);
        } else {
          set_one(class_id, object_id, data);
        }
        dfd.resolve(data);
      })
      .fail(function (jqXHR, text_status, error_thrown) {
        if (jqXHR.status == 410) {
          if (!object_id) {
            remove_all(class_id);
          } else {
            remove_one(class_id, object_id);
          }
        }
        dfd.reject(jqXHR, text_status, error_thrown);
      });
      return dfd.promise();
    },
    update: function(class_id, object_id, object, files) {
      var url = 'api/' + class_id + '/' + object_id;
      var dfd = new $.Deferred;
      Connector.update(url, object, files, "json")
      .done(function (response, text_status, jqXHR) {
        dfd.resolve(response, text_status, jqXHR);
      })
      .fail(function (jqXHR, text_status, error_thrown) {
        if (jqXHR.status == 410) {
          remove_one(class_id, object_id);
        }
        dfd.reject(jqXHR, text_status, error_thrown);
      });
      return dfd.promise();
    },
    delete: function(class_id, object_id) {
      var url = 'api/' + class_id + '/' + object_id;
      var dfd = new $.Deferred;
      Connector.delete(url, "json")
      .done(function (response, text_status, jqXHR) {
        remove_one(class_id, object_id);
        dfd.resolve(response, text_status, jqXHR);
      })
      .fail(function (jqXHR, text_status, error_thrown) {
        if (jqXHR.status == 410) {
          remove_one(class_id, object_id);
        }
        dfd.reject(jqXHR, text_status, error_thrown);
      });
      return dfd.promise();
    }
  };
  
  return Storage;
});

{'fraction_non_alphanumeric': 0.13741403026134802, 'fraction_numerical': 0.0031636863823933975, 'mean_word_length': 2.4856184084372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6938073', 'n_tokens_mistral': 2488, 'n_tokens_neox': 2454, 'n_words': 488}