src/app-registry.js
/**
 * Adds an RDF class to a user's app registry, and returns the
 * profile (with the appropriate registry graph updated).
 * Called by `registerApp()`, which does all the argument validation.
 * @method addToAppRegistry
 * @param profile {SolidProfile}
 * @param app {AppRegistration}
 * @param webClient {SolidWebClient}
 * @return {Promise<SolidProfile>} Returns updated profile
 */
Adds an RDF class to a user's app registry, and returns the
profile (with the appropriate registry graph updated).
Called by `registerApp()`, which does all the argument validation.
Adds an RDF class to a user ' s app registry and returns the profile ( with the appropriate registry graph updated ) . Called by ` registerApp () ` which does all the argument validation .
function addToAppRegistry (profile, app, webClient) {
  var registryUri
  var registryGraph
  if (app.isListed) {
    registryUri = profile.appRegistryListed.uri
    registryGraph = profile.appRegistryListed.graph
  } else {
    registryUri = profile.appRegistryUnlisted.uri
    registryGraph = profile.appRegistryUnlisted.graph
  }
  if (!registryUri) {
    throw new Error('Cannot register app, registry URL missing')
  }
  var rdf = profile.rdf
  var toDel = []
  var toAdd = app.rdfStatements(rdf)
  return webClient.patch(registryUri, toDel, toAdd)
    .then(function (response) {
      var newRegistration = graphUtil.graphFromStatements(toAdd, rdf)
      if (registryGraph) {
        graphUtil.appendGraph(registryGraph, newRegistration)
      } else {
        profile[app.isListed ? 'appRegistryListed' : 'appRegistryUnlisted'].graph = newRegistration
      }
      return profile
    })
}
function addToAppRegistry ( profile , app , webClient ) { var registryUri var registryGraph if ( app . isListed ) { registryUri = profile . appRegistryListed . uri registryGraph = profile . appRegistryListed . graph } else { registryUri = profile . appRegistryUnlisted . uri registryGraph = profile . appRegistryUnlisted . graph } if ( ! registryUri ) { throw new Error ( 'Cannot register app, registry URL missing' ) } var rdf = profile . rdf var toDel = [ ] var toAdd = app . rdfStatements ( rdf ) return webClient . patch ( registryUri , toDel , toAdd ) . then ( function ( response ) { var newRegistration = graphUtil . graphFromStatements ( toAdd , rdf ) if ( registryGraph ) { graphUtil . appendGraph ( registryGraph , newRegistration ) } else { profile [ app . isListed ? 'appRegistryListed' : 'appRegistryUnlisted' ] . graph = newRegistration } return profile } ) }
Adds an RDF class to a user's app registry, and returns the
 profile (with the appropriate registry graph updated).
Adds an RDF class to a user ' s app registry and returns the profile ( with the appropriate registry graph updated ) .
// TODO: Check to see if a registry entry for this type already exists. // triples to delete (none for the moment) // Create the list of triples to add in the PATCH operation // Update the profile object with the new registry without reloading