本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Rdn类的典型用法代码示例。如果您正苦于以下问题:Java Rdn类的具体用法?Java Rdn怎么用?Java Rdn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rdn类属于org.apache.directory.api.ldap.model.name包,在下文中一共展示了Rdn类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:ModifyDnRequestImplTest.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:LdifRevertorTest.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:TestDnNode.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:TestDnNode.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:RdnTest.java
示例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" ) ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:TestDnNode.java
示例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 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:RdnTest.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:TestDnNode.java
示例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() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:TestDnNode.java
示例10: setNewRdn
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
getDecorated().setNewRdn( newRdn );
return this;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:11,代码来源:ModifyDNRequestDsml.java
示例11: setNewRdn
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModifyDnRequest setNewRdn( Rdn newRdn )
{
this.newRdn = newRdn;
return this;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:11,代码来源:ModifyDnRequestImpl.java
示例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;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:47,代码来源:LdifRevertor.java
示例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;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:42,代码来源:LdifRevertor.java
示例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;
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:31,代码来源:LdifRevertor.java
示例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();
}
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:43,代码来源:DnNode.java
示例16: testRdnWithEmptyValue
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* test an Rdn with empty value
*/
@Test
public void testRdnWithEmptyValue() throws LdapException
{
assertTrue( Rdn.isValid( "a=" ) );
assertTrue( Rdn.isValid( "a=\"\"" ) );
assertEquals( "a=\"\"", new Rdn( "a=\"\"" ).getName() );
assertEquals( "a=", new Rdn( "a=" ).getName() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:12,代码来源:RdnTest.java
示例17: testNotEqualDiffNewRdn
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test for inequality when only the new Rdn properties are different.
*/
@Test
public void testNotEqualDiffNewRdn() throws LdapException
{
ModifyDnRequestImpl req0 = getRequest();
req0.setNewRdn( new Rdn( "cn=admin0" ) );
ModifyDnRequestImpl req1 = getRequest();
req1.setNewRdn( new Rdn( "cn=admin1" ) );
assertFalse( req0.equals( req1 ) );
assertFalse( req1.equals( req0 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:16,代码来源:ModifyDnRequestImplTest.java
示例18: testEmptyIterator
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
@Test
public void testEmptyIterator()
{
Rdn rdn = new Rdn();
Iterator<Ava> iterator = rdn.iterator();
assertNotNull( iterator );
assertFalse( iterator.hasNext() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:9,代码来源:FastRdnParserTest.java
示例19: testReverseModifyDNDeleteOldRdnSuperior
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Test a reversed ModifyDN with a deleteOldRdn, rdn change, and a superior
*
* @throws NamingException on error
*/
@Test
public void testReverseModifyDNDeleteOldRdnSuperior() throws LdapException
{
Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
Dn newSuperior = new Dn( "ou=system" );
Entry entry = new DefaultEntry( dn );
entry.add( "objectClass", "person", "uidObject" );
entry.add( "cn", "john doe" );
entry.add( "sn", "doe" );
entry.add( "uid", "jdoe" );
List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename( entry, newSuperior, new Rdn( "cn=jack doe" ),
false );
assertNotNull( reverseds );
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
assertEquals( "cn=jack doe,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( "cn=john doe", reversed.getNewRdn() );
assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) );
assertNull( reversed.getEntry() );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:32,代码来源:LdifUtilsTest.java
示例20: testRDNCompareToNC2NCNotEquals
import org.apache.directory.api.ldap.model.name.Rdn; //导入依赖的package包/类
/**
* Compares a simple NC to a different simple NC.
*
* @throws LdapException
*/
@Test
public void testRDNCompareToNC2NCNotEquals() throws LdapException
{
Rdn rdn1 = new Rdn( " a = b " );
Rdn rdn2 = new Rdn( " A = d " );
assertFalse( rdn1.equals( rdn2 ) );
}
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:FastRdnParserTest.java
注:本文中的org.apache.directory.api.ldap.model.name.Rdn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论