/** * Read the configuration for the ChangeLog system * * @param changeLogBean The Bean containing the ChangeLog configuration * @return The instantiated ChangeLog element */ public static ChangeLog createChangeLog( ChangeLogBean changeLogBean ) { if ( ( changeLogBean == null ) || changeLogBean.isDisabled() ) { return null; } ChangeLog changeLog = new DefaultChangeLog(); changeLog.setEnabled( changeLogBean.isEnabled() ); changeLog.setExposed( changeLogBean.isChangeLogExposed() ); return changeLog; }
public long revert() throws LdapException { if ( changeLog == null || !changeLog.isEnabled() ) { throw new IllegalStateException( I18n.err( I18n.ERR_310 ) ); } Tag latest = changeLog.getLatest(); if ( null != latest ) { if ( latest.getRevision() < changeLog.getCurrentRevision() ) { return revert( latest.getRevision() ); } else { LOG.info( "Ignoring request to revert without changes since the latest tag." ); return changeLog.getCurrentRevision(); } } throw new IllegalStateException( I18n.err( I18n.ERR_311 ) ); }
private long getCurrentRevision( DirectoryService dirService ) throws Exception { if ( ( dirService != null ) && ( dirService.getChangeLog().isEnabled() ) ) { long revision = dirService.getChangeLog().getCurrentRevision(); LOG.debug( "Create revision {}", revision ); return revision; } return 0; }
directoryService.getChangeLog().setEnabled( true );
if ( changeLog.isEnabled() ) changeLog.init( this ); if ( changeLog.isExposed() && changeLog.isTagSearchSupported() ) String clSuffix = ( ( TaggableSearchableChangeLogStore ) changeLog.getChangeLogStore() ).getPartition() .getSuffixDn().getName(); partitionNexus.getRootDse( null ).add( SchemaConstants.CHANGELOG_CONTEXT_AT, clSuffix );
public long revert( long revision ) throws LdapException if ( changeLog == null || !changeLog.isEnabled() ) if ( revision >= changeLog.getChangeLogStore().getCurrentRevision() ) Cursor<ChangeLogEvent> cursor = changeLog.getChangeLogStore().findAfter( revision ); return changeLog.getCurrentRevision();
@Override public void evaluate() throws Throwable { Tag tag = directoryService.getChangeLog().tag(); DSAnnotationProcessor.applyLdifs( description, directoryService ); LOG.debug( "Tagged change log: {}", tag ); try { base.evaluate(); } finally { if ( directoryService.getChangeLog().getCurrentRevision() > tag.getRevision() ) { LOG.debug( "Reverting to tag: {}", tag ); directoryService.revert( tag.getRevision() ); } else { LOG.debug( "No changes made, nothing to revert" ); } } } };
if ( directoryService != null && directoryService.getChangeLog().isEnabled() )
ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor());
/** * {@inheritDoc} */ @Override public void move( MoveOperationContext moveContext ) throws LdapException { next( moveContext ); if ( !changeLog.isEnabled() ) { return; } LdifEntry forward = new LdifEntry(); forward.setChangeType( ChangeType.ModDn ); forward.setDn( moveContext.getDn() ); forward.setNewSuperior( moveContext.getNewSuperior().getName() ); LdifEntry reverse = LdifRevertor.reverseMove( moveContext.getNewSuperior(), moveContext.getDn() ); moveContext.setChangeLogEvent( changeLog.log( getPrincipal( moveContext ), forward, reverse ) ); }
private void revert( DirectoryService dirService, long revision ) throws Exception { if ( dirService == null ) { return; } ChangeLog cl = dirService.getChangeLog(); if ( cl.isEnabled() && ( revision < cl.getCurrentRevision() ) ) { LOG.debug( "Revert revision {}", revision ); dirService.revert( revision ); } }
ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor());
ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor());
ds.setSystemPartition(systemPartition); ds.getChangeLog().setEnabled(false); ds.setDenormalizeOpAttrsEnabled(true); ds.addLast(new KeyDerivationInterceptor());
/** * {@inheritDoc} */ @Override public void add( AddOperationContext addContext ) throws LdapException { next( addContext ); if ( !changeLog.isEnabled() ) { return; } Entry addEntry = addContext.getEntry(); // we don't want to record addition of a tag as a change if ( addEntry.get( REV_AT_OID ) != null ) { return; } LdifEntry forward = new LdifEntry(); forward.setChangeType( ChangeType.Add ); forward.setDn( addContext.getDn() ); for ( Attribute attribute : addEntry.getAttributes() ) { AttributeType attributeType = attribute.getAttributeType(); forward.addAttribute( addEntry.get( attributeType ).clone() ); } LdifEntry reverse = LdifRevertor.reverseAdd( addContext.getDn() ); addContext.setChangeLogEvent( changeLog.log( getPrincipal( addContext ), forward, reverse ) ); }
private ApacheDS startDirectoryService(String workDirStr) throws Exception { DefaultDirectoryServiceFactory factory = new DefaultDirectoryServiceFactory(); factory.init(realm); directoryService = factory.getDirectoryService(); directoryService.getChangeLog().setEnabled(false); directoryService.setShutdownHookEnabled(false); directoryService.setAllowAnonymousAccess(true); File workDir = new File(workDirStr); if (workDir.exists()) { FileUtils.deleteDirectory(workDir); } InstanceLayout instanceLayout = new InstanceLayout(workDir); directoryService.setInstanceLayout(instanceLayout); AvlPartition partition = new AvlPartition(directoryService.getSchemaManager()); partition.setId("Test"); partition.setSuffixDn(new Dn(directoryService.getSchemaManager(), baseDn)); partition.addIndexedAttributes( new AvlIndex<>("ou"), new AvlIndex<>("uid"), new AvlIndex<>("dc"), new AvlIndex<>("objectClass")); partition.initialize(); directoryService.addPartition(partition); directoryService.addLast(new KeyDerivationInterceptor()); directoryService.shutdown(); directoryService.startup(); return this; }