Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-20401

Fix wrong repository retrieval for comments in multi-repository context

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.10, 8.3
    • Fix Version/s: 7.10-HF17, 8.10
    • Component/s: Comments
    • Tags:
    • Backlog priority:
      700
    • Sprint:
      nxGang Sprint 8.4.5, nxGang Sprint 8.4.6
    • Story Points:
      3

      Description

      1. setup a multiple repositories (check attached template to setup Oracle DB in this case)
      2. login in
      3. select the second repository
      4. create a workspace
      5. create a file
      6. add a comment
      7. it is not visible
      8. check the DB table COMMENT, the comment has been created
      9. there is nothing in the RELATION table though
      10. check the logs, it shows:
        2016-09-08 11:51:34,339 WARN  [http-bio-0.0.0.0-8080-exec-19] [org.nuxeo.ecm.platform.comment.impl.CommentManagerImpl] Could not adapt comment relation subject to a document model; check the service relation adapters configur  ation
        

      The error is due to problems while retrieving comments in the CommentManagerImpl.getComments method. While debugging it shows that the default repository is used. For example id secondrepo/47b5fd33-3a30-4524-8d23-94f39679136a becomes default/47b5fd33-3a30-4524-8d23-94f39679136a.

      Check around this code in CommentManagerImpl.getComments:

      List<Statement> statementList = graph.getStatements(null, null, docResource);
              if (graph instanceof JenaGraph) {
                  // XXX AT: BBB for when repository name was not included in the
                  // resource uri
                  Resource oldDocResource = new QNameResourceImpl(config.documentNamespace, docModel.getId());
                  statementList.addAll(graph.getStatements(null, null, oldDocResource));
              }
      

      The resulting statementList contains mismatched repositories.

      Looking at CoreGraph.run(), a call to createId returns wrong localName in QNameResource objects. While graph.getStatements passes oldDocResource to the Graph, it is not used to create the QName Resource:

      protected QNameResource createId(String id) {
                  return NodeFactory.createQNameResource(DOCUMENT_NAMESPACE, session.getRepositoryName() + '/' + id);
              }
      

      Since the session is not passed as a parameter to the graph, it is created in the graph itself:

      StatementFinder statementFinder = session == null ? new StatementFinder(statement) : new StatementFinder(
                      statement, session);

      As a result, the default repository is used.

      maybe adding methods taking the session as a parameter could fix this:

       getStatements(Statement statement, Session session)
      getStatements(Node subject, Node predicate, Node object, Session)

      This way the StatementFinder would be created with the proper session, using the right repository.

      Also please note that this may be only one issue. After fixing this, one has to check a comment is correctly created and read.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 3 hours
                  1d 3h