Search in sources :

Example 1 with InetAddressEx

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

the class InterfaceDetailsAdapter method setValues.

/**
 * Set alarms
 *
 * @param alarms
 */
public void setValues(Interface i) {
    addRow(r.getString(R.string.if_id), Long.toString(i.getObjectId()));
    addRow(r.getString(R.string.if_name), i.getObjectName());
    addRow(r.getString(R.string.if_alias), i.getAlias());
    addRow(r.getString(R.string.if_type), Integer.toString(i.getIfType()));
    addRow(r.getString(R.string.if_index), Integer.toString(i.getIfIndex()));
    addRow(r.getString(R.string.if_slot), Integer.toString(i.getSlot()));
    addRow(r.getString(R.string.if_port), Integer.toString(i.getPort()));
    addRow(r.getString(R.string.if_mtu), Integer.toString(i.getMtu()));
    addRow(r.getString(R.string.if_description), i.getDescription());
    addRow(r.getString(R.string.if_mac_address), i.getMacAddress().toString());
    for (InetAddressEx a : i.getIpAddressList()) addRow(r.getString(R.string.if_ip_address), a.toString());
    addRow(r.getString(R.string.if_admin_state), i.getAdminStateAsText(), getAdminStateColor(i.getAdminState()));
    addRow(r.getString(R.string.if_oper_state), i.getOperStateAsText(), getOperStateColor(i.getOperState()));
    addRow(r.getString(R.string.if_exp_state), getExpStateText(i.getExpectedState()));
    addRow(r.getString(R.string.if_status), getNodeStatusText(i.getStatus()), getNodeStatusColor(i.getStatus()));
}
Also used : InetAddressEx(org.netxms.base.InetAddressEx)

Example 2 with InetAddressEx

use of org.netxms.base.InetAddressEx 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 3 with InetAddressEx

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

the class ObjectTest method testObjectCreateAndDelete.

public void testObjectCreateAndDelete() throws Exception {
    final NXCSession session = connect();
    session.syncObjects();
    AbstractObject object = session.findObjectById(2);
    assertNotNull(object);
    NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NODE, "TestNode", 2);
    cd.setCreationFlags(NXCObjectCreationData.CF_CREATE_UNMANAGED);
    cd.setIpAddress(new InetAddressEx(InetAddress.getByName("192.168.10.1"), 0));
    long id = session.createObject(cd);
    assertFalse(id == 0);
    // Object update should be received from server
    Thread.sleep(1000);
    object = session.findObjectById(id);
    assertNotNull(object);
    assertEquals("TestNode", object.getObjectName());
    session.deleteObject(id);
    // Object update should be received from server
    Thread.sleep(1000);
    object = session.findObjectById(id);
    assertNull(object);
    session.disconnect();
}
Also used : InetAddressEx(org.netxms.base.InetAddressEx) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 4 with InetAddressEx

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

the class InetAddressExAdapter method read.

/* (non-Javadoc)
    * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
    */
@Override
public InetAddressEx read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
        reader.nextNull();
        return null;
    }
    try {
        String value = reader.nextString();
        String[] parts = value.split("/");
        InetAddress addr = InetAddress.getByName(parts[0]);
        return (parts.length == 1) ? new InetAddressEx(addr) : new InetAddressEx(addr, Integer.parseInt(parts[1]));
    } catch (Exception e) {
        return null;
    }
}
Also used : InetAddressEx(org.netxms.base.InetAddressEx) InetAddress(java.net.InetAddress) IOException(java.io.IOException)

Example 5 with InetAddressEx

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

the class ObjectSearchResultLabelProvider method getColumnText.

/* (non-Javadoc)
    * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
    */
@Override
public String getColumnText(Object element, int columnIndex) {
    if (!(element instanceof AbstractObject))
        return null;
    AbstractObject object = (AbstractObject) element;
    switch(columnIndex) {
        case ObjectFinder.COL_CLASS:
            return object.getObjectClassName();
        case ObjectFinder.COL_ID:
            return Long.toString(object.getObjectId());
        case ObjectFinder.COL_IP_ADDRESS:
            if (object instanceof AbstractNode) {
                InetAddressEx addr = ((AbstractNode) object).getPrimaryIP();
                return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
            }
            if (object instanceof AccessPoint) {
                InetAddressEx addr = ((AccessPoint) object).getIpAddress();
                return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
            }
            if (object instanceof Interface) {
                return ((Interface) object).getIpAddressListAsString();
            }
            return null;
        case ObjectFinder.COL_NAME:
            return wbLabelProvider.getText(element);
        case ObjectFinder.COL_PARENT:
            return getParentNames((AbstractObject) element);
        case ObjectFinder.COL_ZONE:
            if (object instanceof AbstractNode) {
                long zoneId = ((AbstractNode) object).getZoneId();
                Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
                return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
            } else if (object instanceof Interface) {
                long zoneId = ((Interface) object).getZoneId();
                Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
                return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
            }
            return null;
    }
    return null;
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) InetAddressEx(org.netxms.base.InetAddressEx) Zone(org.netxms.client.objects.Zone) AbstractObject(org.netxms.client.objects.AbstractObject) AccessPoint(org.netxms.client.objects.AccessPoint) Interface(org.netxms.client.objects.Interface)

Aggregations

InetAddressEx (org.netxms.base.InetAddressEx)16 AbstractObject (org.netxms.client.objects.AbstractObject)4 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 AccessPoint (org.netxms.client.objects.AccessPoint)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 Interface (org.netxms.client.objects.Interface)2 IOException (java.io.IOException)1 Inet4Address (java.net.Inet4Address)1 HashSet (java.util.HashSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1