0 Replies Latest reply on Jun 6, 2012 8:34 AM by K. Bachl

    Modeshape 2.8.0 vs. 2.8.1: ReferenceIntegrity and XML Import

    K. Bachl Novice

      Hello,

       

      in our app we have an import/ export feature where a workspace can be exported to a file and also imported. Till 2.8.0 it following was possible:

       

       

      <code>

                              InputStream s = u.getInputStream();

                              String id = ManageSnapshotsPanel.this.getModelObject().getId();

                              Brix brix = getBrix();

                              JcrSession session = brix.getCurrentSession(id);

       

                              if (session.itemExists(brix.getRootPath())) {

                                  session.getItem(brix.getRootPath()).remove();

                              }

       

                              session.importXML("/", s,

                                      ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);

                              session.save();

      </code>

       

       

      But from 2.8.1 on we have an enhanced ReferenceIntegrity check in modeshape, meaning we'll get an error if we want the import to overwrite an existing path (first overwrite clears sub and therefore references get lost old nodes that would be filled by not yet imported ones;

       

      A solution for this was to explicitely call

       

       

      <code>

      // explicitely clear brix root and save it to session prior import!

                              if (session.itemExists(brix.getRootPath())) {

                                  session.getItem(brix.getRootPath()).remove();

                                  session.save();

                              }

      </code>

       

      session.save in between, but this now means that during the time of the delete and full XML import the content can't be accessed by third party requests - a feature that was possible before as modeshape replaced the nodes one by one; As ModeShape 2.x doenst support transactions I wonder how this could be solved. Is it possible to explicitely disable reference-checking for XML imports?

       

      PS: how's the state of modeshape 3 going? any e.t.a for beta?