Search in sources :

Example 21 with NXCException

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();
        }
    }
}
Also used : IOException(java.io.IOException) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) NXCException(org.netxms.client.NXCException)

Example 22 with NXCException

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
            }
        }
    }
}
Also used : Node(org.netxms.client.objects.Node) Interface(org.netxms.client.objects.Interface) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) NXCException(org.netxms.client.NXCException)

Example 23 with NXCException

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException)

Example 24 with NXCException

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();
    }
}
Also used : NXCSession(org.netxms.client.NXCSession) KeepAliveTimer(org.netxms.ui.eclipse.console.KeepAliveTimer) NXCException(org.netxms.client.NXCException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NXCException(org.netxms.client.NXCException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 25 with NXCException

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException) NXCException(org.netxms.client.NXCException)

Aggregations

NXCException (org.netxms.client.NXCException)34 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)20 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)20 NXCSession (org.netxms.client.NXCSession)16 PartInitException (org.eclipse.ui.PartInitException)13 IOException (java.io.IOException)12 AbstractObject (org.netxms.client.objects.AbstractObject)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)4 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 Alarm (org.netxms.client.events.Alarm)3 AbstractNode (org.netxms.client.objects.AbstractNode)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 AccessListElement (org.netxms.client.AccessListElement)2 DataCollectionConfiguration (org.netxms.client.datacollection.DataCollectionConfiguration)2 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)2 GraphSettings (org.netxms.client.datacollection.GraphSettings)2 AgentPolicy (org.netxms.client.objects.AgentPolicy)2 Node (org.netxms.client.objects.Node)2