Closed ghukill closed 7 years ago
More fuel for the fire: it's not tenable to add triples to a resource before creation, so this might all be moot.
Tried instantiating a resource, adding a triple, then creating without specifying a URI (thereby issuing a POST
request), which failed with the following error:
ERROR 22:45:43.016 (PersistingRdfStreamConsumer) http://localhost:8080/rest/ is not in the topic of this RDF, which is http://localhost:8080/rest/a8/9f/a1/19/a89fa119-0b79-4ad5-aaab-6c827ee53296.
Which is now unsurprising, as this resource was attempting to write triples for a URI it did not yet know. So, perhaps it makes sense to restrict add_triple
unless resource.exists
is True? This is set during creation and retrieval. Downside to this would be creating resources with auto_refresh
off, as it would not yet know it exists....
Perhaps work to catch this error and inform, but not prevent?
Might be a little trickier, as DirectContainer
and IndirectContainer
both create triples on creation, outside of controlled channels like resource.update
.
For example, for an empty repository without namespace prefixes pcdm
or ore
, creating Direct
or Indirect
containers that automatically created triples with those prefixes -- if those prefixes have not been created through update
-- results in bad prefixes.
Not quite "bad" in the same way, these are not ns001
, but instead use the entire URI like http://www.openarchives.org/ore/terms/
.
One two-prong approach might work:
repo.context
, and issues an update to the root node to propagate those namespaces throughout the repositoryadd_triple
from working before resource creation, or inform as mentioned aboveThis would add those namespaces to the repository before any Direct
or Indirect
containers could do so automatically, and would also prevent resources that had not been created (which we've determined is not a good idea) from adding triples.
See forum post above - fixed in Fedora 4.8. Continuing to use 4.7 for testing, as this behavior has not yet affected tests, but will update docker image for travis if need be, and certainly when 4.8 is released.
New namespaces to the repository are only correctly added when going through
resource.update()
.For example, if a new resource is created, and a triple is added before
create
that contains a namespace new to the repository, this namespace is not added correctly.This happens if:
repo.context
, and thus the nascent resource'srdf.prefix
resource.add_namespace
is run prior tocreate
But it does not happen if the resource has been created and
update
is run, even if adding namespace. This would seem to suggest it's related to new namespaces in.create
, which does not correctly pass along this new namespace.The only successful way to introduce a new namespace appears to be through a
PATCH
request, as is done withresource.update()
?