valkyrie icon indicating copy to clipboard operation
valkyrie copied to clipboard

Mark Resource as read only.

Open jcoyne opened this issue 8 years ago • 3 comments

Solr is not always roundtrip-able (fields can be indexed without being stored). That means if you retrieve a record from Solr, you should not attempt to persist that record (to the database perhaps) or data could be lost.

It should be possible to configure QueryService to return only read only records. The Persister, before saving should validate that the record is not so marked.

jcoyne avatar Oct 12 '17 16:10 jcoyne

Thinking about an api for this...

resource = Book.new
resource.lock!
resource.locked?
resource = Book.new
resource.read_only!
resource.read_only?

Something similar?

tpendragon avatar Oct 12 '17 17:10 tpendragon

Yes. I'm in favor of read_only! / read_only?

jcoyne avatar Oct 12 '17 17:10 jcoyne

Success Criteria:

class Resource < Valkyrie::Resource
end

resource = Resource.new
resource.read_only!
persister.save(resource: resource) # raises Valkyrie::Persistence::ReadOnlyPersistence

tpendragon avatar Mar 14 '18 23:03 tpendragon