org.apache.directory.api.ldap.model.entry.DefaultModification Java Examples
The following examples show how to use
org.apache.directory.api.ldap.model.entry.DefaultModification.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LdapDataProvider.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * Given a collection of {@link java.util.Properties}, convert to raw data name-value format and load into ldap * modification set in preparation for ldap modify. * * @param props contains {@link java.util.Properties} targeted for removal from ldap. * @param mods ldap modification set containing name-value pairs in raw ldap format to be removed. * @param attrName contains the name of the ldap attribute to be removed. */ protected void removeProperties( Properties props, List<Modification> mods, String attrName ) { if ( props != null && props.size() > 0 ) { for ( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) { String key = ( String ) e.nextElement(); String val = props.getProperty( key ); // This LDAP attr is stored as a name-value pair separated by a ':'. mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrName, key + GlobalIds.PROP_SEP + val ) ); } } }
Example #2
Source File: ModificationTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testCreateServerModification() throws LdapException { Attribute attribute = new DefaultAttribute( "cn" ); attribute.add( "test1", "test2" ); Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute ); Modification clone = mod.clone(); attribute.remove( "test2" ); Attribute clonedAttribute = clone.getAttribute(); assertEquals( 1, mod.getAttribute().size() ); assertTrue( mod.getAttribute().contains( "test1" ) ); assertEquals( 2, clonedAttribute.size() ); assertTrue( clone.getAttribute().contains( "test1" ) ); assertTrue( clone.getAttribute().contains( "test2" ) ); }
Example #3
Source File: GroupDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * @param entity * @param userDn * @return * @throws org.apache.directory.fortress.core.UpdateException * */ Group assign( Group entity, String userDn ) throws FinderException, UpdateException { LdapConnection ld = null; String dn = getDn( entity.getName(), entity.getContextId() ); LOG.debug( "assign group property dn [{}], member dn [{}]", dn, userDn ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, SchemaConstants.MEMBER_AT, userDn ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "assign group name [" + entity.getName() + "] user dn [" + userDn + "] caught " + "LDAPException=" + e; throw new UpdateException( GlobalErrIds.GROUP_USER_ASSIGN_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return get( entity ); }
Example #4
Source File: UserDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * @param user * @return * @throws UpdateException * @throws Exception */ String deletePwPolicy( User user ) throws UpdateException { LdapConnection ld = null; String userDn = getDn( user.getUserId(), user.getContextId() ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, OPENLDAP_POLICY_SUBENTRY ) ); ld = getAdminConnection(); modify( ld, userDn, mods, user ); } catch ( LdapException e ) { String warning = "deletePwPolicy userId [" + user.getUserId() + "] caught LDAPException=" + e + " msg=" + e; throw new UpdateException( GlobalErrIds.USER_PW_PLCY_DEL_FAILED, warning, e ); } finally { closeAdminConnection( ld ); } return userDn; }
Example #5
Source File: SchemaAwareModificationSerializationTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testCreateServerModification() throws LdapException { Attribute attribute = new DefaultAttribute( "cn", cnAT ); attribute.add( "test1", "test2" ); Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute ); Modification clone = mod.clone(); attribute.remove( "test2" ); Attribute clonedAttribute = clone.getAttribute(); assertEquals( 1, mod.getAttribute().size() ); assertTrue( mod.getAttribute().contains( "TEST1" ) ); assertEquals( 2, clonedAttribute.size() ); assertTrue( clone.getAttribute().contains( "test1" ) ); assertTrue( clone.getAttribute().contains( "test2" ) ); }
Example #6
Source File: UserDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * Given a collection of RBAC roles, {@link UserRole}, convert to raw data format and load into ldap modification * set in preparation for ldap modify. * * @param list contains List of type {@link UserRole} targeted for updating into ldap. * @param mods contains ldap modification set containing RBAC role assignments in raw ldap format to be updated. * @throws LdapInvalidAttributeValueException */ private void loadUserRoles( List<UserRole> list, List<Modification> mods ) throws LdapInvalidAttributeValueException { Attribute userRoleData = new DefaultAttribute( GlobalIds.USER_ROLE_DATA ); Attribute userRoleAssign = new DefaultAttribute( USER_ROLE_ASSIGN ); if ( list != null ) { for ( UserRole userRole : list ) { userRoleData.add( userRole.getRawData() ); userRoleAssign.add( userRole.getName() ); } if ( userRoleData.size() != 0 ) { mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, userRoleData ) ); mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, userRoleAssign ) ); } } }
Example #7
Source File: GroupDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
Group delete( Group group, String key, String value ) throws FinderException, RemoveException { LdapConnection ld = null; String nodeDn = getDn( group.getName(), group.getContextId() ); try { LOG.debug( "delete group property dn [{}], key [{}], value [{}]", nodeDn, key, value ); List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, GROUP_PROPERTY_ATTR_IMPL, key + "=" + value ) ); ld = getAdminConnection(); modify( ld, nodeDn, mods, group ); } catch ( LdapException e ) { String error = "delete group property node dn [" + nodeDn + "] caught LDAPException=" + e; throw new RemoveException( GlobalErrIds.GROUP_DELETE_PROPERTY_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return get( group ); }
Example #8
Source File: GroupDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
Group add( Group group, String key, String value ) throws FinderException, CreateException { LdapConnection ld = null; String nodeDn = getDn( group.getName(), group.getContextId() ); try { LOG.debug( "add group property dn [{}], key [{}], value [{}]", nodeDn, key, value ); List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, GROUP_PROPERTY_ATTR_IMPL, key + "=" + value ) ); ld = getAdminConnection(); modify( ld, nodeDn, mods, group ); } catch ( LdapException e ) { String error = "update group property node dn [" + nodeDn + "] caught LDAPException=" + e; throw new CreateException( GlobalErrIds.GROUP_ADD_PROPERTY_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return get( group ); }
Example #9
Source File: AdminRoleDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * This method will remove the supplied DN as a role occupant to the target record. * This data will be stored in the {@link GlobalIds#ADMIN_ROLE_ROOT} container. * * @param entity record contains {@link AdminRole#name}. Null attributes will be ignored. * @param userDn contains the DN for userId who is being deassigned. * @return input record back to client. * @throws UpdateException in the event LDAP errors occur. */ AdminRole deassign( AdminRole entity, String userDn ) throws UpdateException { LdapConnection ld = null; String dn = getDn( entity ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, ROLE_OCCUPANT, userDn ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "deassign role name [" + entity.getName() + "] user dn [" + userDn + "] caught LdapException=" + e; throw new UpdateException( GlobalErrIds.ARLE_USER_DEASSIGN_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return entity; }
Example #10
Source File: RoleDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * @param entity * @param userDn * @return * @throws org.apache.directory.fortress.core.UpdateException * */ Role deassign( Role entity, String userDn ) throws UpdateException { LdapConnection ld = null; String dn = getDn( entity.getName(), entity.getContextId() ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, SchemaConstants.ROLE_OCCUPANT_AT, userDn ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "deassign role name [" + entity.getName() + "] user dn [" + userDn + "] caught LdapException=" + e; throw new UpdateException( GlobalErrIds.ROLE_USER_DEASSIGN_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return entity; }
Example #11
Source File: ModifyRequestImpl.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public int hashCode() { int hash = 37; if ( name != null ) { hash = hash * 17 + name.hashCode(); } hash = hash * 17 + mods.size(); for ( int i = 0; i < mods.size(); i++ ) { hash = hash * 17 + ( ( DefaultModification ) mods.get( i ) ).hashCode(); } hash = hash * 17 + super.hashCode(); return hash; }
Example #12
Source File: AdminRoleDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * * @param entity * @throws UpdateException */ void deleteParent( AdminRole entity ) throws UpdateException { LdapConnection ld = null; String dn = getDn( entity ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, GlobalIds.PARENT_NODES ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "deleteParent name [" + entity.getName() + "] caught LdapException=" + e; throw new UpdateException( GlobalErrIds.ARLE_REMOVE_PARENT_FAILED, error, e ); } finally { closeAdminConnection( ld ); } }
Example #13
Source File: AdminRoleDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * This method will add the supplied DN as a role occupant to the target record. * This data will be stored in the {@link GlobalIds#ADMIN_ROLE_ROOT} container. * * @param entity record contains {@link AdminRole#name}. Null attributes will be ignored. * @param userDn contains the DN for userId who is being assigned. * @return input record back to client. * @throws UpdateException in the event LDAP errors occur. */ AdminRole assign( AdminRole entity, String userDn ) throws UpdateException { LdapConnection ld = null; String dn = getDn( entity ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, ROLE_OCCUPANT, userDn ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "assign role name [" + entity.getName() + "] user dn [" + userDn + "] caught LdapException=" + e; throw new UpdateException( GlobalErrIds.ARLE_USER_ASSIGN_FAILED, error, e ); } finally { closeAdminConnection( ld ); } return entity; }
Example #14
Source File: RoleDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * * @param entity * @throws UpdateException */ void deleteParent( Role entity ) throws UpdateException { LdapConnection ld = null; String dn = getDn( entity.getName(), entity.getContextId() ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, GlobalIds.PARENT_NODES ) ); ld = getAdminConnection(); modify( ld, dn, mods, entity ); } catch ( LdapException e ) { String error = "deleteParent name [" + entity.getName() + "] caught LdapException=" + e; throw new UpdateException( GlobalErrIds.ROLE_REMOVE_PARENT_FAILED, error, e ); } finally { closeAdminConnection( ld ); } }
Example #15
Source File: AttributeUtilsTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test a addModification applied to an entry */ @Test public void testApplyAddModificationToEntry() throws LdapException { Entry entry = new DefaultEntry(); entry.add( "dc", "apache" ); assertEquals( 1, entry.size() ); Attribute attr = new DefaultAttribute( "cn", "test" ); Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr ); AttributeUtils.applyModification( entry, modification ); assertNotNull( entry.get( "cn" ) ); assertEquals( 2, entry.size() ); assertEquals( attr, entry.get( "cn" ) ); }
Example #16
Source File: UserDAO.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * @param user * @throws org.apache.directory.fortress.core.UpdateException */ void lock( User user ) throws UpdateException { LdapConnection ld = null; String userDn = getDn( user.getUserId(), user.getContextId() ); try { List<Modification> mods = new ArrayList<Modification>(); mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, OPENLDAP_PW_LOCKED_TIME, LOCK_VALUE ) ); ld = getAdminConnection(); modify( ld, userDn, mods, user ); } catch ( LdapException e ) { String error = "lock user [" + user.getUserId() + "] caught LDAPException=" + e; throw new UpdateException( GlobalErrIds.USER_PW_LOCK_FAILED, error, e ); } finally { closeAdminConnection( ld ); } }
Example #17
Source File: LdapDataProvider.java From directory-fortress-core with Apache License 2.0 | 6 votes |
/** * Given a collection of {@link java.util.Properties}, convert to raw data name-value format and load into ldap * modification set in preparation for ldap modify. * * @param props contains {@link java.util.Properties} targeted for updating in ldap. * @param mods ldap modification set containing name-value pairs in raw ldap format. * @param attrName contains the name of the ldap attribute to be updated. * @param replace boolean variable, if set to true use {@link ModificationOperation#REPLACE_ATTRIBUTE} else {@link * ModificationOperation#ADD_ATTRIBUTE}. * @param separator contains the char value used to separate name and value in ldap raw format. */ protected void loadProperties( Properties props, List<Modification> mods, String attrName, boolean replace, char separator ) { if ( props != null && props.size() > 0 ) { if ( replace ) { mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrName ) ); } for ( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) { String key = ( String ) e.nextElement(); String val = props.getProperty( key ); // This LDAP attr is stored as a name-value pair separated by a ':'. mods.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrName, key + separator + val ) ); } } }
Example #18
Source File: AttributeUtilsTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test the deletion of an attribute into an entry which does not contain the attribute */ @Test public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws LdapException { Entry entry = new DefaultEntry(); Attribute dc = new DefaultAttribute( "dc", "apache" ); entry.put( dc ); Attribute cn = new DefaultAttribute( "cn", "test" ); Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, cn ); AttributeUtils.applyModification( entry, modification ); assertNull( entry.get( "cn" ) ); assertNotNull( entry.get( "dc" ) ); assertEquals( 1, entry.size() ); assertEquals( dc, entry.get( "dc" ) ); }
Example #19
Source File: AttributeUtilsTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test the deletion of an attribute into an entry which contains the attribute * but without the value to be deleted */ @Test public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException { Entry entry = new DefaultEntry(); Attribute cn = new DefaultAttribute( "cn", "apache" ); entry.put( cn ); Attribute attr = new DefaultAttribute( "cn", "test" ); Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr ); AttributeUtils.applyModification( entry, modification ); assertNotNull( entry.get( "cn" ) ); assertEquals( 1, entry.size() ); assertEquals( cn, entry.get( "cn" ) ); }
Example #20
Source File: AttributeUtilsTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test the deletion of an attribute into an entry which contains the attribute. * * The entry should not contain the attribute after the operation */ @Test public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException { Entry entry = new DefaultEntry(); entry.put( "cn", "test" ); Attribute attr = new DefaultAttribute( "cn", "test" ); Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr ); AttributeUtils.applyModification( entry, modification ); assertNull( entry.get( "cn" ) ); assertEquals( 0, entry.size() ); }
Example #21
Source File: ApacheLdapProviderImpl.java From ldapchai with GNU Lesser General Public License v2.1 | 6 votes |
public void writeStringAttribute( final String entryDN, final String attributeName, final Set<String> values, final boolean overwrite ) throws ChaiOperationException, ChaiUnavailableException, IllegalStateException { activityPreCheck(); getInputValidator().writeStringAttribute( entryDN, attributeName, values, overwrite ); try { final ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setName( new Dn( entryDN ) ); { final Modification modification = new DefaultModification(); modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE ); modification.setAttribute( new DefaultAttribute( attributeName, values.toArray( new String[values.size()] ) ) ); modifyRequest.addModification( modification ); } final ModifyResponse response = connection.modify( modifyRequest ); processResponse( response ); } catch ( LdapException e ) { throw ChaiOperationException.forErrorMessage( e.getMessage() ); } }
Example #22
Source File: AttributeUtilsTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Test the removing by modification of an existing attribute in an . * * @throws LdapException */ @Test public void testApplyModifyModificationRemoveAttribute() throws LdapException { Entry entry = new DefaultEntry(); entry.put( "cn", "test" ); entry.put( "ou", "apache", "acme corp" ); Attribute newOu = new DefaultAttribute( "ou" ); Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu ); AttributeUtils.applyModification( entry, modification ); assertEquals( 1, entry.size() ); assertNotNull( entry.get( "cn" ) ); assertNull( entry.get( "ou" ) ); }
Example #23
Source File: ApacheLdapProviderImpl.java From ldapchai with GNU Lesser General Public License v2.1 | 6 votes |
public void writeBinaryAttribute( final String entryDN, final String attributeName, final byte[][] values, final boolean overwrite, final ChaiRequestControl[] controls ) throws ChaiUnavailableException, ChaiOperationException { try { final ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setName( new Dn( entryDN ) ); modifyRequest.addAllControls( figureControls( controls ) ); { final Modification modification = new DefaultModification(); modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE ); modification.setAttribute( new DefaultAttribute( attributeName, values ) ); modifyRequest.addModification( modification ); } final ModifyResponse response = connection.modify( modifyRequest ); processResponse( response ); } catch ( LdapException e ) { throw ChaiOperationException.forErrorMessage( e.getMessage() ); } }
Example #24
Source File: ApacheLdapProviderImpl.java From ldapchai with GNU Lesser General Public License v2.1 | 6 votes |
public void writeBinaryAttribute( final String entryDN, final String attributeName, final byte[][] values, final boolean overwrite ) throws ChaiUnavailableException, ChaiOperationException { activityPreCheck(); getInputValidator().writeBinaryAttribute( entryDN, attributeName, values, overwrite ); try { final ModifyRequest modifyRequest = new ModifyRequestImpl(); modifyRequest.setName( new Dn( entryDN ) ); { final Modification modification = new DefaultModification(); modification.setOperation( overwrite ? ModificationOperation.REPLACE_ATTRIBUTE : ModificationOperation.ADD_ATTRIBUTE ); modification.setAttribute( new DefaultAttribute( attributeName, values ) ); modifyRequest.addModification( modification ); } final ModifyResponse response = connection.modify( modifyRequest ); processResponse( response ); } catch ( LdapException e ) { throw ChaiOperationException.forErrorMessage( e.getMessage() ); } }
Example #25
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( Dn dn, List<Modification> mods, LogChange log ) throws LdapException { if ( mods == null ) { return; } List<Modification> serverModifications = new ArrayList<Modification>( mods.size() ); for ( Modification mod : mods ) { serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) ); } ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications ); modifyContext.setLogChange( log ); OperationManager operationManager = directoryService.getOperationManager(); operationManager.modify( modifyContext ); }
Example #26
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( Dn dn, List<Modification> mods, boolean ignoreReferral, LogChange log ) throws LdapException { if ( mods == null ) { return; } List<Modification> serverModifications = new ArrayList<Modification>( mods.size() ); for ( Modification mod : mods ) { serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) ); } ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications ); setReferralHandling( modifyContext, ignoreReferral ); modifyContext.setLogChange( log ); OperationManager operationManager = directoryService.getOperationManager(); operationManager.modify( modifyContext ); }
Example #27
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
private void createContextCsnModList() throws LdapException { Modification contextCsnMod = new DefaultModification(); contextCsnMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute contextCsnAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.CONTEXT_CSN_AT ) ); contextCsnMod.setAttribute( contextCsnAt ); mods.add( contextCsnMod ); Modification timeStampMod = new DefaultModification(); timeStampMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute timeStampAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ) ); timeStampMod.setAttribute( timeStampAt ); mods.add( timeStampMod ); }
Example #28
Source File: DefaultPartitionNexus.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
private void createContextCsnModList() throws LdapException { Modification contextCsnMod = new DefaultModification(); contextCsnMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute contextCsnAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.CONTEXT_CSN_AT ) ); contextCsnMod.setAttribute( contextCsnAt ); mods.add( contextCsnMod ); Modification timeStampMod = new DefaultModification(); timeStampMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute timeStampAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ) ); timeStampMod.setAttribute( timeStampAt ); mods.add( timeStampMod ); }
Example #29
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( Dn dn, List<Modification> mods, LogChange log ) throws LdapException { if ( mods == null ) { return; } List<Modification> serverModifications = new ArrayList<Modification>( mods.size() ); for ( Modification mod : mods ) { serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) ); } ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications ); modifyContext.setLogChange( log ); OperationManager operationManager = directoryService.getOperationManager(); operationManager.modify( modifyContext ); }
Example #30
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void modify( Dn dn, List<Modification> mods, boolean ignoreReferral, LogChange log ) throws LdapException { if ( mods == null ) { return; } List<Modification> serverModifications = new ArrayList<Modification>( mods.size() ); for ( Modification mod : mods ) { serverModifications.add( new DefaultModification( directoryService.getSchemaManager(), mod ) ); } ModifyOperationContext modifyContext = new ModifyOperationContext( this, dn, serverModifications ); setReferralHandling( modifyContext, ignoreReferral ); modifyContext.setLogChange( log ); OperationManager operationManager = directoryService.getOperationManager(); operationManager.modify( modifyContext ); }