Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 74122 invoked from network); 5 Jul 2007 13:52:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jul 2007 13:52:55 -0000 Received: (qmail 62551 invoked by uid 500); 5 Jul 2007 13:52:44 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 62519 invoked by uid 500); 5 Jul 2007 13:52:44 -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 62484 invoked by uid 99); 5 Jul 2007 13:52:43 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2007 06:52:43 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2007 06:52:38 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id CA2641A981A; Thu, 5 Jul 2007 06:52:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553507 [1/2] - in /jackrabbit/trunk/contrib/spi: commons/src/main/java/org/apache/jackrabbit/spi/ commons/src/main/java/org/apache/jackrabbit/spi/commons/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ spi-rmi/src/main/java/or... Date: Thu, 05 Jul 2007 13:52:16 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070705135217.CA2641A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mreutegg Date: Thu Jul 5 06:52:13 2007 New Revision: 553507 URL: http://svn.apache.org/viewvc?view=rev&rev=553507 Log: JCR-1007: Move common implementations of SPI interfaces to spi-commons module Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (with props) jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (with props) Removed: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/ChildInfoImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/EventBundleImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/EventFilterImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/EventImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/IteratorHelper.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/LockInfoImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/NodeInfoImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/PropertyInfoImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QItemDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QNodeTypeDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/QPropertyDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/common/SerializableIdFactory.java jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ChildInfoImpl.java jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventBundleImpl.java jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventFilterImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventBundleImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventFilterImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ItemInfoImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QItemDefinitionImpl.java Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/PropertyInfoImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QNodeTypeDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.ChildInfo; +import org.apache.jackrabbit.name.QName; + +import java.io.Serializable; + +/** + * ChildInfoImpl implements a serializable ChildInfo. + */ +public class ChildInfoImpl implements ChildInfo, Serializable { + + /** + * The name of this child info. + */ + private final QName name; + + /** + * The unique id for this child info or null if it does not + * have a unique id. + */ + private final String uniqueId; + + /** + * 1-based index of this child info. + */ + private final int index; + + /** + * Creates a new serializable ChildInfoImpl. + * + * @param name the name of the child node. + * @param uniqueId the unique id of the child node or null. + * @param index the index of the child node. + */ + public ChildInfoImpl(QName name, String uniqueId, int index) { + this.name = name; + this.uniqueId = uniqueId; + this.index = index; + } + + /** + * {@inheritDoc} + */ + public QName getName() { + return name; + } + + /** + * {@inheritDoc} + */ + public String getUniqueID() { + return uniqueId; + } + + /** + * {@inheritDoc} + */ + public int getIndex() { + return index; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ChildInfoImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.EventBundle; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; + +/** + * EventBundleImpl implements a serializable {@link EventBundle}. + */ +public class EventBundleImpl implements EventBundle, Serializable { + + /** + * Indicates if this bundle was created due to a local change. + */ + private final boolean isLocal; + + /** + * The bundle id. + */ + private final String bundleId; + + /** + * The events in this bundle. + */ + private final Collection events; + + /** + * Creates a new event bundle with events. + * + * @param events the events for this bundle. + * @param isLocal if this events were created due to a local change. + * @param bundleId the bundle id. + */ + public EventBundleImpl(Collection events, boolean isLocal, String bundleId) { + this.events = events; + this.isLocal = isLocal; + this.bundleId = bundleId; + } + + /** + * {@inheritDoc} + */ + public Iterator getEvents() { + return events.iterator(); + } + + /** + * {@inheritDoc} + */ + public String getBundleId() { + return bundleId; + } + + /** + * {@inheritDoc} + */ + public boolean isLocal() { + return isLocal; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventBundleImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.EventFilter; +import org.apache.jackrabbit.spi.Event; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.name.Path; +import org.apache.jackrabbit.name.MalformedPathException; + +import javax.jcr.PathNotFoundException; +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; +import java.util.Collections; +import java.io.Serializable; + +/** + * EventFilterImpl is the simple bean style implementation of an + * {@link EventFilter}. + */ +public class EventFilterImpl implements EventFilter, Serializable { + + private final int eventTypes; + + private final boolean isDeep; + + private final Path absPath; + + private final Set uuids; + + private final Set nodeTypeNames; + + private final boolean noLocal; + + /** + * Creates a new EventFilterImpl. + * + * @param eventTypes the event types this filter is interested in. + * @param absPath filter events that are below this path. + * @param isDeep whether this filter is applied deep. + * @param uuids the jcr:uuid of the nodes this filter allows. + * @param nodeTypeNames the QNames of the already resolved node types this + * filter allows. + * @param noLocal whether this filter accepts local events or not. + */ + public EventFilterImpl(int eventTypes, + Path absPath, + boolean isDeep, + String[] uuids, + Set nodeTypeNames, + boolean noLocal) { + this.eventTypes = eventTypes; + this.absPath = absPath; + this.isDeep = isDeep; + this.uuids = uuids != null ? new HashSet(Arrays.asList(uuids)) : null; + this.nodeTypeNames = nodeTypeNames != null ? new HashSet(nodeTypeNames) : null; + this.noLocal = noLocal; + } + + /** + * {@inheritDoc} + */ + public boolean accept(Event event, boolean isLocal) { + int type = event.getType(); + // check type + if ((type & eventTypes) == 0) { + return false; + } + + // check local flag + if (isLocal && noLocal) { + return false; + } + + // check UUIDs + NodeId parentId = event.getParentId(); + if (uuids != null) { + if (parentId.getPath() == null) { + if (!uuids.contains(parentId.getUniqueID())) { + return false; + } + } else { + return false; + } + } + + // check node types + if (nodeTypeNames != null) { + Set eventTypes = new HashSet(); + eventTypes.addAll(Arrays.asList(event.getMixinTypeNames())); + eventTypes.add(event.getPrimaryNodeTypeName()); + // create intersection + eventTypes.retainAll(nodeTypeNames); + if (eventTypes.isEmpty()) { + return false; + } + } + + // finally check path + try { + // the relevant path for the path filter depends on the event type + // for node events, the relevant path is the one returned by + // Event.getPath(). + // for property events, the relevant path is the path of the + // node where the property belongs to. + Path eventPath; + if (type == Event.NODE_ADDED || type == Event.NODE_REMOVED) { + eventPath = event.getQPath(); + } else { + eventPath = event.getQPath().getAncestor(1); + } + + boolean match = eventPath.equals(absPath); + if (!match && isDeep) { + match = eventPath.isDescendantOf(absPath); + } + return match; + } catch (MalformedPathException e) { + // should never get here + } catch (PathNotFoundException e) { + // should never get here + } + // if we get here an exception occurred while checking for the path + return false; + } + + /** + * @return the event types this event filter accepts. + */ + public int getEventTypes() { + return eventTypes; + } + + /** + * @return true if this event filter is deep. + */ + public boolean isDeep() { + return isDeep; + } + + /** + * @return the path to the item where events are filtered. + */ + public Path getAbsPath() { + return absPath; + } + + /** + * @return the uuids of the nodes of this filter or null if + * this filter does not care about uuids. + */ + public String[] getUUIDs() { + if (uuids == null) { + return null; + } else { + return (String[]) uuids.toArray(new String[uuids.size()]); + } + } + + /** + * @return an unmodifiable set of node type names or null if + * this filter does not care about node types. + */ + public Set getNodeTypeNames() { + if (nodeTypeNames == null) { + return null; + } else { + return Collections.unmodifiableSet(nodeTypeNames); + } + } + + /** + * @return if this filter accepts local events. + */ + public boolean getNoLocal() { + return noLocal; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventFilterImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.Event; +import org.apache.jackrabbit.spi.ItemId; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.name.Path; +import org.apache.jackrabbit.name.QName; + +import java.io.Serializable; + +/** + * EventImpl implements a serializable SPI + * {@link org.apache.jackrabbit.spi.Event}. + */ +public class EventImpl implements Event, Serializable { + + /** + * The SPI event type. + * @see Event + */ + private final int type; + + /** + * The path of the affected item. + */ + private final Path path; + + /** + * The id of the affected item. + */ + private final ItemId itemId; + + /** + * The id of the affected item. + */ + private final NodeId parentId; + + /** + * The name of the primary node type of the 'associated' node of this event. + */ + private final QName primaryNodeTypeName; + + /** + * The names of the mixin types of the 'associated' node of this event. + */ + private final QName[] mixinTypeNames; + + /** + * The user ID connected with this event. + */ + private final String userId; + + /** + * Creates a new serializable event. + */ + public EventImpl(int type, Path path, ItemId itemId, NodeId parentId, + QName primaryNodeTypeName, QName[] mixinTypeNames, + String userId) { + this.type = type; + this.path = path; + this.itemId = itemId; + this.parentId = parentId; + this.primaryNodeTypeName = primaryNodeTypeName; + this.mixinTypeNames = mixinTypeNames; + this.userId = userId; + } + + /** + * {@inheritDoc} + */ + public int getType() { + return type; + } + + /** + * {@inheritDoc} + */ + public Path getQPath() { + return path; + } + + /** + * {@inheritDoc} + */ + public ItemId getItemId() { + return itemId; + } + + /** + * {@inheritDoc} + */ + public NodeId getParentId() { + return parentId; + } + + /** + * {@inheritDoc} + */ + public QName getPrimaryNodeTypeName() { + return primaryNodeTypeName; + } + + /** + * {@inheritDoc} + */ + public QName[] getMixinTypeNames() { + QName[] mixins = new QName[mixinTypeNames.length]; + System.arraycopy(mixinTypeNames, 0, mixins, 0, mixinTypeNames.length); + return mixins; + } + + /** + * {@inheritDoc} + */ + public String getUserID() { + return userId; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/EventImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.ItemInfo; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.name.Path; + +import java.io.Serializable; + +/** + * ItemInfoImpl is a base class for ItemInfo + * implementations. + */ +public abstract class ItemInfoImpl implements ItemInfo, Serializable { + + /** + * The parent node id of this item or null if this item + * represents the root node info. + */ + private final NodeId parentId; + + /** + * The name of this item info. + */ + private final QName name; + + /** + * The path of this item info. + */ + private final Path path; + + /** + * Flag indicating whether this is a node or a property info. + */ + private final boolean isNode; + + /** + * Creates a new serializable item info for the given qualified + * item info. + * + * @param parentId the parent id. + * @param name the name of this item. + * @param path the path to this item. + * @param isNode if this item is a node. + */ + public ItemInfoImpl(NodeId parentId, QName name, Path path, boolean isNode) { + this.parentId = parentId; + this.name = name; + this.path = path; + this.isNode = isNode; + } + + /** + * {@inheritDoc} + */ + public NodeId getParentId() { + return parentId; + } + + /** + * {@inheritDoc} + */ + public QName getQName() { + return name; + } + + /** + * {@inheritDoc} + */ + public boolean denotesNode() { + return isNode; + } + + /** + * {@inheritDoc} + */ + public Path getPath() { + return path; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.LockInfo; +import org.apache.jackrabbit.spi.NodeId; + +import java.io.Serializable; + +/** + * LockInfoImpl implements a serializable LockInfo + * based on another lock info. + */ +public class LockInfoImpl implements LockInfo, Serializable { + + /** + * The lock token for this lock info. + */ + private final String lockToken; + + /** + * The owner of the lock. + */ + private final String lockOwner; + + /** + * The isDeep flag. + */ + private final boolean isDeep; + + /** + * The isSessionScoped flag. + */ + private final boolean isSessionScoped; + + /** + * The NodeId of the locked node. + */ + private final NodeId nodeId; + + /** + * Creates a new lock info for the given lock info. + * + * @param lockToken the lock token + * @param lockOwner the lock owner + * @param isDeep whether this lock is deep or not + * @param isSessionScoped whether this lock is session scoped or not + * @param nodeId the node id of the locked node. + */ + public LockInfoImpl(String lockToken, String lockOwner, boolean isDeep, + boolean isSessionScoped, NodeId nodeId) { + this.lockToken = lockToken; + this.lockOwner = lockOwner; + this.isDeep = isDeep; + this.isSessionScoped = isSessionScoped; + this.nodeId = nodeId; + } + + /** + * {@inheritDoc} + */ + public String getLockToken() { + return lockToken; + } + + /** + * {@inheritDoc} + */ + public String getOwner() { + return lockOwner; + } + + /** + * {@inheritDoc} + */ + public boolean isDeep() { + return isDeep; + } + + /** + * {@inheritDoc} + */ + public boolean isSessionScoped() { + return isSessionScoped; + } + + /** + * {@inheritDoc} + */ + public NodeId getNodeId() { + return nodeId; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/LockInfoImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.NodeInfo; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.spi.PropertyId; +import org.apache.jackrabbit.spi.IdFactory; +import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.name.Path; +import org.apache.jackrabbit.util.IteratorHelper; + +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; +import java.io.Serializable; + +/** + * NodeInfoImpl implements a serializable NodeInfo + * based on another node info. + */ +public class NodeInfoImpl extends ItemInfoImpl implements NodeInfo { + + /** + * The node id of the underlying node. + */ + private final NodeId id; + + /** + * 1-based index of the underlying node. + */ + private final int index; + + /** + * The name of the primary node type. + */ + private final QName primaryTypeName; + + /** + * The names of assigned mixins. + */ + private final QName[] mixinNames; + + /** + * The list of {@link PropertyId}s that reference this node info. + */ + private final List references; + + /** + * The list of {@link PropertyId}s of this node info. + */ + private final List propertyIds; + + /** + * Creates a new serializable NodeInfo for the given + * NodeInfo. + * + * @param nodeInfo + */ + public static NodeInfo createSerializableNodeInfo( + NodeInfo nodeInfo, final IdFactory idFactory) { + if (nodeInfo instanceof Serializable) { + return nodeInfo; + } else { + PropertyId[] refs = nodeInfo.getReferences(); + List serRefs = new ArrayList(); + for (int i = 0; i < refs.length; i++) { + NodeId parentId = refs[i].getParentId(); + parentId = idFactory.createNodeId( + parentId.getUniqueID(), parentId.getPath()); + serRefs.add(idFactory.createPropertyId(parentId, refs[i].getQName())); + } + NodeId parentId = null; + if (nodeInfo.getParentId() != null) { + parentId = nodeInfo.getParentId(); + parentId = idFactory.createNodeId( + parentId.getUniqueID(), parentId.getPath()); + } + NodeId nodeId = nodeInfo.getId(); + nodeId = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath()); + return new NodeInfoImpl(parentId, nodeInfo.getQName(), + nodeInfo.getPath(), nodeId, + nodeInfo.getIndex(), nodeInfo.getNodetype(), + nodeInfo.getMixins(), serRefs.iterator(), + new IteratorHelper(nodeInfo.getPropertyIds()) { + public Object next() { + PropertyId propId = (PropertyId) super.next(); + NodeId parentId = propId.getParentId(); + idFactory.createNodeId( + parentId.getUniqueID(), parentId.getPath()); + return idFactory.createPropertyId( + parentId, propId.getQName()); + } + }); + } + } + + /** + * Creates a new serializable node info for the given node + * info. + * + * @param parentId the parent id. + * @param name the name of this item. + * @param path the path to this item. + * @param id the id of this item. + * @param index the index of this item. + * @param primaryTypeName the name of the primary node type. + * @param mixinNames the names of the assigned mixins. + * @param references the references to this node. + * @param propertyIds the properties of this node. + */ + public NodeInfoImpl(NodeId parentId, QName name, Path path, NodeId id, + int index, QName primaryTypeName, QName[] mixinNames, + Iterator references, Iterator propertyIds) { + super(parentId, name, path, true); + this.id = id; + this.index = index; + this.primaryTypeName = primaryTypeName; + this.mixinNames = mixinNames; + this.references = new ArrayList(); + while (references.hasNext()) { + this.references.add(references.next()); + } + this.propertyIds = new ArrayList(); + while (propertyIds.hasNext()) { + this.propertyIds.add(propertyIds.next()); + } + } + + //-------------------------------< NodeInfo >------------------------------- + + /** + * {@inheritDoc} + */ + public NodeId getId() { + return id; + } + + /** + * {@inheritDoc} + */ + public int getIndex() { + return index; + } + + /** + * {@inheritDoc} + */ + public QName getNodetype() { + return primaryTypeName; + } + + /** + * {@inheritDoc} + */ + public QName[] getMixins() { + QName[] ret = new QName[mixinNames.length]; + System.arraycopy(mixinNames, 0, ret, 0, mixinNames.length); + return ret; + } + + /** + * {@inheritDoc} + */ + public PropertyId[] getReferences() { + return (PropertyId[]) references.toArray(new PropertyId[references.size()]); + } + + /** + * {@inheritDoc} + */ + public Iterator getPropertyIds() { + return propertyIds.iterator(); + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/NodeInfoImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.PropertyInfo; +import org.apache.jackrabbit.spi.PropertyId; +import org.apache.jackrabbit.spi.QValue; +import org.apache.jackrabbit.spi.NodeId; +import org.apache.jackrabbit.spi.IdFactory; +import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.name.Path; + +import java.io.Serializable; + +/** + * PropertyInfoImpl implements a serializable + * PropertyInfo based on another property info. + */ +public class PropertyInfoImpl extends ItemInfoImpl implements PropertyInfo { + + /** + * The property info of the underlying property. + */ + private final PropertyId propertyId; + + /** + * The type of the property. + */ + private final int type; + + /** + * The multiValued flag. + */ + private final boolean isMultiValued; + + /** + * The values of this property info. + */ + private final QValue[] values; + + /** + * Creates a new serializable property info for the given + * PropertyInfo. + * + * @param propertyInfo + */ + public static PropertyInfo createSerializablePropertyInfo( + PropertyInfo propertyInfo, IdFactory idFactory) { + if (propertyInfo instanceof Serializable) { + return propertyInfo; + } else { + NodeId parentId = propertyInfo.getParentId(); + parentId = idFactory.createNodeId( + parentId.getUniqueID(), parentId.getPath()); + PropertyId propId = idFactory.createPropertyId( + parentId, propertyInfo.getId().getQName()); + return new PropertyInfoImpl(parentId, propertyInfo.getQName(), + propertyInfo.getPath(), propId, propertyInfo.getType(), + propertyInfo.isMultiValued(), propertyInfo.getValues()); + } + } + + /** + * Creates a new serializable property info for the given parameters. + * + * @param parentId the parent id. + * @param name the name of this property. + * @param path the path to this property. + * @param id the id of this property. + * @param type the type of this property. + * @param isMultiValued whether this property is multi-valued. + * @param values the values. + */ + public PropertyInfoImpl(NodeId parentId, QName name, Path path, + PropertyId id, int type, boolean isMultiValued, + QValue[] values) { + super(parentId, name, path, false); + this.propertyId = id; + this.type = type; + this.isMultiValued = isMultiValued; + this.values = values; + } + + /** + * {@inheritDoc} + */ + public PropertyId getId() { + return propertyId; + } + + /** + * {@inheritDoc} + */ + public int getType() { + return type; + } + + /** + * {@inheritDoc} + */ + public boolean isMultiValued() { + return isMultiValued; + } + + /** + * {@inheritDoc} + */ + public QValue[] getValues() { + QValue[] vals = new QValue[values.length]; + System.arraycopy(values, 0, vals, 0, values.length); + return vals; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/PropertyInfoImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,179 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.QItemDefinition; +import org.apache.jackrabbit.spi.QNodeDefinition; +import org.apache.jackrabbit.spi.QPropertyDefinition; + +import java.io.Serializable; + +/** + * This abstract class implements the QItemDefinition + * interface and additionally provides setter methods for the + * various item definition attributes. + */ +public abstract class QItemDefinitionImpl implements QItemDefinition, Serializable { + + /** + * The special wildcard name used as the name of residual item definitions. + */ + public static final QName ANY_NAME = new QName("", "*"); + + /** + * The name of the child item. + */ + private final QName name; + + /** + * The name of the declaring node type. + */ + private final QName declaringNodeType; + + /** + * The 'autoCreated' flag. + */ + private final boolean autoCreated; + + /** + * The 'onParentVersion' attribute. + */ + private final int onParentVersion; + + /** + * The 'protected' flag. + */ + private final boolean writeProtected; + + /** + * The 'mandatory' flag. + */ + private final boolean mandatory; + + /** + * HashCode of this object + */ + protected transient int hashCode = 0; + + /** + * Creates a new QItemDefinitionImpl. + * + * @param name the name of the child item. + * @param declaringNodeType the delaring node type + * @param isAutoCreated if this item is auto created. + * @param isMandatory if this is a mandatory item. + * @param onParentVersion the on parent version behaviour. + * @param isProtected if this item is protected. + */ + QItemDefinitionImpl(QName name, QName declaringNodeType, + boolean isAutoCreated, boolean isMandatory, + int onParentVersion, boolean isProtected) { + this.name = name; + this.declaringNodeType = declaringNodeType; + this.autoCreated = isAutoCreated; + this.mandatory = isMandatory; + this.onParentVersion = onParentVersion; + this.writeProtected = isProtected; + } + + //--------------------------------------------------------------< QItemDefinition > + /** + * {@inheritDoc} + */ + public QName getDeclaringNodeType() { + return declaringNodeType; + } + + /** + * {@inheritDoc} + */ + public QName getQName() { + return name; + } + + /** + * {@inheritDoc} + */ + public boolean isAutoCreated() { + return autoCreated; + } + + /** + * {@inheritDoc} + */ + public int getOnParentVersion() { + return onParentVersion; + } + + /** + * {@inheritDoc} + */ + public boolean isProtected() { + return writeProtected; + } + + /** + * {@inheritDoc} + */ + public boolean isMandatory() { + return mandatory; + } + + /** + * {@inheritDoc} + */ + public boolean definesResidual() { + return name.equals(ANY_NAME); + } + + //-------------------------------------------< java.lang.Object overrides > + /** + * Compares two item definitions for equality. Returns true + * if the given object is an item defintion and has the same attributes + * as this item definition. + * + * @param obj the object to compare this item definition with + * @return true if the object is equal to this item definition, + * false otherwise + * @see Object#equals(Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof QItemDefinition) { + QItemDefinition other = (QItemDefinition) obj; + return (declaringNodeType == null + ? other.getDeclaringNodeType() == null + : declaringNodeType.equals(other.getDeclaringNodeType())) + && (name == null ? other.getQName() == null : name.equals(other.getQName())) + && autoCreated == other.isAutoCreated() + && onParentVersion == other.getOnParentVersion() + && writeProtected == other.isProtected() + && mandatory == other.isMandatory(); + } + return false; + } + + /** + * See {@link QNodeDefinition#hashCode()} and {@link QPropertyDefinition#hashCode()}. + * + * @return + */ + public abstract int hashCode(); +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.QNodeDefinition; +import org.apache.jackrabbit.name.QName; + +import java.util.Arrays; +import java.util.TreeSet; + +/** + * QNodeDefinitionImpl implements a QNodeDefinition. + */ +public class QNodeDefinitionImpl + extends QItemDefinitionImpl + implements QNodeDefinition { + + /** + * The name of the default primary type. + */ + private final QName defaultPrimaryType; + + /** + * The names of the required primary types. + */ + private final QName[] requiredPrimaryTypes; + + /** + * The 'allowsSameNameSiblings' flag. + */ + private final boolean allowsSameNameSiblings; + + /** + * Copy constructor. + * + * @param nodeDef some other node definition. + */ + public QNodeDefinitionImpl(QNodeDefinition nodeDef) { + this(nodeDef.getQName(), nodeDef.getDeclaringNodeType(), + nodeDef.isAutoCreated(), nodeDef.isMandatory(), + nodeDef.getOnParentVersion(), nodeDef.isProtected(), + nodeDef.getDefaultPrimaryType(), + nodeDef.getRequiredPrimaryTypes(), + nodeDef.allowsSameNameSiblings()); + } + + /** + * Creates a new qualified node definition based on a JCR NodeDefinition. + * + * @param name the name of the child item. + * @param declaringNodeType the delaring node type + * @param isAutoCreated if this item is auto created. + * @param isMandatory if this is a mandatory item. + * @param onParentVersion the on parent version behaviour. + * @param isProtected if this item is protected. + */ + public QNodeDefinitionImpl(QName name, QName declaringNodeType, + boolean isAutoCreated, boolean isMandatory, + int onParentVersion, boolean isProtected, + QName defaultPrimaryType, QName[] requiredPrimaryTypes, + boolean allowsSameNameSiblings) { + super(name, declaringNodeType, isAutoCreated, isMandatory, + onParentVersion, isProtected); + this.defaultPrimaryType = defaultPrimaryType; + this.requiredPrimaryTypes = requiredPrimaryTypes; + this.allowsSameNameSiblings = allowsSameNameSiblings; + } + + //-------------------------------------------------------< QNodeDefinition > + /** + * {@inheritDoc} + */ + public QName getDefaultPrimaryType() { + return defaultPrimaryType; + } + + /** + * {@inheritDoc} + */ + public QName[] getRequiredPrimaryTypes() { + return requiredPrimaryTypes; + } + + /** + * {@inheritDoc} + */ + public boolean allowsSameNameSiblings() { + return allowsSameNameSiblings; + } + + /** + * {@inheritDoc} + * + * @return always true + */ + public boolean definesNode() { + return true; + } + + //-------------------------------------------< java.lang.Object overrides > + /** + * Compares two node definitions for equality. Returns true + * if the given object is a node defintion and has the same attributes + * as this node definition. + * + * @param obj the object to compare this node definition with + * @return true if the object is equal to this node definition, + * false otherwise + * @see Object#equals(Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof QNodeDefinition) { + QNodeDefinition other = (QNodeDefinition) obj; + return super.equals(obj) + && Arrays.equals(requiredPrimaryTypes, other.getRequiredPrimaryTypes()) + && (defaultPrimaryType == null + ? other.getDefaultPrimaryType() == null + : defaultPrimaryType.equals(other.getDefaultPrimaryType())) + && allowsSameNameSiblings == other.allowsSameNameSiblings(); + } + return false; + } + + /** + * Overwrites {@link QItemDefinitionImpl#hashCode()}. + * + * @return + */ + public int hashCode() { + if (hashCode == 0) { + // build hashCode (format: //) + StringBuffer sb = new StringBuffer(); + + if (getDeclaringNodeType() != null) { + sb.append(getDeclaringNodeType().toString()); + sb.append('/'); + } + if (definesResidual()) { + sb.append('*'); + } else { + sb.append(getQName().toString()); + } + sb.append('/'); + // set of required node type names, sorted in ascending order + TreeSet set = new TreeSet(); + QName[] names = getRequiredPrimaryTypes(); + for (int i = 0; i < names.length; i++) { + set.add(names[i]); + } + sb.append(set.toString()); + + hashCode = sb.toString().hashCode(); + } + return hashCode; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,258 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.QNodeTypeDefinition; +import org.apache.jackrabbit.spi.QPropertyDefinition; +import org.apache.jackrabbit.spi.QNodeDefinition; +import org.apache.jackrabbit.name.QName; + +import javax.jcr.PropertyType; +import java.util.Collection; +import java.util.HashSet; +import java.util.Collections; +import java.io.Serializable; + +/** + * QNodeTypeDefinitionImpl implements a serializable qualified node + * type definition. + */ +public class QNodeTypeDefinitionImpl implements QNodeTypeDefinition, Serializable { + + /** + * The name of the node definition. + */ + private final QName name; + + /** + * The names of the declared super types of this node type definition. + */ + private final QName[] supertypes; + + /** + * Indicates whether this is a mixin node type definition. + */ + private final boolean isMixin; + + /** + * Indicates whether this node type definition has orderable child nodes. + */ + private final boolean hasOrderableChildNodes; + + /** + * The name of the primary item or null if none is defined. + */ + private final QName primaryItemName; + + /** + * The list of property definitions. + */ + private final QPropertyDefinition[] propertyDefs; + + /** + * The list of child node definitions. + */ + private final QNodeDefinition[] childNodeDefs; + + /** + * Unmodifiable collection of dependent node type QNames. + * @see #getDependencies() + */ + private transient Collection dependencies; + + /** + * Copy constructor. + * + * @param nt the qualified node type definition. + */ + public QNodeTypeDefinitionImpl(QNodeTypeDefinition nt) { + this(nt.getQName(), nt.getSupertypes(), nt.isMixin(), + nt.hasOrderableChildNodes(), nt.getPrimaryItemName(), + nt.getPropertyDefs(), nt.getChildNodeDefs()); + } + + /** + * Creates a new serializable qualified node type definition. + * + * @param name the name of the node type + * @param supertypes the names of the supertypes + * @param isMixin if this is a mixin node type + * @param hasOrderableChildNodes if this node type has orderable child + * nodes. + * @param primaryItemName the name of the primary item, or + * null. + * @param declaredPropDefs the declared property definitions. + * @param declaredNodeDefs the declared child node definitions. + */ + public QNodeTypeDefinitionImpl(QName name, + QName[] supertypes, + boolean isMixin, + boolean hasOrderableChildNodes, + QName primaryItemName, + QPropertyDefinition[] declaredPropDefs, + QNodeDefinition[] declaredNodeDefs) { + this.name = name; + this.supertypes = supertypes; + this.isMixin = isMixin; + this.hasOrderableChildNodes = hasOrderableChildNodes; + this.primaryItemName = primaryItemName; + this.propertyDefs = getSerializablePropertyDefs(declaredPropDefs); + this.childNodeDefs = getSerializableNodeDefs(declaredNodeDefs); + } + + /** + * {@inheritDoc} + */ + public QName getQName() { + return name; + } + + /** + * {@inheritDoc} + */ + public QName[] getSupertypes() { + QName[] sTypes = new QName[supertypes.length]; + System.arraycopy(supertypes, 0, sTypes, 0, supertypes.length); + return sTypes; + } + + /** + * {@inheritDoc} + */ + public boolean isMixin() { + return isMixin; + } + + /** + * {@inheritDoc} + */ + public boolean hasOrderableChildNodes() { + return hasOrderableChildNodes; + } + + /** + * {@inheritDoc} + */ + public QName getPrimaryItemName() { + return primaryItemName; + } + + /** + * {@inheritDoc} + */ + public QPropertyDefinition[] getPropertyDefs() { + QPropertyDefinition[] pDefs = new QPropertyDefinition[propertyDefs.length]; + System.arraycopy(propertyDefs, 0, pDefs, 0, propertyDefs.length); + return pDefs; + } + + /** + * {@inheritDoc} + */ + public QNodeDefinition[] getChildNodeDefs() { + QNodeDefinition[] cnDefs = new QNodeDefinition[childNodeDefs.length]; + System.arraycopy(childNodeDefs, 0, cnDefs, 0, childNodeDefs.length); + return cnDefs; + } + + /** + * {@inheritDoc} + */ + public Collection getDependencies() { + if (dependencies == null) { + Collection deps = new HashSet(); + // supertypes + for (int i = 0; i < supertypes.length; i++) { + deps.add(supertypes[i]); + } + // child node definitions + for (int i = 0; i < childNodeDefs.length; i++) { + // default primary type + QName ntName = childNodeDefs[i].getDefaultPrimaryType(); + if (ntName != null && !name.equals(ntName)) { + deps.add(ntName); + } + // required primary type + QName[] ntNames = childNodeDefs[i].getRequiredPrimaryTypes(); + for (int j = 0; j < ntNames.length; j++) { + if (ntNames[j] != null && !name.equals(ntNames[j])) { + deps.add(ntNames[j]); + } + } + } + // property definitions + for (int i = 0; i < propertyDefs.length; i++) { + // REFERENCE value constraints + if (propertyDefs[i].getRequiredType() == PropertyType.REFERENCE) { + String[] ca = propertyDefs[i].getValueConstraints(); + if (ca != null) { + for (int j = 0; j < ca.length; j++) { + QName ntName = QName.valueOf(ca[j]); + if (!name.equals(ntName)) { + deps.add(ntName); + } + } + } + } + } + dependencies = Collections.unmodifiableCollection(deps); + } + return dependencies; + } + + //-------------------------------< internal >------------------------------- + + /** + * Returns an array of serializable property definitions for + * propDefs. + * + * @param propDefs the qualified property definitions. + * @return an array of serializable property definitions. + */ + private static QPropertyDefinition[] getSerializablePropertyDefs( + QPropertyDefinition[] propDefs) { + QPropertyDefinition[] serDefs = new QPropertyDefinition[propDefs.length]; + for (int i = 0; i < propDefs.length; i++) { + if (propDefs[i] instanceof Serializable) { + serDefs[i] = propDefs[i]; + } else { + serDefs[i] = new QPropertyDefinitionImpl(propDefs[i]); + } + } + return serDefs; + } + + /** + * Returns an array of serializable node definitions for + * nodeDefs. + * + * @param nodeDefs the qualified node definitions. + * @return an array of serializable node definitions. + */ + private static QNodeDefinition[] getSerializableNodeDefs( + QNodeDefinition[] nodeDefs) { + QNodeDefinition[] serDefs = new QNodeDefinition[nodeDefs.length]; + for (int i = 0; i < nodeDefs.length; i++) { + if (nodeDefs[i] instanceof Serializable) { + serDefs[i] = nodeDefs[i]; + } else { + serDefs[i] = new QNodeDefinitionImpl(nodeDefs[i]); + } + } + return serDefs; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?view=auto&rev=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (added) +++ jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java Thu Jul 5 06:52:13 2007 @@ -0,0 +1,190 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.spi.commons; + +import org.apache.jackrabbit.spi.QPropertyDefinition; +import org.apache.jackrabbit.spi.QValue; +import org.apache.jackrabbit.name.QName; + +import java.util.Arrays; + +/** + * QPropertyDefinitionImpl implements a qualified property + * definition. + */ +public class QPropertyDefinitionImpl + extends QItemDefinitionImpl + implements QPropertyDefinition { + + /** + * The required type. + */ + private final int requiredType; + + /** + * The value constraints. + */ + private final String[] valueConstraints; + + /** + * The default values. + */ + private final QValue[] defaultValues; + + /** + * The 'multiple' flag + */ + private final boolean multiple; + + /** + * Copy constructor. + * + * @param propDef some other property definition. + */ + public QPropertyDefinitionImpl(QPropertyDefinition propDef) { + this(propDef.getQName(), propDef.getDeclaringNodeType(), + propDef.isAutoCreated(), propDef.isMandatory(), + propDef.getOnParentVersion(), propDef.isProtected(), + propDef.getDefaultValues(), propDef.isMultiple(), + propDef.getRequiredType(), propDef.getValueConstraints()); + } + + /** + * Creates a new serializable qualified property definition. + * + * @param name the name of the child item. + * @param declaringNodeType the delaring node type + * @param isAutoCreated if this item is auto created. + * @param isMandatory if this is a mandatory item. + * @param onParentVersion the on parent version behaviour. + * @param isProtected if this item is protected. + * @param defaultValues the default values or null if there + * are none. + * @param isMultiple if this property is multi-valued. + * @param requiredType the required type for this property. + * @param valueConstraints the value constraints for this property. If none + * exist an empty array must be passed. + * @throws NullPointerException if valueConstraints is + * null. + */ + public QPropertyDefinitionImpl(QName name, QName declaringNodeType, + boolean isAutoCreated, boolean isMandatory, + int onParentVersion, boolean isProtected, + QValue[] defaultValues, boolean isMultiple, + int requiredType, String[] valueConstraints) { + super(name, declaringNodeType, isAutoCreated, isMandatory, + onParentVersion, isProtected); + if (valueConstraints == null) { + throw new NullPointerException("valueConstraints"); + } + this.defaultValues = defaultValues; + this.multiple = isMultiple; + this.requiredType = requiredType; + this.valueConstraints = valueConstraints; + } + + //------------------------------------------------< QPropertyDefinition >--- + /** + * {@inheritDoc} + */ + public int getRequiredType() { + return requiredType; + } + + /** + * {@inheritDoc} + */ + public String[] getValueConstraints() { + return valueConstraints; + } + + /** + * {@inheritDoc} + */ + public QValue[] getDefaultValues() { + return defaultValues; + } + + /** + * {@inheritDoc} + */ + public boolean isMultiple() { + return multiple; + } + + /** + * {@inheritDoc} + * + * @return always false + */ + public boolean definesNode() { + return false; + } + + //-------------------------------------------< java.lang.Object overrides > + /** + * Compares two property definitions for equality. Returns true + * if the given object is a property defintion and has the same attributes + * as this property definition. + * + * @param obj the object to compare this property definition with + * @return true if the object is equal to this property definition, + * false otherwise + * @see Object#equals(Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof QPropertyDefinition) { + QPropertyDefinition other = (QPropertyDefinition) obj; + return super.equals(obj) + && requiredType == other.getRequiredType() + && Arrays.equals(valueConstraints, other.getValueConstraints()) + && Arrays.equals(defaultValues, other.getDefaultValues()) + && multiple == other.isMultiple(); + } + return false; + } + + /** + * Overwrites {@link QItemDefinitionImpl#hashCode()}. + * + * @return + */ + public int hashCode() { + if (hashCode == 0) { + // build hashCode (format: ///) + StringBuffer sb = new StringBuffer(); + + sb.append(getDeclaringNodeType().toString()); + sb.append('/'); + if (definesResidual()) { + sb.append('*'); + } else { + sb.append(getQName().toString()); + } + sb.append('/'); + sb.append(getRequiredType()); + sb.append('/'); + sb.append(isMultiple() ? 1 : 0); + + hashCode = sb.toString().hashCode(); + } + return hashCode; + } +} Propchange: jackrabbit/trunk/contrib/spi/commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?view=diff&rev=553507&r1=553506&r2=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java Thu Jul 5 06:52:13 2007 @@ -37,11 +37,11 @@ import org.apache.jackrabbit.spi.rmi.remote.RemoteSessionInfo; import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator; import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo; -import org.apache.jackrabbit.spi.rmi.common.SerializableIdFactory; import org.apache.jackrabbit.spi.rmi.common.SerializableInputStream; import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.name.Path; import org.apache.jackrabbit.value.QValueFactoryImpl; +import org.apache.jackrabbit.identifier.IdFactoryImpl; import javax.jcr.RepositoryException; import javax.jcr.Credentials; @@ -84,7 +84,7 @@ /** * The id factory. */ - private final SerializableIdFactory idFactory = SerializableIdFactory.getInstance(); + private final IdFactory idFactory = IdFactoryImpl.getInstance(); /** * The QValue factory. Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=553507&r1=553506&r2=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java (original) +++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java Thu Jul 5 06:52:13 2007 @@ -21,18 +21,6 @@ import org.apache.jackrabbit.spi.rmi.remote.RemoteBatch; import org.apache.jackrabbit.spi.rmi.remote.RemoteQueryInfo; import org.apache.jackrabbit.spi.rmi.remote.RemoteIterator; -import org.apache.jackrabbit.spi.rmi.common.SerializableIdFactory; -import org.apache.jackrabbit.spi.rmi.common.QNodeDefinitionImpl; -import org.apache.jackrabbit.spi.rmi.common.QPropertyDefinitionImpl; -import org.apache.jackrabbit.spi.rmi.common.NodeInfoImpl; -import org.apache.jackrabbit.spi.rmi.common.PropertyInfoImpl; -import org.apache.jackrabbit.spi.rmi.common.LockInfoImpl; -import org.apache.jackrabbit.spi.rmi.common.QNodeTypeDefinitionImpl; -import org.apache.jackrabbit.spi.rmi.common.ChildInfoImpl; -import org.apache.jackrabbit.spi.rmi.common.IteratorHelper; -import org.apache.jackrabbit.spi.rmi.common.EventImpl; -import org.apache.jackrabbit.spi.rmi.common.EventBundleImpl; -import org.apache.jackrabbit.spi.rmi.common.EventFilterImpl; import org.apache.jackrabbit.spi.ItemId; import org.apache.jackrabbit.spi.RepositoryService; import org.apache.jackrabbit.spi.SessionInfo; @@ -48,10 +36,23 @@ import org.apache.jackrabbit.spi.QNodeTypeDefinition; import org.apache.jackrabbit.spi.QueryInfo; import org.apache.jackrabbit.spi.ChildInfo; -import org.apache.jackrabbit.spi.Event; import org.apache.jackrabbit.spi.ItemInfo; +import org.apache.jackrabbit.spi.Event; +import org.apache.jackrabbit.spi.IdFactory; +import org.apache.jackrabbit.spi.commons.EventFilterImpl; +import org.apache.jackrabbit.spi.commons.QPropertyDefinitionImpl; +import org.apache.jackrabbit.spi.commons.QNodeDefinitionImpl; +import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl; +import org.apache.jackrabbit.spi.commons.EventImpl; +import org.apache.jackrabbit.spi.commons.EventBundleImpl; +import org.apache.jackrabbit.spi.commons.ChildInfoImpl; +import org.apache.jackrabbit.spi.commons.NodeInfoImpl; +import org.apache.jackrabbit.spi.commons.PropertyInfoImpl; +import org.apache.jackrabbit.spi.commons.LockInfoImpl; import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.name.Path; +import org.apache.jackrabbit.identifier.IdFactoryImpl; +import org.apache.jackrabbit.util.IteratorHelper; import javax.jcr.Credentials; import javax.jcr.RepositoryException; @@ -89,7 +90,7 @@ /** * The id factory. */ - private final SerializableIdFactory idFactory = SerializableIdFactory.getInstance(); + private final IdFactory idFactory = IdFactoryImpl.getInstance(); /** * Maps remote stubs to {@link ServerSessionInfo}s. @@ -213,8 +214,8 @@ public NodeId getRootId(RemoteSessionInfo sessionInfo) throws RepositoryException, RemoteException { try { - return idFactory.createSerializableNodeId( - service.getRootId(getSessionInfo(sessionInfo))); + NodeId id = service.getRootId(getSessionInfo(sessionInfo)); + return idFactory.createNodeId(id.getUniqueID(), id.getPath()); } catch (RepositoryException e) { throw getRepositoryException(e); } @@ -472,10 +473,11 @@ if (lockInfo instanceof Serializable) { return lockInfo; } else { + NodeId id = lockInfo.getNodeId(); return new LockInfoImpl(lockInfo.getLockToken(), lockInfo.getOwner(), lockInfo.isDeep(), lockInfo.isSessionScoped(), - idFactory.createSerializableNodeId(lockInfo.getNodeId())); + idFactory.createNodeId(id.getUniqueID(), id.getPath())); } } catch (RepositoryException e) { throw getRepositoryException(e); @@ -495,10 +497,11 @@ if (lockInfo instanceof Serializable) { return lockInfo; } else { + NodeId id = lockInfo.getNodeId(); return new LockInfoImpl(lockInfo.getLockToken(), lockInfo.getOwner(), lockInfo.isDeep(), lockInfo.isSessionScoped(), - idFactory.createSerializableNodeId(lockInfo.getNodeId())); + idFactory.createNodeId(id.getUniqueID(), id.getPath())); } } catch (RepositoryException e) { throw getRepositoryException(e); @@ -740,14 +743,19 @@ for (Iterator it = bundles[i].getEvents(); it.hasNext(); ) { Event e = (Event) it.next(); ItemId id; + // make sure node ids are serializable + NodeId parentId = e.getParentId(); + parentId = idFactory.createNodeId( + parentId.getUniqueID(), parentId.getPath()); if (e.getItemId().denotesNode()) { - id = idFactory.createSerializableNodeId((NodeId) e.getItemId()); + NodeId nodeId = (NodeId) e.getItemId(); + id = idFactory.createNodeId(nodeId.getUniqueID(), nodeId.getPath()); } else { - id = idFactory.createSerializablePropertyId((PropertyId) e.getItemId()); + PropertyId propId = (PropertyId) e.getItemId(); + id = idFactory.createPropertyId(parentId, propId.getQName()); } Event serEvent = new EventImpl(e.getType(), - e.getQPath(), id, - idFactory.createSerializableNodeId(e.getParentId()), + e.getQPath(), id, parentId, e.getPrimaryNodeTypeName(), e.getMixinTypeNames(), e.getUserID()); events.add(serEvent); Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java?view=diff&rev=553507&r1=553506&r2=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java (original) +++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java Thu Jul 5 06:52:13 2007 @@ -20,65 +20,23 @@ import org.apache.jackrabbit.spi.ItemId; import org.apache.jackrabbit.name.Path; import org.apache.jackrabbit.spi.NodeId; -import org.apache.jackrabbit.name.QName; import org.apache.jackrabbit.webdav.xml.DomUtil; import org.apache.jackrabbit.webdav.observation.ObservationConstants; import org.w3c.dom.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * EventImpl... */ -public class EventImpl implements Event, ObservationConstants { - - private static Logger log = LoggerFactory.getLogger(EventImpl.class); - - private final ItemId eventId; - private final int type; - private final Path eventPath; - private final NodeId parentId; - - private final Element eventElement; +public class EventImpl + extends org.apache.jackrabbit.spi.commons.EventImpl + implements ObservationConstants { public EventImpl(ItemId eventId, Path eventPath, NodeId parentId, int eventType, Element eventElement) { - this.eventId = eventId; - this.eventPath = eventPath; - this.parentId = parentId; - type = getSpiEventType(eventType); - - this.eventElement = eventElement; - } - - public int getType() { - return type; - } - - public Path getQPath() { - return eventPath; - } - - public ItemId getItemId() { - return eventId; - } - - public NodeId getParentId() { - return parentId; - } - - public QName getPrimaryNodeTypeName() { - // TODO not available from XML_EVENT element - return null; - } - - public QName[] getMixinTypeNames() { - // TODO not available from XML_EVENT element - return new QName[0]; - } - - public String getUserID() { - return DomUtil.getChildTextTrim(eventElement, XML_EVENTUSERID, NAMESPACE); + super(getSpiEventType(eventType), eventPath, eventId, parentId, + null, // TODO not available from XML_EVENT element + null, // TODO not available from XML_EVENT element + DomUtil.getChildTextTrim(eventElement, XML_EVENTUSERID, NAMESPACE)); } //-------------------------------------------------------------------------- Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=553507&r1=553506&r2=553507 ============================================================================== --- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (original) +++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java Thu Jul 5 06:52:13 2007 @@ -130,6 +130,9 @@ import org.apache.jackrabbit.spi.QValue; import org.apache.jackrabbit.spi.QValueFactory; import org.apache.jackrabbit.spi.NodeInfo; +import org.apache.jackrabbit.spi.commons.EventFilterImpl; +import org.apache.jackrabbit.spi.commons.EventBundleImpl; +import org.apache.jackrabbit.spi.commons.ChildInfoImpl; import org.apache.jackrabbit.util.Text; import org.apache.jackrabbit.uuid.UUID; import org.apache.jackrabbit.value.ValueFormat; @@ -949,7 +952,7 @@ int index = getIndex(childProps); String uuid = getUniqueID(childProps); - ChildInfo childInfo = new ChildInfoImpl(qName, index, uuid); + ChildInfo childInfo = new ChildInfoImpl(qName, uuid, index); childEntries.add(childInfo); } // else: property -> ignore } // else: ignore the response related to the parent @@ -1589,7 +1592,10 @@ if (value != null) { isLocal = value.equals(sessionInfo.getLastBatchId()); } - bundles.add(new EventBundleImpl(buildEventList(bundleElement, sessionInfo), isLocal)); + bundles.add(new EventBundleImpl( + buildEventList(bundleElement, sessionInfo), + isLocal, + null)); // TODO: bundle id is missing } events = (EventBundle[]) bundles.toArray(new EventBundle[bundles.size()]); }