use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method renameAgentFile.
/**
* Rename agent's file
*
* @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 renameAgentFile(long nodeId, String oldName, String newFileName, boolean overwrite) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_FILEMGR_RENAME_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());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getSnmpCommunities.
/**
* Get list of well-known SNMP communities configured on server.
*
* @return map of SNMP community strings
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public Map<Integer, List<String>> getSnmpCommunities() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_COMMUNITY_LIST);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_STRINGS);
long stringBase = NXCPCodes.VID_COMMUNITY_STRING_LIST_BASE, zoneBase = NXCPCodes.VID_COMMUNITY_STRING_ZONE_LIST_BASE;
Map<Integer, List<String>> map = new HashMap<Integer, List<String>>(count);
List<String> stringList = new ArrayList<String>();
int zoneId = 0;
for (int i = 0; i < count; i++) {
if (i != 0 && zoneId != response.getFieldAsInt32(zoneBase)) {
map.put(zoneId, stringList);
stringList = new ArrayList<String>();
}
stringList.add(response.getFieldAsString(stringBase++));
zoneId = response.getFieldAsInt32(zoneBase++);
}
if (count > 0)
map.put(zoneId, stringList);
return map;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method modifyObjectTool.
/**
* Modify object tool.
*
* @param tool Object tool
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void modifyObjectTool(ObjectToolDetails tool) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_OBJECT_TOOL);
tool.fillMessage(msg);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method createAction.
/**
* Create new server action.
*
* @param name action name
* @return ID assigned to new action
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public long createAction(final String name) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_CREATE_ACTION);
msg.setField(NXCPCodes.VID_ACTION_NAME, name);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return response.getFieldAsInt64(NXCPCodes.VID_ACTION_ID);
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method modifyRepository.
/**
* Modify repository.
*
* @param r The repository
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void modifyRepository(Repository r) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_MODIFY_REPOSITORY);
r.fillMessage(msg);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
Aggregations