X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/155848c15844554a5d5fd50f9577aa2e19767d9e..fb1d42add817ea57e391c9aeb8e6b9e4d35ad2fd:/app/controllers/orvos/v1/collections_controller.rb diff --git a/app/controllers/orvos/v1/collections_controller.rb b/app/controllers/orvos/v1/collections_controller.rb index 3a47d14c22..a1afd1e715 100644 --- a/app/controllers/orvos/v1/collections_controller.rb +++ b/app/controllers/orvos/v1/collections_controller.rb @@ -1,90 +1,21 @@ class Orvos::V1::CollectionsController < ApplicationController - # GET /collections - # GET /collections.json - def index - @collections = Collection.all - - @collectionlist = { - :kind => "orvos#collectionList", - :etag => "", - :self_link => "", - :next_page_token => "", - :next_link => "", - :items => @collections.map { |collection| collection } - } - respond_to do |format| - format.json { render json: @collectionlist } - end - end - - # GET /collections/1 - # GET /collections/1.json - def show - @collection = Collection.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @collection } - end - end - - # GET /collections/new - # GET /collections/new.json - def new - @collection = Collection.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @collection } - end - end - - # GET /collections/1/edit - def edit - @collection = Collection.find(params[:id]) - end - - # POST /collections - # POST /collections.json def create - @collection = Collection.new(params[:collection]) - - respond_to do |format| - if @collection.save - format.html { redirect_to @collection, notice: 'Collection was successfully created.' } - format.json { render json: @collection, status: :created, location: @collection } - else - format.html { render action: "new" } - format.json { render json: @collection.errors, status: :unprocessable_entity } - end - end - end - - # PUT /collections/1 - # PUT /collections/1.json - def update - @collection = Collection.find(params[:id]) - - respond_to do |format| - if @collection.update_attributes(params[:collection]) - format.html { redirect_to @collection, notice: 'Collection was successfully updated.' } - format.json { head :ok } - else - format.html { render action: "edit" } - format.json { render json: @collection.errors, status: :unprocessable_entity } + # It's not an error for a client to re-register a manifest that we + # already know about. + @object = model_class.new resource_attrs + begin + @object.save! + rescue ActiveRecord::RecordNotUnique + logger.debug resource_attrs.inspect + if resource_attrs['manifest_text'] and resource_attrs['uuid'] + @existing_object = model_class. + where('uuid=? and manifest_text=?', + resource_attrs['uuid'], + resource_attrs['manifest_text']). + first + @object = @existing_object || @object end end - end - - # DELETE /collections/1 - # DELETE /collections/1.json - def destroy - @collection = Collection.find(params[:id]) - @collection.destroy - - respond_to do |format| - format.html { redirect_to collections_url } - format.json { head :ok } - end + show end end