示例#1
0
 @Override
 public void execute(LDAPConnection connection) throws NetworkErrorException {
   try {
     this.result = new LDAPResult(connection.add(m_dn, m_attributes));
   } catch (LDAPException e) {
     this.result = new LDAPResult(e.toLDAPResult());
     if (isNetworkError(e.getResultCode())) {
       throw new NetworkErrorException(e.getMessage());
     }
   }
 }
示例#2
0
 private Filter createAnyFilterByUrls(List<String> p_scopeUrls) {
   try {
     if (p_scopeUrls != null && !p_scopeUrls.isEmpty()) {
       final StringBuilder sb = new StringBuilder("(|");
       for (String url : p_scopeUrls) {
         sb.append("(");
         sb.append("oxUrl=");
         sb.append(url);
         sb.append(")");
       }
       sb.append(")");
       final String filterAsString = sb.toString();
       log.trace("Uma scope urls: " + p_scopeUrls + ", ldapFilter: " + filterAsString);
       return Filter.create(filterAsString);
     }
   } catch (LDAPException e) {
     log.error(e.getMessage(), e);
   }
   return null;
 }
示例#3
0
  /** {@inheritDoc} */
  @Override()
  public void runJob() {
    String jobID = getJobID();
    String prefix = rdnAttribute + '=' + rdnValuePrefix;
    String dnSuffix = rdnValueSuffix + ',' + parentDN;
    String newRDNSuffix = rdnValueSuffix + '-' + jobID;

    StringBuilder dnBuffer = new StringBuilder();
    StringBuilder newRDNBuffer = new StringBuilder();

    modDNsCompleted.startTracker();
    modDNTimer.startTracker();
    resultCodes.startTracker();
    modDNsExceedingThreshold.startTracker();

    // Iterate through the entries to rename them to include the job ID.
    while (!shouldStop()) {
      if (rateLimiter != null) {
        if (rateLimiter.await()) {
          continue;
        }
      }

      long opStartTime = System.currentTimeMillis();
      int i = entryNumber.getAndIncrement();
      if (i > upperBound) {
        break;
      }

      dnBuffer.setLength(0);
      dnBuffer.append(prefix);
      dnBuffer.append(i);
      dnBuffer.append(dnSuffix);

      newRDNBuffer.setLength(0);
      newRDNBuffer.append(prefix);
      newRDNBuffer.append(i);
      newRDNBuffer.append(newRDNSuffix);

      modDNTimer.startTimer();

      try {
        LDAPResult modDNResult = conn.modifyDN(dnBuffer.toString(), newRDNBuffer.toString(), true);
        resultCodes.increment(modDNResult.getResultCode().toString());
      } catch (LDAPException le) {
        resultCodes.increment(le.getResultCode().toString());
      } finally {
        modDNTimer.stopTimer();
        modDNsCompleted.increment();

        if ((responseTimeThreshold > 0)
            && (modDNTimer.getLastOperationTime() > responseTimeThreshold)) {
          modDNsExceedingThreshold.increment();
        }
      }

      if (timeBetweenRequests > 0) {
        long elapsedTime = System.currentTimeMillis() - opStartTime;
        long sleepTime = timeBetweenRequests - elapsedTime;
        if (sleepTime > 0) {
          try {
            Thread.sleep(sleepTime);
          } catch (Exception e) {
          }
        }
      }
    }

    // Wait until all of the threads have completed the first modify DN before
    // starting the second.
    int remainingActive = activeThreads.decrementAndGet();
    if (remainingActive == 0) {
      entryNumber.set(lowerBound);
      activeThreads.decrementAndGet();
    } else {
      while (activeThreads.get() >= 0) {
        try {
          Thread.sleep(0, 1);
        } catch (Exception e) {
        }
      }
    }

    // Iterate through the entries to rename them to remove the job ID.
    dnSuffix = rdnValueSuffix + '-' + jobID + ',' + parentDN;
    newRDNSuffix = rdnValueSuffix;
    while (!shouldStop()) {
      if (rateLimiter != null) {
        if (rateLimiter.await()) {
          continue;
        }
      }

      long opStartTime = System.currentTimeMillis();
      int i = entryNumber.getAndIncrement();
      if (i > upperBound) {
        break;
      }

      dnBuffer.setLength(0);
      dnBuffer.append(prefix);
      dnBuffer.append(i);
      dnBuffer.append(dnSuffix);

      newRDNBuffer.setLength(0);
      newRDNBuffer.append(prefix);
      newRDNBuffer.append(i);
      newRDNBuffer.append(newRDNSuffix);

      modDNTimer.startTimer();

      try {
        LDAPResult modDNResult = conn.modifyDN(dnBuffer.toString(), newRDNBuffer.toString(), true);
        resultCodes.increment(modDNResult.getResultCode().toString());
      } catch (LDAPException le) {
        resultCodes.increment(le.getResultCode().toString());
      } finally {
        modDNTimer.stopTimer();
        modDNsCompleted.increment();

        if ((responseTimeThreshold > 0)
            && (modDNTimer.getLastOperationTime() > responseTimeThreshold)) {
          modDNsExceedingThreshold.increment();
        }
      }

      if (timeBetweenRequests > 0) {
        long elapsedTime = System.currentTimeMillis() - opStartTime;
        long sleepTime = timeBetweenRequests - elapsedTime;
        if (sleepTime > 0) {
          try {
            Thread.sleep(sleepTime);
          } catch (Exception e) {
          }
        }
      }
    }

    modDNsCompleted.stopTracker();
    modDNTimer.stopTracker();
    resultCodes.stopTracker();
    modDNsExceedingThreshold.stopTracker();
  }