Search in sources :

Example 41 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-platform by pentaho.

the class JcrRepositoryFileUtils method getVersionSummaries.

public static Object getVersionSummaries(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final boolean includeAclOnlyChanges) throws RepositoryException {
    Node fileNode = session.getNodeByIdentifier(fileId.toString());
    VersionHistory versionHistory = session.getWorkspace().getVersionManager().getVersionHistory(fileNode.getPath());
    // get root version but don't include it in version summaries; from JSR-170 specification section 8.2.5:
    // [root version] is a dummy version that serves as the starting point of the version graph. Like all version
    // nodes,
    // it has a subnode called jcr:frozenNode. But, in this case that frozen node does not contain any state
    // information
    // about N
    Version version = versionHistory.getRootVersion();
    Version[] successors = version.getSuccessors();
    List<VersionSummary> versionSummaries = new ArrayList<VersionSummary>();
    while (successors != null && successors.length > 0) {
        // branching not supported
        version = successors[0];
        VersionSummary sum = toVersionSummary(pentahoJcrConstants, versionHistory, version);
        if (!sum.isAclOnlyChange() || (includeAclOnlyChanges && sum.isAclOnlyChange())) {
            versionSummaries.add(sum);
        }
        successors = version.getSuccessors();
    }
    return versionSummaries;
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary) VersionHistory(javax.jcr.version.VersionHistory)

Aggregations

VersionSummary (org.pentaho.platform.api.repository2.unified.VersionSummary)32 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)18 Matchers.anyString (org.mockito.Matchers.anyString)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)16 List (java.util.List)12 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)9 Date (java.util.Date)7 ITenant (org.pentaho.platform.api.mt.ITenant)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)5 Serializable (java.io.Serializable)4 KettleException (org.pentaho.di.core.exception.KettleException)4 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 SampleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.sample.SampleRepositoryFileData)4 Calendar (java.util.Calendar)3 Node (javax.jcr.Node)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)3 KettleFileException (org.pentaho.di.core.exception.KettleFileException)3