Modified: branches/wf4ever/app/controllers/workflows_controller.rb (3218 => 3219)
--- branches/wf4ever/app/controllers/workflows_controller.rb 2012-12-03 14:31:40 UTC (rev 3218)
+++ branches/wf4ever/app/controllers/workflows_controller.rb 2012-12-04 11:30:01 UTC (rev 3219)
@@ -528,6 +528,30 @@
if @workflow.update_attributes(params[:workflow])
+ # Check that the RO exists and if not, create it.
+
+ unless params[:workflow][:ro_uri].empty?
+
+ rodl_uri = URI.parse(@workflow.ro_uri)
+
+ path_bits = rodl_uri.path.sub(/\/$/, "").split("/")
+
+ slug = path_bits.pop
+
+ rodl_uri.path = "#{path_bits.join("/")}/"
+
+ session = ROSRS::Session.new(rodl_uri.to_s, Conf.rodl_bearer_token)
+
+ if session.check_research_object(slug) == false
+ c, r, u, m = session.create_research_object(slug)
+
+ if c != 201
+ flash.now[:error] = "Unable to create research object: #{r}"
+ end
+ end
+
+ end
+
if params[:workflow][:tag_list]
@workflow.refresh_tags(convert_tags_to_gem_format(params[:workflow][:tag_list]), current_user)
@workflow.reload
Modified: branches/wf4ever/vendor/plugins/rosrs/lib/wf4ever/rosrs/session.rb (3218 => 3219)
--- branches/wf4ever/vendor/plugins/rosrs/lib/wf4ever/rosrs/session.rb 2012-12-03 14:31:40 UTC (rev 3218)
+++ branches/wf4ever/vendor/plugins/rosrs/lib/wf4ever/rosrs/session.rb 2012-12-04 11:30:01 UTC (rev 3219)
@@ -225,6 +225,20 @@
end
end
+ def check_research_object(ro_uri)
+ code, reason = do_request_follow_redirect("GET", ro_uri,
+ :accept => "application/rdf+xml")
+
+ case code
+ when 200
+ true
+ when 404
+ false
+ else
+ error(code, "Error checking for RO #{ro_uri}: #{code} #{reason}")
+ end
+ end
+
# ---------------------
# Resource manipulation
# ---------------------