Changeset 1529

Show
Ignore:
Timestamp:
04/16/08 17:16:50 (4 weeks ago)
Author:
kindlund
Message:

Added utility functions to check if a client exists in the database.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/app/apis/hc_database_api.rb

    r1454 r1529  
    1919  api_method :get_broken_clients, :expects => [:string], :returns => [:string] 
    2020  api_method :get_not_deleted_clients, :expects => [:string], :returns => [:string] 
     21  api_method :client_exists, :expects => [:string], :returns => [:string] 
    2122end 
  • hive/trunk/data_webapp/app/controllers/hc_database_controller.rb

    r1519 r1529  
    314314    RbYAML.dump(clients_hash) 
    315315  end 
     316 
     317  # Indicates if the specified client ID is in the database. 
     318  def client_exists(obj_str) 
     319    obj_hash = RbYAML.load(obj_str) 
     320    cid = obj_hash.delete("client_id") 
     321    c = Client.find(:first, :conditions => {:cid => cid}) 
     322    if not c.nil? 
     323       return 1 
     324    else 
     325       return 0 
     326    end 
     327  end 
     328 
    316329end