function createRecord(id, collection) {
    let placeId = this.idForGUID(id);
    let record;
    if (placeId <= 0) { // deleted item
      record = new PlacesItem(collection, id);
      record.deleted = true;
      return record;
    }

    let parent = PlacesUtils.bookmarks.getFolderIdForItem(placeId);
    switch (PlacesUtils.bookmarks.getItemType(placeId)) {
    case PlacesUtils.bookmarks.TYPE_BOOKMARK:
      let bmkUri = PlacesUtils.bookmarks.getBookmarkURI(placeId).spec;
      if (bmkUri.indexOf("place:") == 0) {
        record = new BookmarkQuery(collection, id);

        // Get the actual tag name instead of the local itemId
        let folder = bmkUri.match(/[:&]folder=(\d+)/);
        try {
          // There might not be the tag yet when creating on a new client
          if (folder != null) {
            folder = folder[1];
            record.folderName = PlacesUtils.bookmarks.getItemTitle(folder);
            this._log.trace("query id: " + folder + " = " + record.folderName);
          }
        }
        catch(ex) {}
        
        // Persist the Smart Bookmark anno, if found.
        try {
          let anno = PlacesUtils.annotations.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO);
          if (anno != null) {
            this._log.trace("query anno: " + SMART_BOOKMARKS_ANNO +
                            " = " + anno);
            record.queryId = anno;
          }
        }
        catch(ex) {}
      }
      else {
        record = new Bookmark(collection, id);
      }
      record.title = PlacesUtils.bookmarks.getItemTitle(placeId);

      record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      record.bmkUri = bmkUri;
      record.tags = this._getTags(record.bmkUri);
      record.keyword = PlacesUtils.bookmarks.getKeywordForBookmark(placeId);
      record.description = this._getDescription(placeId);
      record.loadInSidebar = this._isLoadInSidebar(placeId);
      break;

    case PlacesUtils.bookmarks.TYPE_FOLDER:
      if (PlacesUtils.annotations
                     .itemHasAnnotation(placeId, PlacesUtils.LMANNO_FEEDURI)) {
        record = new Livemark(collection, id);
        let as = PlacesUtils.annotations;
        record.feedUri = as.getItemAnnotation(placeId, PlacesUtils.LMANNO_FEEDURI);
        try {
          record.siteUri = as.getItemAnnotation(placeId, PlacesUtils.LMANNO_SITEURI);
        } catch (ex) {}
      } else {
        record = new BookmarkFolder(collection, id);
      }

      if (parent > 0)
        record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      record.title = PlacesUtils.bookmarks.getItemTitle(placeId);
      record.description = this._getDescription(placeId);
      record.children = this._getChildGUIDsForId(placeId);
      break;

    case PlacesUtils.bookmarks.TYPE_SEPARATOR:
      record = new BookmarkSeparator(collection, id);
      if (parent > 0)
        record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      // Create a positioning identifier for the separator, used by _mapDupe
      record.pos = PlacesUtils.bookmarks.getItemIndex(placeId);
      break;

    default:
      record = new PlacesItem(collection, id);
      this._log.warn("Unknown item type, cannot serialize: " +
                     PlacesUtils.bookmarks.getItemType(placeId));
    }

    record.parentid = this.GUIDForId(parent);
    record.sortindex = this._calculateIndex(record);

    return record;
  }
// Create a record starting from the weave id (places guid)
Create a record starting from the weave id (places guid)
Create a record starting from the weave id ( places guid )
function createRecord(id, collection) {
    let placeId = this.idForGUID(id);
    let record;
    if (placeId <= 0) { 
      record = new PlacesItem(collection, id);
      record.deleted = true;
      return record;
    }
    let parent = PlacesUtils.bookmarks.getFolderIdForItem(placeId);
    switch (PlacesUtils.bookmarks.getItemType(placeId)) {
    case PlacesUtils.bookmarks.TYPE_BOOKMARK:
      let bmkUri = PlacesUtils.bookmarks.getBookmarkURI(placeId).spec;
      if (bmkUri.indexOf("place:") == 0) {
        record = new BookmarkQuery(collection, id);
        let folder = bmkUri.match(/[:&]folder=(\d+)/);
        try {
          if (folder != null) {
            folder = folder[1];
            record.folderName = PlacesUtils.bookmarks.getItemTitle(folder);
            this._log.trace("query id: " + folder + " = " + record.folderName);
          }
        }
        catch(ex) {}
        try {
          let anno = PlacesUtils.annotations.getItemAnnotation(placeId, SMART_BOOKMARKS_ANNO);
          if (anno != null) {
            this._log.trace("query anno: " + SMART_BOOKMARKS_ANNO +
                            " = " + anno);
            record.queryId = anno;
          }
        }
        catch(ex) {}
      }
      else {
        record = new Bookmark(collection, id);
      }
      record.title = PlacesUtils.bookmarks.getItemTitle(placeId);
      record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      record.bmkUri = bmkUri;
      record.tags = this._getTags(record.bmkUri);
      record.keyword = PlacesUtils.bookmarks.getKeywordForBookmark(placeId);
      record.description = this._getDescription(placeId);
      record.loadInSidebar = this._isLoadInSidebar(placeId);
      break;
    case PlacesUtils.bookmarks.TYPE_FOLDER:
      if (PlacesUtils.annotations
                     .itemHasAnnotation(placeId, PlacesUtils.LMANNO_FEEDURI)) {
        record = new Livemark(collection, id);
        let as = PlacesUtils.annotations;
        record.feedUri = as.getItemAnnotation(placeId, PlacesUtils.LMANNO_FEEDURI);
        try {
          record.siteUri = as.getItemAnnotation(placeId, PlacesUtils.LMANNO_SITEURI);
        } catch (ex) {}
      } else {
        record = new BookmarkFolder(collection, id);
      }
      if (parent > 0)
        record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      record.title = PlacesUtils.bookmarks.getItemTitle(placeId);
      record.description = this._getDescription(placeId);
      record.children = this._getChildGUIDsForId(placeId);
      break;
    case PlacesUtils.bookmarks.TYPE_SEPARATOR:
      record = new BookmarkSeparator(collection, id);
      if (parent > 0)
        record.parentName = PlacesUtils.bookmarks.getItemTitle(parent);
      record.pos = PlacesUtils.bookmarks.getItemIndex(placeId);
      break;
    default:
      record = new PlacesItem(collection, id);
      this._log.warn("Unknown item type, cannot serialize: " +
                     PlacesUtils.bookmarks.getItemType(placeId));
    }
    record.parentid = this.GUIDForId(parent);
    record.sortindex = this._calculateIndex(record);
    return record;
  }
function createRecord ( id , collection ) { let placeId = this . idForGUID ( id ) ; let record ; if ( placeId <= 0 ) { record = new PlacesItem ( collection , id ) ; record . deleted = true ; return record ; } let parent = PlacesUtils . bookmarks . getFolderIdForItem ( placeId ) ; switch ( PlacesUtils . bookmarks . getItemType ( placeId ) ) { case PlacesUtils . bookmarks . TYPE_BOOKMARK : let bmkUri = PlacesUtils . bookmarks . getBookmarkURI ( placeId ) . spec ; if ( bmkUri . indexOf ( "place:" ) == 0 ) { record = new BookmarkQuery ( collection , id ) ; let folder = bmkUri . match ( / [:&]folder=(\d+) / ) ; try { if ( folder != null ) { folder = folder [ 1 ] ; record . folderName = PlacesUtils . bookmarks . getItemTitle ( folder ) ; this . _log . trace ( "query id: " + folder + " = " + record . folderName ) ; } } catch ( ex ) { } try { let anno = PlacesUtils . annotations . getItemAnnotation ( placeId , SMART_BOOKMARKS_ANNO ) ; if ( anno != null ) { this . _log . trace ( "query anno: " + SMART_BOOKMARKS_ANNO + " = " + anno ) ; record . queryId = anno ; } } catch ( ex ) { } } else { record = new Bookmark ( collection , id ) ; } record . title = PlacesUtils . bookmarks . getItemTitle ( placeId ) ; record . parentName = PlacesUtils . bookmarks . getItemTitle ( parent ) ; record . bmkUri = bmkUri ; record . tags = this . _getTags ( record . bmkUri ) ; record . keyword = PlacesUtils . bookmarks . getKeywordForBookmark ( placeId ) ; record . description = this . _getDescription ( placeId ) ; record . loadInSidebar = this . _isLoadInSidebar ( placeId ) ; break ; case PlacesUtils . bookmarks . TYPE_FOLDER : if ( PlacesUtils . annotations . itemHasAnnotation ( placeId , PlacesUtils . LMANNO_FEEDURI ) ) { record = new Livemark ( collection , id ) ; let as = PlacesUtils . annotations ; record . feedUri = as . getItemAnnotation ( placeId , PlacesUtils . LMANNO_FEEDURI ) ; try { record . siteUri = as . getItemAnnotation ( placeId , PlacesUtils . LMANNO_SITEURI ) ; } catch ( ex ) { } } else { record = new BookmarkFolder ( collection , id ) ; } if ( parent > 0 ) record . parentName = PlacesUtils . bookmarks . getItemTitle ( parent ) ; record . title = PlacesUtils . bookmarks . getItemTitle ( placeId ) ; record . description = this . _getDescription ( placeId ) ; record . children = this . _getChildGUIDsForId ( placeId ) ; break ; case PlacesUtils . bookmarks . TYPE_SEPARATOR : record = new BookmarkSeparator ( collection , id ) ; if ( parent > 0 ) record . parentName = PlacesUtils . bookmarks . getItemTitle ( parent ) ; record . pos = PlacesUtils . bookmarks . getItemIndex ( placeId ) ; break ; default : record = new PlacesItem ( collection , id ) ; this . _log . warn ( "Unknown item type, cannot serialize: " + PlacesUtils . bookmarks . getItemType ( placeId ) ) ; } record . parentid = this . GUIDForId ( parent ) ; record . sortindex = this . _calculateIndex ( record ) ; return record ; }
Create a record starting from the weave id (places guid)
Create a record starting from the weave id ( places guid )
// deleted item // Get the actual tag name instead of the local itemId // There might not be the tag yet when creating on a new client // Persist the Smart Bookmark anno, if found. // Create a positioning identifier for the separator, used by _mapDupe