Search in sources :

Example 41 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method forceDCIPoll.

/**
 * Force DCI poll for given DCI
 *
 * @param nodeId Node object ID
 * @param dciId  DCI ID
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void forceDCIPoll(long nodeId, long dciId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FORCE_DCI_POLL);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setFieldInt32(NXCPCodes.VID_DCI_ID, (int) dciId);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 42 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method generateEventCode.

/**
 * Generate code for new event template.
 *
 * @return Code for new event template
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public long generateEventCode() throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GENERATE_EVENT_CODE);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsInt64(NXCPCodes.VID_EVENT_CODE);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 43 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method openServerLog.

/**
 * Open server log by name.
 *
 * @param logName Log name
 * @return Log object
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public Log openServerLog(final String logName) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_OPEN_SERVER_LOG);
    msg.setField(NXCPCodes.VID_LOG_NAME, logName);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    Log log = new Log(this, response, logName);
    return log;
}
Also used : Log(org.netxms.client.log.Log) NXCPMessage(org.netxms.base.NXCPMessage)

Example 44 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method modifyObject.

/**
 * Modify object (generic interface, in most cases wrapper functions should
 * be used instead).
 *
 * @param data     Object modification data
 * @param userData user-defined data for custom object modification
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyObject(final NXCObjectModificationData data, final Object userData) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_MODIFY_OBJECT);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) data.getObjectId());
    // Object name
    if (data.isFieldSet(NXCObjectModificationData.NAME)) {
        msg.setField(NXCPCodes.VID_OBJECT_NAME, data.getName());
    }
    // Primary IP
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_IP)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getPrimaryIpAddress());
    }
    // Access control list
    if (data.isFieldSet(NXCObjectModificationData.ACL)) {
        final AccessListElement[] acl = data.getACL();
        msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, acl.length);
        msg.setFieldInt16(NXCPCodes.VID_INHERIT_RIGHTS, data.isInheritAccessRights() ? 1 : 0);
        long id1 = NXCPCodes.VID_ACL_USER_BASE;
        long id2 = NXCPCodes.VID_ACL_RIGHTS_BASE;
        for (int i = 0; i < acl.length; i++) {
            msg.setFieldInt32(id1++, (int) acl[i].getUserId());
            msg.setFieldInt32(id2++, acl[i].getAccessRights());
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CUSTOM_ATTRIBUTES)) {
        Map<String, String> attrList = data.getCustomAttributes();
        Iterator<String> it = attrList.keySet().iterator();
        long id = NXCPCodes.VID_CUSTOM_ATTRIBUTES_BASE;
        int count = 0;
        while (it.hasNext()) {
            String key = it.next();
            String value = attrList.get(key);
            msg.setField(id++, key);
            msg.setField(id++, value);
            count++;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_CUSTOM_ATTRIBUTES, count);
    }
    if (data.isFieldSet(NXCObjectModificationData.AUTOBIND_FILTER)) {
        msg.setField(NXCPCodes.VID_AUTOBIND_FILTER, data.getAutoBindFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.FILTER)) {
        msg.setField(NXCPCodes.VID_FILTER, data.getFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.DESCRIPTION)) {
        msg.setField(NXCPCodes.VID_DESCRIPTION, data.getDescription());
    }
    if (data.isFieldSet(NXCObjectModificationData.VERSION)) {
        msg.setFieldInt32(NXCPCodes.VID_VERSION, data.getVersion());
    }
    // Configuration file
    if (data.isFieldSet(NXCObjectModificationData.POLICY_CONFIG)) {
        msg.setField(NXCPCodes.VID_CONFIG_FILE_DATA, data.getConfigFileContent());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_PORT, data.getAgentPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_AGENT_PROXY, (int) data.getAgentProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_AUTH)) {
        msg.setFieldInt16(NXCPCodes.VID_AUTH_METHOD, data.getAgentAuthMethod());
        msg.setField(NXCPCodes.VID_SHARED_SECRET, data.getAgentSecret());
    }
    if (data.isFieldSet(NXCObjectModificationData.TRUSTED_NODES)) {
        final long[] nodes = data.getTrustedNodes();
        msg.setFieldInt32(NXCPCodes.VID_NUM_TRUSTED_NODES, nodes.length);
        msg.setField(NXCPCodes.VID_TRUSTED_NODES, nodes);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_VERSION)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_VERSION, data.getSnmpVersion());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_AUTH)) {
        msg.setField(NXCPCodes.VID_SNMP_AUTH_OBJECT, data.getSnmpAuthName());
        msg.setField(NXCPCodes.VID_SNMP_AUTH_PASSWORD, data.getSnmpAuthPassword());
        msg.setField(NXCPCodes.VID_SNMP_PRIV_PASSWORD, data.getSnmpPrivPassword());
        int methods = data.getSnmpAuthMethod() | (data.getSnmpPrivMethod() << 8);
        msg.setFieldInt16(NXCPCodes.VID_SNMP_USM_METHODS, methods);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SNMP_PROXY, (int) data.getSnmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_PORT, data.getSnmpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.ICMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ICMP_PROXY, (int) data.getIcmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.GEOLOCATION)) {
        final GeoLocation gl = data.getGeolocation();
        msg.setFieldInt16(NXCPCodes.VID_GEOLOCATION_TYPE, gl.getType());
        msg.setField(NXCPCodes.VID_LATITUDE, gl.getLatitude());
        msg.setField(NXCPCodes.VID_LONGITUDE, gl.getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_ACCURACY, gl.getAccuracy());
        if (gl.getTimestamp() != null) {
            msg.setFieldInt64(NXCPCodes.VID_GEOLOCATION_TIMESTAMP, gl.getTimestamp().getTime() / 1000);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_LAYOUT)) {
        msg.setFieldInt16(NXCPCodes.VID_LAYOUT, data.getMapLayout().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_BACKGROUND)) {
        msg.setField(NXCPCodes.VID_BACKGROUND, data.getMapBackground());
        msg.setField(NXCPCodes.VID_BACKGROUND_LATITUDE, data.getMapBackgroundLocation().getLatitude());
        msg.setField(NXCPCodes.VID_BACKGROUND_LONGITUDE, data.getMapBackgroundLocation().getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_BACKGROUND_ZOOM, data.getMapBackgroundZoom());
        msg.setFieldInt32(NXCPCodes.VID_BACKGROUND_COLOR, data.getMapBackgroundColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.IMAGE)) {
        msg.setField(NXCPCodes.VID_IMAGE, data.getImage());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_CONTENT)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getMapElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (NetworkMapElement e : data.getMapElements()) {
            e.fillMessage(msg, varId);
            varId += 100;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_LINKS, data.getMapLinks().size());
        varId = NXCPCodes.VID_LINK_LIST_BASE;
        for (NetworkMapLink l : data.getMapLinks()) {
            l.fillMessage(msg, varId);
            varId += 20;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.COLUMN_COUNT)) {
        msg.setFieldInt16(NXCPCodes.VID_NUM_COLUMNS, data.getColumnCount());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_ELEMENTS)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getDashboardElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (DashboardElement e : data.getDashboardElements()) {
            e.fillMessage(msg, varId);
            varId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.URL_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_URLS, data.getUrls().size());
        long fieldId = NXCPCodes.VID_URL_LIST_BASE;
        for (ObjectUrl u : data.getUrls()) {
            u.fillMessage(msg, fieldId);
            fieldId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.SCRIPT)) {
        msg.setField(NXCPCodes.VID_SCRIPT, data.getScript());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_ACTIVATION_EVENT, data.getActivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_DEACTIVATION_EVENT, data.getDeactivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.SOURCE_OBJECT)) {
        msg.setFieldInt32(NXCPCodes.VID_SOURCE_OBJECT, (int) data.getSourceObject());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_ACTIVE_STATUS, data.getActiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.INACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_INACTIVE_STATUS, data.getInactiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.DCI_LIST)) {
        List<ConditionDciInfo> dciList = data.getDciList();
        msg.setFieldInt32(NXCPCodes.VID_NUM_ITEMS, dciList.size());
        long varId = NXCPCodes.VID_DCI_LIST_BASE;
        for (ConditionDciInfo dci : dciList) {
            msg.setFieldInt32(varId++, (int) dci.getDciId());
            msg.setFieldInt32(varId++, (int) dci.getNodeId());
            msg.setFieldInt16(varId++, dci.getFunction());
            msg.setFieldInt16(varId++, dci.getPolls());
            varId += 6;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.DRILL_DOWN_OBJECT_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_DRILL_DOWN_OBJECT_ID, (int) data.getDrillDownObjectId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERVICE_TYPE)) {
        msg.setFieldInt16(NXCPCodes.VID_SERVICE_TYPE, data.getServiceType());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_ADDRESS)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PROTOCOL)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PROTO, data.getIpProtocol());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PORT, data.getIpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.POLLER_NODE)) {
        msg.setFieldInt32(NXCPCodes.VID_POLLER_NODE_ID, (int) data.getPollerNode());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUIRED_POLLS)) {
        msg.setFieldInt16(NXCPCodes.VID_REQUIRED_POLLS, data.getRequiredPolls());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUEST)) {
        msg.setField(NXCPCodes.VID_SERVICE_REQUEST, data.getRequest());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSE)) {
        msg.setField(NXCPCodes.VID_SERVICE_RESPONSE, data.getResponse());
    }
    if (data.isFieldSet(NXCObjectModificationData.OBJECT_FLAGS)) {
        msg.setFieldInt32(NXCPCodes.VID_FLAGS, data.getObjectFlags());
        msg.setFieldInt32(NXCPCodes.VID_FLAGS_MASK, data.getObjectFlagsMask());
    }
    if (data.isFieldSet(NXCObjectModificationData.IFXTABLE_POLICY)) {
        msg.setFieldInt16(NXCPCodes.VID_USE_IFXTABLE, data.getIfXTablePolicy());
    }
    if (data.isFieldSet(NXCObjectModificationData.REPORT_DEFINITION)) {
        msg.setField(NXCPCodes.VID_REPORT_DEFINITION, data.getReportDefinition());
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_RESOURCES)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_RESOURCES, data.getResourceList().size());
        long varId = NXCPCodes.VID_RESOURCE_LIST_BASE;
        for (ClusterResource r : data.getResourceList()) {
            msg.setFieldInt32(varId++, (int) r.getId());
            msg.setField(varId++, r.getName());
            msg.setField(varId++, r.getVirtualAddress());
            varId += 7;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_NETWORKS)) {
        int count = data.getNetworkList().size();
        msg.setFieldInt32(NXCPCodes.VID_NUM_SYNC_SUBNETS, count);
        long varId = NXCPCodes.VID_SYNC_SUBNETS_BASE;
        for (InetAddressEx n : data.getNetworkList()) {
            msg.setField(varId++, n);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_NAME)) {
        msg.setField(NXCPCodes.VID_PRIMARY_NAME, data.getPrimaryName());
    }
    if (data.isFieldSet(NXCObjectModificationData.STATUS_CALCULATION)) {
        msg.setFieldInt16(NXCPCodes.VID_STATUS_CALCULATION_ALG, data.getStatusCalculationMethod());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_PROPAGATION_ALG, data.getStatusPropagationMethod());
        msg.setFieldInt16(NXCPCodes.VID_FIXED_STATUS, data.getFixedPropagatedStatus().getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SHIFT, data.getStatusShift());
        ObjectStatus[] transformation = data.getStatusTransformation();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_1, transformation[0].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_2, transformation[1].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_3, transformation[2].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_4, transformation[3].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SINGLE_THRESHOLD, data.getStatusSingleThreshold());
        int[] thresholds = data.getStatusThresholds();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_1, thresholds[0]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_2, thresholds[1]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_3, thresholds[2]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_4, thresholds[3]);
    }
    if (data.isFieldSet(NXCObjectModificationData.EXPECTED_STATE)) {
        msg.setFieldInt16(NXCPCodes.VID_EXPECTED_STATE, data.getExpectedState());
    }
    if (data.isFieldSet(NXCObjectModificationData.LINK_COLOR)) {
        msg.setFieldInt32(NXCPCodes.VID_LINK_COLOR, data.getLinkColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONNECTION_ROUTING)) {
        msg.setFieldInt16(NXCPCodes.VID_LINK_ROUTING, data.getConnectionRouting());
    }
    if (data.isFieldSet(NXCObjectModificationData.DISCOVERY_RADIUS)) {
        msg.setFieldInt32(NXCPCodes.VID_DISCOVERY_RADIUS, data.getDiscoveryRadius());
    }
    if (data.isFieldSet(NXCObjectModificationData.HEIGHT)) {
        msg.setFieldInt16(NXCPCodes.VID_HEIGHT, data.getHeight());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_NUMB_SCHEME)) {
        msg.setField(NXCPCodes.VID_TOP_BOTTOM, data.isRackNumberingTopBottom());
    }
    if (data.isFieldSet(NXCObjectModificationData.PEER_GATEWAY)) {
        msg.setFieldInt32(NXCPCodes.VID_PEER_GATEWAY, (int) data.getPeerGatewayId());
    }
    if (data.isFieldSet(NXCObjectModificationData.VPN_NETWORKS)) {
        long fieldId = NXCPCodes.VID_VPN_NETWORK_BASE;
        msg.setFieldInt32(NXCPCodes.VID_NUM_LOCAL_NETS, data.getLocalNetworks().size());
        for (InetAddressEx a : data.getLocalNetworks()) {
            msg.setField(fieldId++, a);
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_REMOTE_NETS, data.getRemoteNetworks().size());
        for (InetAddressEx a : data.getRemoteNetworks()) {
            msg.setField(fieldId++, a);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.POSTAL_ADDRESS)) {
        data.getPostalAddress().fillMessage(msg);
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_CACHE_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_CACHE_MODE, data.getAgentCacheMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_COMPRESSION_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_COMPRESSION_MODE, data.getAgentCompressionMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAPOBJ_DISP_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_DISPLAY_MODE, data.getMapObjectDisplayMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_PLACEMENT)) {
        msg.setFieldInt32(NXCPCodes.VID_RACK_ID, (int) data.getRackId());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_FRONT, data.getFrontRackImage());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_REAR, data.getRearRackImage());
        msg.setFieldInt16(NXCPCodes.VID_RACK_POSITION, data.getRackPosition());
        msg.setFieldInt16(NXCPCodes.VID_RACK_HEIGHT, data.getRackHeight());
        msg.setFieldInt16(NXCPCodes.VID_RACK_ORIENTATION, data.getRackOrientation().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_LIST)) {
        msg.setField(NXCPCodes.VID_DASHBOARDS, data.getDashboards());
    }
    if (data.isFieldSet(NXCObjectModificationData.CHASSIS_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int) data.getChassisId());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONTROLLER_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CONTROLLER_ID, (int) data.getControllerId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SSH_PROXY, (int) data.getSshProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_LOGIN)) {
        msg.setField(NXCPCodes.VID_SSH_LOGIN, data.getSshLogin());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PASSWORD)) {
        msg.setField(NXCPCodes.VID_SSH_PASSWORD, data.getSshPassword());
    }
    if (data.isFieldSet(NXCObjectModificationData.ZONE_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_PROXY, (int) data.getZoneProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SEED_OBJECTS)) {
        msg.setField(NXCPCodes.VID_SEED_OBJECTS, data.getSeedObjectIds());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAC_ADDRESS)) {
        msg.setField(NXCPCodes.VID_MAC_ADDR, data.getMacAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_CLASS)) {
        msg.setFieldInt32(NXCPCodes.VID_DEVICE_CLASS, data.getDeviceClass());
    }
    if (data.isFieldSet(NXCObjectModificationData.VENDOR)) {
        msg.setField(NXCPCodes.VID_VENDOR, data.getVendor());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERIAL_NUMBER)) {
        msg.setField(NXCPCodes.VID_SERIAL_NUMBER, data.getSerialNumber());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_ADDRESS)) {
        msg.setField(NXCPCodes.VID_DEVICE_ADDRESS, data.getDeviceAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.META_TYPE)) {
        msg.setField(NXCPCodes.VID_META_TYPE, data.getMetaType());
    }
    if (data.isFieldSet(NXCObjectModificationData.SENSOR_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SENSOR_PROXY, (int) data.getSensorProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.XML_CONFIG)) {
        msg.setField(NXCPCodes.VID_XML_CONFIG, data.getXmlConfig());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_SNMP_PORT_COUNT, data.getSnmpPorts().size());
        for (int i = 0; i < data.getSnmpPorts().size(); i++) {
            msg.setField(NXCPCodes.VID_ZONE_SNMP_PORT_LIST_BASE + i, data.getSnmpPorts().get(i));
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PASSIVE_ELEMENTS)) {
        msg.setField(NXCPCodes.VID_PASSIVE_ELEMENTS, data.getPassiveElements());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSIBLE_USERS)) {
        Long[] users = data.getResponsibleUsers().toArray(new Long[data.getResponsibleUsers().size()]);
        msg.setField(NXCPCodes.VID_RESPONSIBLE_USERS, users);
    }
    modifyCustomObject(data, userData, msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConditionDciInfo(org.netxms.client.datacollection.ConditionDciInfo) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) DashboardElement(org.netxms.client.dashboards.DashboardElement) ClusterResource(org.netxms.client.objects.ClusterResource) ObjectStatus(org.netxms.client.constants.ObjectStatus) InetAddressEx(org.netxms.base.InetAddressEx) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) AtomicLong(java.util.concurrent.atomic.AtomicLong) GeoLocation(org.netxms.base.GeoLocation) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 45 with NXCPMessage

use of org.netxms.base.NXCPMessage in project netxms by netxms.

the class NXCSession method getWirelessStations.

/**
 * Get list of wireless stations registered at given wireless controller.
 *
 * @param nodeId controller node ID
 * @return list of wireless stations
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<WirelessStation> getWirelessStations(long nodeId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_WIRELESS_STATIONS);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
    List<WirelessStation> stations = new ArrayList<WirelessStation>(count);
    long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
    for (int i = 0; i < count; i++) {
        stations.add(new WirelessStation(response, varId));
        varId += 10;
    }
    return stations;
}
Also used : WirelessStation(org.netxms.client.topology.WirelessStation) NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Aggregations

NXCPMessage (org.netxms.base.NXCPMessage)274 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)69 AccessPoint (org.netxms.client.objects.AccessPoint)66 ArrayList (java.util.ArrayList)44 IOException (java.io.IOException)8 HashMap (java.util.HashMap)7 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)7 MappingTable (org.netxms.client.mt.MappingTable)7 NXCPException (org.netxms.base.NXCPException)5 UnknownHostException (java.net.UnknownHostException)3 GeneralSecurityException (java.security.GeneralSecurityException)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 UUID (java.util.UUID)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 MessageProcessingResult (com.radensolutions.reporting.service.MessageProcessingResult)2 FileInputStream (java.io.FileInputStream)2 Socket (java.net.Socket)2 SignatureException (java.security.SignatureException)2 Date (java.util.Date)2 List (java.util.List)2