| | |
| | | |
| | | import org.opends.server.controls.*; |
| | | import org.opends.server.controls.ProxiedAuthV2Control; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.plugins.ChangeNumberControlPlugin; |
| | | import org.opends.server.protocols.asn1.ASN1Exception; |
| | | import org.opends.server.protocols.ldap.AddRequestProtocolOp; |
| | |
| | | import org.opends.server.util.args.StringArgument; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | */ |
| | | public class LDAPModify |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The fully-qualified name of this class. |
| | |
| | | reader = new LDIFReader(importConfig); |
| | | } catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | LocalizableMessage message = |
| | | ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ.get(fileNameValue, |
| | | e.getLocalizedMessage()); |
| | |
| | | entry = reader.readChangeRecord(modifyOptions.getDefaultAdd()); |
| | | } catch (LDIFException le) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, le); |
| | | } |
| | | logger.traceException(le); |
| | | if (!modifyOptions.continueOnError()) |
| | | { |
| | | try |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | LocalizableMessage message = ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get( |
| | |
| | | } |
| | | } catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | |
| | | if (!modifyOptions.continueOnError()) |
| | | { |
| | |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e2); |
| | | } |
| | | logger.traceException(e2); |
| | | } |
| | | |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | break; |
| | |
| | | responseMessage = connection.getLDAPReader().readMessage(); |
| | | } catch(ASN1Exception ae) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ae); |
| | | } |
| | | logger.traceException(ae); |
| | | LocalizableMessage message = INFO_OPERATION_FAILED.get(operationType); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | |
| | | // This shouldnt happen but if it does debug |
| | | // log it, set the error code to OTHER and |
| | | // fall thru. |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ce); |
| | | } |
| | | logger.traceException(ce); |
| | | resultCode = ResultCode.OTHER.getIntValue(); |
| | | errorMessage = null; |
| | | matchedDN = null; |
| | |
| | | portNumber = port.getIntValue(); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ae); |
| | | } |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ae); |
| | | } |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | bindPasswordValue = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, ex); |
| | | } |
| | | logger.traceException(ex); |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | ldapModify.readAndExecute(connection, fileNameValue, modifyOptions); |
| | | } catch(LDAPException le) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, le); |
| | | } |
| | | logger.traceException(le); |
| | | LDAPToolUtils.printErrorMessage(err, le.getMessageObject(), |
| | | le.getResultCode(), |
| | | le.getErrorMessage(), le.getMatchedDN()); |
| | |
| | | return code; |
| | | } catch(LDAPConnectionException lce) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, lce); |
| | | } |
| | | logger.traceException(lce); |
| | | LDAPToolUtils.printErrorMessage(err, lce.getMessageObject(), |
| | | lce.getResultCode(), |
| | | lce.getErrorMessage(), |
| | |
| | | return code; |
| | | } catch (FileNotFoundException fe) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, fe); |
| | | } |
| | | logger.traceException(fe); |
| | | err.println(wrapText(fe.getMessage(), MAX_LINE_WIDTH)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } catch(Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | return OPERATIONS_ERROR; |
| | | } finally |