jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SalmasCM <sal...@criticalmass.com>
Subject Re: modified externally: node / when deleting node
Date Tue, 05 May 2009 14:08:34 GMT

The reason I think its the index is because if I:

1. Load a file in from XML import under /nodeA in workspace 1.
2. Clone nodeA to workspace2 
2. Exit my application.
3. Delete nodeA from workspace 1 and 2
4. Reload a file in from XML import.
5. Do a XPATH query for a node in the imported data I get errors.

BUT if I:

1. Load a file in from XML import under /nodeA in workspace 1.
2. Clone nodeA to workspace2 
2. Exit my application.
4. Delete the repository home directory manually
3. Delete nodeA from both workspace 1 and 2
4. Reload a file in from XML import.
5. Do a XPATH query for a node in the imported data I do NOTget errors.

Please advise as I my system is to go to production next week and its an
adminable consumer website for a company which expends a fair amount of
traffic on their site.

My code is below. Please let me know if anything looks weird. I have an
object per session that I lock whenever each of these sessions are modified.
The lock object is an instance variable on a singleton.

    private void removeTopLevelNode(String name) {
        Session prodSession =
JCRConnectionUtil.getInstance().getProductionSession();
        Session previewSession =
JCRConnectionUtil.getInstance().getPreviewSession();
        Boolean prodLockObject =
JCRConnectionUtil.getInstance().getProductionSessionLock();
        Boolean previewLockObj =
JCRConnectionUtil.getInstance().getPreviewSessionLock();

        try {
            Node previewRoot = previewSession.getRootNode();
            Node prodRoot = prodSession.getRootNode();
            Node prodNode = null;

            if (previewRoot.hasNode(name)) {
                synchronized (previewLockObj) {
                    Node previewNode = previewRoot.getNode(name);
                    previewRoot.addMixin("mix:lockable");
                    JCRConnectionUtil.getInstance().savePreviewSession();
                    if (!previewRoot.isLocked()) {
                        previewRoot.lock(true, true);
                    }

                    previewNode.remove();
                    JCRConnectionUtil.getInstance().savePreviewSession();
                    previewRoot.unlock();
                }
                synchronized (previewLockObj) {
                    synchronized (prodLockObject) {
                        if (prodRoot.hasNode(name)) {
                            prodNode = prodRoot.getNode(name);
                            prodRoot.addMixin("mix:lockable");
                           
JCRConnectionUtil.getInstance().saveProductionSession();
                            if (!prodRoot.isLocked()) {
                                prodRoot.lock(true, true);
                            }

                            if (prodRoot.hasNode(name)) {
                                if (prodRoot.hasNode(name)) {
                                    logger.info("explicitly removing node");
                                   
prodNode.update(ConnectionManager.PREVIEW_WORKSPACE);
                                    prodNode.remove();
                                   
JCRConnectionUtil.getInstance().saveProductionSession();
                                    prodRoot.unlock();
                                   
JCRUtil.getInstance().listChildrenOfRoot(prodSession, "In PROD SESSION");
                                }
                            }
                        }
                    }
                }
            }
        } catch (PathNotFoundException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:PathNotFoundException",
e);
        } catch (VersionException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:VersionException", e);
        } catch (LockException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:LockException", e);
        } catch (ConstraintViolationException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:ConstraintViolationException",
e);
        } catch (NoSuchWorkspaceException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:NoSuchWorkspaceException",
e);
        } catch (AccessDeniedException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:AccessDeniedException",
e);
        } catch (InvalidItemStateException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:InvalidItemStateException",
e);
        } catch (RepositoryException e) {
           
logger.error("LegacyDataLoader:removeTopLevelNode:RepositoryException", e);
        }
    }

    public static void importXMLFile(InputStream stream, String
topLevelNodeName) {
        //removeNode(topLevelNodeName);
        Session session = JCRUtil.getSession();
        try {
            if (session != null) {
                if
(JCRConnectionUtil.getInstance().getCurrentSessionLock()!=null) {
                    Node root = session.getRootNode();
                    synchronized
(JCRConnectionUtil.getInstance().getCurrentSessionLock()) {
                        root.addMixin("mix:lockable");
                        JCRUtil.saveSession();
                        root.lock(true, true);
                        session.getWorkspace().importXML("/", stream,
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
                        session.save();
                        root.unlock();
                    }
                }
            }
        } catch (PathNotFoundException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
PathNotFoundException: " + e);
        } catch (ItemExistsException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
ItemExistsException: " + e);
        } catch (ConstraintViolationException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
ConstraintViolationException: " + e);
        } catch (VersionException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
VersionException: " + e);
        } catch (InvalidSerializedDataException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
InvalidSerializedDataException: " + e);
        } catch (LockException e) {
            logger.error("In ContentLoadUtil:importXMLFile, LockException: "
+ e);
        } catch (IOException e) {
            logger.error("In ContentLoadUtil:importXMLFile, IOException: " +
e);
        } catch (RepositoryException e) {
            logger.error("In ContentLoadUtil:importXMLFile,
RepositoryException: " + e);
        } finally {
            try {
                stream.close();
            } catch (IOException e) {
                logger.error("In ContentLoadUtil:importXMLFile, IOException:
" + e);
            }
        }

    }
Regads

Alexander Klimetschek wrote:
> 
> On Mon, May 4, 2009 at 11:57 PM, SalmasCM <salmas@criticalmass.com> wrote:
>> I've found that my latest problem is because when I delete a node from
>> the
>> preview workspace and its clone from the default workspace, these deletes
>> do
>> not trigger a lucene index refresh.
>> All works fine while the app is running, things are indexed fine, I can
>> drop
>> the nodes and reload as many times as I like but but if I stop my
>> application server and restart and then do the deletes then the indexres
>> are
>> out of wack. However, if I stop the server and manually delete the
>> indexes
>> then I do not get these errors.
>> Is there a way that I can programmatically make lucene reindex after the
>> deletes?
> 
> The lucene index is automatically updated for all JCR operations,
> including node removal. What makes you think that the index is not
> updated? Please note that a node removal does not map to a simple file
> or directory delete in the lucene index, it's somewhat complex. The
> right way to test it is to run a search - after the delete, the node
> should no longer appear in the results.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/modified-externally%3A-node---when-deleting-node-tp23352361p23387753.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message