Find the message application.
@param strDBPrefix The database prefix.
@param strDomain The domain to get the message app for (or default/best guess if null)
@return The message manager or null if no match.
515895
public MessageApp getMessageApplication(String strDBPrefix, String strSubSystem)
    {
        strSubSystem = Utility.getSystemSuffix(strSubSystem, this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME));    // Normalize
        MessageApp messageApplication = null;
		for (int i = 0; i < this.getApplicationCount(); i++)
		{
			App app = this.getApplication(i);
			if (app instanceof MessageApp)
			{
			    Map<String, Object> messageAppProperties = app.getProperties();  // Only message app's properties (not env).
				String strAppDBPrefix = (messageAppProperties == null) ? null : (String)messageAppProperties.get(DBConstants.DB_USER_PREFIX);
				String strAppSubSystem = (messageAppProperties == null) ? null : (String)messageAppProperties.get(DBConstants.SYSTEM_NAME);
				strAppSubSystem = Utility.getSystemSuffix(strAppSubSystem, this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME));    // Normalize
				boolean bDBMatch = false;
				if ((strAppDBPrefix == null) && (strDBPrefix == null))
					bDBMatch = true;
				if (strAppDBPrefix != null)
					if (strAppDBPrefix.equalsIgnoreCase(strDBPrefix))
						bDBMatch = true;
				boolean bSubSystemMatch = false;
				if ((strAppSubSystem == null) && (strSubSystem == null))
					bSubSystemMatch = true;
				if (strAppSubSystem != null)
					if (strAppSubSystem.equalsIgnoreCase(strSubSystem))
						bSubSystemMatch = true;
				if ((bDBMatch) && (bSubSystemMatch))
					messageApplication = (MessageApp)app;
			}
		}
		return messageApplication;
    }
857297
public String getMsgPhrase(final SelectBuilder _selectBldr,
                               final MsgPhrase _msgPhrase)
        throws EFapsException
    {
        final List<Object> objects = new ArrayList<>();
        final String baseSel;
        if (_selectBldr == null) {
            baseSel = "";
        } else {
            baseSel = _selectBldr.toString() + ".";
        }
        boolean allNull = true;
        for (final String select : _msgPhrase.getArguments()) {
            final Object tmpObj = getSelect(baseSel + select);
            allNull = allNull && tmpObj == null;
            objects.add(tmpObj == null ? "" : tmpObj);
        }
        return allNull ? null : _msgPhrase.format(objects.toArray());
    }
1274781
public PDatabase getPDatabase(String strDBName, char charPDatabaseType, boolean bCreateIfNew)
    {
        PDatabase pDB = (PDatabase)m_htDBList.get(charPDatabaseType + ":" + strDBName);
        if (pDB == null)
            if (bCreateIfNew)
        {
            String strClassName = (String)this.getProperty(DBCLASS);
            if (strClassName != null)
            {
                try
                {
                    Class<?> c = Class.forName(strClassName);
                    if (c != null)
                    {
                        pDB = (PDatabase)c.newInstance();
                        if (pDB != null)
                        {
                            pDB.init(this, strDBName, charPDatabaseType);
                            String strPrefix = (String)this.getProperty(PREFIX);
                            String strSuffix = (String)this.getProperty(SUFFIX);
                            if ((strPrefix != null) || (strSuffix != null))
                                pDB.setFilePath(strPrefix, strSuffix);
                        }
                    }
                }
                catch (Exception e) {
                    e.printStackTrace();
                    pDB = null;
                }
            }
        }
        return pDB;
    }
874847
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
  {
  global $php_errormsg;

    if (!function_exists('ads_connect')) return null;

    if (isset($php_errormsg)) $php_errormsg = '';
    $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
    if ($this->debug && $argDatabasename) {
            ADOConnection::outp("For PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
    }
  //  print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
    if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
    else $this->_connectionID = ads_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);

    $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
    if ($this->_connectionID && $this->autoRollback) @ads_rollback($this->_connectionID);
    if (isset($this->connectStmt)) $this->Execute($this->connectStmt);

    return $this->_connectionID != false;
  }
749204
public MessageProcessInfoModel getMessageProcessInfo(String strMessageInfoType, String strContactType, String strRequestType, String strMessageProcessType, String strProcessType)
    {
        return null;    // No thin impl
    }
388570
public String app() {
    if (d1 < 0) {
      // No stack or detail is present
      return asg.length() > 0 ? asg : null;
    } else if (d1 == 0) {
      // Application portion is empty
      return null;
    } else {
      // Application is present along with stack, detail, or sequence
      return substr(asg, 0, d1);
    }
  }
712263
private function getMessageHeader(AMQPMessage $message, $header)
    {
        $headers = $message->has('application_headers') ? $message->get('application_headers') : [];

        return array_key_exists($header, $headers) ? $headers[$header] : null;
    }
423341
public StringBuffer getMessageKey(StringBuffer sb)
    {
        if (sb == null)
            sb = new StringBuffer();
        if (m_messageDataDescChildren != null)
        {
            for (String strKey : m_messageDataDescChildren.keySet())
            {
                MessageDataDesc messageDataDesc = m_messageDataDescChildren.get(strKey);
                messageDataDesc.getMessageKey(sb);
            }
        }
        return sb;
    }
1035102
public BaseMessage getTargetMessage()
    {
        if (m_trxMessage == null)
            if (this.getProperties() != null)   // NOTE: I remove message from the properties
                m_trxMessage = (BaseMessage)this.getProperties().remove(DBParams.MESSAGE);
        return m_trxMessage;
    }
896764
public MessageManager getMessageManager(App application, boolean bCreateIfNotFound)
    {
    	if (application == null)
    		application = this.getDefaultApplication();
        if (this.getMessageApplication(bCreateIfNotFound, application.getProperties()) != null)
            return this.getMessageApplication(bCreateIfNotFound, application.getProperties()).getThickMessageManager();
        return null;
    }
380657
public String getRootCauseMessage() {
        String rcmessage = null;
        if (getRootCause() != null) {
            if (getRootCause().getCause() != null) {
                rcmessage = getRootCause().getCause().getMessage();
            }
            rcmessage = rcmessage == null ? getRootCause().getMessage() : rcmessage;
            rcmessage = rcmessage == null ? super.getMessage() : rcmessage;
            rcmessage = rcmessage == null ? "NONE" : rcmessage;
        }
        return rcmessage;
    }
698629
public CharSequence app() {
    if (d1 < 0) {
      // No stack or detail is present
      return asg.length() > 0 ? asg : null;
    } else if (d1 == 0) {
      // Application portion is empty
      return null;
    } else {
      // Application is present along with stack, detail, or sequence
      return substr(asg, 0, d1);
    }
  }
1229598
protected String getMessage(final SmsSendRequestDto smsSendRequestDto) {
    if (StringUtils.isNotBlank(smsSendRequestDto.getMessage())) {
      return smsSendRequestDto.getMessage();
    }
    Validate.notEmpty(defaultMessage, "defaultMessage must not be null or blank");
    return defaultMessage;
  }
502772
public BaseMessage getMessage()
    {
        String strTrxID = this.getProperty(TrxMessageHeader.LOG_TRX_ID);
        if (m_strTrxID != null)
            if (m_strTrxID.equalsIgnoreCase(strTrxID))
                return m_message;   // Cached message is what you are looking for.
        m_strTrxID = null;
        m_message = null;
        if (strTrxID != null)
        {   // Good, they are referencing a transaction (access the transaction properties).
            MessageLogModel recMessageLog = (MessageLogModel)this.getRecord(MessageLogModel.MESSAGE_LOG_FILE);
            if (recMessageLog == null)
                recMessageLog = (MessageLogModel)Record.makeRecordFromClassName(MessageLogModel.THICK_CLASS, this);
            if (recMessageLog != null)
                m_message = (BaseMessage)recMessageLog.createMessage(strTrxID);
        }
        return m_message;
    }
1254823
private static function _findProgram($strProgram)
    {
        $path_parts = pathinfo($strProgram);
        if (empty($path_parts['basename'])) {
            return null;
        }
        $arrPath = array();

        if (empty($path_parts['dirname']) || ($path_parts['dirname'] == '.')) {
            if ((PSI_OS == 'WINNT') && empty($path_parts['extension'])) {
                $strProgram .= '.exe';
                $path_parts = pathinfo($strProgram);
            }
            if (PSI_OS == 'WINNT') {
                if (CommonFunctions::readenv('Path', $serverpath)) {
                    $arrPath = preg_split('/;/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
                }
            } else {
                if (CommonFunctions::readenv('PATH', $serverpath)) {
                    $arrPath = preg_split('/:/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
                }
            }
            if (defined('PSI_UNAMEO') && (PSI_UNAMEO === 'Android') && !empty($arrPath)) {
                array_push($arrPath, '/system/bin'); // Termux patch
            }
            if (defined('PSI_ADD_PATHS') && is_string(PSI_ADD_PATHS)) {
                if (preg_match(ARRAY_EXP, PSI_ADD_PATHS)) {
                    $arrPath = array_merge(eval(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
                } else {
                    $arrPath = array_merge(array(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
                }
            }
        } else { //directory defined
            array_push($arrPath, $path_parts['dirname']);
            $strProgram = $path_parts['basename'];
        }

        //add some default paths if we still have no paths here
        if (empty($arrPath) && PSI_OS != 'WINNT') {
            if (PSI_OS == 'Android') {
                array_push($arrPath, '/system/bin');
            } else {
                array_push($arrPath, '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');
            }
        }

        $exceptPath = "";
        if ((PSI_OS == 'WINNT') && CommonFunctions::readenv('WinDir', $windir)) {
            foreach ($arrPath as $strPath) {
                if ((strtolower($strPath) == $windir."\\system32") && is_dir($windir."\\SysWOW64")) {
                    if (is_dir($windir."\\sysnative")) {
                        $exceptPath = $windir."\\sysnative"; //32-bit PHP on 64-bit Windows
                    } else {
                        $exceptPath = $windir."\\SysWOW64"; //64-bit PHP on 64-bit Windows
                    }
                    array_push($arrPath, $exceptPath);
                    break;
                }
            }
        } elseif (PSI_OS == 'Android') {
            $exceptPath = '/system/bin';
        }

        foreach ($arrPath as $strPath) {
            // Path with and without trailing slash
            if (PSI_OS == 'WINNT') {
                $strPath = rtrim($strPath, "\\");
                $strPathS = $strPath."\\";
            } else {
                $strPath = rtrim($strPath, "/");
                $strPathS = $strPath."/";
            }
            if (($strPath !== $exceptPath) && !is_dir($strPath)) {
                continue;
            }
            if (PSI_OS == 'WINNT') {
                $strProgrammpath = $strPathS.$strProgram;
            } else {
                $strProgrammpath = $strPathS.$strProgram;
            }
            if (is_executable($strProgrammpath)) {
                return $strProgrammpath;
            }
        }

        return null;
    }
279885
public static function findByKey($nb_messaging, $key)
    {
        $nb_messaging_id = nb_getMixedValue($nb_messaging, 'nb_messaging_id');
        if (is_numeric($nb_messaging_id)) {
            $retval = CNabuMessagingService::buildObjectFromSQL(
                    'select * '
                    . 'from nb_messaging_service '
                   . 'where nb_messaging_id=%messaging_id$d '
                     . "and nb_messaging_service_key='%key\$s'",
                    array(
                        'messaging_id' => $nb_messaging_id,
                        'key' => $key
                    )
            );
        } else {
            $retval = null;
        }
        
        return $retval;
    }
1269980
@Nullable
  public static String getCompactMessage (final String sMsg)
  {
    UPCA.validateMessage (sMsg);
    final String sUPCA = UPCA.handleChecksum (sMsg, EEANChecksumMode.AUTO);
    final byte nNumberSystem = _extractNumberSystem (sUPCA);
    if (nNumberSystem != 0 && nNumberSystem != 1)
      return null;

    final byte nCheck = StringParser.parseByte (sUPCA.substring (11, 12), (byte) -1);
    if (nCheck == (byte) -1)
      return null;

    final StringBuilder aSB = new StringBuilder ();
    aSB.append (Byte.toString (nNumberSystem));
    final String manufacturer = sUPCA.substring (1, 1 + 5);
    final String product = sUPCA.substring (6, 6 + 5);
    // Rule 1
    String mtemp = manufacturer.substring (2, 2 + 3);
    String ptemp = product.substring (0, 0 + 2);
    if ("000|100|200".indexOf (mtemp) >= 0 && "00".equals (ptemp))
    {
      aSB.append (manufacturer.substring (0, 2));
      aSB.append (product.substring (2, 2 + 3));
      aSB.append (mtemp.charAt (0));
    }
    else
    {
      // Rule 2
      ptemp = product.substring (0, 0 + 3);
      if ("300|400|500|600|700|800|900".indexOf (mtemp) >= 0 && "000".equals (ptemp))
      {
        aSB.append (manufacturer.substring (0, 0 + 3));
        aSB.append (product.substring (3, 3 + 2));
        aSB.append ('3');
      }
      else
      {
        // Rule 3
        mtemp = manufacturer.substring (3, 3 + 2);
        ptemp = product.substring (0, 0 + 4);
        if ("10|20|30|40|50|60|70|80|90".indexOf (mtemp) >= 0 && "0000".equals (ptemp))
        {
          aSB.append (manufacturer.substring (0, 0 + 4));
          aSB.append (product.substring (4, 4 + 1));
          aSB.append ('4');
        }
        else
        {
          // Rule 4
          mtemp = manufacturer.substring (4, 4 + 1);
          ptemp = product.substring (4, 4 + 1);
          if (!"0".equals (mtemp) && "5|6|7|8|9".indexOf (ptemp) >= 0)
          {
            aSB.append (manufacturer);
            aSB.append (ptemp);
          }
          else
          {
            return null;
          }
        }
      }
    }
    aSB.append (Byte.toString (nCheck));
    return aSB.toString ();
  }