Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1CD456650 for ; Fri, 29 Jul 2011 11:35:48 +0000 (UTC) Received: (qmail 20388 invoked by uid 500); 29 Jul 2011 11:35:48 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 20208 invoked by uid 500); 29 Jul 2011 11:35:41 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 19560 invoked by uid 99); 29 Jul 2011 11:35:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jul 2011 11:35:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jul 2011 11:35:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 012502388980; Fri, 29 Jul 2011 11:35:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1152173 - /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java Date: Fri, 29 Jul 2011 11:35:17 -0000 To: commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110729113518.012502388980@eris.apache.org> Author: mduerig Date: Fri Jul 29 11:35:17 2011 New Revision: 1152173 URL: http://svn.apache.org/viewvc?rev=1152173&view=rev Log: spi2microkernel (WIP) - avoid IndexOutOfBoundException in observation - logging Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java?rev=1152173&r1=1152172&r2=1152173&view=diff ============================================================================== --- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java (original) +++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/SubscriptionImpl.java Fri Jul 29 11:35:17 2011 @@ -41,6 +41,8 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.jcr.RepositoryException; import java.util.ArrayList; @@ -56,6 +58,8 @@ import java.util.concurrent.ExecutionExc import java.util.concurrent.FutureTask; public class SubscriptionImpl implements Subscription { + static final Logger log = LoggerFactory.getLogger(SubscriptionImpl.class); + private final MicroKernel microKernel; private final SessionState sessionState; private final WaitForCommit waitForCommit; @@ -140,7 +144,7 @@ public class SubscriptionImpl implements return path.getAncestor(1); } catch (RepositoryException e) { - // todo log + log.error("Error getting parent of " + path, e); return null; } } @@ -150,14 +154,18 @@ public class SubscriptionImpl implements return PathFactoryImpl.getInstance().create(parent, name, true); } catch (RepositoryException e) { - // todo log + log.error("Error creating path for " + parent + ", " + name, e); return null; } } private static Path readPath(JsopTokenizer jsopTokenizer) { String path = jsopTokenizer.readString(); - path = path.substring(PathUtils.getNextSlash(path, 1)); // slash off workspace name + int index = PathUtils.getNextSlash(path, 1); // slash off workspace name + path = index == -1 + ? "/" + : path.substring(index); + return Paths.stringToPath(path); } @@ -324,7 +332,10 @@ public class SubscriptionImpl implements private void addItem(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection events) { Path path = readPath(jsopTokenizer); - NodeId parentId = createNodeId(getParent(path)); + NodeId parentId = path.denotesRoot() + ? null + : createNodeId(getParent(path)); + addItem(jsopTokenizer, eventTemplate, events, path, parentId); } @@ -379,7 +390,9 @@ public class SubscriptionImpl implements private void removeNode(JsopTokenizer jsopTokenizer, EventTemplate eventTemplate, Collection events) { Path path = readPath(jsopTokenizer); - NodeId parentId = createNodeId(getParent(path)); + NodeId parentId = path.denotesRoot() + ? null + : createNodeId(getParent(path)); EventTemplate removeNodeEvent = eventTemplate.copy(); removeNodeEvent.setType(Event.NODE_REMOVED);