Hi, On Tue, Jan 8, 2019 at 9:54 PM Bertrand Delacretaz <[email protected]> wrote:
> Hi, > > On Tue, Jan 8, 2019 at 2:15 PM Bertrand Delacretaz > <[email protected]> wrote: > > ...That common ground might be a Java API used to access the underlying > > models, exposing their semantics in a way that clearly defines how > > they are used in Sling and possibly other applications.... > > I have had a closer look at > https://github.com/christanto/sling-whiteboard/tree/master/modeling > and I think the above is contained in that, but I think we might > reduce that "common ground" to a smaller core API to start with. > The core is basically just [Models.class]( https://github.com/christanto/sling-whiteboard/blob/08fd3637c4045470e2b2ba8f8d9bbf4fcf82c211/modeling/src/main/java/org/apache/sling/modeling/Models.java ) BTW, I think Sling should really consider enhancing the Adaptable interface for this instead as I explained at https://github.com/christanto/sling-whiteboard/blob/master/modeling/docs/explainer.md#alternative-way-getting-the-models This way we can inspect any adaptable on what adaptations are available. > > I'm using the "Content Types" name for now to avoid both the Models > and Sling terms. > > How about this, roughly? > > -A ContentType can be retrieved by name from the TypeSystem service > -A ContentType contains a list of Properties (name, data type, > validation etc..) and nested ContentTypes > -A ContentType can include a list of Links > -A Link has a Relation, Description and Target > -Link Relations are namespaced and the TypeSystem can reserve some > namespace prefixes > > I think this would be enough for my use case of implementing a > self-describing HTTP API - there's probably a number of details > missing but that would be the essence of the Type System API. > > Christanto, would that work for you assuming we move the above into a > "type system core" module to allow us to work in parallel on the > "details" in other modules? > Certainly Sling can decide to have `org.apache.sling.types.rest.ContentType` interface, such that one can do something like this: ``` Resource content = slingRequest.getResource(); ContentType contentType = content.adaptTo(ContentType.class); // Use the contentType contentType.getProperties(); contentType.getLinks(); ``` Other modules can decide to define their own modules for their own purposes. Cheers, Christanto > > -Bertrand >
