Chemistry
  1. Chemistry
  2. CMIS-440

Introduce type handlers to allow different content structures

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: OpenCMIS 0.6.0
    • Fix Version/s: OpenCMIS 0.6.0
    • Component/s: opencmis-server-jcr
    • Labels:
      None

      Description

      We have a content structure that differs from the structure that is assumed in opencmis jcr. I.e. our documents are not of type nt:file, our folders are a sub-type of nt:folder but we have meta-data around in nodes of type nt:folder which we don't want to show and we want to hide the system folders directly under the root.

      To get things working with our structure we've had to make customizations in quite a few places. To make it manageable we've introduced a handler that is responsible for tasks related to a certain type. This is similar to what the TODO in JcrNodeFactory describes.

      A type handler is responsible for:

      • providing a TypeDefinition (see CMIS-439)
      • testing if it handles a specific javax.jcr.Node
      • creating a JcrNode instance for the type (which is now done by JcrNodeFactory)
      • providing IdentifierMap for queries (now done by JcrNodeFactory)
      • creating a new object of the type, this is now done in JcrFolder addNode and addFolder so if you have many documents you have to add the code for creating all of them there, spreading the handling of your new type around

      The type handlers are managed by TypeHandlerManager which keep the list of handlers and have utility methods that loop through the handlers to calls the right handler.

      A really nifty thing here is that the TypeHandlerManager can expose a Predicate that loops type handlers to see if a Node is handled or not, this means that things in the jcr repository for which there is no CMIS type are hidden. This predicate needs to take effect in alot of places, both in JcrFolder and in JcrRepository, I've solved this by giving JcrFolder a wrapped Node that applies the predicate to all NodeIterators it returns.

      What do you think?

      1. JcrTypeHandler.patch
        86 kB
        Tobias Mattsson

        Activity

        Hide
        Michael Dürig added a comment -

        This sounds very promising. As the TODO tag in JcrNodeFactory indicates, this class is a stub intended to be replaced by a more flexible mechanism for creating JcrNode instances from javax.jcr.Node instances.

        If you could supply a patch, that would be great.

        Show
        Michael Dürig added a comment - This sounds very promising. As the TODO tag in JcrNodeFactory indicates, this class is a stub intended to be replaced by a more flexible mechanism for creating JcrNode instances from javax.jcr.Node instances. If you could supply a patch, that would be great.
        Hide
        Tobias Mattsson added a comment -

        Here we go, this is a patch that introduces JcrTypeHandler and JcrTypeHandlerManager. There's quite a few changes in this patch since it touches so much of the existing functionality.

        Show
        Tobias Mattsson added a comment - Here we go, this is a patch that introduces JcrTypeHandler and JcrTypeHandlerManager. There's quite a few changes in this patch since it touches so much of the existing functionality.
        Hide
        Michael Dürig added a comment -

        Applied patch with some modifications at revision 1182520
        Thanks for the patch!

        Show
        Michael Dürig added a comment - Applied patch with some modifications at revision 1182520 Thanks for the patch!
        Hide
        Tobias Mattsson added a comment -

        Thanks, brilliant!

        Show
        Tobias Mattsson added a comment - Thanks, brilliant!

          People

          • Assignee:
            Unassigned
            Reporter:
            Tobias Mattsson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development