use of org.netxms.client.NXCException in project netxms by netxms.
the class ImageLibrary method deleteImage.
/**
*/
protected void deleteImage() {
final GalleryItem[] selection = gallery.getSelection();
for (GalleryItem item : selection) {
try {
session.deleteImage((LibraryImage) item.getData());
final GalleryItem category = item.getParentItem();
gallery.remove(item);
if (category != null) {
if (category.getItemCount() == 0) {
gallery.remove(category);
}
}
} catch (NXCException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class VlanMap method processVlanPort.
/**
* Process single member port of VLAN. Will add connected switch on other site to the map.
*
* @param page
* @param root
* @param port
* @throws Exception
*/
private void processVlanPort(NetworkMapPage page, Node root, Port port, long rootElementId) throws Exception {
Interface iface = (Interface) session.findObjectById(port.getObjectId(), Interface.class);
if (iface != null) {
Node peerNode = (Node) session.findObjectById(iface.getPeerNodeId(), Node.class);
if ((peerNode != null) && ((peerNode.getCapabilities() & Node.NC_IS_BRIDGE) != 0)) {
try {
long nodeElementId = collectVlanInfo(page, peerNode);
if (nodeElementId != -1) {
Interface peerIf = (Interface) session.findObjectById(iface.getPeerInterfaceId(), Interface.class);
page.addLink(new NetworkMapLink(null, NetworkMapLink.NORMAL, rootElementId, nodeElementId, iface.getObjectName(), (peerIf != null) ? peerIf.getObjectName() : "???", // $NON-NLS-1$ //$NON-NLS-2$
0));
}
} catch (NXCException e) {
// Ignore NetXMS errors for remote bridges
}
}
}
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class SubnetAddressMap method refresh.
/**
* Refresh widget
*/
public void refresh() {
if (subnet == null) {
addressMap = null;
rowCount = 0;
redraw();
return;
}
new ConsoleJob(Messages.get().SubnetAddressMap_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
final long[] map = session.getSubnetAddressMap(subnet.getObjectId());
runInUIThread(new Runnable() {
@Override
public void run() {
addressMap = map;
rowCount = (map.length + ELEMENTS_PER_ROW - 1) / ELEMENTS_PER_ROW;
if (rowCount > MAX_ROWS)
rowCount = MAX_ROWS;
redraw();
}
});
} catch (NXCException e) {
runInUIThread(new Runnable() {
@Override
public void run() {
addressMap = null;
rowCount = 0;
redraw();
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SubnetAddressMap_JobError;
}
}.start();
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class LoginJob method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.get(display).LoginJob_connecting, 100);
try {
final String hostName;
int port = NXCSession.DEFAULT_CONN_PORT;
// $NON-NLS-1$
final String[] split = server.split(":");
if (split.length == 2) {
hostName = split[0];
try {
port = Integer.valueOf(split[1]);
} catch (NumberFormatException e) {
// ignore
}
} else {
hostName = server;
}
final NXCSession session = createSession(hostName, port);
session.setClientLanguage(language);
// $NON-NLS-1$
session.setClientInfo("nxweb/" + NXCommon.VERSION);
session.setIgnoreProtocolVersion(ignoreProtocolVersion);
session.setClientType(NXCSession.WEB_CLIENT);
session.setClientAddress(clientAddress);
monitor.worked(10);
session.connect(new int[] { ProtocolVersion.INDEX_FULL });
session.login(authMethod, (loginName != null) ? loginName : "?", password, certificate, signature);
monitor.worked(40);
monitor.setTaskName(Messages.get(display).LoginJob_sync_objects);
session.syncObjects();
monitor.worked(25);
monitor.setTaskName(Messages.get(display).LoginJob_sync_users);
session.syncUserDatabase();
monitor.worked(5);
monitor.setTaskName(Messages.get(display).LoginJob_sync_event_db);
try {
session.syncEventObjects();
} catch (NXCException e) {
if (e.getErrorCode() != RCC.ACCESS_DENIED)
throw e;
}
try {
session.syncAlarmCategories();
} catch (NXCException e) {
if (e.getErrorCode() != RCC.ACCESS_DENIED)
throw e;
}
monitor.worked(5);
monitor.setTaskName(Messages.get(display).LoginJob_subscribe);
session.subscribe(NXCSession.CHANNEL_ALARMS);
monitor.worked(5);
RWT.getUISession(display).setAttribute(ConsoleSharedData.ATTRIBUTE_SESSION, session);
display.syncExec(new Runnable() {
@Override
public void run() {
SourceProvider.getInstance().updateAccessRights(session.getUserSystemRights());
}
});
monitor.setTaskName(Messages.get(display).LoginJob_init_extensions);
callLoginListeners(session);
monitor.worked(5);
new KeepAliveTimer(session).start();
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
// $NON-NLS-1$
monitor.setTaskName("");
monitor.done();
}
}
use of org.netxms.client.NXCException in project netxms by netxms.
the class PackageManager method dispose.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
*/
@Override
public void dispose() {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().PackageManager_UnlockDatabase, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
try {
session.unlockPackageDatabase();
} catch (NXCException e) {
// New versions may not require package DB lock
if (e.getErrorCode() != RCC.NOT_IMPLEMENTED)
throw e;
}
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DBUnlockError;
}
}.start();
super.dispose();
}
Aggregations