@Override
 public void create(String repositoryName)
     throws RepositoryExistsException, InterruptedException, RepositoryModelException {
   if (!RepoDefUtil.isValidRepositoryName(repositoryName)) {
     throw new IllegalArgumentException(
         String.format(
             "'%s' is not a valid repository name. " + RepoDefUtil.VALID_NAME_EXPLANATION,
             repositoryName));
   }
   RepositoryDefinition repoDef =
       new RepositoryDefinition(repositoryName, RepositoryLifecycleState.CREATE_REQUESTED);
   byte[] repoBytes = RepositoryDefinitionJsonSerDeser.INSTANCE.toJsonBytes(repoDef);
   try {
     zk.create(
         REPOSITORY_COLLECTION_PATH + "/" + repositoryName,
         repoBytes,
         ZooDefs.Ids.OPEN_ACL_UNSAFE,
         CreateMode.PERSISTENT);
   } catch (KeeperException.NodeExistsException e) {
     throw new RepositoryExistsException(
         "Can't create repository, a repository with this name already exists: " + repositoryName);
   } catch (KeeperException e) {
     throw new RepositoryModelException(e);
   }
 }
 private void assureDefaultRepositoryExists() throws KeeperException, InterruptedException {
   byte[] repoBytes = RepositoryDefinitionJsonSerDeser.INSTANCE.toJsonBytes(DEFAULT_REPOSITORY);
   try {
     zk.create(
         REPOSITORY_COLLECTION_PATH + "/" + DEFAULT_REPOSITORY.getName(),
         repoBytes,
         ZooDefs.Ids.OPEN_ACL_UNSAFE,
         CreateMode.PERSISTENT);
   } catch (KeeperException.NodeExistsException e) {
     // it already exists, fine
   }
 }
 private RepositoryDefinition loadRepository(String name, boolean watch)
     throws KeeperException, InterruptedException {
   byte[] repoJson =
       zk.getData(REPOSITORY_COLLECTION_PATH + "/" + name, watch ? zkWatcher : null, new Stat());
   return RepositoryDefinitionJsonSerDeser.INSTANCE.fromJsonBytes(name, repoJson);
 }
 public void storeRepository(RepositoryDefinition repoDef)
     throws InterruptedException, KeeperException {
   byte[] repoBytes = RepositoryDefinitionJsonSerDeser.INSTANCE.toJsonBytes(repoDef);
   zk.setData(REPOSITORY_COLLECTION_PATH + "/" + repoDef.getName(), repoBytes, -1);
 }