| | |
| | | } |
| | | |
| | | private static final CountDownLatch COMPLETION_LATCH = new CountDownLatch(1); |
| | | private static final CountDownLatch CANCEL_LATCH = new CountDownLatch(1); |
| | | private static final LDIFEntryWriter WRITER = new LDIFEntryWriter(System.out); |
| | | private static String userName; |
| | | private static String password; |
| | |
| | | public void handleErrorResult(final ErrorResultException error) { |
| | | System.err.println("Cancel request failed with result code: " |
| | | + error.getResult().getResultCode().intValue()); |
| | | CANCEL_LATCH.countDown(); |
| | | } |
| | | |
| | | @Override |
| | | public void handleResult(final ExtendedResult result) { |
| | | System.err.println("Cancel request succeeded"); |
| | | CANCEL_LATCH.countDown(); |
| | | } |
| | | |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | // Await completion of the cancel request. |
| | | try { |
| | | CANCEL_LATCH.await(); |
| | | } catch (final InterruptedException e) { |
| | | System.err.println(e.getMessage()); |
| | | System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue()); |
| | | return; |
| | | } |
| | | |
| | | if (connection != null) { |
| | | connection.close(); |
| | | } |