Skip to content

Commit 5fef70c

Browse files
authored
[#859] Warn and continue loading LDIF schemas on install (#860)
1 parent 385197d commit 5fef70c

File tree

3 files changed

+68
-18
lines changed

3 files changed

+68
-18
lines changed

openam-core/src/main/java/com/sun/identity/setup/AMSetupDSConfig.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* $Id: AMSetupDSConfig.java,v 1.20 2009/11/20 23:52:55 ww203982 Exp $
2626
*
2727
* Portions Copyrighted 2011-2016 ForgeRock AS.
28+
* Portions Copyrighted 2025 3A Systems LLC.
2829
*/
2930
package com.sun.identity.setup;
3031

@@ -43,6 +44,7 @@
4344
import java.util.concurrent.TimeUnit;
4445

4546
import org.forgerock.openam.ldap.LDAPRequests;
47+
import org.forgerock.openam.ldap.LDAPSchemaModificationException;
4648
import org.forgerock.openam.ldap.LDAPUtils;
4749
import org.forgerock.openam.ldap.LdifUtils;
4850
import org.forgerock.opendj.ldap.Connection;
@@ -245,24 +247,27 @@ String isDITLoaded(boolean ssl) {
245247
*/
246248
public void loadSchemaFiles(List schemaFiles)
247249
throws ConfiguratorException {
248-
try {
249-
for (Iterator i = schemaFiles.iterator(); i.hasNext(); ) {
250-
String file = (String)i.next();
251-
int idx = file.lastIndexOf("/");
252-
String schemaFile = (idx != -1) ? file.substring(idx+1) : file;
253-
Object[] params = {schemaFile};
254-
SetupProgress.reportStart("emb.loadingschema", params);
250+
251+
for (Iterator i = schemaFiles.iterator(); i.hasNext(); ) {
252+
String file = (String) i.next();
253+
int idx = file.lastIndexOf("/");
254+
String schemaFile = (idx != -1) ? file.substring(idx + 1) : file;
255+
Object[] params = {schemaFile};
256+
SetupProgress.reportStart("emb.loadingschema", params);
257+
try {
255258
LdifUtils.createSchemaFromLDIF(basedir + "/" + schemaFile, ld.getConnection());
256259
SetupProgress.reportEnd("emb.success", null);
260+
} catch (IOException e) {
261+
Debug.getInstance(SetupConstants.DEBUG_NAME).error(
262+
"AMSetupDSConfig.loadSchemaFiles:failed", e);
263+
SetupProgress.reportEnd("emb.failed", null);
264+
InstallLog.getInstance().write(
265+
"AMSetupDSConfig.loadSchemaFiles:failed", e);
266+
if(!(e instanceof LDAPSchemaModificationException)) {
267+
throw new ConfiguratorException("configurator.ldiferror",
268+
null, locale);
269+
}
257270
}
258-
} catch (IOException e) {
259-
Debug.getInstance(SetupConstants.DEBUG_NAME).error(
260-
"AMSetupDSConfig.loadSchemaFiles:failed", e);
261-
SetupProgress.reportEnd("emb.failed", null);
262-
InstallLog.getInstance().write(
263-
"AMSetupDSConfig.loadSchemaFiles:failed", e);
264-
throw new ConfiguratorException("configurator.ldiferror",
265-
null, locale);
266271
}
267272
}
268273

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* The contents of this file are subject to the terms of the Common Development and
3+
* Distribution License (the License). You may not use this file except in compliance with the
4+
* License.
5+
*
6+
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7+
* specific language governing permission and limitations under the License.
8+
*
9+
* When distributing Covered Software, include this CDDL Header Notice in each file and include
10+
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11+
* Header, with the fields enclosed by brackets [] replaced by your own identifying
12+
* information: "Portions copyright [year] [name of copyright owner]".
13+
*
14+
* Copyright 2025 3A Systems LLC.
15+
*/
16+
17+
package org.forgerock.openam.ldap;
18+
19+
import java.io.IOException;
20+
21+
/**
22+
* Exception thrown when an LDAP schema modification fails.
23+
*/
24+
public class LDAPSchemaModificationException extends IOException {
25+
26+
/**
27+
* Constructs a new exception with the specified detail message.
28+
*
29+
* @param message The detail message explaining the error.
30+
*/
31+
public LDAPSchemaModificationException(String message) {
32+
super(message);
33+
}
34+
35+
/**
36+
* Constructs a new exception with the specified detail message
37+
* and cause of the error.
38+
*
39+
* @param message The detail message explaining the error.
40+
* @param cause The cause of the error (can be null).
41+
*/
42+
public LDAPSchemaModificationException(String message, Throwable cause) {
43+
super(message, cause);
44+
}
45+
}

openam-ldap-utils/src/main/java/org/forgerock/openam/ldap/LdifUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ public IOException visitChangeRecord(Void aVoid, AddRequest change) {
117117
} catch (LdapException ex) {
118118
DEBUG.error("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}",
119119
modifyRequest, ex);
120-
return new IOException(String.format("LDAPUtils.createSchemaFromLDIF - " +
120+
return new LDAPSchemaModificationException(String.format("LDAPUtils.createSchemaFromLDIF - " +
121121
"Could not modify schema: %s; ex: %s", modifyRequest, ex));
122122
}
123123
}
124124
} else {
125125
DEBUG.error("LDAPUtils.createSchemaFromLDIF - Could not add to schema: {}", change, e);
126-
return new IOException(String.format("LDAPUtils.createSchemaFromLDIF - " +
126+
return new LDAPSchemaModificationException(String.format("LDAPUtils.createSchemaFromLDIF - " +
127127
"Could not add to schema: %s; ex: %s", change, e));
128128
}
129129
}
@@ -138,7 +138,7 @@ public IOException visitChangeRecord(Void aVoid, ModifyRequest change) {
138138
ld.modify(change);
139139
} catch (LdapException e) {
140140
DEBUG.error("LDAPUtils.createSchemaFromLDIF - Could not modify schema: {}", change, e);
141-
return new IOException(String.format("LDAPUtils.createSchemaFromLDIF - " +
141+
return new LDAPSchemaModificationException(String.format("LDAPUtils.createSchemaFromLDIF - " +
142142
"Could not modify schema: %s; ex: %s", change, e));
143143
}
144144
return null;

0 commit comments

Comments
 (0)