info.magnolia.jcr.util
Class VersionUtil

java.lang.Object
  extended by info.magnolia.jcr.util.VersionUtil

public class VersionUtil
extends Object

Various utility methods useful for JCR-Versioning.


Constructor Summary
VersionUtil()
           
 
Method Summary
static javax.jcr.version.Version getLatestVersion(javax.jcr.Node node)
           
static javax.jcr.version.Version getNextVersion(javax.jcr.version.Version version)
           
static String getNextVersionLabel(javax.jcr.Node node, String versionLabel)
           
static String getNodeTypeName(javax.jcr.Node node)
          Return the NodeType-name for the provided Node.
static javax.jcr.version.Version getPreviousVersion(javax.jcr.version.Version version)
           
static String getPreviousVersionLabel(javax.jcr.Node node, String versionLabel)
           
static javax.jcr.version.Version getVersion(javax.jcr.Node node, String versionLabel)
          Returns the version object of a labelled version.
static List<VersionInfo> getVersionInfoList(javax.jcr.Node node)
          Returns version history of a content as a List of VersionInfos.
static boolean hasPreviousVersion(javax.jcr.Node node, String versionLabel)
          Checks if a version label of a Node has a previous version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionUtil

public VersionUtil()
Method Detail

getNodeTypeName

public static String getNodeTypeName(javax.jcr.Node node)
                              throws javax.jcr.RepositoryException
Return the NodeType-name for the provided Node. It it's a JCPropertiesFilteringNodeWrapper the unwrapped node will be used for retrieving the property from. As it's about versioning, the frozen primary type if existing (else primary type) will be returned.

Throws:
javax.jcr.RepositoryException

getVersionInfoList

public static List<VersionInfo> getVersionInfoList(javax.jcr.Node node)
Returns version history of a content as a List of VersionInfos.

Parameters:
node - Node
Returns:
list of version info
See Also:
VersionInfo

getVersion

public static javax.jcr.version.Version getVersion(javax.jcr.Node node,
                                                   String versionLabel)
                                            throws javax.jcr.RepositoryException
Returns the version object of a labelled version.

Returns:
version object or null if the requested version doesn't exist.
Throws:
javax.jcr.RepositoryException

getPreviousVersionLabel

public static String getPreviousVersionLabel(javax.jcr.Node node,
                                             String versionLabel)
                                      throws javax.jcr.RepositoryException
Returns:
the label of the first predecessor version or null if no previous version exists.
Throws:
javax.jcr.RepositoryException

hasPreviousVersion

public static boolean hasPreviousVersion(javax.jcr.Node node,
                                         String versionLabel)
Checks if a version label of a Node has a previous version.


getLatestVersion

public static javax.jcr.version.Version getLatestVersion(javax.jcr.Node node)
                                                  throws javax.jcr.RepositoryException
Returns:
Latest version or null if not found.
Throws:
javax.jcr.RepositoryException

getPreviousVersion

public static javax.jcr.version.Version getPreviousVersion(javax.jcr.version.Version version)
                                                    throws javax.jcr.RepositoryException
Returns:
the first predecessor or null if no previous version exists.
Throws:
javax.jcr.RepositoryException

getNextVersionLabel

public static String getNextVersionLabel(javax.jcr.Node node,
                                         String versionLabel)
                                  throws javax.jcr.RepositoryException
Returns:
the label of the next successor version or null if no next version exists.
Throws:
javax.jcr.RepositoryException

getNextVersion

public static javax.jcr.version.Version getNextVersion(javax.jcr.version.Version version)
                                                throws javax.jcr.RepositoryException
Returns:
the first successor or null if no next version exists.
Throws:
javax.jcr.RepositoryException


Copyright © 2003-2014 Magnolia International Ltd.. All Rights Reserved.