View Javadoc
1   /*
2    * Copyright 2013-2016 Brian Thomas Matthews
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.btmatthews.maven.plugins.ldap.ldif;
18  
19  import com.btmatthews.maven.plugins.ldap.AbstractFormatHandler;
20  import com.btmatthews.maven.plugins.ldap.FormatLogger;
21  import com.btmatthews.maven.plugins.ldap.FormatReader;
22  import com.btmatthews.maven.plugins.ldap.FormatWriter;
23  
24  import java.io.InputStream;
25  import java.io.OutputStream;
26  
27  /**
28   * This {@link com.btmatthews.maven.plugins.ldap.FormatHandler} is used to load data from or dump data
29   * to LDIF files.
30   *
31   * @author <a href="mailto:brian@btmatthews.com">Brian Matthews</a>
32   * @since 1.2.0
33   */
34  public final class LDIFFormatHandler extends AbstractFormatHandler {
35  
36      /**
37       * Create the {@link LDIFFormatWriter} that will dump LDAP entries in LDIF format
38       * to the target output stream.
39       *
40       * @param outputStream The target output stream.
41       * @param logger       Used to log information or error messages.
42       * @return A {@link LDIFFormatWriter} object.
43       */
44      @Override
45      protected FormatWriter createWriter(final OutputStream outputStream,
46                                          final FormatLogger logger) {
47          return new LDIFFormatWriter(outputStream);
48      }
49  
50      /**
51       * Create {@link LDIFFormatReader} that reads LDIF change records from the source
52       * input stream.
53       *
54       * @param inputStream The source input stream.
55       * @param logger      Used to log information or error messages.
56       * @return A {@link LDIFFormatReader} object.
57       */
58      @Override
59      protected FormatReader openReader(final InputStream inputStream,
60                                        final FormatLogger logger) {
61          return new LDIFFormatReader(inputStream);
62      }
63  }