本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Rdn类的典型用法代码示例。如果您正苦于以下问题:Java Rdn类的具体用法?Java Rdn怎么用?Java Rdn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rdn类属于org.apache.directory.api.ldap.model.name包,在下文中一共展示了Rdn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequest
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Constructs a ModifyDnrequest to test.
*
* @return the request
*/
private ModifyDnRequestImpl getRequest()
{
// Construct the ModifyDn request to test
ModifyDnRequestImpl request = new ModifyDnRequestImpl();
request.setMessageId( 45 );
request.setDeleteOldRdn( true );
try
{
request.setName( new Dn( "dc=admins,dc=apache,dc=org" ) );
request.setNewRdn( new Rdn( "dc=administrators" ) );
request.setNewSuperior( new Dn( "dc=groups,dc=apache,dc=org" ) );
}
catch ( LdapException ine )
{
// do nothing
}
return request;
}
示例2: testReverseModifyDNMove
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test a reversed move ModifyDN
*
* @throws LdapException on error
*/
@Test
public void testReverseModifyDNMove() throws LdapException
{
Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
Dn newSuperior = new Dn( "ou=system" );
Rdn rdn = new Rdn( "cn=john doe" );
LdifEntry reversed = LdifRevertor.reverseMove( newSuperior, dn );
assertNotNull( reversed );
assertEquals( "cn=john doe,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModDn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( rdn.getName(), reversed.getNewRdn() );
assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) );
assertNull( reversed.getEntry() );
}
示例3: testHasParent
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
@Test
public void testHasParent() throws Exception
{
DnNode<Dn> tree = new DnNode<Dn>();
Dn dn = new Dn( "dc=c,dc=b,dc=a" );
tree.add( dn, dn );
assertFalse( tree.hasParent() );
DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) );
assertTrue( child.hasParent() );
DnNode<Dn> child1 = child.getChild( new Rdn( "dc=b" ) );
assertTrue( child1.hasParent() );
child = child1.getChild( new Rdn( "dc=c" ) );
assertTrue( child.hasParent() );
}
示例4: testHasChildren
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
@Test
public void testHasChildren() throws Exception
{
DnNode<Dn> tree = new DnNode<Dn>();
Dn dn1 = new Dn( "dc=b,dc=a" );
tree.add( dn1 );
assertTrue( tree.hasChildren() );
Map<String, DnNode<Dn>> children = tree.getChildren();
assertNotNull( children );
DnNode<Dn> child = children.get( new Rdn( "dc=a" ).getNormName() );
assertTrue( child.hasChildren() );
children = child.getChildren();
child = children.get( new Rdn( "dc=b" ).getNormName() );
assertFalse( child.hasChildren() );
}
示例5: testRdnCompositeWithSpace
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* test a composite Rdn with or without spaces: a=b, a =b, a= b, a = b, a =
* b
*
* @throws LdapException
*/
@Test
public void testRdnCompositeWithSpace() throws LdapException
{
assertEquals( "a=b", new Rdn( "a", "b" ).getName() );
assertEquals( " a=b", new Rdn( " a", "b" ).getName() );
assertEquals( "a =b", new Rdn( "a ", "b" ).getName() );
assertEquals( "a= b", new Rdn( "a", " b" ).getName() );
assertEquals( "a=b ", new Rdn( "a", "b " ).getName() );
assertEquals( " a =b", new Rdn( " a ", "b" ).getName() );
assertEquals( " a= b", new Rdn( " a", " b" ).getName() );
assertEquals( " a=b ", new Rdn( " a", "b " ).getName() );
assertEquals( "a = b", new Rdn( "a ", " b" ).getName() );
assertEquals( "a =b ", new Rdn( "a ", "b " ).getName() );
assertEquals( "a= b ", new Rdn( "a", " b " ).getName() );
assertEquals( " a = b", new Rdn( " a ", " b" ).getName() );
assertEquals( " a =b ", new Rdn( " a ", "b " ).getName() );
assertEquals( " a= b ", new Rdn( " a", " b " ).getName() );
assertEquals( "a = b ", new Rdn( "a ", " b " ).getName() );
assertEquals( " a = b ", new Rdn( " a ", " b " ).getName() );
}
示例6: testHasParentDN
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
@Test
public void testHasParentDN() throws Exception
{
DnNode<Dn> tree = new DnNode<Dn>();
Dn dn1 = new Dn( "dc=c,dc=b,dc=a" );
tree.add( dn1, dn1 );
Dn dn2 = new Dn( "dc=e,dc=a" );
tree.add( dn2, dn2 );
assertFalse( tree.hasParent( Dn.EMPTY_DN ) );
DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) );
assertTrue( tree.hasParent( new Dn( "dc=a" ) ) );
child = child.getChild( new Rdn( "dc=b" ) );
assertTrue( tree.hasParent( new Dn( "dc=b,dc=a" ) ) );
child = child.getChild( new Rdn( "dc=c" ) );
assertTrue( tree.hasParent( new Dn( "dc=c,dc=b,dc=a" ) ) );
assertTrue( tree.hasParent( new Dn( "dc=f,dc=e,dc=c,dc=b,dc=a" ) ) );
}
示例7: testCompareSecondAtav
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test for DIRSHARED-2.
* The first ATAV is equal, the second or following ATAV differs.
*
* @throws LdapException
*/
@Test
public void testCompareSecondAtav() throws LdapException
{
// the second ATAV differs
Rdn rdn1 = new Rdn( " a = b + c = d " );
Rdn rdn2 = new Rdn( " a = b + c = y " );
assertFalse( rdn1.equals( rdn2 ) );
assertFalse( rdn2.equals( rdn1 ) );
// the third ATAV differs
Rdn rdn3 = new Rdn( " a = b + c = d + e = f " );
Rdn rdn4 = new Rdn( " a = b + c = d + e = y " );
assertFalse( rdn3.equals( rdn4 ) );
assertFalse( rdn4.equals( rdn3 ) );
// the second ATAV differs in value only
Rdn rdn5 = new Rdn( " a = b + b = c " );
Rdn rdn6 = new Rdn( " a = b + b = y " );
assertFalse( rdn5.equals( rdn6 ) );
assertFalse( rdn6.equals( rdn5 ) );
}
示例8: testAdd3LevelDNNoElem
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test the addition of a Dn with three Rdn
*/
@Test
public void testAdd3LevelDNNoElem() throws LdapException
{
DnNode<Dn> tree = new DnNode<Dn>( Dn.EMPTY_DN, null );
Dn dn = new Dn( "dc=c,dc=b,dc=a" );
tree.add( dn );
assertNotNull( tree );
Map<String, DnNode<Dn>> children = tree.getChildren();
assertNotNull( children );
assertEquals( 1, children.size() );
assertNull( tree.getElement() );
DnNode<Dn> level1 = children.get( new Rdn( "dc=a" ).getNormName() );
DnNode<Dn> level2 = level1.getChildren().get( new Rdn( "dc=b" ).getNormName() );
DnNode<Dn> level3 = level2.getChildren().get( new Rdn( "dc=c" ).getNormName() );
assertNotNull( level3 );
assertFalse( level3.hasElement() );
}
示例9: testAdd2DistinctDNsNoElem
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test the addition of two DNs not overlapping
*/
@Test
public void testAdd2DistinctDNsNoElem() throws LdapException
{
DnNode<Dn> tree = new DnNode<Dn>();
Dn dn1 = new Dn( "dc=b,dc=a" );
Dn dn2 = new Dn( "dc=f,dc=e" );
tree.add( dn1 );
tree.add( dn2 );
assertNotNull( tree );
Map<String, DnNode<Dn>> children = tree.getChildren();
assertNotNull( children );
assertEquals( 2, children.size() );
assertNull( tree.getElement() );
DnNode<Dn> level1 = children.get( new Rdn( "dc=a" ).getNormName() );
DnNode<Dn> level2 = level1.getChildren().get( new Rdn( "dc=b" ).getNormName() );
assertNotNull( level2 );
assertFalse( level2.hasElement() );
level1 = children.get( new Rdn( "dc=e" ).getNormName() );
level2 = level1.getChildren().get( new Rdn( "dc=f" ).getNormName() );
assertNotNull( level2 );
assertFalse( level2.hasElement() );
}
示例10: setNewRdn
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
getDecorated().setNewRdn( newRdn );
return this;
}
示例11: setNewRdn
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
this.newRdn = newRdn;
return this;
}
示例12: reverseMove
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Compute a reverse LDIF for a forward change which if in LDIF format
* would represent a Move operation. Hence there is no newRdn in the
* picture here.
*
* @param newSuperiorDn the new parent dn to be (must not be null)
* @param modifiedDn the dn of the entry being moved (must not be null)
* @return a reverse LDIF
* @throws LdapException if something went wrong
*/
public static LdifEntry reverseMove( Dn newSuperiorDn, Dn modifiedDn ) throws LdapException
{
LdifEntry entry = new LdifEntry();
Dn currentParent;
Rdn currentRdn;
Dn newDn;
if ( newSuperiorDn == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12074 ) );
}
if ( modifiedDn == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12075 ) );
}
if ( modifiedDn.size() == 0 )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_12076 ) );
}
currentParent = modifiedDn;
currentRdn = currentParent.getRdn();
currentParent = currentParent.getParent();
newDn = newSuperiorDn;
newDn = newDn.add( modifiedDn.getRdn() );
entry.setChangeType( ChangeType.ModDn );
entry.setDn( newDn );
entry.setNewRdn( currentRdn.getName() );
entry.setNewSuperior( currentParent.getName() );
entry.setDeleteOldRdn( false );
return entry;
}
示例13: revertEntry
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* A small helper class to compute the simple revert.
*/
private static LdifEntry revertEntry( Entry entry, Dn newDn, Dn newSuperior, Rdn oldRdn, Rdn newRdn )
throws LdapInvalidDnException
{
LdifEntry reverted = new LdifEntry();
// We have a composite old Rdn, something like A=a+B=b
// It does not matter if the RDNs overlap
reverted.setChangeType( ChangeType.ModRdn );
if ( newSuperior != null )
{
Dn restoredDn = newSuperior.add( newRdn );
reverted.setDn( restoredDn );
}
else
{
reverted.setDn( newDn );
}
reverted.setNewRdn( oldRdn.getName() );
// Is the newRdn's value present in the entry ?
// ( case 3, 4 and 5)
// If keepOldRdn = true, we cover case 4 and 5
boolean keepOldRdn = entry.contains( newRdn.getNormType(), newRdn.getValue() );
reverted.setDeleteOldRdn( !keepOldRdn );
if ( newSuperior != null )
{
Dn oldSuperior = entry.getDn();
oldSuperior = oldSuperior.getParent();
reverted.setNewSuperior( oldSuperior.getName() );
}
return reverted;
}
示例14: generateModify
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* A helper method to generate the modified attribute after a rename.
*/
private static LdifEntry generateModify( Dn parentDn, Entry entry, Rdn oldRdn, Rdn newRdn )
{
LdifEntry restored = new LdifEntry();
restored.setChangeType( ChangeType.Modify );
// We have to use the parent Dn, the entry has already
// been renamed
restored.setDn( parentDn );
for ( Ava ava : newRdn )
{
// No need to add something which has already been added
// in the previous modification
if ( !entry.contains( ava.getNormType(), ava.getValue().getValue() )
&& !( ava.getNormType().equals( oldRdn.getNormType() ) && ava.getValue().getValue().equals(
oldRdn.getValue() ) ) )
{
// Create the modification, which is an Remove
Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
new DefaultAttribute( ava.getType(), ava.getValue().getValue() ) );
restored.addModification( modification );
}
}
return restored;
}
示例15: remove
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Removes a node from the tree.
*
* @param dn the node's Dn
* @throws LdapException if the Dn is null or empty
*/
public synchronized void remove( Dn dn ) throws LdapException
{
checkDn( dn );
// Find the parent first : we won't be able to remove
// a node if it's not present in the tree !
DnNode<N> parentNode = getNode( dn );
if ( parentNode == null )
{
return;
}
// Now, check that this parent has the same Dn than the one
// we gave and that there is no children
if ( ( dn.size() != parentNode.depth ) || parentNode.hasChildren() )
{
return;
}
// Ok, no children, same Dn, let's remove what we can.
parentNode = parentNode.getParent();
for ( Rdn rdn : dn.getRdns() )
{
parentNode.children.remove( rdn.getNormName() );
if ( parentNode.children.size() > 0 )
{
// We have to stop here, because the parent's node is shared with other Node.
break;
}
parentNode = parentNode.getParent();
}
}