jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Muniz <neur0ma...@gmail.com>
Subject Re: Strange behaviour when deleting and Item in jackrabbit 1.5.6
Date Thu, 02 Sep 2010 12:12:27 GMT
Hi Alexander,

Thanks for taking interest in my issue.

To be able to be clear, I would like to show my application log (here
successively trying to delete twice the same Node), and also the Jackrabbit
log. Don't get confused by the namespace notion, it has nothing to do with
the JCR namespaces, it is just a qualifier that is combined with the node
name in order to provide uniqueness inside my application. In short, a node
can be found by combining a node name and a namespace.

I will also post a code excerpt of the doing the deleting and the query. The
code is only informative, I am not asking you to correct it, although if you
find a bug i'd be extremely grateful :)


Application Log:

2010-09-02 13:59:46,798 [http-8082-1] DEBUG resource.JcrResourceFactory  -
Deleting resource with namespace:MESSAGE_REPO
path:MSG-6363===original.message===Hell
o.txt
2010-09-02 13:59:46,798 [http-8082-1] DEBUG resource.JcrUtils  - Executing
query:/jcr:root/CRS/MESSAGE_REPO//MSG-6363_x003d__x003d__x003d_original.message_x003d
__x003d__x003d_Hello.txt
2010-09-02 13:59:46,813 [http-8082-1] DEBUG resource.JcrUtils  - Query
executed, results size:1
2010-09-02 13:59:46,813 [http-8082-1] DEBUG resource.JcrResourceFactory  -
The jcr node was found.
Path:/CRS/MESSAGE_REPO/2010-09-02/MSG-6363===original.message
===Hello.txt Name:MSG-6363===original.message===Hello.txt
UUID:e7276c5a-0d63-4244-ab5c-37fcbb90c3ba
2010-09-02 13:59:46,813 [http-8082-1] DEBUG resource.JcrResourceFactory  -
Fetching parent: /CRS/MESSAGE_REPO/2010-09-02
2010-09-02 13:59:46,829 [http-8082-1] DEBUG resource.JcrResourceFactory  -
Finished deleting resource with namespace:MESSAGE_REPO and
path:MSG-6363===original.m
essage===Hello.txt
Try #2
2010-09-02 13:59:46,829 [http-8082-1] DEBUG resource.JcrResourceFactory  -
Deleting resource with namespace:MESSAGE_REPO
path:MSG-6363===original.message===Hell
o.txt
2010-09-02 13:59:46,845 [http-8082-1] DEBUG resource.JcrUtils  - Executing
query:/jcr:root/CRS/MESSAGE_REPO//MSG-6363_x003d__x003d__x003d_original.message_x003d
__x003d__x003d_Hello.txt
2010-09-02 13:59:46,845 [http-8082-1] DEBUG resource.JcrUtils  - Query
executed, results size:0
2010-09-02 13:59:46,845 [http-8082-1] DEBUG resource.JcrResourceFactory  -
The jcr node was not found.
2010-09-02 13:59:46,845 [http-8082-1] DEBUG resource.JcrResourceFactory  -
Finished deleting resource with namespace:MESSAGE_REPO and
path:MSG-6363===original.m
essage===Hello.txt

You will see that the second time I try to delete the node, it is not foiund
anymore.



Here is the relevant Jackrabbit log:

02.09.2010 13:59:46 *WARN * QueryResultImpl: Exception retrieving Node with
UUID: e7276c5a-0d63-4244-ab5c-37fcbb90c3ba: javax.jcr.ItemNotFoundException:
e7276c5a-0d63-4244-ab5c-37fcbb90c3ba

I only have this exception once (i guess the second time I try to find the
resource)



This is the code that is trying to delete the Node.

            jcrTemplate.execute(new JcrCallback() {
                public Object doInJcr(Session session) throws IOException,
RepositoryException {
                    Node node = JcrUtils.findUniqueNode(session, namespace,
path);
                    if (node == null) {
                        LOGGER.debug("The jcr node was not found.");
                        return null;
                    }

                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug(String.format("The jcr node was found.
Path:%s Name:%s UUID:%s", node.getPath(), node.getName(), node.getUUID()));
                    }
                    Node parent=node.getParent();
                    LOGGER.debug(String.format("Fetching parent: %s ",
parent.getPath()));
                    node.remove();
                    parent.save();
                    session.save();
                    return null;
                }
            });

The code that locates the node:

    public static Node findUniqueNode(Session session, final String
namespace, final String path) throws RepositoryException,
InvalidQueryException, ItemExistsException {
        QueryResult result = findNodes(session, namespace, path);
        NodeIterator nodes = result.getNodes();
        if (!nodes.hasNext()) {
            return null;
        } else {
            Node found = (Node) nodes.next();
            if (nodes.hasNext()) {
                throw new RuntimeException(String.format("Non unique node
found. %s:%s", namespace, path));
            }
            return found;
        }
    }

    public static QueryResult findNodes(Session session, String namespace,
String unescapedResourcePath) throws RepositoryException,
InvalidQueryException, ItemExistsException {
        QueryManager queryManager =
session.getWorkspace().getQueryManager();
        String qStr="/jcr:root/CRS/" + namespace + "//" +
encodeXpathQuery(unescapedResourcePath);
        LOGGER.debug(String.format("Executing query:%s", qStr));
        Query query = queryManager.createQuery(qStr, Query.XPATH);
        QueryResult result = query.execute();
        LOGGER.debug(String.format("Query executed, results size:%d",
result.getNodes().getSize()));
        return result;
    }


Let me know if I can provide more valuable information.

Luis


On Thu, Sep 2, 2010 at 9:21 AM, Alexander Klimetschek <aklimets@day.com>wrote:

> On Thu, Sep 2, 2010 at 03:05, Luis Muniz <neur0maner@gmail.com> wrote:
> > Hi,
> >
> > I am trying to delete a Node, and following the API documentation, I need
> to
> > call remove() on the Node, and then save() on the parent of the Node.
> >
> > When I then view the repository with a webdav client, I can still see the
> > 'deleted' node under the parent.
> >
> > But the strange thing is that If I try to find the node via XPath, once
> it
> > has been deleted in this way, I can't find it.
> >
> > So the delete operation did work in the sense that the Node cannot be
> found
> > by XPath anymore, but the Parent Node still lists it as its children.
> >
> > Am I missing anything?
> >
> > Technical details:
> >
> > I am using the jcr spring module, and this is my configuration:
> >
> > My transactionManager is a
> > org.springmodules.jcr.jackrabbit.LocalTransactionManager
> >
> > My DataStore is a org.apache.jackrabbit.core.data.FileDataStore
>
> What is your Persistence Manager? Any exceptions in the logs?
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> alexander.klimetschek@day.com
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message