org.apache.jackrabbit.oak.jcr.version
Class VersionHistoryImpl

java.lang.Object
  extended by org.apache.jackrabbit.oak.jcr.session.NodeImpl<VersionHistoryDelegate>
      extended by org.apache.jackrabbit.oak.jcr.version.VersionHistoryImpl
All Implemented Interfaces:
javax.jcr.Item, javax.jcr.Node, javax.jcr.version.VersionHistory, org.apache.jackrabbit.api.JackrabbitNode

public class VersionHistoryImpl
extends NodeImpl<VersionHistoryDelegate>
implements javax.jcr.version.VersionHistory

VersionHistoryImpl...


Field Summary
protected  T dlg
           
static String ITEM_SAVE_DOES_SESSION_SAVE
           
static int MV_PROPERTY_WARN_THRESHOLD
           
static boolean SAVE_SESSION
          The value of this flag determines the behaviour of save().
protected  SessionContext sessionContext
           
protected  SessionDelegate sessionDelegate
           
 
Fields inherited from interface javax.jcr.Node
JCR_CHILD_NODE_DEFINITION, JCR_CONTENT, JCR_FROZEN_NODE, JCR_PROPERTY_DEFINITION, JCR_ROOT_VERSION, JCR_VERSION_LABELS
 
Constructor Summary
VersionHistoryImpl(VersionHistoryDelegate dlg, SessionContext sessionContext)
           
 
Method Summary
 void addVersionLabel(String versionName, String label, boolean moveLabel)
           
protected  org.apache.jackrabbit.oak.api.PropertyState createMultiState(String oakName, List<javax.jcr.Value> values, org.apache.jackrabbit.oak.api.Type<?> type)
           
protected  org.apache.jackrabbit.oak.api.PropertyState createSingleState(String oakName, javax.jcr.Value value, org.apache.jackrabbit.oak.api.Type<?> type)
           
 javax.jcr.NodeIterator getAllFrozenNodes()
           
 javax.jcr.NodeIterator getAllLinearFrozenNodes()
           
 javax.jcr.version.VersionIterator getAllLinearVersions()
           
 javax.jcr.version.VersionIterator getAllVersions()
           
 javax.jcr.Item getAncestor(int depth)
           
 int getDepth()
           
 String getName()
           
 String getPath()
           
 javax.jcr.version.Version getRootVersion()
           
 javax.jcr.Session getSession()
           
 javax.jcr.version.Version getVersion(String versionName)
           
 String getVersionableIdentifier()
           
 String getVersionableUUID()
           
 javax.jcr.version.Version getVersionByLabel(String label)
           
 String[] getVersionLabels()
           
 String[] getVersionLabels(javax.jcr.version.Version version)
           
 boolean hasVersionLabel(String label)
           
 boolean hasVersionLabel(javax.jcr.version.Version version, String label)
           
 boolean isSame(javax.jcr.Item otherItem)
           
protected
<U> U
perform(SessionOperation<U> op)
          Perform the passed SessionOperation.
 void refresh(boolean keepChanges)
           
 void removeVersion(String versionName)
           
 void removeVersionLabel(String label)
           
protected
<U> U
safePerform(SessionOperation<U> op)
          Perform the passed SessionOperation assuming it does not throw an RepositoryException.
 void save()
          This implementation delegates to Session.save() if SAVE_SESSION is true.
 String toString()
           
 
Methods inherited from class org.apache.jackrabbit.oak.jcr.session.NodeImpl
accept, addMixin, addNode, addNode, canAddMixin, cancelMerge, checkin, checkout, createNode, createNodeOrNull, doneMerge, followLifecycleTransition, getAllowedLifecycleTransistions, getBaseVersion, getCorrespondingNodePath, getDefinition, getIdentifier, getIndex, getLock, getMixinNodeTypes, getNode, getNodes, getNodes, getNodes, getParent, getPrimaryItem, getPrimaryNodeType, getProperties, getProperties, getProperties, getProperty, getReferences, getReferences, getSharedSet, getUUID, getVersionHistory, getWeakReferences, getWeakReferences, hasNode, hasNodes, hasProperties, hasProperty, holdsLock, isCheckedOut, isLocked, isModified, isNew, isNode, isNodeType, lock, merge, orderBefore, remove, removeMixin, removeShare, removeSharedSet, rename, restore, restore, restore, restoreByLabel, setMixins, setPrimaryType, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, unlock, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jcr.Node
addMixin, addNode, addNode, canAddMixin, cancelMerge, checkin, checkout, doneMerge, followLifecycleTransition, getAllowedLifecycleTransistions, getBaseVersion, getCorrespondingNodePath, getDefinition, getIdentifier, getIndex, getLock, getMixinNodeTypes, getNode, getNodes, getNodes, getNodes, getPrimaryItem, getPrimaryNodeType, getProperties, getProperties, getProperties, getProperty, getReferences, getReferences, getSharedSet, getUUID, getVersionHistory, getWeakReferences, getWeakReferences, hasNode, hasNodes, hasProperties, hasProperty, holdsLock, isCheckedOut, isLocked, isNodeType, lock, merge, orderBefore, removeMixin, removeShare, removeSharedSet, restore, restore, restore, restoreByLabel, setPrimaryType, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, unlock, update
 
Methods inherited from interface javax.jcr.Item
accept, getAncestor, getDepth, getName, getParent, getPath, getSession, isModified, isNew, isNode, isSame, refresh, remove, save
 

Field Detail

ITEM_SAVE_DOES_SESSION_SAVE

public static final String ITEM_SAVE_DOES_SESSION_SAVE
See Also:
Constant Field Values

MV_PROPERTY_WARN_THRESHOLD

public static final int MV_PROPERTY_WARN_THRESHOLD
See Also:
Constant Field Values

SAVE_SESSION

public static final boolean SAVE_SESSION
The value of this flag determines the behaviour of save(). If false, save will throw a UnsupportedRepositoryOperationException if the sub tree rooted at this item does not contain all transient changes. If true, save will delegate to Session.save().


sessionContext

protected final SessionContext sessionContext

dlg

protected final T extends ItemDelegate dlg

sessionDelegate

protected final SessionDelegate sessionDelegate
Constructor Detail

VersionHistoryImpl

public VersionHistoryImpl(VersionHistoryDelegate dlg,
                          SessionContext sessionContext)
Method Detail

getVersionableUUID

public String getVersionableUUID()
                          throws javax.jcr.RepositoryException
Specified by:
getVersionableUUID in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getVersionableIdentifier

public String getVersionableIdentifier()
                                throws javax.jcr.RepositoryException
Specified by:
getVersionableIdentifier in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getRootVersion

public javax.jcr.version.Version getRootVersion()
                                         throws javax.jcr.RepositoryException
Specified by:
getRootVersion in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getAllLinearVersions

public javax.jcr.version.VersionIterator getAllLinearVersions()
                                                       throws javax.jcr.RepositoryException
Specified by:
getAllLinearVersions in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getAllVersions

public javax.jcr.version.VersionIterator getAllVersions()
                                                 throws javax.jcr.RepositoryException
Specified by:
getAllVersions in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getAllLinearFrozenNodes

public javax.jcr.NodeIterator getAllLinearFrozenNodes()
                                               throws javax.jcr.RepositoryException
Specified by:
getAllLinearFrozenNodes in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getAllFrozenNodes

public javax.jcr.NodeIterator getAllFrozenNodes()
                                         throws javax.jcr.RepositoryException
Specified by:
getAllFrozenNodes in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getVersion

public javax.jcr.version.Version getVersion(String versionName)
                                     throws javax.jcr.version.VersionException,
                                            javax.jcr.RepositoryException
Specified by:
getVersion in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.VersionException
javax.jcr.RepositoryException

getVersionByLabel

public javax.jcr.version.Version getVersionByLabel(String label)
                                            throws javax.jcr.version.VersionException,
                                                   javax.jcr.RepositoryException
Specified by:
getVersionByLabel in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.VersionException
javax.jcr.RepositoryException

addVersionLabel

public void addVersionLabel(String versionName,
                            String label,
                            boolean moveLabel)
                     throws javax.jcr.version.LabelExistsVersionException,
                            javax.jcr.version.VersionException,
                            javax.jcr.RepositoryException
Specified by:
addVersionLabel in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.LabelExistsVersionException
javax.jcr.version.VersionException
javax.jcr.RepositoryException

removeVersionLabel

public void removeVersionLabel(String label)
                        throws javax.jcr.version.VersionException,
                               javax.jcr.RepositoryException
Specified by:
removeVersionLabel in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.VersionException
javax.jcr.RepositoryException

hasVersionLabel

public boolean hasVersionLabel(String label)
                        throws javax.jcr.RepositoryException
Specified by:
hasVersionLabel in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

hasVersionLabel

public boolean hasVersionLabel(javax.jcr.version.Version version,
                               String label)
                        throws javax.jcr.version.VersionException,
                               javax.jcr.RepositoryException
Specified by:
hasVersionLabel in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.VersionException
javax.jcr.RepositoryException

getVersionLabels

public String[] getVersionLabels()
                          throws javax.jcr.RepositoryException
Specified by:
getVersionLabels in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.RepositoryException

getVersionLabels

public String[] getVersionLabels(javax.jcr.version.Version version)
                          throws javax.jcr.version.VersionException,
                                 javax.jcr.RepositoryException
Specified by:
getVersionLabels in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.version.VersionException
javax.jcr.RepositoryException

removeVersion

public void removeVersion(String versionName)
                   throws javax.jcr.ReferentialIntegrityException,
                          javax.jcr.AccessDeniedException,
                          javax.jcr.UnsupportedRepositoryOperationException,
                          javax.jcr.version.VersionException,
                          javax.jcr.RepositoryException
Specified by:
removeVersion in interface javax.jcr.version.VersionHistory
Throws:
javax.jcr.ReferentialIntegrityException
javax.jcr.AccessDeniedException
javax.jcr.UnsupportedRepositoryOperationException
javax.jcr.version.VersionException
javax.jcr.RepositoryException

perform

@CheckForNull
protected final <U> U perform(@Nonnull
                                           SessionOperation<U> op)
                   throws javax.jcr.RepositoryException
Perform the passed SessionOperation.

Type Parameters:
U - return type of the operation
Parameters:
op - operation to perform
Returns:
the result of op.perform()
Throws:
javax.jcr.RepositoryException - as thrown by op.perform().

safePerform

@CheckForNull
protected final <U> U safePerform(@Nonnull
                                               SessionOperation<U> op)
Perform the passed SessionOperation assuming it does not throw an RepositoryException. If it does, wrap it into and throw it as a RuntimeException.

Type Parameters:
U - return type of the operation
Parameters:
op - operation to perform
Returns:
the result of op.perform()

getName

@Nonnull
public String getName()
               throws javax.jcr.RepositoryException
Specified by:
getName in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException
See Also:
Item.getName()

getPath

@Nonnull
public String getPath()
               throws javax.jcr.RepositoryException
Specified by:
getPath in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException
See Also:
Item.getPath()

getSession

@Nonnull
public javax.jcr.Session getSession()
Specified by:
getSession in interface javax.jcr.Item

getAncestor

public javax.jcr.Item getAncestor(int depth)
                           throws javax.jcr.RepositoryException
Specified by:
getAncestor in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

getDepth

public int getDepth()
             throws javax.jcr.RepositoryException
Specified by:
getDepth in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException

isSame

public boolean isSame(javax.jcr.Item otherItem)
               throws javax.jcr.RepositoryException
Specified by:
isSame in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException
See Also:
Item.isSame(javax.jcr.Item)

save

public void save()
          throws javax.jcr.RepositoryException
This implementation delegates to Session.save() if SAVE_SESSION is true. Otherwise it only performs the save if the subtree rooted at this item contains all transient changes. That is, if calling Session.save() would have the same effect as calling this method. In all other cases this method will throw an UnsupportedRepositoryOperationException

Specified by:
save in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException
See Also:
Item.save()

refresh

public void refresh(boolean keepChanges)
             throws javax.jcr.RepositoryException
Specified by:
refresh in interface javax.jcr.Item
Throws:
javax.jcr.RepositoryException
See Also:
Item.refresh(boolean)

toString

public String toString()
Overrides:
toString in class Object

createSingleState

protected org.apache.jackrabbit.oak.api.PropertyState createSingleState(String oakName,
                                                                        javax.jcr.Value value,
                                                                        org.apache.jackrabbit.oak.api.Type<?> type)
                                                                 throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException

createMultiState

protected org.apache.jackrabbit.oak.api.PropertyState createMultiState(String oakName,
                                                                       List<javax.jcr.Value> values,
                                                                       org.apache.jackrabbit.oak.api.Type<?> type)
                                                                throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.