/** * @return Wrapped {@link VersionSummary} with a {@link ObjectRevision}. */ protected ObjectRevision createObjectRevision( final VersionSummary versionSummary ) { return new PurObjectRevision( versionSummary.getId(), versionSummary.getAuthor(), versionSummary.getDate(), versionSummary.getMessage() ); }
@Override public void deleteVersionsBeforeDate( Serializable fileId, Date beforeDate ) { List<VersionSummary> versionList = unifiedRepository.getVersionSummaries( fileId ); int listSize = versionList.size(); int removedCount = 0; for ( VersionSummary versionSummary : versionList ) { if ( listSize - removedCount <= 1 ) { break; // Don't delete the last instance of this file. } if ( versionSummary.getDate().before( beforeDate ) ) { Serializable versionId = versionSummary.getId(); getLogger().debug( "removing version " + versionId.toString() ); unifiedRepository.deleteFileAtVersion( fileId, versionId ); removedCount++; } } }
@Override public VersionSummaryDto marshal( final VersionSummary v ) { VersionSummaryDto s = new VersionSummaryDto(); s.setId( v.getId().toString() ); s.setAuthor( v.getAuthor() ); s.setDate( v.getDate() ); s.setMessage( v.getMessage() ); s.setVersionedFileId( v.getVersionedFileId().toString() ); s.setLabels( v.getLabels() ); s.setAclOnlyChange( v.isAclOnlyChange() ); return s; }
public VersionSummary getVersionSummary( Serializable fileId, Serializable versionId ) { RepositoryFile file = getFile( fileId, versionId ); List<String> labels = new ArrayList<String>(); return new VersionSummary( fileId, ( versionId != null ? versionId : fileId ), false, file.getCreatedDate(), file.getCreatorId(), StringUtils.EMPTY, labels ); }
@Override public void keepNumberOfVersions( Serializable fileId, int versionCount ) { List<VersionSummary> versionList = unifiedRepository.getVersionSummaries( fileId ); int i = 0; int listSize = versionList.size(); if ( listSize > versionCount ) { getLogger().info( "version count: removing versions" ); } for ( VersionSummary versionSummary : versionList ) { if ( i < listSize - versionCount ) { Serializable versionId = versionSummary.getId(); getLogger().debug( "removing version " + versionId.toString() ); unifiedRepository.deleteFileAtVersion( fileId, versionId ); i++; } else { break; } } }
public VersionSummary( final Serializable id, final Serializable versionedFileId, final boolean aclOnlyChange, final Date date, final String author, final String message, final List<String> labels ) { super(); notNull( id ); notNull( versionedFileId ); notNull( date ); hasText( author ); notNull( labels ); this.id = id; this.versionedFileId = versionedFileId; this.date = new Date( date.getTime() ); this.author = author; this.message = message; this.labels = Collections.unmodifiableList( labels ); this.aclOnlyChange = aclOnlyChange; }
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 ) { version = successors[0]; // branching not supported VersionSummary sum = toVersionSummary( pentahoJcrConstants, versionHistory, version ); if ( !sum.isAclOnlyChange() || ( includeAclOnlyChanges && sum.isAclOnlyChange() ) ) { versionSummaries.add( sum ); } successors = version.getSuccessors(); } return versionSummaries; }
private static VersionSummary toVersionSummary( final PentahoJcrConstants pentahoJcrConstants, final VersionHistory versionHistory, final Version version ) throws RepositoryException { List<String> labels = Arrays.asList( versionHistory.getVersionLabels( version ) ); // get custom Hitachi Vantara properties (i.e. author and message) Node nodeAtVersion = getNodeAtVersion( pentahoJcrConstants, version ); String author = "BASE_VERSION"; if ( nodeAtVersion.hasProperty( pentahoJcrConstants.getPHO_VERSIONAUTHOR() ) ) { author = nodeAtVersion.getProperty( pentahoJcrConstants.getPHO_VERSIONAUTHOR() ).getString(); } String message = null; if ( nodeAtVersion.hasProperty( pentahoJcrConstants.getPHO_VERSIONMESSAGE() ) ) { message = nodeAtVersion.getProperty( pentahoJcrConstants.getPHO_VERSIONMESSAGE() ).getString(); } boolean aclOnlyChange = false; if ( nodeAtVersion.hasProperty( pentahoJcrConstants.getPHO_ACLONLYCHANGE() ) && nodeAtVersion.getProperty( pentahoJcrConstants.getPHO_ACLONLYCHANGE() ).getBoolean() ) { aclOnlyChange = true; } return new VersionSummary( version.getName(), versionHistory.getVersionableIdentifier(), aclOnlyChange, version .getCreated().getTime(), author, message, labels ); }
String versionId = (String) versionSummary.getId(); session.getWorkspace().getVersionManager().getVersionHistory( versionableNode.getPath() ).removeVersion( versionId );
@Override public List<ObjectRevision> getRevisions( ObjectId fileId ) throws KettleException { String absPath = null; try { List<ObjectRevision> versions = new ArrayList<ObjectRevision>(); List<VersionSummary> versionSummaries = unifiedRepository.getVersionSummaries( fileId.getId() ); for ( VersionSummary versionSummary : versionSummaries ) { versions.add( new PurObjectRevision( versionSummary.getId(), versionSummary.getAuthor(), versionSummary .getDate(), versionSummary.getMessage() ) ); } return versions; } catch ( Exception e ) { throw new KettleException( "Could not retrieve version history of object with path [" + absPath + "]", e ); } }
@Override public List<VersionSummary> getVersionSummaries( final Serializable fileId ) { List<VersionSummary> sums = new ArrayList<VersionSummary>(); List<FrozenFileRecord> records = versionManager.getVersions( fileId ); for ( FrozenFileRecord record : records ) { sums.add( new VersionSummary( record.getVersionId(), record.getFile().getId(), false, record.getDate(), record .getAuthor(), record.getVersionMessage(), new ArrayList<String>( 0 ) ) ); } return sums; }
@Override public VersionSummary unmarshal( final VersionSummaryDto v ) { return new VersionSummary( v.getId(), v.getVersionedFileId(), v.isAclOnlyChange(), v.getDate(), v.getAuthor(), v.getMessage(), v.getLabels() ); }
@Override public VersionSummary getVersionSummary( final Serializable fileId, final Serializable versionId ) { FrozenFileRecord r = null; if ( versionId == null ) { r = versionManager.getLatestVersion( fileId ); } else { r = versionManager.getFileAtVersion( fileId, versionId ); } return new VersionSummary( r.getVersionId(), r.getFile().getId(), false, r.getDate(), r.getAuthor(), r .getVersionMessage(), new ArrayList<String>( 0 ) ); }