package com.hubspot.singularity.data;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.utils.ZKPaths;

import com.codahale.metrics.MetricRegistry;
import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.hubspot.singularity.SingularityUserSettings;
import com.hubspot.singularity.config.SingularityConfiguration;
import com.hubspot.singularity.data.transcoders.Transcoder;

public class UserManager extends CuratorManager {

  private final Transcoder<SingularityUserSettings> settingsTranscoder;

  private static final String USER_ROOT = "/users";

  private static final String SETTINGS_ROOT = USER_ROOT + "/settings";

  @Inject
  public UserManager(CuratorFramework curator, SingularityConfiguration configuration, MetricRegistry metricRegistry,
                     Transcoder<SingularityUserSettings> settingsTranscoder) {
    super(curator, configuration, metricRegistry);
    this.settingsTranscoder = settingsTranscoder;
  }

  private String getUserSettingsPath(String id) {
    return ZKPaths.makePath(SETTINGS_ROOT, id);
  }

  public void updateUserSettings(String id, SingularityUserSettings userSettings) {
    save(getUserSettingsPath(id), userSettings, settingsTranscoder);
  }

  public Optional<SingularityUserSettings> getUserSettings(String id) {
    return getData(getUserSettingsPath(id), settingsTranscoder);
  }

  public void deleteUserSettings(String id) {
    delete(getUserSettingsPath(id));
  }

}

@@ -1024,33 +1024,37 @@
 ingsPath(String 
-i
+userI
 d) %7B%0A    return 
@@ -1085,17 +1085,21 @@
 S_ROOT, 
-i
+userI
 d);%0A  %7D%0A
@@ -1139,17 +1139,21 @@
 (String 
-i
+userI
 d, Singu
@@ -1212,25 +1212,29 @@
 ettingsPath(
-i
+userI
 d), userSett
@@ -1323,33 +1323,37 @@
 Settings(String 
-i
+userI
 d) %7B%0A    return 
@@ -1380,17 +1380,21 @@
 ngsPath(
-i
+userI
 d), sett
@@ -1455,17 +1455,21 @@
 (String 
-i
+userI
 d) %7B%0A   
@@ -1496,17 +1496,21 @@
 ngsPath(
-i
+userI
 d));%0A  %7D

Rename id -> userId in UserManager