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));
}
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));
}
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));
}
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();
}
}
}
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));
}
Aggregations