- # Remove any permission signatures from the manifest.
- resource_attrs[:manifest_text]
- .gsub!(/ [[:xdigit:]]{32}(\+[[:digit:]]+)?(\+\S+)/) { |word|
- word.strip!
- loc = Locator.parse(word)
- if loc
- " " + loc.without_signature.to_s
- else
- " " + word
- end
- }
-
- # Save the collection with the stripped manifest.
- act_as_system_user do
- @object = model_class.new resource_attrs.reject { |k,v| k == :owner_uuid }
- 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
- if @object
- link_attrs = {
- owner_uuid: owner_uuid,
- link_class: 'permission',
- name: 'can_read',
- head_uuid: @object.uuid,
- tail_uuid: owner_uuid
+ def find_object_by_uuid
+ if loc = Keep::Locator.parse(params[:id])
+ loc.strip_hints!
+ if c = Collection.readable_by(*@read_users).where({ portable_data_hash: loc.to_s }).limit(1).first
+ @object = {
+ uuid: c.portable_data_hash,
+ portable_data_hash: c.portable_data_hash,
+ manifest_text: c.signed_manifest_text,