| | |
| | | import java.io.Reader; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.asn1.ASN1Element; |
| | |
| | | */ |
| | | private static final String CLASS_NAME = "org.opends.server.tools.LDAPDelete"; |
| | | |
| | | |
| | | |
| | | // The message ID counter to use for requests. |
| | | private AtomicInteger nextMessageID; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructor for the LDAPDelete object. |
| | | * |
| | | * @param nextMessageID The next message ID to use for requests. |
| | | */ |
| | | public LDAPDelete() |
| | | public LDAPDelete(AtomicInteger nextMessageID) |
| | | { |
| | | this.nextMessageID = nextMessageID; |
| | | } |
| | | |
| | | /** |
| | |
| | | LDAPDeleteOptions deleteOptions) |
| | | throws IOException, LDAPException |
| | | { |
| | | int messageID = 1; |
| | | for(String line : lines) |
| | | { |
| | | executeDelete(connection, line, messageID, deleteOptions); |
| | | messageID++; |
| | | executeDelete(connection, line, deleteOptions); |
| | | } |
| | | } |
| | | |
| | |
| | | LDAPDeleteOptions deleteOptions) |
| | | throws IOException, LDAPException |
| | | { |
| | | int messageID = 1; |
| | | BufferedReader in = new BufferedReader(reader); |
| | | String line = null; |
| | | |
| | | while ((line = in.readLine()) != null) |
| | | { |
| | | executeDelete(connection, line, messageID, deleteOptions); |
| | | messageID++; |
| | | executeDelete(connection, line, deleteOptions); |
| | | } |
| | | in.close(); |
| | | } |
| | |
| | | * |
| | | * @param connection The connection to use to execute the request. |
| | | * @param line The DN to delete. |
| | | * @param messageID The messageID for the request. |
| | | * @param deleteOptions The list of constraints for this request. |
| | | * |
| | | * @throws IOException If a problem occurs while attempting to communicate |
| | |
| | | * @throws LDAPException If the Directory Server returns an error response. |
| | | */ |
| | | private void executeDelete(LDAPConnection connection, String line, |
| | | int messageID, LDAPDeleteOptions deleteOptions) |
| | | LDAPDeleteOptions deleteOptions) |
| | | throws IOException, LDAPException |
| | | { |
| | | ArrayList<LDAPControl> controls = deleteOptions.getControls(); |
| | |
| | | System.out.println(getMessage(msgID, "DELETE", asn1OctetStr)); |
| | | if(!deleteOptions.showOperations()) |
| | | { |
| | | LDAPMessage message = new LDAPMessage(messageID, protocolOp, controls); |
| | | LDAPMessage message = new LDAPMessage(nextMessageID.getAndIncrement(), |
| | | protocolOp, controls); |
| | | LDAPMessage responseMessage = null; |
| | | try |
| | | { |
| | |
| | | connectionOptions.setSSLConnectionFactory(sslConnectionFactory); |
| | | } |
| | | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | LDAPDelete ldapDelete = new LDAPDelete(); |
| | | LDAPDelete ldapDelete = new LDAPDelete(nextMessageID); |
| | | if(fileNameValue == null && dnStrings.isEmpty()) |
| | | { |
| | | // Read from stdin. |