Changeset 363

Show
Ignore:
Timestamp:
03/17/09 18:48:30 (9 years ago)
Author:
samuraraujo
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Explorator/trunk/app/controllers/repository_controller.rb

    r355 r363  
    88  @repositories 
    99  def index 
    10     
     10     
    1111    render :layout => false 
    1212  end 
     
    4343    render :text => '',:layout => false 
    4444  end 
     45  
    4546  def add 
    4647    if params[:title]==nil || params[:title]  == '' 
     
    4950    end 
    5051    begin 
    51       adapter = ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => params[:uri], :results => :sparql_xml, :caching =>true 
     52      adapter = ConnectionPool.add_data_source :type => :sparql, :url => params[:uri], :results => :sparql_xml, :caching =>true    
    5253      adapter.title=params[:title]     
    5354      adapter.limit=params[:limit]  if params[:limit] != nil && params[:limit].rstrip != ''   
    54       session[:addrepositories]<<adapter 
    55     session[:disablerepositories] << (params[:title])  
    56     session[:disablerepositories].uniq! 
    57      
    58 rescue Exception => e 
    59   puts e.message 
    60   puts e.backtrace 
    61    
    62    session[:addrepositories].delete(adapter) 
    63     session[:disablerepositories].delete(params[:title])  
    64    ConnectionPool.remove_data_source(adapter) 
    65 #      render_component :controller => 'message',:action => 'error', :message => "SPARQL Enpoint invalid: "+e.message ,:layout => false 
    66 redirect_to :action => 'endpointsform' , :message => "SPARQL Enpoint invalid: "+e.message ,:layout => false 
    67 return 
    68 end 
    69        begin  
     55      session[:addrepositories]<< adapter 
     56      session[:disablerepositories] << (params[:title])  
     57      session[:disablerepositories].uniq! 
     58       
     59    rescue Exception => e 
     60      puts e.message 
     61      puts e.backtrace 
     62       
     63      session[:addrepositories].delete(adapter) 
     64      session[:disablerepositories].delete(params[:title])  
     65      ConnectionPool.remove_data_source(adapter) 
     66      #      render_component :controller => 'message',:action => 'error', :message => "SPARQL Enpoint invalid: "+e.message ,:layout => false 
     67      redirect_to :action => 'endpointsform' , :message => "SPARQL Enpoint invalid: "+e.message ,:layout => false 
     68      return 
     69    end 
     70    begin  
    7071      RDFS::Resource.find_all_predicates     
    7172      # construct the necessary Ruby Modules and Classes to use the Namespace 
     
    7475      #Test the sparql endpoint. 
    7576      Query.new.distinct(:s).where(:s,Namespace.lookup(:rdf,:type),Namespace.lookup(:rdfs,:Class)).limit(5).execute       
    76 rescue Exception => e 
    77   puts e.message 
    78   puts e.backtrace 
    79    session[:addrepositories].delete(adapter) 
    80     session[:disablerepositories].delete(params[:title])  
    81     ConnectionPool.remove_data_source(adapter) 
    82 redirect_to :action => 'endpointsform' ,:message => e.message ,:layout => false 
    83 return 
    84 #       render_component :controller => 'message',:action => 'error',:message => e.message ,:layout => false 
    85 end 
    86 redirect_to :action => 'endpointsform',:message => 'Sparql endpoint added successfully!' ,:messageaction=>'confirmation' 
    87   
    88 end 
    89 def listenabledrepositories 
    90  render :partial => 'listenabledrepositories',:layout =>false 
    91 end 
    92  
    93 def endpointsform 
    94    #variable that will store the list of adapters. 
     77    rescue Exception => e 
     78      puts e.message 
     79      puts e.backtrace 
     80      session[:addrepositories].delete(adapter) 
     81      session[:disablerepositories].delete(params[:title])  
     82      ConnectionPool.remove_data_source(adapter) 
     83      redirect_to :action => 'endpointsform' ,:message => e.message ,:layout => false 
     84      return 
     85      #       render_component :controller => 'message',:action => 'error',:message => e.message ,:layout => false 
     86    end 
     87    redirect_to :action => 'endpointsform',:message => 'Sparql endpoint added successfully!' ,:messageaction=>'confirmation' 
     88     
     89  end 
     90  def listenabledrepositories 
     91    render :partial => 'listenabledrepositories',:layout =>false 
     92  end 
     93   
     94  def endpointsform 
     95    #variable that will store the list of adapters. 
    9596    @repositories = Array.new 
    9697    @message = params[:message] 
     
    104105      end 
    105106    end        
    106  
    107  render :layout =>false 
     107     
     108    render :layout =>false 
     109  end 
    108110end 
    109 end