本文整理汇总了Java中org.apache.directory.api.ldap.model.message.AddRequest类的典型用法代码示例。如果您正苦于以下问题:Java AddRequest类的具体用法?Java AddRequest怎么用?Java AddRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AddRequest类属于org.apache.directory.api.ldap.model.message包,在下文中一共展示了AddRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRequestWithDn
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with the dn attribute
*/
@Test
public void testRequestWithDn()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_dn_attribute.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
assertTrue( addRequest.getEntryDn().equals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM" ) );
}
示例2: testRequestWithRequestId
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with the (optional) requestID attribute
*/
@Test
public void testRequestWithRequestId()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
assertEquals( 456, addRequest.getMessageId() );
}
示例3: add
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void add( Entry entry ) throws LdapException
{
if ( entry == null )
{
String msg = "Cannot add an empty entry";
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );
AddResponse addResponse = add( addRequest );
processResponse( addResponse );
}
示例4: addAsync
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddFuture addAsync( Entry entry ) throws LdapException
{
if ( entry == null )
{
String msg = "Cannot add null entry";
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );
return addAsync( addRequest );
}
示例5: add
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddResponse add( AddRequest addRequest )
{
LdapConnection connection = null;
try
{
connection = connectionPool.getConnection();
return connection.add( addRequest );
}
catch ( LdapException e )
{
throw new LdapRuntimeException( e );
}
finally
{
returnLdapConnection( connection );
}
}
示例6: action
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void action( LdapMessageContainer<AddRequestDecorator> container ) throws DecoderException
{
// Now, we can allocate the AddRequest Object
int messageId = container.getMessageId();
AddRequest internalAddRequest = new AddRequestImpl();
internalAddRequest.setMessageId( messageId );
AddRequestDecorator addRequest = new AddRequestDecorator(
container.getLdapCodecService(), internalAddRequest );
container.setMessage( addRequest );
// We will check that the request is not null
TLV tlv = container.getCurrentTLV();
if ( tlv.getLength() == 0 )
{
String msg = I18n.err( I18n.ERR_04084 );
LOG.error( msg );
// Will generate a PROTOCOL_ERROR
throw new DecoderException( msg );
}
}
示例7: addEntry
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* 添加条目
*
* Apache LDAP 主要提供三种添加条目的方法。当前用:同步的、服务器有返回响应的。
*
* @author ZhengWei(HY)
* @createDate 2017-02-14
* @version v1.0
*
* @param i_Entry
* @return 添加成功返回true。
*/
public boolean addEntry(Entry i_Entry)
{
LdapConnection v_Conn = null;
AddRequest v_AddRequest = new AddRequestImpl();
AddResponse v_Response = null;
try
{
v_AddRequest.setEntry( i_Entry);
v_AddRequest.addControl(new ManageDsaITImpl());
v_Conn = this.getConnection();
v_Response = v_Conn.add(v_AddRequest);
}
catch (Exception exce)
{
exce.printStackTrace();
}
finally
{
this.closeConnection(v_Conn);
}
return LDAP.isSuccess(v_Response);
}
示例8: add
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void add( AddRequest addRequest, LogChange log ) throws LdapException
{
AddOperationContext addContext = new AddOperationContext( this, addRequest );
addContext.setLogChange( log );
OperationManager operationManager = directoryService.getOperationManager();
try
{
operationManager.add( addContext );
}
catch ( LdapException e )
{
addRequest.getResultResponse().addAllControls( addContext.getResponseControls() );
throw e;
}
addRequest.getResultResponse().addAllControls( addContext.getResponseControls() );
}
示例9: setEntryDn
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddRequest setEntryDn( Dn entryDn )
{
getDecorated().setEntryDn( entryDn );
return this;
}
示例10: setEntry
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddRequest setEntry( Entry entry )
{
getDecorated().setEntry( entry );
return this;
}
示例11: setMessageId
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AddRequest setMessageId( int messageId )
{
super.setMessageId( messageId );
return this;
}
示例12: testRequestWith1Control
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element
*/
@Test
public void testRequestWith1Control()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_control.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertEquals( "Some text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例13: testRequestWith1ControlBase64Value
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element with Base64 value
*/
@Test
public void testRequestWith1ControlBase64Value()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput(
AddRequestTest.class.getResource( "request_with_1_control_base64_value.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertEquals( "DSMLv2.0 rocks!!", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
示例14: testRequestWith1ControlEmptyValue
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with a (optional) Control element with empty value
*/
@Test
public void testRequestWith1ControlEmptyValue()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_1_control_empty_value.xml" ).openStream(),
"UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 1, addRequest.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.643" );
assertNotNull( control );
assertTrue( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
示例15: testRequestWith2Controls
import org.apache.directory.api.ldap.model.message.AddRequest; //导入依赖的package包/类
/**
* Test parsing of a request with 2 (optional) Control elements
*/
@Test
public void testRequestWith2Controls()
{
Dsmlv2Parser parser = null;
try
{
parser = newParser();
parser.setInput( AddRequestTest.class.getResource( "request_with_2_controls.xml" ).openStream(), "UTF-8" );
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = addRequest.getControls();
assertEquals( 2, addRequest.getControls().size() );
Control control = controls.get( "1.2.840.113556.1.4.789" );
assertNotNull( control );
assertFalse( control.isCritical() );
assertEquals( "1.2.840.113556.1.4.789", control.getOid() );
assertEquals( "Some other text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}