From b3e481095aa2c24189ed0435e921dc021054cd2d Mon Sep 17 00:00:00 2001
From: Mark Craig <mark.craig@forgerock.com>
Date: Fri, 11 May 2012 08:03:11 +0000
Subject: [PATCH] Cleanup
---
opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java | 125 ++++++++++++++++++-------------
opendj-sdk/opendj3/src/main/docbkx/dev-guide/chap-controls.xml | 92 +++++++++++-----------
2 files changed, 119 insertions(+), 98 deletions(-)
diff --git a/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
index 20dc662..bc7d773 100644
--- a/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
+++ b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
@@ -184,7 +184,8 @@
writer.writeEntry(connection.readEntry(dn, "description"));
writer.close();
} catch (final IOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("AssertionRequestControl not supported.");
@@ -219,7 +220,8 @@
System.out.println("Authorization ID returned: "
+ control.getAuthorizationID());
} catch (final DecodeException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
} else {
System.err.println("AuthorizationIdentityRequestControl not supported.");
@@ -237,8 +239,7 @@
* @throws ErrorResultException
* Operation failed.
*/
- static void useGetEffectiveRightsRequestControl(Connection connection)
- throws ErrorResultException {
+ static void useGetEffectiveRightsRequestControl(Connection connection) throws ErrorResultException {
if (isSupported(GetEffectiveRightsRequestControl.OID)) {
final String authDN = "uid=kvaughan,ou=People,dc=example,dc=com";
@@ -260,11 +261,13 @@
}
writer.close();
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(e.getCause().getResult().getResultCode().intValue());
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ System.err.println("Got search reference(s): " + e.getReference().getURIs().toString());
} catch (final IOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("GetEffectiveRightsRequestControl not supported.");
@@ -305,11 +308,13 @@
writer.writeEntry(entry);
writer.close();
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(e.getCause().getResult().getResultCode().intValue());
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ System.err.println("Got search reference(s): " + e.getReference().getURIs().toString());
} catch (final IOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("ManageDsaITRequestControl not supported.");
@@ -343,7 +348,8 @@
writer.writeEntry(entry);
writer.close();
} catch (final IOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("MatchedValuesRequestControl not supported.");
@@ -367,7 +373,7 @@
try {
connection.bind(dn, pwd);
- } catch (ErrorResultException e) {
+ } catch (final ErrorResultException e) {
final Result result = e.getResult();
try {
final PasswordExpiredResponseControl control =
@@ -376,8 +382,9 @@
if (!(control == null) && control.hasValue()) {
System.out.println("Password expired for " + dn);
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ System.err.println(de.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
}
} else {
@@ -398,8 +405,7 @@
* @throws ErrorResultException
* Operation failed.
*/
- static void usePasswordExpiringResponseControl(Connection connection)
- throws ErrorResultException {
+ static void usePasswordExpiringResponseControl(Connection connection) throws ErrorResultException {
if (isSupported(PasswordExpiringResponseControl.OID)) {
final String dn = "uid=bjensen,ou=People,dc=example,dc=com";
final char[] pwd = "hifalutin".toCharArray();
@@ -413,8 +419,9 @@
System.out.println("Password for " + dn + " expires in "
+ control.getSecondsUntilExpiration() + " seconds.");
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ System.err.println(de.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
} else {
System.err.println("PasswordExpiringResponseControl not supported");
@@ -451,7 +458,7 @@
+ control.getWarningType().toString() + ", value "
+ control.getWarningValue() + " for " + dn);
}
- } catch (ErrorResultException e) {
+ } catch (final ErrorResultException e) {
final Result result = e.getResult();
try {
final PasswordPolicyResponseControl control =
@@ -461,11 +468,13 @@
System.out.println("Password policy error "
+ control.getErrorType().toString() + " for " + dn);
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ System.err.println(de.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
} else {
System.err.println("PasswordPolicyRequestControl not supported");
@@ -483,8 +492,7 @@
* @throws ErrorResultException
* Operation failed.
*/
- static void usePermissiveModifyRequestControl(Connection connection)
- throws ErrorResultException {
+ static void usePermissiveModifyRequestControl(Connection connection) throws ErrorResultException {
if (isSupported(PermissiveModifyRequestControl.OID)) {
final String dn = "uid=bjensen,ou=People,dc=example,dc=com";
@@ -553,11 +561,13 @@
}
}
} catch (final DecodeException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ System.err.println(e.getMessage());
+ System.exit(e.getCause().getResult().getResultCode().intValue());
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ System.err.println("Got search reference(s): " + e.getReference().getURIs().toString());
}
} else {
System.err.println("PersistentSearchRequestControl not supported.");
@@ -595,10 +605,12 @@
final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
writer.writeEntry(entry);
writer.close();
- } catch (DecodeException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
+ } catch (final IOException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("PostReadRequestControl not supported");
@@ -635,10 +647,12 @@
final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
writer.writeEntry(entry);
writer.close();
- } catch (DecodeException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
+ } catch (final IOException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("PreReadRequestControl not supported");
@@ -675,8 +689,9 @@
try {
writer.writeEntry(entry);
writer.close();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final IOException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("ProxiedAuthV2RequestControl not supported");
@@ -713,8 +728,9 @@
} else {
System.out.println("# Entries not necessarily sorted");
}
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
} else {
System.err.println("ServerSideSortRequestControl not supported");
@@ -739,8 +755,9 @@
try {
writer.writeEntry(entry);
writer.flush();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final IOException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
return true;
}
@@ -785,8 +802,9 @@
result.getControl(SimplePagedResultsControl.DECODER,
new DecodeOptions());
cookie = control.getCookie();
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
++page;
@@ -825,12 +843,14 @@
}
}
writer.close();
- } catch (ErrorResultIOException e) {
- e.printStackTrace();
- } catch (SearchResultReferenceIOException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final ErrorResultIOException e) {
+ System.err.println(e.getMessage());
+ System.exit(e.getCause().getResult().getResultCode().intValue());
+ } catch (final SearchResultReferenceIOException e) {
+ System.err.println("Got search reference(s): " + e.getReference().getURIs().toString());
+ } catch (final IOException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
}
} else {
System.err.println("SubentriesRequestControl not supported");
@@ -917,8 +937,9 @@
System.out.println("# Position in list: "
+ vlvControl.getTargetPosition() + "/"
+ vlvControl.getContentCount());
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_DECODING_ERROR.intValue());
}
} else {
System.err.println("VirtualListViewRequestControl not supported");
diff --git a/opendj-sdk/opendj3/src/main/docbkx/dev-guide/chap-controls.xml b/opendj-sdk/opendj3/src/main/docbkx/dev-guide/chap-controls.xml
index 952b498..7aef6d0 100644
--- a/opendj-sdk/opendj3/src/main/docbkx/dev-guide/chap-controls.xml
+++ b/opendj-sdk/opendj3/src/main/docbkx/dev-guide/chap-controls.xml
@@ -152,7 +152,7 @@
writer.writeEntry(connection.readEntry(dn, "description"));
writer.close();
} catch (final IOException e) {
- e.printStackTrace();
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -189,7 +189,7 @@
System.out.println("Authorization ID returned: "
+ control.getAuthorizationID());
} catch (final DecodeException e) {
- e.printStackTrace();
+ // Failed to decode the response control.
}
}
</programlisting>
@@ -249,11 +249,11 @@
}
}
} catch (final DecodeException e) {
- e.printStackTrace();
+ // Failed to decode the response control.
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ // Request failed due to an IO problem.
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ // Read a reference, rather than an entry.
}
}
</programlisting>
@@ -306,11 +306,11 @@
}
writer.close();
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ // Request failed due to an IO problem.
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ // Read a reference, rather than an entry.
} catch (final IOException e) {
- e.printStackTrace();
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -411,11 +411,11 @@
writer.writeEntry(entry);
writer.close();
} catch (final ErrorResultIOException e) {
- e.printStackTrace();
+ // Request failed due to an IO problem.
} catch (final SearchResultReferenceIOException e) {
- e.printStackTrace();
+ // Read a reference, rather than an entry.
} catch (final IOException e) {
- e.printStackTrace();
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -460,7 +460,7 @@
writer.writeEntry(entry);
writer.close();
} catch (final IOException e) {
- e.printStackTrace();
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -491,7 +491,7 @@
try {
connection.bind(dn, pwd);
- } catch (ErrorResultException e) {
+ } catch (final ErrorResultException e) {
final Result result = e.getResult();
try {
final PasswordExpiredResponseControl control =
@@ -500,8 +500,8 @@
if (!(control == null) && control.hasValue()) {
System.out.println("Password expired for " + dn);
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ // Failed to decode the response control.
}
}
}
@@ -539,8 +539,8 @@
System.out.println("Password for " + dn + " expires in "
+ control.getSecondsUntilExpiration() + " seconds.");
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ // Failed to decode the response control.
}
}
</programlisting>
@@ -585,7 +585,7 @@
+ control.getWarningType().toString() + ", value "
+ control.getWarningValue() + " for " + dn);
}
- } catch (ErrorResultException e) {
+ } catch (final ErrorResultException e) {
final Result result = e.getResult();
try {
final PasswordPolicyResponseControl control =
@@ -595,11 +595,11 @@
System.out.println("Password policy error "
+ control.getErrorType().toString() + " for " + dn);
}
- } catch (DecodeException de) {
- de.printStackTrace();
+ } catch (final DecodeException de) {
+ // Failed to decode the response control.
}
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
}
}
</programlisting>
@@ -683,10 +683,10 @@
final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
writer.writeEntry(entry);
writer.close();
- } catch (DecodeException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
+ } catch (final IOException e) {
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -725,10 +725,10 @@
final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
writer.writeEntry(entry);
writer.close();
- } catch (DecodeException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
+ } catch (final IOException e) {
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -770,8 +770,8 @@
try {
writer.writeEntry(entry);
writer.close();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final IOException e) {
+ // The writer could not write to System.out.
}
}</programlisting>
@@ -814,8 +814,8 @@
} else {
System.out.println("# Entries not necessarily sorted");
}
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
}
} else {
System.out.println("ServerSideSortRequestControl not supported");
@@ -840,8 +840,8 @@
try {
writer.writeEntry(entry);
writer.flush();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final IOException e) {
+ // The writer could not write to System.out.
}
return true;
}
@@ -918,8 +918,8 @@
result.getControl(SimplePagedResultsControl.DECODER,
new DecodeOptions());
cookie = control.getCookie();
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
}
++page;
@@ -991,12 +991,12 @@
}
}
writer.close();
- } catch (ErrorResultIOException e) {
- e.printStackTrace();
- } catch (SearchResultReferenceIOException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (final ErrorResultIOException e) {
+ // Request failed due to an IO problem.
+ } catch (final SearchResultReferenceIOException e) {
+ // Read a reference, rather than an entry.
+ } catch (final IOException e) {
+ // The writer could not write to System.out.
}
}
</programlisting>
@@ -1100,8 +1100,8 @@
System.out.println("# Position in list: "
+ vlvControl.getTargetPosition() + "/"
+ vlvControl.getContentCount());
- } catch (DecodeException e) {
- e.printStackTrace();
+ } catch (final DecodeException e) {
+ // Failed to decode the response control.
}
}
</programlisting>
--
Gitblit v1.10.0