Write the page's meta object to the DB

@param {String} uri
@param {Object} data
@returns {Promise}
332077
function putMeta(uri, data) {
  const id = replaceVersion(uri.replace('/meta', ''));

  return db.putMeta(id, data)
    .then(pubToBus(id));
}
269571
private void buildData(String path, WebPage page, List<TreePageData> data, WebSiteRequest req) throws IOException, SQLException {
		if(isVisible(page)) {
			if(path.length()>0) path=path+'/'+page.getShortTitle();
			else path=page.getShortTitle();
			WebPage[] pages=page.getCachedPages(req);
			int len=pages.length;
			data.add(
				new TreePageData(
					len>0 ? (path+'/') : path,
					req.getContextPath()+req.getURL(page),
					page.getDescription()
				)
			);
			for(int c=0; c<len; c++) buildData(path, pages[c], data, req);
		}
	}
1199411
function UriDataCharateristic(opts) {
	UriDataCharateristic.super_.call(this, objectAssign({
		uuid: 'ee0c2084-8786-40ba-ab96-99b91ac981d8',
		properties: ['read', 'write']
	}, opts));

	this.on('beforeWrite', function(data, res) {
		res(Results.Success);
	});

	this.toBuffer = encoding.encode;
	this.fromBuffer = encoding.decode;
}
243732
function createQueryMetadata (pageSize, bookmark) {
    const metadata = new _serviceProto.QueryMetadata();
    metadata.setPageSize(pageSize);
    metadata.setBookmark(bookmark);
    return metadata.toBuffer();
}
1148526
function Uri(str) {
    this.uriParts = parseUri(str);
    this.queryPairs = parseQuery(this.uriParts.query);
    this.hasAuthorityPrefixUserPref = null;
  }
457284
function publishPage(uri, publishMeta, user) {
  const NOW = new Date().toISOString(),
    update = {
      published: true,
      publishTime: NOW,
      history: [{ action: 'publish', timestamp: NOW, users: [userOrRobot(user)] }]
    };

  return changeMetaState(uri, Object.assign(publishMeta, update));
}
1286401
function ajax(url, callback, data) {
  if (data) {
    var reqOptions = typeof url === 'string' ? { uri: url, body: data, json: true } : _extends({}, url, { body: data, json: true });
    _request2.default.post(reqOptions, function (err, res, body) {
      if (err) console.log(err);
      callback(err, body, res);
    });
  } else {
    (0, _request2.default)(url, function (err, res, body) {
      if (err) console.log(err);
      callback(err, body, res);
    });
  }
}
1122032
function onData(data) {

		data = data.toString("ascii");
		bufferedData += data;

		if (debug) console.log("Server: " + util.inspect(data));

		if (checkResp === true) {

			if (bufferedData.substr(0, 3) === "+OK") {

				checkResp = false;
				response = true;

			} else if (bufferedData.substr(0, 4) === "-ERR") {

				checkResp = false;
				response = false;

			// The following is only used for SASL
			} else if (multiline === false) {

				checkResp = false;
				response = true;

			}
		}

		if (checkResp === false) {

			if (multiline === true && (response === false || bufferedData.substr(bufferedData.length-5) === "\r\n.\r\n")) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			} else if (multiline === false) {

				// Make a copy to avoid race conditions
				var responseCopy = response;
				var bufferedDataCopy = bufferedData;

				response = null;
				checkResp = true;
				multiline = false;
				bufferedData = "";

				callback(responseCopy, bufferedDataCopy);

			}
		} 
	}
161230
function(data) {
    var h, headerArray, headers, i, l, len, o;
    headers = {};
    headerArray = data.getAllResponseHeaders().split('\r');
    for (l = 0, len = headerArray.length; l < len; l++) {
      i = headerArray[l];
      h = i.match(/^([^:]*?):(.*)$/);
      if (!h) {
        h = [];
      }
      h.shift();
      if (h[0] !== void 0 && h[1] !== void 0) {
        headers[h[0].trim()] = h[1].trim();
      }
    }
    o = {};
    o.content = {};
    o.content.data = data.responseText;
    o.headers = headers;
    o.request = {};
    o.request.url = this.invocationUrl;
    o.status = data.status;
    return o;
  }
860047
function create(uri, data, locals) {
  const layoutReference = data && data.layout,
    pageData = data && references.omitPageConfiguration(data),
    prefix = getPrefix(uri),
    pageReference = `${prefix}/_pages/${uid.get()}`,
    user = locals && locals.user;

  if (!layoutReference || !isLayout(layoutReference)) {
    throw new Error('Client: Data missing layout reference.');
  }

  return layouts.get(layoutReference, locals) // check to make sure the layout 200's
    .then(() => {
      return getPageClonePutOperations(pageData, locals)
        .then(ops => {
          pageData.layout = layoutReference;
          return addOp(pageReference, pageData, ops);
        });
    })
    .then(applyBatch)
    .then(newPage => {
      newPage._ref = pageReference;

      return meta.createPage(newPage._ref, user)
        .then(() => {
          bus.publish('createPage', { uri: pageReference, data: newPage, user });

          return newPage;
        });
    });
}
230837
function (cb) {
            Y.log('Writing API Meta Data', 'info', 'builder');
            var self = this;
            this.renderAPIMeta(function (js) {
                fs.writeFile(path.join(self.options.outdir, 'api.js'), js, Y.charset, cb);
            });
        }
1129672
function(data) {

	// Strip out the old query string and append the new one
	if (data) {
		this.url = this.url.split('?', 1)[0] + '?' + data;
	}

	this.req.open('GET', this.url);
	return this._run();
}
502209
function put(model, uri, data, locals) {
  const startTime = process.hrtime(),
    timeoutLimit = TIMEOUT_CONSTANT * TIMEOUT_PUT_COEFFICIENT;

  return bluebird.try(() => {
    return bluebird.resolve(model.save(uri, data, locals))
      .then(resolvedData => {
        if (!_.isObject(resolvedData)) {
          throw new Error(`Unable to save ${uri}: Data from model.save must be an object!`);
        }

        return {
          key: uri,
          type: 'put',
          value: JSON.stringify(resolvedData)
        };
      });
  }).tap(() => {
    const ms = timer.getMillisecondsSince(startTime);

    if (ms > timeoutLimit * 0.5) {
      log('warn', `slow put ${uri} ${ms}ms`);
    }
  }).timeout(timeoutLimit, `Module PUT exceeded ${timeoutLimit}ms: ${uri}`);
}
948065
function retrieve(uri, callback) {
  var buffer = '';
  http.get(uri, function(res) {
    res.on('data', function (chunk) {
      buffer += chunk;
    });
    res.on('end', function() {
      callback(null, buffer);
    });
  }).on('error', function(e) {
    callback(e);
  });
}
1091726
function(apiType, data) {
            var arg = (data) ? data : {};
            var collection = null;

            if (!apiType) {
              apiType = paginationAPIType.github;
            }
            if (apiType === paginationAPIType.github) {
              collection = new paginatedCollection(arg);
              collection.setPaginationConfiguration({
                currentPageParam: "page",
                pageSizeParam: "per_page"
              });
            } else if (apiType === paginationAPIType.solr) {
              collection = new paginatedCollection(arg);
              collection.setPaginationConfiguration({
                currentPageParam: "start",
                pageSizeParam: "rows"
              });
            } else if (apiType === paginationAPIType.database) {
              collection = new paginatedCollection(arg);
              collection.setPaginationConfiguration({
                currentPageParam: "offset",
                pageSizeParam: "limit"
              });
            }
            return collection;
          }
1175522
function writeFile(filename, data) {
	return new Promise(
		(resolve, reject) => fs.writeFile(filename, data,
			(error) => error ? reject(error) : resolve()
		)
	);
}
894355
function(data) {
      var extras = {};

      if (data instanceof File) {
        extras = this.meta(data);
        data = data.toDataURL();
      }
      var parts = data.split(","), headers = parts[0].split(":"), body;

      if (parts.length !== 2 || headers.length !== 2 || headers[0] !== "data") {
        throw new Error("Invalid data URI.");
      }
      headers = headers[1].split(";");
      body = (headers[1] === "base64") ? atob(parts[1]) : decodeURI(parts[1]);
      var length = body.length, buffer = new ArrayBuffer(length), bytes = new Uint8Array(buffer);

      for (var i = 0; i < length; i++) {
        bytes[i] = body.charCodeAt(i);
      }
      return angular.extend(new Blob([bytes], { type: headers[0] }), extras);
    }