1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.directory.server.core.journal;
20
21
22 import java.io.IOException;
23
24 import org.apache.directory.api.ldap.model.exception.LdapException;
25 import org.apache.directory.api.ldap.model.ldif.LdifEntry;
26 import org.apache.directory.server.core.api.DirectoryService;
27 import org.apache.directory.server.core.api.LdapPrincipal;
28 import org.apache.directory.server.core.api.journal.Journal;
29 import org.apache.directory.server.core.api.journal.JournalStore;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33
34
35
36
37
38
39
40
41 public class DefaultJournal implements Journal
42 {
43
44 private static final Logger LOG = LoggerFactory.getLogger( DefaultJournal.class );
45
46
47 private boolean enabled;
48
49
50 private JournalStore store;
51
52
53
54
55
56 private int rotation;
57
58
59
60
61
62 @Override
63 public void destroy() throws LdapException
64 {
65 LOG.debug( "Stopping the journal" );
66
67
68
69 if ( store != null )
70 {
71 try
72 {
73 store.destroy();
74 }
75 catch ( IOException ioe )
76 {
77 throw new LdapException( ioe.getMessage(), ioe );
78 }
79 }
80 }
81
82
83
84
85
86 @Override
87 public JournalStore getJournalStore()
88 {
89 return store;
90 }
91
92
93
94
95
96 @Override
97 public void init( DirectoryService directoryService ) throws LdapException
98 {
99 LOG.debug( "Starting the journal" );
100
101 if ( store == null )
102 {
103 store = new DefaultJournalStore();
104 }
105
106 try
107 {
108 store.init( directoryService );
109 }
110 catch ( IOException ioe )
111 {
112 throw new LdapException( ioe.getMessage(), ioe );
113 }
114
115 LOG.debug( "The Journal service has been initialized" );
116 }
117
118
119
120
121
122 @Override
123 public boolean isEnabled()
124 {
125 return enabled;
126 }
127
128
129
130
131
132 @Override
133 public void log( LdapPrincipal principal, long revision, LdifEntry entry ) throws LdapException
134 {
135 store.log( principal, revision, entry );
136 }
137
138
139
140
141
142 @Override
143 public void ack( long revision )
144 {
145 store.ack( revision );
146 }
147
148
149
150
151
152 @Override
153 public void nack( long revision )
154 {
155 store.nack( revision );
156 }
157
158
159
160
161
162 @Override
163 public int getRotation()
164 {
165 return rotation;
166 }
167
168
169
170
171
172 @Override
173 public void setRotation( int rotation )
174 {
175 this.rotation = rotation;
176 }
177
178
179 @Override
180 public void setEnabled( boolean enabled )
181 {
182 this.enabled = enabled;
183 }
184
185
186 @Override
187 public void setJournalStore( JournalStore store )
188 {
189 this.store = store;
190 }
191 }