docs: function updateLibrary(webgmeToken, parameters, callback) {
          var projectId = parameters.projectId,
              context,
              storage,
              projectJson,
              blobClient = getBlobClient(webgmeToken),
              finish = function (err, result) {
                  if (err) {
                      err = err instanceof Error ? err : new Error(err);
                      logger.error('updateLibrary failed with error', err);
                  } else {
                      logger.debug('updateLibrary completed');
                  }
  
                  if (storage) {
                      storage.close(function (closeErr) {
                          callback(err || closeErr, result);
                      });
                  } else {
                      callback(err, result);
                  }
              };
  
          logger.debug('updateLibrary', {metadata: parameters});
  
          getConnectedStorage(webgmeToken)
              .then(function (storage_) {
                  storage = storage_;
                  storage.addEventListener(storage.CONSTANTS.NETWORK_STATUS_CHANGED,
                      getNetworkStatusChangeHandler(finish));
                  return _getCoreAndRootNode(storage, projectId, null, parameters.branchName, null);
              })
              .then(function (context_) {
                  var libs = context_.core.getLibraryNames(context_.rootNode),
                      libraryInfo;
  
                  context = context_;
  
                  if (libs.indexOf(parameters.libraryName) < 0) {
                      throw new Error('No such library "' + parameters.libraryName +
                          '" among [' + libs.toString() + '].');
                  }
  
                  libraryInfo = context_.core.getLibraryInfo(context_.rootNode, parameters.libraryName);
  
                  if (parameters.blobHash) {
                      return _getProjectJsonFromBlob(blobClient, parameters.blobHash, true);
                  } else if (parameters.libraryInfo) {
                      return _getProjectJsonFromProject(storage,
                          parameters.libraryInfo.projectId,
                          parameters.libraryInfo.branchName,
                          parameters.libraryInfo.commitHash);
                  } else if (parameters.seed) {
                      return _getProjectJsonFromFileSeed(parameters.seed, webgmeToken);
                  } else if (libraryInfo && libraryInfo.projectId && libraryInfo.branchName) {
                      // We have to dig out library info from our own project
                      if (projectId === libraryInfo.projectId) {
                          throw new Error('Automatic update of self-contained libraries are not allowed!');
                      }
  
                      return _getProjectJsonFromProject(storage, libraryInfo.projectId, libraryInfo.branchName, null);
                  } else {
                      throw new Error('only libraries that follows branch can be refreshed!');
                  }
              })
              .then(function (res) {
                  projectJson = res.projectJson;
                  return storageUtils.insertProjectJson(context.project, projectJson, {
                      commitMessage: 'commit that represents the library to be updated'
                  });
              })
              .then(function (/*commitResult*/) {
                  return context.core.updateLibrary(context.rootNode, parameters.libraryName, projectJson.rootHash, {
                      projectId: projectJson.projectId,
                      branchName: projectJson.branchName,
                      commitHash: projectJson.commitHash
                  }, null/*placeholder for instructions*/);
              })
              .then(function () {
                  return _persistLibrary(context, parameters.libraryName, parameters.branchName, true);
              })
              .nodeify(finish);
      }