Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
bundlerepository-1.6.6
-
None
-
Felix Framework 4.0.2
Description
Make the API safer by generating an error if someone tries to create an invalid repository.
In current implementation, somebody could create an invalid bundle repository (particularly, a repository in which the resources have no URI associated) through the bundlerepository API.
This can be accomplished throught the use of the methods:
1- DataModelHelper#createResource(Bundle)
For creating a Resource from a Bundle (note that, then, the Resources won't have an associated URI)
2- DataModelHelper#repository(Resource[])
For creating a (invalid) Repository from the Resources just created
3- DataModelHelper#writeRepository(..) //any of the writeRepository variants will work
For writing the just created Repository
------------
It may be useful if the DataModelHelper could "prevent" the writing of such an invalid Repository by validating it has all the "mandatory" fields.
However, because the use of the Repository created (in memory) from Bundles may be useful, the validation may/should be done only when trying to generate an "external" representation of it (i.e. when trying to write it as XML).
The afore mentioned "validation" may simply be a check followed by an exception if the mandatory fields are not present. This way, the execution will fail and not silently ignore the invalid repository just created (possibly leading to a worse inconsistency).