opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -548,7 +548,7 @@ try { String filePath = remainder.substring(1, remainder.length()); attributeVal = LDAPToolUtils.readBytesFromFile(filePath); attributeVal = LDAPToolUtils.readBytesFromFile(filePath, err); } catch (Exception e) { @@ -631,7 +631,7 @@ if(controlStr.hasValue()) { String ctrlString = controlStr.getValue(); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); if(ctrl == null) { err.println("Invalid control specified:" + ctrlString); opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -528,7 +528,7 @@ if(controlStr.hasValue()) { String ctrlString = controlStr.getValue(); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); if(ctrl == null) { err.println("Invalid control specified:" + ctrlString); opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -810,7 +810,7 @@ if(controlStr.hasValue()) { String ctrlString = controlStr.getValue(); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); if(ctrl == null) { err.println("Invalid control specified:" + ctrlString); opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -839,12 +839,12 @@ err.println(ex1.getMessage()); return 1; } boolean val = searchOptions.setSearchScope(searchScope.getValue()); boolean val = searchOptions.setSearchScope(searchScope.getValue(), err); if(val == false) { return 1; } val = searchOptions.setDereferencePolicy(dereferencePolicy.getValue()); val = searchOptions.setDereferencePolicy(dereferencePolicy.getValue(), err); if(val == false) { return 1; @@ -853,7 +853,7 @@ if(controlStr.hasValue()) { String ctrlString = controlStr.getValue(); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); if(ctrl == null) { err.println("Invalid control specified:" + ctrlString); opends/src/server/org/opends/server/tools/LDAPSearchOptions.java
@@ -26,6 +26,8 @@ */ package org.opends.server.tools; import java.io.PrintStream; import org.opends.server.types.DereferencePolicy; import org.opends.server.types.SearchScope; @@ -112,12 +114,14 @@ * Set the search scope . * * @param scope The search scope string. * @param err A print stream to which error messages should be written if * a problem occurs. * * @return <CODE>true</CODE> if the scope was set properly, or * <CODE>false</CODE> if not. */ public boolean setSearchScope(String scope) public boolean setSearchScope(String scope, PrintStream err) { if(scope == null) { @@ -138,7 +142,7 @@ } else { int msgID = MSGID_SEARCH_INVALID_SEARCH_SCOPE; System.err.println(getMessage(msgID, scope)); err.println(getMessage(msgID, scope)); return false; } return true; @@ -157,13 +161,15 @@ /** * Set the dereference policy. * * @param policy The dereference policy. * @param policy The dereference policy. * @param err A print stream to which error messages should be written if * a problem occurs. * * @return <CODE>true</CODE> if the dereference policy was set properly, or * <CODE>false</CODE> if not. */ public boolean setDereferencePolicy(String policy) public boolean setDereferencePolicy(String policy, PrintStream err) { if(policy == null) { @@ -182,7 +188,7 @@ dereferencePolicy = DEREF_FINDING_BASE_OBJECT; } else { System.err.println("Invalid deref alias specified:" + policy); err.println("Invalid deref alias specified:" + policy); return false; } return true; opends/src/server/org/opends/server/tools/LDAPToolUtils.java
@@ -29,6 +29,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintStream; import org.opends.server.protocols.asn1.ASN1OctetString; import org.opends.server.protocols.ldap.LDAPControl; @@ -56,11 +57,13 @@ * * @param argString The argument string containing the encoded control * information. * @param err A print stream to which error messages should be * written if a problem occurs. * * @return The control decoded from the provided string, or <CODE>null</CODE> * if an error occurs while parsing the argument value. */ public static LDAPControl getControl(String argString) public static LDAPControl getControl(String argString, PrintStream err) { LDAPControl control = null; String controlOID = null; @@ -88,7 +91,7 @@ controlCriticality = false; } else { System.err.println("Invalid format for criticality value:" + remainder); err.println("Invalid format for criticality value:" + remainder); return null; } control = new LDAPControl(controlOID, controlCriticality); @@ -105,7 +108,7 @@ controlCriticality = false; } else { System.err.println("Invalid format for criticality value:" + critical); err.println("Invalid format for criticality value:" + critical); return null; } @@ -117,10 +120,10 @@ } else if(valString.charAt(0) == '<') { // Read data from the file. String fileURL = valString.substring(1, valString.length()); String filePath = valString.substring(1, valString.length()); try { byte[] val = readBytesFromFile(fileURL); byte[] val = readBytesFromFile(filePath, err); controlValue = new ASN1OctetString(val); } catch (Exception e) @@ -140,14 +143,16 @@ /** * Read the data from the specified file and return it in a byte array. * * @param filePath The path to the file that should be read. * @param filePath The path to the file that should be read. * @param err A print stream to which error messages should be * written if a problem occurs. * * @return A byte array containing the contents of the requested file. * * @throws IOException If a problem occurs while trying to read the * specified file. */ public static byte[] readBytesFromFile(String filePath) public static byte[] readBytesFromFile(String filePath, PrintStream err) throws IOException { byte[] val = null; @@ -169,7 +174,7 @@ // Ensure all the bytes have been read in if (offset < val.length) { System.err.println("Could not completely read file "+filePath); err.println("Could not completely read file "+filePath); return null; }