Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 66104 invoked from network); 2 Oct 2006 10:13:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Oct 2006 10:13:11 -0000 Received: (qmail 86718 invoked by uid 500); 2 Oct 2006 10:13:11 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 86631 invoked by uid 500); 2 Oct 2006 10:13:11 -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 86622 invoked by uid 99); 2 Oct 2006 10:13:11 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Oct 2006 03:13:11 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received: from [140.211.166.113] ([140.211.166.113:61831] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id BB/94-16499-636E0254 for ; Mon, 02 Oct 2006 03:13:10 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2230B1A981A; Mon, 2 Oct 2006 03:13:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r451945 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Date: Mon, 02 Oct 2006 10:13:07 -0000 To: commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061002101308.2230B1A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: angela Date: Mon Oct 2 03:13:05 2006 New Revision: 451945 URL: http://svn.apache.org/viewvc?view=rev&rev=451945 Log: work in progress - cleanup todos (remove methods marked from deletion) - reorder methods - remove public access modf. from methods used by sessionISM only. Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?view=diff&rev=451945&r1=451944&r2=451945 ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java Mon Oct 2 03:13:05 2006 @@ -22,7 +22,6 @@ import org.apache.jackrabbit.spi.IdFactory; import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.spi.QPropertyDefinition; -import org.apache.commons.collections.iterators.IteratorChain; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @@ -73,76 +72,15 @@ ((TransientISFactory) getTransientFactory()).setListener(this); } - //-----------------------< ItemStateManager >------------------------------- - /** - * Return the root node state. - * - * @return the root node state. - * @throws ItemStateException if an error occurs while retrieving the root - * node state. - * @see ItemStateManager#getRootState() - */ - public NodeState getRootState() throws ItemStateException { - if (rootNodeState == null) { - rootNodeState = getItemStateFactory().createRootState(this); - rootNodeState.addListener(this); - } - return rootNodeState; - } - - /** - * Return an item state given its id. Please note that this implementation - * also returns item states that are in removed state ({@link - * ItemState.STATUS_EXISTING_REMOVED} but not yet saved. - * - * @return item state. - * @throws NoSuchItemStateException if there is no item state (not even a - * removed item state) with the given id. - * @see ItemStateManager#getItemState(ItemId) - */ - public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException { - return super.getItemState(id); - } - - /** - * Return a flag indicating whether a given item state exists. - * - * @return true if item state exists within this item state - * manager; false otherwise - * @see ItemStateManager#hasItemState(ItemId) - */ - public boolean hasItemState(ItemId id) { - return super.hasItemState(id); - } - - /** - * Always throws an {@link UnsupportedOperationException}. A transient item - * state manager cannot not maintain node references. - * - * @param nodeState - * @throws UnsupportedOperationException - * @see ItemStateManager#getReferingStates(NodeState) - */ - public Collection getReferingStates(NodeState nodeState) { - throw new UnsupportedOperationException("getNodeReferences() not implemented"); - } - /** - * Always throws an {@link UnsupportedOperationException}. A transient item - * state manager cannot not maintain node references. - * - * @param nodeState - * @throws UnsupportedOperationException - * @see ItemStateManager#hasReferingStates(NodeState) - */ - public boolean hasReferingStates(NodeState nodeState) { - throw new UnsupportedOperationException("hasNodeReferences() not implemented"); + private TransientItemStateFactory getTransientFactory() { + return (TransientItemStateFactory) getItemStateFactory(); } /** * @return the operations that have been recorded until now. */ - public Iterator getOperations() { + Iterator getOperations() { return changeLog.getOperations(); } @@ -168,35 +106,11 @@ /** * @return true if this transient ISM has pending changes. */ - public boolean hasPendingChanges() { + boolean hasPendingChanges() { return !changeLog.isEmpty(); } /** - * @return true if there are any deleted item states. - */ - public boolean hasDeletedItemStates() { - return !changeLog.deletedStates.isEmpty(); - } - - /** - * @return an iterator over all modified or added item states. - */ - public Iterator getModifiedOrAddedItemStates() { - IteratorChain it = new IteratorChain(); - it.addIterator(changeLog.modifiedStates()); - it.addIterator(changeLog.addedStates()); - return it; - } - - /** - * @return an iterator over all deleted item states. - */ - public Iterator getDeletedItemStates() { - return changeLog.deletedStates(); - } - - /** * TODO: throw ItemExistsException? how to check? * Creates a new transient {@link NodeState} that does not overlay any other * {@link NodeState}. @@ -245,7 +159,7 @@ * Disposes this transient item state manager. Clears all references to * transiently modified item states. */ - public void dispose() { + void dispose() { changeLog.reset(); } @@ -254,45 +168,80 @@ * * @param operations the operations. */ - public void disposeOperations(Iterator operations) { + void disposeOperations(Iterator operations) { while (operations.hasNext()) { changeLog.removeOperation((Operation) operations.next()); } } + //---------------------------------------------------< ItemStateManager >--- /** - * TODO: remove this method when not used anymore - * Return an iterator over all added states. + * Return the root node state. * - * @return iterator over all added states. + * @return the root node state. + * @throws ItemStateException if an error occurs while retrieving the root + * node state. + * @see ItemStateManager#getRootState() */ - public Iterator addedStates() { - return changeLog.addedStates(); + public NodeState getRootState() throws ItemStateException { + if (rootNodeState == null) { + rootNodeState = getItemStateFactory().createRootState(this); + rootNodeState.addListener(this); + } + return rootNodeState; } /** - * TODO: remove this method when not used anymore - * Return an iterator over all modified states. + * Return an item state given its id. Please note that this implementation + * also returns item states that are in removed state ({@link + * ItemState.STATUS_EXISTING_REMOVED} but not yet saved. * - * @return iterator over all modified states. + * @return item state. + * @throws NoSuchItemStateException if there is no item state (not even a + * removed item state) with the given id. + * @see ItemStateManager#getItemState(ItemId) */ - public Iterator modifiedStates() { - return changeLog.modifiedStates(); + public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException { + return super.getItemState(id); } /** - * TODO: remove this method when not used anymore - * Return an iterator over all deleted states. + * Return a flag indicating whether a given item state exists. * - * @return iterator over all deleted states. + * @return true if item state exists within this item state + * manager; false otherwise + * @see ItemStateManager#hasItemState(ItemId) */ - public Iterator deletedStates() { - return changeLog.deletedStates(); + public boolean hasItemState(ItemId id) { + return super.hasItemState(id); } - //-----------------------< ItemStateLifeCycleListener >--------------------- + /** + * Always throws an {@link UnsupportedOperationException}. A transient item + * state manager cannot not maintain node references. + * + * @param nodeState + * @throws UnsupportedOperationException + * @see ItemStateManager#getReferingStates(NodeState) + */ + public Collection getReferingStates(NodeState nodeState) { + throw new UnsupportedOperationException("getNodeReferences() not implemented"); + } /** + * Always throws an {@link UnsupportedOperationException}. A transient item + * state manager cannot not maintain node references. + * + * @param nodeState + * @throws UnsupportedOperationException + * @see ItemStateManager#hasReferingStates(NodeState) + */ + public boolean hasReferingStates(NodeState nodeState) { + throw new UnsupportedOperationException("hasNodeReferences() not implemented"); + } + + //-----------------------------------------< ItemStateLifeCycleListener >--- + /** * @inheritDoc * @see ItemStateListener#stateCreated(ItemState) */ @@ -326,26 +275,31 @@ // go into the modified set of the change log, etc. switch (state.getStatus()) { case ItemState.STATUS_EXISTING: - if (previousStatus == ItemState.STATUS_EXISTING_MODIFIED) { - // was modified and is now refreshed - changeLog.modifiedStates.remove(state); - } else if (previousStatus == ItemState.STATUS_EXISTING_REMOVED) { - // was removed and is now refreshed - changeLog.deletedStates.remove(state); - } else if (previousStatus == ItemState.STATUS_STALE_MODIFIED) { - // was modified and state and is now refreshed - changeLog.modifiedStates.remove(state); - } else if (previousStatus == ItemState.STATUS_NEW) { - // was new and has been saved now - changeLog.addedStates.remove(state); - // state needs to be connected to the overlayed-state now - try { - ItemState overlayedState = parent.getItemState(state.getId()); - state.connect(overlayedState); - } catch (ItemStateException e) { - // TODO, handle property - log.error(e.getMessage()); - } + switch (previousStatus) { + case ItemState.STATUS_EXISTING_MODIFIED: + // was modified and is now refreshed + changeLog.modifiedStates.remove(state); + break; + case ItemState.STATUS_EXISTING_REMOVED: + // was removed and is now refreshed + changeLog.deletedStates.remove(state); + break; + case ItemState.STATUS_STALE_MODIFIED: + // was modified and state and is now refreshed + changeLog.modifiedStates.remove(state); + break; + case ItemState.STATUS_NEW: + // was new and has been saved now + changeLog.addedStates.remove(state); + // state needs to be connected to the overlayed-state now + try { + ItemState overlayedState = parent.getItemState(state.getId()); + state.connect(overlayedState); + } catch (ItemStateException e) { + // TODO, handle property + log.error(e.getMessage()); + } + break; } break; case ItemState.STATUS_EXISTING_MODIFIED: @@ -381,9 +335,5 @@ default: log.warn("ItemState has invalid status: " + state.getStatus()); } - } - - private TransientItemStateFactory getTransientFactory() { - return (TransientItemStateFactory) getItemStateFactory(); } }