1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.ldap.handlers.extended;
21
22
23 import java.util.Collections;
24 import java.util.HashSet;
25 import java.util.Set;
26
27 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionRequest;
28 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponse;
29 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponseImpl;
30 import org.apache.directory.api.ldap.model.message.ExtendedRequest;
31 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
32 import org.apache.directory.server.core.api.CoreSession;
33 import org.apache.directory.server.ldap.ExtendedOperationHandler;
34 import org.apache.directory.server.ldap.LdapServer;
35 import org.apache.directory.server.ldap.LdapSession;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 import jdbm.helper.Conversion;
40
41
42
43
44
45
46
47 public class StartTransactionHandler implements ExtendedOperationHandler<ExtendedRequest, ExtendedResponse>
48 {
49 private static final Logger LOG = LoggerFactory.getLogger( StartTransactionHandler.class );
50 public static final Set<String> EXTENSION_OIDS;
51
52 static
53 {
54 Set<String> set = new HashSet<>( 2 );
55 set.add( StartTransactionRequest.EXTENSION_OID );
56 EXTENSION_OIDS = Collections.unmodifiableSet( set );
57 }
58
59
60
61
62
63 public String getOid()
64 {
65 return StartTransactionRequest.EXTENSION_OID;
66 }
67
68
69
70
71
72 public void handleExtendedOperation( LdapSession session, ExtendedRequest req ) throws Exception
73 {
74 LOG.debug( "StartTransaction requested" );
75
76
77
78 CoreSession coreSession = session.getCoreSession();
79 long transactionId = coreSession.beginSessionTransaction();
80
81 StartTransactionResponse startTransactionResponse = new StartTransactionResponseImpl(
82 req.getMessageId(), Conversion.convertToByteArray( transactionId ) );
83
84
85
86
87
88 startTransactionResponse.setResponseName( StartTransactionRequest.EXTENSION_OID );
89
90
91 session.getIoSession().write( startTransactionResponse );
92 }
93
94
95
96
97
98 public Set<String> getExtensionOids()
99 {
100 return EXTENSION_OIDS;
101 }
102
103
104
105
106
107 public void setLdapServer( LdapServer ldapServer )
108 {
109 }
110 }