Search in sources :

Example 16 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getActiveOperationsMonitorEntry.

/**
 * Retrieves the active operations monitor entry from the Directory Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The active operations monitor entry from the Directory Server, or
 *          {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static ActiveOperationsMonitorEntry getActiveOperationsMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", ActiveOperationsMonitorEntry.ACTIVE_OPERATIONS_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getActiveOperationsMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getActiveOperationsMonitorEntry");
    }
    return new ActiveOperationsMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 17 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getGroupCacheMonitorEntry.

/**
 * Retrieves the group cache monitor entry from the Directory Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The group cache monitor entry from the Directory Server, or
 *          {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static GroupCacheMonitorEntry getGroupCacheMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", GroupCacheMonitorEntry.GROUP_CACHE_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getGroupCacheMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in getGroupCacheMonitorEntry");
    }
    return new GroupCacheMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 18 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class MonitorManager method getProcessingTimeHistogramMonitorEntry.

/**
 * Retrieves the processing time histogram monitor entry from the Directory
 * Server.
 *
 * @param  connection  The connection to use to communicate with the Directory
 *                     Server.
 *
 * @return  The processing time histogram monitor entry from the Directory
 *          Server, or {@code null} if it is not available.
 *
 * @throws  LDAPSearchException  If a problem occurs while communicating with
 *                               the Directory Server.
 */
@Nullable()
public static ProcessingTimeHistogramMonitorEntry getProcessingTimeHistogramMonitorEntry(@NotNull final LDAPInterface connection) throws LDAPSearchException {
    final Filter filter = Filter.createEqualityFilter("objectClass", ProcessingTimeHistogramMonitorEntry.PROCESSING_TIME_HISTOGRAM_MONITOR_OC);
    final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
    final int numEntries = searchResult.getEntryCount();
    if (numEntries == 0) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "No entries returned in getProcessingTimeHistogramMonitorEntry");
        return null;
    } else if (numEntries != 1) {
        Debug.debug(Level.FINE, DebugType.MONITOR, "Multiple entries returned in " + "getProcessingTimeHistogramMonitorEntry");
    }
    return new ProcessingTimeHistogramMonitorEntry(searchResult.getSearchEntries().get(0));
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) SearchResult(com.unboundid.ldap.sdk.SearchResult) Nullable(com.unboundid.util.Nullable)

Example 19 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class FileArgument method getFileInputStream.

/**
 * Retrieves an input stream that may be used to read the contents of the file
 * specified as the value to this argument.  If there are multiple values for
 * this argument, then the file specified as the first value will be used.
 *
 * @return  An input stream that may be used to read the data from the file,
 *          or {@code null} if no values were provided.
 *
 * @throws  IOException  If the specified file does not exist or if a problem
 *                       occurs while obtaining the input stream.
 */
@Nullable()
public InputStream getFileInputStream() throws IOException {
    final File f = getValue();
    if (f == null) {
        return null;
    }
    InputStream inputStream = new FileInputStream(f);
    boolean closeStream = true;
    try {
        final List<char[]> potentialPassphrases = new ArrayList<>();
        try {
            final ObjectPair<InputStream, char[]> streamPair = ToolUtils.getPossiblyPassphraseEncryptedInputStream(inputStream, POTENTIAL_PASSPHRASES_TO_AVOID_PROMPTING, false, INFO_FILE_ENTER_ENC_PW.get(f.getAbsolutePath()), ERR_FILE_WRONG_ENC_PW.get(f.getAbsolutePath()), System.out, System.err);
            inputStream = streamPair.getFirst();
        } catch (final GeneralSecurityException e) {
            throw new IOException(ERR_FILE_CANNOT_DECRYPT.get(f.getAbsolutePath(), StaticUtils.getExceptionMessage(e)), e);
        }
        inputStream = ToolUtils.getPossiblyGZIPCompressedInputStream(inputStream);
        closeStream = false;
        return inputStream;
    } finally {
        if (closeStream) {
            inputStream.close();
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) GeneralSecurityException(java.security.GeneralSecurityException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) Nullable(com.unboundid.util.Nullable)

Example 20 with Nullable

use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.

the class InMemoryRequestHandler method handlePreReadControl.

/**
 * Checks to see if the provided control map includes a pre-read request
 * control, and if so then generates the appropriate response control that
 * should be returned to the client.
 *
 * @param  m  The map of request controls, indexed by OID.
 * @param  e  The entry as it appeared before the operation.
 *
 * @return  The pre-read response control that should be returned to the
 *          client, or {@code null} if there is none.
 */
@Nullable()
private PreReadResponseControl handlePreReadControl(@NotNull final Map<String, Control> m, @NotNull final Entry e) {
    final PreReadRequestControl c = (PreReadRequestControl) m.get(PreReadRequestControl.PRE_READ_REQUEST_OID);
    if (c == null) {
        return null;
    }
    final SearchEntryParer parer = new SearchEntryParer(Arrays.asList(c.getAttributes()), schemaRef.get());
    final Entry trimmedEntry = parer.pareEntry(e);
    return new PreReadResponseControl(new ReadOnlyEntry(trimmedEntry));
}
Also used : ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) SearchResultEntry(com.unboundid.ldap.sdk.SearchResultEntry) Entry(com.unboundid.ldap.sdk.Entry) ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) Nullable(com.unboundid.util.Nullable)

Aggregations

Nullable (com.unboundid.util.Nullable)149 ArrayList (java.util.ArrayList)47 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)42 Entry (com.unboundid.ldap.sdk.Entry)30 LDAPException (com.unboundid.ldap.sdk.LDAPException)30 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)21 Attribute (com.unboundid.ldap.sdk.Attribute)21 ASN1Element (com.unboundid.asn1.ASN1Element)20 Filter (com.unboundid.ldap.sdk.Filter)20 SearchResult (com.unboundid.ldap.sdk.SearchResult)18 IOException (java.io.IOException)16 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)14 File (java.io.File)14 DN (com.unboundid.ldap.sdk.DN)12 ArgumentException (com.unboundid.util.args.ArgumentException)10 RDN (com.unboundid.ldap.sdk.RDN)9 LDIFException (com.unboundid.ldif.LDIFException)8 ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)7 Modification (com.unboundid.ldap.sdk.Modification)7 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)7