本文整理汇总了Java中org.apache.directory.api.ldap.model.name.Dn.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java Dn.getParent方法的具体用法?Java Dn.getParent怎么用?Java Dn.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.name.Dn
的用法示例。
在下文中一共展示了Dn.getParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reverseMove
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的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;
}
示例2: revertEntry
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的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;
}
示例3: generateReverted
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* A helper method which generates a reverted entry
*/
private static LdifEntry generateReverted( Dn newSuperior, Rdn newRdn, Dn newDn, Rdn oldRdn, boolean deleteOldRdn )
throws LdapInvalidDnException
{
LdifEntry reverted = new LdifEntry();
reverted.setChangeType( ChangeType.ModRdn );
if ( newSuperior != null )
{
Dn restoredDn = newSuperior.add( newRdn );
reverted.setDn( restoredDn );
}
else
{
reverted.setDn( newDn );
}
reverted.setNewRdn( oldRdn.getName() );
if ( newSuperior != null )
{
Dn oldSuperior = newDn;
oldSuperior = oldSuperior.getParent();
reverted.setNewSuperior( oldSuperior.getName() );
}
// Delete the newRDN values
reverted.setDeleteOldRdn( deleteOldRdn );
return reverted;
}
示例4: checkPartition
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
private void checkPartition(LdifEntry ldifEntry) throws Exception {
Dn dn = ldifEntry.getDn();
Dn parent = dn.getParent();
try {
directoryService.getAdminSession().exists(parent);
} catch (Exception e) {
System.out.println("Creating new partition for DN=" + dn + "\n");
AvlPartition partition = new AvlPartition(directoryService.getSchemaManager());
partition.setId(dn.getName());
partition.setSuffixDn(dn);
directoryService.addPartition(partition);
}
}
示例5: moveAndRename
import org.apache.directory.api.ldap.model.name.Dn; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
{
// Check the parameters first
if ( entryDn == null )
{
throw new IllegalArgumentException( "The entry Dn must not be null" );
}
if ( entryDn.isRootDse() )
{
throw new IllegalArgumentException( "The RootDSE cannot be moved" );
}
if ( newDn == null )
{
throw new IllegalArgumentException( "The new Dn must not be null" );
}
if ( newDn.isRootDse() )
{
throw new IllegalArgumentException( "The RootDSE cannot be the target" );
}
// Create the request
ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
modDnRequest.setName( entryDn );
modDnRequest.setNewRdn( newDn.getRdn() );
// Check if we really need to specify newSuperior.
// newSuperior is optional [RFC4511, section 4.9]
// Some servers (e.g. OpenDJ 2.6) require a special privilege if
// newSuperior is specified even if it is the same as the old one. Therefore let's not
// specify it if we do not need it. This is better interoperability.
Dn newDnParent = newDn.getParent();
if ( newDnParent != null && !newDnParent.equals( entryDn.getParent() ) )
{
modDnRequest.setNewSuperior( newDnParent );
}
modDnRequest.setDeleteOldRdn( deleteOldRdn );
ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );
processResponse( modifyDnResponse );
}