Search in sources :

Example 66 with NXCPMessage

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

the class NXCSession method getAgentConfig.

/**
 * Get agent's master configuration file.
 *
 * @param nodeId Node ID
 * @return Master configuration file of agent running on given node
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public String getAgentConfig(long nodeId) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_AGENT_CONFIG);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsString(NXCPCodes.VID_CONFIG_FILE);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 67 with NXCPMessage

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

the class NXCSession method getEffectiveRights.

/**
 * Get effective rights of currently logged in user to given object.
 *
 * @param objectId The object ID
 * @return The effective rights
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public int getEffectiveRights(final long objectId) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_EFFECTIVE_RIGHTS);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
    sendMessage(msg);
    return waitForRCC(msg.getMessageId()).getFieldAsInt32(NXCPCodes.VID_EFFECTIVE_RIGHTS);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 68 with NXCPMessage

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

the class NXCSession method copyAgentFile.

/**
 * Copy file from agent
 *
 * @param nodeId node id
 * @param oldName old file path
 * @param newFileName new file path
 * @param overwrite should the file in destination be overwritten
 * @throws IOException  if socket or file I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void copyAgentFile(long nodeId, String oldName, String newFileName, boolean overwrite) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_FILEMGR_COPY_FILE);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    msg.setField(NXCPCodes.VID_FILE_NAME, oldName);
    msg.setField(NXCPCodes.VID_NEW_FILE_NAME, newFileName);
    msg.setField(NXCPCodes.VID_OVERWRITE, overwrite);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 69 with NXCPMessage

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

the class NXCSession method updateMappingTable.

/**
 * Create or update mapping table. If table ID is 0, new table will be created on server.
 *
 * @param table mapping table
 * @return ID of new table object
 * @throws IOException if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public int updateMappingTable(MappingTable table) throws IOException, NXCException {
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_MAPPING_TABLE);
    table.fillMessage(msg);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    return response.getFieldAsInt32(NXCPCodes.VID_MAPPING_TABLE_ID);
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

Example 70 with NXCPMessage

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

the class NXCSession method modifyImage.

/**
 * Modify an image
 *
 * @param image The image to modify
 * @param listener The ProgressListener
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyImage(LibraryImage image, ProgressListener listener) throws IOException, NXCException {
    if (image.isProtected()) {
        throw new NXCException(RCC.INVALID_REQUEST);
    }
    final NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_IMAGE);
    image.fillMessage(msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
    sendFile(msg.getMessageId(), image.getBinaryData(), listener, allowCompression);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage)

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