diff --git a/src/alias/AliasList.java b/src/alias/AliasList.java index de387a4e..3ff0c546 100644 --- a/src/alias/AliasList.java +++ b/src/alias/AliasList.java @@ -79,9 +79,11 @@ public class AliasList implements Comparable private HashMap mUniqueID = new HashMap(); private boolean mESNWildcard = false; + private boolean mMobileIDWildcard = false; private boolean mFleetsyncWildcard = false; private boolean mMDC1200Wildcard = false; private boolean mMPT1327Wildcard = false; + private boolean mSiteWildcard = false; private boolean mTalkgroupWildcard = false; public AliasList() @@ -125,8 +127,7 @@ public class AliasList implements Comparable { mESNWildcard = true; - //Replace (*) wildcard with regex wildcard (.) - mESN.put( esn.getEsn().replace( "*", "." ), alias ); + mESN.put( fixWildcard( esn.getEsn() ), alias ); } else { @@ -140,8 +141,7 @@ public class AliasList implements Comparable { mFleetsyncWildcard = true; - //Replace (*) wildcard with regex wildcard (.) - mFleetsync.put( fs.getIdent().replace( "*", "." ), alias ); + mFleetsync.put( fixWildcard( fs.getIdent() ), alias ); } else { @@ -156,7 +156,7 @@ public class AliasList implements Comparable mMDC1200Wildcard = true; //Replace (*) wildcard with regex wildcard (.) - mMDC1200.put( mdc.getIdent().replace( "*", "." ), alias ); + mMDC1200.put( fixWildcard( mdc.getIdent() ), alias ); } else { @@ -175,7 +175,7 @@ public class AliasList implements Comparable mMPT1327Wildcard = true; //Replace (*) wildcard with regex wildcard (.) - mMPT1327.put( ident.replace( "*", "." ), alias ); + mMPT1327.put( fixWildcard( ident ), alias ); } else { @@ -185,14 +185,35 @@ public class AliasList implements Comparable break; case MIN: Min min = (Min)id; - mMobileID.put( min.getMin(), alias ); + + if( min.getMin().contains( "*" ) ) + { + mMobileIDWildcard = true; + mMobileID.put( fixWildcard( min.getMin() ), alias ); + } + else + { + mMobileID.put( min.getMin(), alias ); + } break; case LTRNetUID: UniqueID uid = (UniqueID)id; + mUniqueID.put( uid.getUid(), alias ); break; case Site: - mSiteID.put( ((SiteID)id).getSite(), alias ); + SiteID siteID = (SiteID)id; + + if( siteID.getSite().contains( "*" ) ) + { + mSiteWildcard = true; + mSiteID.put( fixWildcard( siteID.getSite() ), alias ); + } + else + { + mSiteID.put( siteID.getSite(), alias ); + } + break; case Status: mStatus.put( ((StatusID)id).getStatus(), alias ); @@ -205,8 +226,7 @@ public class AliasList implements Comparable mTalkgroupWildcard = true; //Replace (*) wildcard with regex wildcard (.) - mTalkgroup.put( tgid.getTalkgroup() - .replace( "*", "." ), alias ); + mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias ); } else { @@ -218,10 +238,42 @@ public class AliasList implements Comparable } } } + + /** + * Converts user wildcard character (*) to regex single character wildcard (.) + * but ignores a regex multi-character wildcard (.*) + */ + private String fixWildcard( String value ) + { + if( value.contains( "*" ) && !value.contains( ".*" ) ) + { + return value.replace( "*", "." ); + } + + return value; + } public Alias getSiteID( String siteID ) { - return mSiteID.get( siteID ); + if( siteID != null ) + { + if( mSiteWildcard ) + { + for( String regex: mSiteID.keySet() ) + { + if( siteID.matches( regex ) ) + { + return mSiteID.get( regex ); + } + } + } + else + { + return mSiteID.get( siteID ); + } + } + + return null; } public Alias getStatus( int status ) @@ -242,11 +294,11 @@ public class AliasList implements Comparable if( mESNWildcard ) { - for( String key: mESN.keySet() ) + for( String regex: mESN.keySet() ) { - if( esn.matches( key ) ) + if( esn.matches( regex ) ) { - return mESN.get( key ); + return mESN.get( regex ); } } } @@ -268,11 +320,11 @@ public class AliasList implements Comparable if( mFleetsyncWildcard ) { - for( String key: mFleetsync.keySet() ) + for( String regex: mFleetsync.keySet() ) { - if( ident.matches( key ) ) + if( ident.matches( regex ) ) { - return mFleetsync.get( key ); + return mFleetsync.get( regex ); } } } @@ -293,11 +345,11 @@ public class AliasList implements Comparable if( mMDC1200Wildcard ) { - for( String key: mMDC1200.keySet() ) + for( String regex: mMDC1200.keySet() ) { - if( ident.matches( key ) ) + if( ident.matches( regex ) ) { - return mMDC1200.get( key ); + return mMDC1200.get( regex ); } } } @@ -314,15 +366,13 @@ public class AliasList implements Comparable { if( ident != null ) { - Alias retVal = null; - if( mMPT1327Wildcard ) { - for( String key: mMPT1327.keySet() ) + for( String regex: mMPT1327.keySet() ) { - if( ident.matches( key ) ) + if( ident.matches( regex ) ) { - return mMPT1327.get( key ); + return mMPT1327.get( regex ); } } } @@ -341,7 +391,7 @@ public class AliasList implements Comparable { for( Group group: mGroups ) { - if( group.contians( alias ) ) + if( group.contains( alias ) ) { return group; } @@ -353,22 +403,38 @@ public class AliasList implements Comparable public Alias getMobileIDNumberAlias( String ident ) { - return mMobileID.get( ident ); + if( ident != null ) + { + if( mMobileIDWildcard ) + { + for( String regex: mMobileID.keySet() ) + { + if( ident.matches( regex ) ) + { + return mMobileID.get( regex ); + } + } + } + else + { + return mMobileID.get( ident ); + } + } + + return null; } public Alias getTalkgroupAlias( String tgid ) { if( tgid != null ) { - Alias retVal = null; - if( mTalkgroupWildcard ) { - for( String key: mTalkgroup.keySet() ) + for( String regex: mTalkgroup.keySet() ) { - if( tgid.matches( key ) ) + if( tgid.matches( regex ) ) { - return mTalkgroup.get( key ); + return mTalkgroup.get( regex ); } } } diff --git a/src/alias/Group.java b/src/alias/Group.java index 6607605e..d5e30228 100644 --- a/src/alias/Group.java +++ b/src/alias/Group.java @@ -66,7 +66,7 @@ public class Group mAliases.remove( alias ); } - public boolean contians( Alias alias ) + public boolean contains( Alias alias ) { return mAliases.contains( alias ); } diff --git a/src/alias/action/AliasActionManager.java b/src/alias/action/AliasActionManager.java index dca4633f..87918777 100644 --- a/src/alias/action/AliasActionManager.java +++ b/src/alias/action/AliasActionManager.java @@ -33,24 +33,27 @@ public class AliasActionManager implements Listener @Override public void receive( Message message ) { - List aliases = message.getAliases(); - - if( aliases != null ) + if( message.isValid() ) { - for( Alias alias: aliases ) + List aliases = message.getAliases(); + + if( aliases != null ) { - if( alias.hasActions() ) + for( Alias alias: aliases ) { - List actions = alias.getAction(); - - for( AliasAction action: actions ) + if( alias.hasActions() ) { - /* Provide access to the thread pool manager in case the - * action needs to setup a timer, and provide the original - * message to be used as part of the action (e.g. sending - * the message as a text message to a cell phone */ - action.execute( mResourceManager.getThreadPoolManager(), - alias, message ); + List actions = alias.getAction(); + + for( AliasAction action: actions ) + { + /* Provide access to the thread pool manager in case the + * action needs to setup a timer, and provide the original + * message to be used as part of the action (e.g. sending + * the message as a text message to a cell phone */ + action.execute( mResourceManager.getThreadPoolManager(), + alias, message ); + } } } } diff --git a/src/alias/action/script/ScriptAction.java b/src/alias/action/script/ScriptAction.java index a32e32fb..ac0615dd 100644 --- a/src/alias/action/script/ScriptAction.java +++ b/src/alias/action/script/ScriptAction.java @@ -48,8 +48,6 @@ public class ScriptAction extends RecurringAction { if( mScript != null ) { - mLog.debug( "Running Script ..." ); - ProcessBuilder pb = new ProcessBuilder( mScript ); pb.redirectErrorStream( true ); diff --git a/src/decode/lj1200/LJ1200Message.java b/src/decode/lj1200/LJ1200Message.java index 4198d947..05aeb01a 100644 --- a/src/decode/lj1200/LJ1200Message.java +++ b/src/decode/lj1200/LJ1200Message.java @@ -144,7 +144,7 @@ public class LJ1200Message extends Message public Alias getSiteIDAlias() { - if( mAliasList != null ) + if( mAliasList != null && getFunction() == Function.F8_SITE_ID ) { return mAliasList.getSiteID( getSiteID() ); }