     [puny.core :refer (entity)]
     [slingshot.slingshot :refer  [throw+]]
     [puny.migrations :refer (Migration register)]
-    [celestial.model :refer (clone hypervizors figure-virt check-validity)] 
-    [clojure.core.strint :refer (<<)]  
+    [celestial.model :refer (clone hypervizors figure-virt check-validity)]
+    [clojure.core.strint :refer (<<)]
      aws.model))
 
 (import-logging)
 
 (declare perm validate-system increase-quota decrease-quota es-put es-delete)
 
-(entity {:version 1} system :indices [type env owner] 
+(entity {:version 1} system :indices [type env owner]
         :intercept {
             :create [perm increase-quota es-put]
             :read [perm] :update [perm es-put]
             :delete [perm decrease-quota es-delete]})
 
-(defn assert-access 
-  "Validates that the current user can access the system, 
+(defn assert-access
+  "Validates that the current user can access the system,
    non super users can only access systems they own.
    All users are limited to certain environments."
   [{:keys [env owner] :as system}]

(comment 
  Celestial, Copyright 2012 Ronen Narkis, narkisr.com
  Licensed under the Apache License,
  Version 2.0  (the "License") you may not use this file except in compliance with the License.

(defrecord EnvIndices [identifier]
  Migration
  (apply- [this]
    (doseq [id (systems-for "admin")]
      (update-system id (update-in (get-system id) [:env] keyword))))
  (rollback [this]))

; triggering owner indexing and setting default to admin
(defrecord OwnerIndices [identifier]
  Migration
  (apply- [this]
    (doseq [id (systems-for "admin")]
      (when-not ((get-system id) :owner)
        (update-system id (assoc (get-system id) :owner "admin")))))
  (rollback [this]))

; index all existing systems into ES
