use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method updateAgentConfig.
/**
* Update agent's master configuration file.
*
* @param nodeId Node ID
* @param config New configuration file content
* @param apply Apply flag - if set to true, agent will restart automatically to
* apply changes
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void updateAgentConfig(long nodeId, String config, boolean apply) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_AGENT_CONFIG);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
msg.setField(NXCPCodes.VID_CONFIG_FILE, config);
msg.setFieldInt16(NXCPCodes.VID_APPLY_FLAG, apply ? 1 : 0);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method changeObjectBinding.
/**
* Common internal implementation for bindObject, unbindObject, and
* removeTemplate
*
* @param parentId parent object's identifier
* @param childId Child object's identifier
* @param bind true if operation is "bind"
* @param removeDci true if DCIs created from template should be removed during
* unbind
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
private void changeObjectBinding(long parentId, long childId, boolean bind, boolean removeDci) throws IOException, NXCException {
NXCPMessage msg = newMessage(bind ? NXCPCodes.CMD_BIND_OBJECT : NXCPCodes.CMD_UNBIND_OBJECT);
msg.setFieldInt32(NXCPCodes.VID_PARENT_ID, (int) parentId);
msg.setFieldInt32(NXCPCodes.VID_CHILD_ID, (int) childId);
msg.setFieldInt16(NXCPCodes.VID_REMOVE_DCI, removeDci ? 1 : 0);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method uploadFileToServer.
/**
* Upload local file to server's file store
*
* @param localFile local file
* @param serverFileName name under which file will be stored on server
* @param listener The ProgressListener to set
* @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 uploadFileToServer(File localFile, String serverFileName, ProgressListener listener) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPLOAD_FILE);
if ((serverFileName == null) || serverFileName.isEmpty()) {
serverFileName = localFile.getName();
}
msg.setField(NXCPCodes.VID_FILE_NAME, serverFileName);
msg.setField(NXCPCodes.VID_MODIFICATION_TIME, new Date(localFile.lastModified()));
sendMessage(msg);
waitForRCC(msg.getMessageId());
sendFile(msg.getMessageId(), localFile, listener, allowCompression);
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getNetworkPath.
/**
* Get IPv4 network path between two nodes. Server will return path based
* on cached routing table information. Network path object may be incomplete
* if server does not have enough information to build full path. In this case,
* no exception thrown, and completness of path can be checked by calling
* NetworkPath.isComplete().
*
* @param node1 source node
* @param node2 destination node
* @return network path object
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public NetworkPath getNetworkPath(long node1, long node2) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_NETWORK_PATH);
msg.setFieldInt32(NXCPCodes.VID_SOURCE_OBJECT_ID, (int) node1);
msg.setFieldInt32(NXCPCodes.VID_DESTINATION_OBJECT_ID, (int) node2);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return new NetworkPath(response);
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getAttributeForCurrentUser.
/**
* Get custom attribute for currently logged in user. If attribute is not set, empty string will
* be returned.
*
* @param name Attribute's name
* @return Attribute's value
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public String getAttributeForCurrentUser(final String name) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_CURRENT_USER_ATTR);
msg.setField(NXCPCodes.VID_NAME, name);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return response.getFieldAsString(NXCPCodes.VID_VALUE);
}
Aggregations