Diff
Modified: branches/packs/app/controllers/resources_controller.rb (3642 => 3643)
--- branches/packs/app/controllers/resources_controller.rb 2013-08-30 13:12:58 UTC (rev 3642)
+++ branches/packs/app/controllers/resources_controller.rb 2013-08-30 13:52:23 UTC (rev 3643)
@@ -69,6 +69,14 @@
redirect_to resource.proxy_for_path, :status => 303
end
else
+
+ # Generate RDF on demand if required.
+
+ if resource.content_blob.nil?
+ resource.generate_graph!
+ resource.reload
+ end
+
send_data(resource.content_blob.data, :type => resource.content_type)
end
end
Modified: branches/packs/app/models/research_object.rb (3642 => 3643)
--- branches/packs/app/models/research_object.rb 2013-08-30 13:12:58 UTC (rev 3642)
+++ branches/packs/app/models/research_object.rb 2013-08-30 13:52:23 UTC (rev 3643)
@@ -65,16 +65,7 @@
end
def update_manifest!
-
- resources.reload
-
- manifest_body = pretty_rdf_xml(RDF::Writer.for(:rdfxml).buffer { |writer| writer << description })
-
- new_or_update_resource(
- :slug => MANIFEST_PATH,
- :content_type => "application/rdf+xml",
- :data ="" manifest_body,
- :force_write => true)
+ manifest_resource.update_graph!
end
def manifest_resource
Modified: branches/packs/app/models/resource.rb (3642 => 3643)
--- branches/packs/app/models/resource.rb 2013-08-30 13:12:58 UTC (rev 3642)
+++ branches/packs/app/models/resource.rb 2013-08-30 13:52:23 UTC (rev 3643)
@@ -202,13 +202,37 @@
end
def update_graph!
-
unless is_resource
+ if content_blob
+ content_blob.destroy
+ update_attribute(:content_blob, nil)
+ end
+ end
+ end
- new_description = create_rdf_xml { |graph| graph << description }
+ def generate_graph!
- content_blob.destroy if content_blob
- update_attribute(:content_blob, ContentBlob.new(:data ="" new_description))
+ if path == ResearchObject::MANIFEST_PATH
+
+ research_object.resources.reload
+
+ manifest_body = pretty_rdf_xml(RDF::Writer.for(:rdfxml).buffer { |writer| writer << research_object.description })
+
+ research_object.new_or_update_resource(
+ :slug => ResearchObject::MANIFEST_PATH,
+ :content_type => "application/rdf+xml",
+ :data ="" manifest_body,
+ :force_write => true)
+
+ else
+
+ unless is_resource
+
+ new_description = create_rdf_xml { |graph| graph << description }
+
+ content_blob.destroy if content_blob
+ update_attribute(:content_blob, ContentBlob.new(:data ="" new_description))
+ end
end
end