public boolean deletePreference(IIdentity dpi, PreferenceDetails details) {
   CtxIdentifier id = this.registry.getCtxID(details);
   if (id == null) {
     // preference doesn't exist. can't delete it
     logging.debug("Preference :" + details.toString() + "\ndoesn't exist. Aborting deletion");
     return false;
   }
   PreferenceStorer storer = new PreferenceStorer(this.broker);
   if (storer.deletePreference(dpi, id)) {
     this.registry.deletePreference(details);
     storer.storeRegistry(dpi, registry);
     return true;
   } else {
     return false;
   }
 }
  public boolean storePreference(
      IIdentity userId, PreferenceDetails details, IPreferenceTreeModel model) {
    this.logging.debug("Request to store preference for:" + details.toString());

    CtxIdentifier id = this.registry.getCtxID(details);
    if (id == null) {
      this.logging.debug("Preference doesn't exist in DB. Attempt  to store new preference");
      // preference doesn't exist. we're going to store new preference in the db
      PreferenceStorer storer = new PreferenceStorer(this.broker);
      CtxIdentifier newCtxIdentifier =
          storer.storeNewPreference(userId, model, this.registry.getNameForNewPreference());
      if (newCtxIdentifier == null) {
        this.logging.debug("Could not store NEW preference in DB. aborting");
        return false;
      }
      this.logging.debug(
          "Successfully stored NEW preference in DB. CtxID: " + newCtxIdentifier.toUriString());
      this.registry.addPreference(details, newCtxIdentifier);
      this.logging.debug("Successfully added preference details to registry: ");
      this.logging.debug("Stored preference for: " + details.toString());
      storer.storeRegistry(userId, registry);
      this.logging.debug("Successfully stored registry in DB");
      this.idToIPreferenceTreeModel.put(newCtxIdentifier, model);
      this.logging.debug("Successfully added preference to cache");

    } else {
      this.logging.debug("Preference exists in DB. Attempt  to update existing preference");
      PreferenceStorer storer = new PreferenceStorer(this.broker);
      if (!storer.storeExisting(userId, id, model)) {
        return false;
      }
      this.logging.debug("Successfully updated preference in DB. CtxID: " + id.toUriString());
      this.idToIPreferenceTreeModel.put(id, model);
      this.logging.debug("Successfully updated preference cache with new preference");
    }
    return true;
  }
 public void deletePreference(
     IIdentity dpi,
     String serviceType,
     ServiceResourceIdentifier serviceID,
     String preferenceName) {
   PreferenceDetails details = new PreferenceDetails(serviceType, serviceID, preferenceName);
   CtxIdentifier id = this.registry.getCtxID(details);
   if (id == null) {
     // preference doesn't exist. can't delete it
     logging.debug(
         "Preference "
             + preferenceName
             + " of "
             + serviceType
             + ":"
             + serviceID.toString()
             + "doesn't exist. Aborting deletion");
   } else {
     PreferenceStorer storer = new PreferenceStorer(this.broker);
     storer.deletePreference(dpi, id);
     this.registry.deletePreference(details);
     storer.storeRegistry(dpi, registry);
   }
 }