private ManagedSystemInfo lookupManagedSystemInfo(ISource S) throws AdeException {
  ManagedSystemInfo M=null;
  final String MANAGED_QUERY=String.format("SELECT * FROM MANAGED_SYSTEMS WHERE SOURCE_INTERNAL_ID=%s",S.getSourceInternalId());
  ResultSet R=null;
  String osName;
  int gmtOffset;
  logger.trace(String.format("lookupManagedSystemInfo(%s) -->entry",S.getSourceId()));
  try {
    R=executeScrollInsensitiveQuery(MANAGED_QUERY);
    if (R == null) {
      final String msg=String.format("lookupManagedSystemInfo(%s) - unexpected null (ResultSet)",S.getSourceId());
      logger.error(msg);
      throw new AdeInternalException(msg);
    }
    if (ExtDataStoreUtils.nonemptyQueryResult(R)) {
      try {
        R.first();
        gmtOffset=R.getInt("GMT_OFFSET");
        osName=R.getString("OPERATING_SYSTEM");
        M=new ManagedSystemInfo(gmtOffset,osName);
      }
 catch (      Throwable t) {
        final String msg=String.format("lookupManagedSystemInfo(%s) - (ResultSet) extract error",S.getSourceId());
        logger.error(msg);
        throw new AdeInternalException(msg,t);
      }
    }
  }
 catch (  AdeException e) {
    throw e;
  }
catch (  Throwable t) {
    final String msg=String.format("lookupManagedSystemInfo(%s) caught unexpected throwable: %s",S.getSourceId(),t.getMessage());
    logger.error(msg);
    throw new AdeInternalException(msg,t);
  }
 finally {
    if (R != null) {
      try {
        R.close();
      }
 catch (      SQLException ex) {
        logger.error("Error encountered closing the ResultSet.",ex);
      }
    }
  }
  logger.trace(String.format("lookupManagedSystemInfo(%s) <--exit",S.getSourceId()));
  return M;
}

private ManagedSystemInfo lookupManagedSystemInfo ( ISource S ) throws AdeException { ManagedSystemInfo M = null ; final String MANAGED_QUERY = String . format ( "SELECT * FROM MANAGED_SYSTEMS WHERE SOURCE_INTERNAL_ID=%s" , S . getSourceInternalId ( ) ) ; ResultSet R = null ; String osName ; int gmtOffset ; logger . trace ( String . format ( "lookupManagedSystemInfo(%s) -->entry" , S . getSourceId ( ) ) ) ; try { R = executeScrollInsensitiveQuery ( MANAGED_QUERY ) ; if ( R == null ) { final String msg = String . format ( "lookupManagedSystemInfo(%s) - unexpected null (ResultSet)" , S . getSourceId ( ) ) ; logger . error ( msg ) ; throw new AdeInternalException ( msg ) ; } if ( ExtDataStoreUtils . nonemptyQueryResult ( R ) ) { try { R . first ( ) ; gmtOffset = R . getInt ( "GMT_OFFSET" ) ; osName = R . getString ( "OPERATING_SYSTEM" ) ; M = new ManagedSystemInfo ( gmtOffset , osName ) ; } catch ( Throwable t ) { final String msg = String . format ( "lookupManagedSystemInfo(%s) - (ResultSet) extract error" , S . getSourceId ( ) ) ; logger . error ( msg ) ; throw new AdeInternalException ( msg , t ) ; } } } catch ( AdeException e ) { throw e ; } catch ( Throwable t ) { final String msg = String . format ( "lookupManagedSystemInfo(%s) caught unexpected throwable: %s" , S . getSourceId ( ) , t . getMessage ( ) ) ; logger . error ( msg ) ; throw new AdeInternalException ( msg , t ) ; } finally { if ( R != null ) { try { R . close ( ) ; } catch ( SQLException ex ) { logger . error ( "Error encountered closing the ResultSet." , ex ) ; } } } logger . trace ( String . format ( "lookupManagedSystemInfo(%s) <--exit" , S . getSourceId ( ) ) ) ; return M ; }
query the analytics database to obtain the current managed system - related information for the managed system designated by the input source . if there is such information in the database , return a second instance of the current class informed by those values , so that the caller knows that it should pursue a " read and perhaps modify database " logic path , based on comparing " this " instance with " that " ( i . e . , to determine what , if any , changes are to be made in the database ) . of course , there may well be no such information , as this may be driven on a " first encounter " , in which case we return a null " that " , and the caller knows that it should pursue a " create various database rows " logic path . special note : practice shows that none of these column values can really be trusted to have content . these are set / reset by various untrusted parties ( e . g . , bulk load ) . it is imperative that a null value be handled and that a non - null object m be returned so that the caller is not mislead into thinking that they need to do a ( erroneous , redundant ) database add operation when in fact the designated managedsystem exists in the database and it is really an update operation that should be performed . hence the super - paranoid try catch logic .
