public IPreferenceTreeModel getPreference(PreferenceDetails details) { CtxIdentifier id = this.registry.getCtxID(details); if (id == null) { this.logging.debug("Could not find preference for :\n" + details.toString()); return null; } else { this.logging.debug( "Found preference in DB. CtxID: " + id.toUriString() + " for: " + details.toString()); } return this.getPreference(id); }
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; }