Object tools filer by client OS for local commands fixes #1249
authorEriks Jenkevics <eriks@netxms.org>
Tue, 30 Aug 2016 15:12:49 +0000 (18:12 +0300)
committerEriks Jenkevics <eriks@netxms.org>
Tue, 30 Aug 2016 15:12:49 +0000 (18:12 +0300)
ChangeLog
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectTool.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolDetails.java
src/java/client/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolFilter.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ru.properties
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/propertypages/Filter.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages.properties
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/messages_ru.properties

index 85bb243..0f38f04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,7 +27,7 @@
        - New editors for Agent Config Policy and Log Parser Policy. 
        - DCI summary tables with empty menu path not shown in object context menu
        - Fixed glitches in table value view
-- Fixed issues: #92, #568, #826, #851, #906, #909, #942, #959, #987, #992, #999, #1006, #1051, #1096, #1100, #1159, #1187, #1191, #1230, #1237, #1245, #1246, #1254, #1261, #1263, #1273, #1275, #1277, #1278
+- Fixed issues: #92, #568, #826, #851, #906, #909, #942, #959, #987, #992, #999, #1006, #1051, #1096, #1100, #1159, #1187, #1191, #1230, #1237, #1245, #1246, #1249, #1254, #1261, #1263, #1273, #1275, #1277, #1278
 
 
 *
index 0d95a25..b793f77 100644 (file)
@@ -52,9 +52,10 @@ public class ObjectTool
        public static final int GENERATES_OUTPUT          = 0x00000010;
        public static final int DISABLED                  = 0x00000020;
        public static final int SHOW_IN_COMMANDS          = 0x00000040;
-       public static final int REQUIRES_OS_MATCH         = 0x00000080;
+   public static final int REQUIRES_REMOTE_OS_MATCH  = 0x00000080;
    public static final int REQUIRES_TEMPLATE_MATCH   = 0x00000100;
        public static final int SNMP_INDEXED_BY_VALUE     = 0x00010000;
+       public static final int REQUIRES_LOCAL_OS_MATCH   = 0x00020000;
        
        protected long id;
        protected String name;
@@ -221,12 +222,12 @@ public class ObjectTool
                                return false;   // OID does not match
                }
                
-          if ((flags & REQUIRES_OS_MATCH) != 0)
+          if ((flags & REQUIRES_REMOTE_OS_MATCH) != 0)
       {
              boolean match = false;
-             String[] substrings = filter.toolOS.split(",");
+             String[] substrings = filter.toolLocOS.split(",");
              for(int i = 0; i < substrings.length; i++)
-             {
+             {;
                 if (Pattern.matches(substrings[i], node.getPlatformName()))
                 {
                    match = true;
@@ -235,6 +236,21 @@ public class ObjectTool
              if (!match)
                 return false;  //Not correct type of OS
       }
+          
+          if ((flags & REQUIRES_LOCAL_OS_MATCH) != 0)
+      {
+         boolean match = false;
+         String[] substrings = filter.toolLocOS.split(",");
+         for(int i = 0; i < substrings.length; i++)
+         {;
+            if (Pattern.matches(substrings[i], System.getProperty("os.name")))
+            {
+               match = true;
+            }
+         }
+         if (!match)
+            return false;  //Not correct type of OS
+      }
            
           if ((flags & REQUIRES_TEMPLATE_MATCH) != 0)
       {
@@ -412,11 +428,19 @@ public class ObjectTool
    }
 
    /**
-    * @return the toolOS
+    * @return the toolRemOS
+    */
+   public String getToolRemOS()
+   {
+      return filter.toolRemOS;
+   }
+   
+   /**
+    * @return the toolLocOS
     */
-   public String getToolOS()
+   public String getToolLocOS()
    {
-      return filter.toolOS;
+      return filter.toolLocOS;
    }
 
    /**
index c61d217..0b3ed9d 100644 (file)
@@ -290,11 +290,20 @@ public class ObjectToolDetails extends ObjectTool
    }
 
    /**
-    * @param toolOS  the comma separated list of OS name regexps
+    * @param toolRemOS  the comma separated list of OS name regexps
     */
-   public void setToolOS(String toolOS)
+   public void setToolRemOS(String toolRemOS)
    {
-      filter.toolOS = toolOS;
+      filter.toolRemOS = toolRemOS;
+      modified = true;
+   }
+   
+   /**
+    * @param toolLocOS  the comma separated list of OS name regexps
+    */
+   public void setToolLocOS(String toolLocOS)
+   {
+      filter.toolLocOS = toolLocOS;
       modified = true;
    }
 
index 2c21c40..5522c78 100644 (file)
@@ -13,8 +13,11 @@ import org.simpleframework.xml.core.Persister;
 @Root(name="objectToolFilter")
 public class ObjectToolFilter
 {
+   @Element(required=false, name="toolOS")
+   public String toolRemOS;
+   
    @Element(required=false)
-   public String toolOS;
+   public String toolLocOS;
    
    @Element(required=false)
    public String toolTemplate;
@@ -51,7 +54,8 @@ public class ObjectToolFilter
    
    public ObjectToolFilter()
    {
-      toolOS = "";
+      toolRemOS = "";
+      toolLocOS = "";
       toolTemplate = "";
       snmpOid = "";
    }
index 088d399..a5ffe5e 100644 (file)
@@ -41,7 +41,7 @@ EditInputFieldDialog_Type=Type
 EditInputFieldDialog_ValidatePassword=Validate password after entry
 Filter_AgentNeeded=NetXMS agent should be available
 Filter_OIDShouldMatch=Node SNMP OID should match with the following template:
-Filter_OSShouldMatch=System OS name should match this template(coma separated regular expression list):
+Filter_OSShouldMatch=Remote system OS name should match this template(coma separated regular expression list):
 Filter_SNMPNeeded=Node should support SNMP
 Filter_TemplateShouldMatch=Parent template name should match this template(coma separated regular expression list):
 General_AgentCommand=Agent's command
index 68b9f66..f70a151 100644 (file)
@@ -41,7 +41,7 @@ EditInputFieldDialog_Type=\u0422\u0438\u043f
 EditInputFieldDialog_ValidatePassword=\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0432\u043e\u0434\u0430
 Filter_AgentNeeded=\u0410\u0433\u0435\u043d\u0442 NetXMS \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d
 Filter_OIDShouldMatch=\u0423\u0437\u0435\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c SNMP OID, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443:
-Filter_OSShouldMatch=\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u041e\u0421 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443(\u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438):
+Filter_OSShouldMatch=\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u041e\u0421 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443(\u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438):
 Filter_SNMPNeeded=\u0423\u0437\u0435\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c SNMP
 Filter_TemplateShouldMatch=\u0418\u043c\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443(\u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438):
 General_AgentCommand=\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430
index 7e597a8..a2d4025 100644 (file)
@@ -42,10 +42,12 @@ public class Filter extends PropertyPage
        private Button checkAgent;
        private Button checkSNMP;
        private Button checkMatchOID;
-       private Button checkMatchOS;
+       private Button checkMatchRemoteOS;
+       private Button checkMatchLocalOS;
        private Button checkMatchTemplate;
        private Text textOID;
-       private Text textOS;
+       private Text textRemOS;
+       private Text textLocOS;
        private Text textTemplate;
 
        /* (non-Javadoc)
@@ -110,16 +112,16 @@ public class Filter extends PropertyPage
                textOID.setLayoutData(gd);
                textOID.setEnabled(checkMatchOID.getSelection());
                
-               checkMatchOS = new Button(dialogArea, SWT.CHECK);
-               checkMatchOS.setText(Messages.get().Filter_OSShouldMatch);
-               checkMatchOS.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_OS_MATCH) != 0);
-               checkMatchOS.addSelectionListener(new SelectionListener() {
+               checkMatchRemoteOS = new Button(dialogArea, SWT.CHECK);
+               checkMatchRemoteOS.setText(Messages.get().Filter_OSShouldMatch);
+               checkMatchRemoteOS.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_REMOTE_OS_MATCH) != 0);
+               checkMatchRemoteOS.addSelectionListener(new SelectionListener() {
                        @Override
                        public void widgetSelected(SelectionEvent e)
                        {
-                               textOS.setEnabled(checkMatchOS.getSelection());
-                               if (checkMatchOS.getSelection())
-                                       textOS.setFocus();
+                               textRemOS.setEnabled(checkMatchRemoteOS.getSelection());
+                               if (checkMatchRemoteOS.getSelection())
+                                       textRemOS.setFocus();
                        }
 
                        @Override
@@ -129,14 +131,42 @@ public class Filter extends PropertyPage
                        }
                });
                
-               textOS = new Text(dialogArea, SWT.BORDER);
-               textOS.setText(objectTool.getToolOS());
+               textRemOS = new Text(dialogArea, SWT.BORDER);
+               textRemOS.setText(objectTool.getToolRemOS());
                gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
                gd.horizontalIndent = 20;
-               textOS.setLayoutData(gd);
-               textOS.setEnabled(checkMatchOS.getSelection());
+               textRemOS.setLayoutData(gd);
+               textRemOS.setEnabled(checkMatchRemoteOS.getSelection());
+               
+               checkMatchLocalOS = new Button(dialogArea, SWT.CHECK);
+               checkMatchLocalOS.setText("Local system OS name should match this template(coma separated regular expression list)");
+               checkMatchLocalOS.setSelection((objectTool.getFlags() & ObjectTool.REQUIRES_LOCAL_OS_MATCH) != 0);
+               checkMatchLocalOS.addSelectionListener(new SelectionListener() {         
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            textLocOS.setEnabled(checkMatchLocalOS.getSelection());
+            if (checkMatchLocalOS.getSelection())
+               textLocOS.setFocus();            
+         }
+         
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);            
+         }
+      });
+               
+               textLocOS = new Text(dialogArea, SWT.BORDER);
+               textLocOS.setText(objectTool.getToolLocOS());
+               gd = new GridData();
+               gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.horizontalIndent = 20;
+      textLocOS.setLayoutData(gd);
+      textLocOS.setEnabled(checkMatchLocalOS.getSelection());
                
                checkMatchTemplate = new Button(dialogArea, SWT.CHECK);
                checkMatchTemplate.setText(Messages.get().Filter_TemplateShouldMatch);
@@ -193,12 +223,19 @@ public class Filter extends PropertyPage
                
                objectTool.setSnmpOid(textOID.getText());               
 
-      if (checkMatchOS.getSelection())
-         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_OS_MATCH);
+      if (checkMatchRemoteOS.getSelection())
+         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_REMOTE_OS_MATCH);
+      else
+         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_REMOTE_OS_MATCH);
+      
+      objectTool.setToolRemOS(textRemOS.getText());
+      
+      if (checkMatchLocalOS.getSelection())
+         objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_LOCAL_OS_MATCH);
       else
-         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_OS_MATCH);
+         objectTool.setFlags(objectTool.getFlags() & ~ObjectTool.REQUIRES_LOCAL_OS_MATCH);
       
-      objectTool.setToolOS(textOS.getText());
+      objectTool.setToolLocOS(textLocOS.getText());
 
       if (checkMatchTemplate.getSelection())
          objectTool.setFlags(objectTool.getFlags() | ObjectTool.REQUIRES_TEMPLATE_MATCH);
index 088d399..a5ffe5e 100644 (file)
@@ -41,7 +41,7 @@ EditInputFieldDialog_Type=Type
 EditInputFieldDialog_ValidatePassword=Validate password after entry
 Filter_AgentNeeded=NetXMS agent should be available
 Filter_OIDShouldMatch=Node SNMP OID should match with the following template:
-Filter_OSShouldMatch=System OS name should match this template(coma separated regular expression list):
+Filter_OSShouldMatch=Remote system OS name should match this template(coma separated regular expression list):
 Filter_SNMPNeeded=Node should support SNMP
 Filter_TemplateShouldMatch=Parent template name should match this template(coma separated regular expression list):
 General_AgentCommand=Agent's command
index 56d8f30..b730eb0 100644 (file)
@@ -41,7 +41,7 @@ EditInputFieldDialog_Type=Type
 EditInputFieldDialog_ValidatePassword=Validate password after entry
 Filter_AgentNeeded=\u0410\u0433\u0435\u043d\u0442 NetXMS \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d
 Filter_OIDShouldMatch=\u0423\u0437\u0435\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c SNMP OID, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443:
-Filter_OSShouldMatch=System OS name should match this template(coma separated regular expression list):
+Filter_OSShouldMatch=\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u041e\u0421 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443(\u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438):
 Filter_SNMPNeeded=\u0423\u0437\u0435\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c SNMP
 Filter_TemplateShouldMatch=Parent template name should match this template(coma separated regular expression list):
 General_AgentCommand=\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430