fixed issue NX-81; other minor changes
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 28 Jan 2012 13:56:46 +0000 (13:56 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 28 Jan 2012 13:56:46 +0000 (13:56 +0000)
doc/internal/tables_with_object_id.txt [new file with mode: 0644]
include/nxclapi.h
src/java/netxms-client/src/main/java/org/netxms/client/NXCException.java
src/java/netxms-client/src/main/java/org/netxms/client/constants/RCC.java
src/java/netxms-eclipse/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/dialogs/ObjectSelectionDialog.java
src/java/netxms-eclipse/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/widgets/ObjectSelector.java
src/java/netxms-eclipse/ObjectManager/src/org/netxms/ui/eclipse/objectmanager/dialogs/ZoneSelectionDialog.java
src/libnxcl/main.cpp
src/server/core/main.cpp
src/server/core/node.cpp
src/server/core/session.cpp

diff --git a/doc/internal/tables_with_object_id.txt b/doc/internal/tables_with_object_id.txt
new file mode 100644 (file)
index 0000000..e5acf82
--- /dev/null
@@ -0,0 +1,48 @@
+The following tables contains object identifiers:
+
+
+object_properties                              object_id, submap_id
+object_custom_attributes       object_id
+zones                                                          id, agent_proxy, snmp_proxy, icmp_proxy
+nodes                                                          id, poller_node_id, proxy_node, snmp_proxy
+clusters                                                       id
+cluster_members                                cluster_id, node_id
+cluster_sync_subnets                   cluster_id
+cluster_resources                              cluster_id, current_owner
+subnets                                                        id
+interfaces                                             id, node_id, peer_node_id
+network_services                               id, node_id, poller_node_id
+vpn_connectors                                 id, node_id, peer_gateway
+vpn_connector_networks         vpn_id
+containers                                             id
+conditions                 id, source_object
+cond_dci_map                                   condition_id, node_id
+templates                                              id
+dct_node_map                                   template_id, node_id
+nsmap                                                          subnet_id, node_id
+container_members                              container_id, object_id
+acl                                                            object_id
+trusted_nodes                                  source_object_id,target_node_id
+items                                                          node_id, template_id, proxy_node
+event_log                                              event_source
+policy_source_list                     object_id
+deleted_objects                                object_id
+alarms                                                 source_object_id
+syslog                                                 source_object_id
+snmp_trap_log                                  object_id
+audit_log                                              object_id
+ap_common                                              id
+ap_bindings                                            policy_id,node_id
+ap_config_files                                policy_id
+network_maps                                   id, seed
+network_map_elements                   map_id                                  + XML
+dashboards                                             id                                                      + XML
+business_services                              service_id
+slm_checks                                             id
+node_links                                             nodelink_id, node_id
+slm_agreements                                 service_id
+slm_tickets                                            service_id, check_id
+slm_service_history                    service_id
+job_history                                            node_id
+reports                                                        id
+report_results                                 report_id
index e447184..2c98a20 100644 (file)
@@ -476,6 +476,7 @@ enum
 #define RCC_JOB_UNHOLD_FAILED       ((DWORD)92)
 #define RCC_ZONE_ID_ALREADY_IN_USE  ((DWORD)93)
 #define RCC_INVALID_ZONE_ID         ((DWORD)94)
+#define RCC_ZONE_NOT_EMPTY          ((DWORD)95)
 
 
 //
index fcbce45..4f40917 100644 (file)
@@ -123,7 +123,8 @@ public class NXCException extends NetXMSClientException
                "Job cannot be put on hold",\r
                "Job on hold cannot be resumed",\r
                "Zone ID is already in use",\r
-               "Invalid zone ID"\r
+               "Invalid zone ID",\r
+               "Cannot delete non-empty zone object"\r
        };\r
        private static final String[] extendedErrorTexts =\r
        {\r
index 14746b5..a978aef 100644 (file)
@@ -91,6 +91,7 @@ public final class RCC extends CommonRCC
        public static final int RCC_JOB_UNHOLD_FAILED = 92;\r
        public static final int RCC_ZONE_ID_ALREADY_IN_USE = 93;\r
        public static final int RCC_INVALID_ZONE_ID = 94;\r
+       public static final int RCC_ZONE_NOT_EMPTY = 95;\r
        \r
        // SNMP-specific, has no corresponding RCC_xxx constants in C library\r
        public static final int BAD_MIB_FILE_HEADER = 1001;\r
index 32cbf16..1403cb9 100644 (file)
@@ -72,6 +72,19 @@ public class ObjectSelectionDialog extends Dialog
        }\r
 \r
        /**\r
+        * Create filter for zone selection - it allows only zone and entire network obejcts.\r
+        * \r
+        * @return Class filter for node selection\r
+        */\r
+       public static Set<Integer> createZoneSelectionFilter()\r
+       {\r
+               HashSet<Integer> classFilter = new HashSet<Integer>(7);\r
+               classFilter.add(GenericObject.OBJECT_NETWORK);\r
+               classFilter.add(GenericObject.OBJECT_ZONE);\r
+               return classFilter;\r
+       }\r
+\r
+       /**\r
         * Create filter for template selection - it allows template objects and possible\r
         * parents - template groups.\r
         * \r
index afc02f4..78157fb 100644 (file)
@@ -18,6 +18,7 @@
  */\r
 package org.netxms.ui.eclipse.objectbrowser.widgets;\r
 \r
+import java.util.Set;\r
 import org.eclipse.jface.window.Window;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.netxms.client.NXCSession;\r
@@ -35,6 +36,7 @@ public class ObjectSelector extends AbstractSelector
 {\r
        private long objectId = 0;\r
        private Class<? extends GenericObject> objectClass = Node.class;\r
+       private Set<Integer> classFilter = null;\r
        private String emptySelectionName = "<none>";\r
        \r
        /**\r
@@ -53,7 +55,7 @@ public class ObjectSelector extends AbstractSelector
        @Override\r
        protected void selectionButtonHandler()\r
        {\r
-               ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, null);\r
+               ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, classFilter);\r
                dlg.enableMultiSelection(false);\r
                if (dlg.open() == Window.OK)\r
                {\r
@@ -127,4 +129,20 @@ public class ObjectSelector extends AbstractSelector
        {\r
                this.emptySelectionName = emptySelectionName;\r
        }\r
+\r
+       /**\r
+        * @return the classFilter\r
+        */\r
+       public Set<Integer> getClassFilter()\r
+       {\r
+               return classFilter;\r
+       }\r
+\r
+       /**\r
+        * @param classFilter the classFilter to set\r
+        */\r
+       public void setClassFilter(Set<Integer> classFilter)\r
+       {\r
+               this.classFilter = classFilter;\r
+       }\r
 }\r
index c57d7bd..8383378 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.netxms.client.NXCSession;\r
 import org.netxms.client.objects.GenericObject;\r
 import org.netxms.client.objects.Zone;\r
+import org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog;\r
 import org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector;\r
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;\r
 import org.netxms.ui.eclipse.tools.WidgetHelper;\r
@@ -77,6 +78,7 @@ public class ZoneSelectionDialog extends Dialog
       objectSelector = new ObjectSelector(dialogArea, SWT.NONE);\r
       objectSelector.setLabel("Zone object");\r
       objectSelector.setObjectClass(Zone.class);\r
+      objectSelector.setClassFilter(ObjectSelectionDialog.createZoneSelectionFilter());\r
       GridData gd = new GridData();\r
       gd.horizontalAlignment = SWT.FILL;\r
       gd.grabExcessHorizontalSpace = true;\r
index 2624113..328550a 100644 (file)
@@ -407,9 +407,10 @@ const TCHAR LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
                _T("Job cannot be hold"),
                _T("Job cannot be unhold"),
                _T("Zone ID is already in use"),
-               _T("Invalid zone ID")
+               _T("Invalid zone ID"),
+               _T("Cannot delete non-empty zone object")
    };
-       return (dwError <= RCC_INVALID_ZONE_ID) ? pszErrorText[dwError] : _T("No text message for this error");
+       return (dwError <= RCC_ZONE_NOT_EMPTY) ? pszErrorText[dwError] : _T("No text message for this error");
 }
 
 
index 2c35c9d..2dbb6f7 100644 (file)
@@ -1032,6 +1032,20 @@ int ProcessConsoleCommand(const TCHAR *pszCmdLine, CONSOLE_CTX pCtx)
        {
                DumpProcess(pCtx);
        }
+       else if (IsCommand(_T("GET"), szBuffer, 3))
+       {
+               pArg = ExtractWord(pArg, szBuffer);
+               if (szBuffer[0] != 0)
+               {
+                       TCHAR value[256];
+                       ConfigReadStr(szBuffer, value, 256, _T(""));
+                       ConsolePrintf(pCtx, _T("%s = %s\n"), szBuffer, value);
+               }
+               else
+               {
+                       ConsolePrintf(pCtx, _T("Variable name missing\n"));
+               }
+       }
        else if (IsCommand(_T("RAISE"), szBuffer, 5))
        {
                // Get argument
@@ -1069,6 +1083,27 @@ int ProcessConsoleCommand(const TCHAR *pszCmdLine, CONSOLE_CTX pCtx)
                        ConsolePrintf(pCtx, _T("Cannot exit from local server console\n"));
                }
        }
+       else if (IsCommand(_T("SET"), szBuffer, 3))
+       {
+               pArg = ExtractWord(pArg, szBuffer);
+               if (szBuffer[0] != 0)
+               {
+                       TCHAR value[256];
+                       pArg = ExtractWord(pArg, value);
+                       if (ConfigWriteStr(szBuffer, value, TRUE, TRUE, TRUE))
+                       {
+                               ConsolePrintf(pCtx, _T("Configuration variable %s updated\n"), szBuffer);
+                       }
+                       else
+                       {
+                               ConsolePrintf(pCtx, _T("ERROR: cannot update configuration variable %s\n"), szBuffer);
+                       }
+               }
+               else
+               {
+                       ConsolePrintf(pCtx, _T("Variable name missing\n"));
+               }
+       }
        else if (IsCommand(_T("SHOW"), szBuffer, 2))
        {
                // Get argument
@@ -1367,8 +1402,10 @@ int ProcessConsoleCommand(const TCHAR *pszCmdLine, CONSOLE_CTX pCtx)
                                _T("   debug [<level>|off]       - Set debug level (valid range is 0..9)\n")
                                _T("   down                      - Down NetXMS server\n")
                                _T("   exit                      - Exit from remote session\n")
+                               _T("   get <variable>            - Get value of server configuration variable\n")
                                _T("   help                      - Display this help\n")
                                _T("   raise <exception>         - Raise exception\n")
+                               _T("   set <variable> <value>    - Set value of server configuration variable\n")
                                _T("   show flags                - Show internal server flags\n")
                                _T("   show index <index>        - Show internal index\n")
                                _T("   show objects              - Dump network objects to screen\n")
index 27766de..ff10f2e 100644 (file)
@@ -3413,6 +3413,7 @@ void Node::changeZone(DWORD newZone)
 
    m_zoneId = newZone;
    m_dwDynamicFlags |= NDF_FORCE_CONFIGURATION_POLL;
+       m_tLastConfigurationPoll = 0;
 
        // Remove from subnets
        LockParentList(FALSE);
@@ -4272,7 +4273,22 @@ void Node::checkSubnetBinding(InterfaceList *pIfList)
                                // Create subnet
                                pSubnet = new Subnet(iface->dwIpAddr & iface->dwIpNetMask, iface->dwIpNetMask, m_zoneId, FALSE);
                                NetObjInsert(pSubnet, TRUE);
-                               g_pEntireNet->AddSubnet(pSubnet);
+                               if (g_dwFlags & AF_ENABLE_ZONING)
+                               {
+                                       Zone *zone = FindZoneByGUID(m_zoneId);
+                                       if (zone != NULL)
+                                       {
+                                               zone->addSubnet(pSubnet);
+                                       }
+                                       else
+                                       {
+                                               DbgPrintf(1, _T("Inconsistent configuration - zone %d does not exist"), (int)m_zoneId);
+                                       }
+                               }
+                               else
+                               {
+                                       g_pEntireNet->AddSubnet(pSubnet);
+                               }
                                pSubnet->AddNode(this);
                                DbgPrintf(4, _T("Node::CheckSubnetBinding(): Creating new subnet %s [%d] for node %s [%d]"),
                                          pSubnet->Name(), pSubnet->Id(), m_szName, m_dwId);
index 547336f..f9b894a 100644 (file)
@@ -4212,14 +4212,21 @@ void ClientSession::deleteObject(CSCPMessage *pRequest)
    pObject = FindObjectById(pRequest->GetVariableLong(VID_OBJECT_ID));
    if (pObject != NULL)
    {
-      // Check if it is a built-in object, like _T("Entire Network")
-      if (pObject->Id() >= 10)
+      // Check if it is a built-in object, like "Entire Network"
+      if (pObject->Id() >= 10)  // FIXME: change to 100
       {
          // Check access rights
          if (pObject->CheckAccessRights(m_dwUserId, OBJECT_ACCESS_DELETE))
          {
-                               ThreadCreate(DeleteObjectWorker, 0, pObject);
-            msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                               if ((pObject->Type() != OBJECT_ZONE) || pObject->isEmpty())
+                               {
+                                       ThreadCreate(DeleteObjectWorker, 0, pObject);
+                                       msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                               }
+                               else
+                               {
+                   msg.SetVariable(VID_RCC, RCC_ZONE_NOT_EMPTY);
+                               }
          }
          else
          {