@@ -99,9 +99,9 @@ public static void createSchemaFromLDIF(InputStream stream, Connection ld) throw
9999 public static void createSchemaFromLDIF (LDIFChangeRecordReader ldif , final Connection ld ) throws IOException {
100100 while (ldif .hasNext ()) {
101101 final ChangeRecord changeRecord = ldif .readChangeRecord ();
102- changeRecord .accept (new ChangeRecordVisitor <Void , Void >() {
102+ final IOException resultException = changeRecord .accept (new ChangeRecordVisitor <IOException , Void >() {
103103 @ Override
104- public Void visitChangeRecord (Void aVoid , AddRequest change ) {
104+ public IOException visitChangeRecord (Void aVoid , AddRequest change ) {
105105 try {
106106 change .addControl (TransactionIdControl .newControl (
107107 AuditRequestContext .createSubTransactionIdValue ()));
@@ -114,41 +114,51 @@ public Void visitChangeRecord(Void aVoid, AddRequest change) {
114114 try {
115115 ld .modify (modifyRequest );
116116 } catch (LdapException ex ) {
117- DEBUG .warning ("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}" ,
117+ DEBUG .error ("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}" ,
118118 modifyRequest , ex );
119+ return new IOException (String .format ("LDAPUtils.createSchemaFromLDIF - " +
120+ "Could not modify schema: %s; ex: %s" , modifyRequest , ex ));
119121 }
120122 }
121123 } else {
122- DEBUG .warning ("LDAPUtils.createSchemaFromLDIF - Could not add to schema: {}" , change , e );
124+ DEBUG .error ("LDAPUtils.createSchemaFromLDIF - Could not add to schema: {}" , change , e );
125+ return new IOException (String .format ("LDAPUtils.createSchemaFromLDIF - " +
126+ "Could not add to schema: %s; ex: %s" , change , e ));
123127 }
124128 }
125129 return null ;
126130 }
127131
128132 @ Override
129- public Void visitChangeRecord (Void aVoid , ModifyRequest change ) {
133+ public IOException visitChangeRecord (Void aVoid , ModifyRequest change ) {
130134 try {
131135 change .addControl (TransactionIdControl .newControl (
132136 AuditRequestContext .createSubTransactionIdValue ()));
133137 ld .modify (change );
134138 } catch (LdapException e ) {
135- DEBUG .warning ("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}" , change , e );
139+ DEBUG .error ("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}" , change , e );
140+ return new IOException (String .format ("LDAPUtils.createSchemaFromLDIF - " +
141+ "Could not modify schema: %s; ex: %s" , change , e ));
136142 }
137143 return null ;
138144 }
139145
140146 @ Override
141- public Void visitChangeRecord (Void aVoid , ModifyDNRequest change ) {
147+ public IOException visitChangeRecord (Void aVoid , ModifyDNRequest change ) {
142148 return null ;
143149 }
144150
145151 @ Override
146- public Void visitChangeRecord (Void aVoid , DeleteRequest change ) {
152+ public IOException visitChangeRecord (Void aVoid , DeleteRequest change ) {
147153 DEBUG .message ("Delete request ignored: {}" , changeRecord );
148154 return null ;
149155 }
150156
151157 }, null );
158+
159+ if (resultException != null ) {
160+ throw resultException ;
161+ }
152162 }
153163 }
154164
0 commit comments