Search in sources :

Example 21 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class AbstractClientService method fireAsync.

public void fireAsync(IRemoteCall call) throws ECFException {
    IRemoteCallable callable = getRegistration().lookupCallable(call);
    if (callable == null)
        // $NON-NLS-1$
        throw new ECFException("Remote callable not found");
    callAsync(call, callable);
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException)

Example 22 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class TrivialClient method run.

public void run() {
    try {
        // Create instance of trivial container
        IContainer container = ContainerFactory.getDefault().createContainer("ecf.container.trivial");
        // Get appropriate container adapter...e.g. IChannelContainerAdapter
        // IChannelContainerAdapter containerAdapter =
        // (IChannelContainerAdapter)
        // container.getAdapter(IChannelContainerAdapter.class);
        // Connect
        ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), "myid");
        container.connect(targetID, null);
    } catch (ECFException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 23 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class RemoteServiceAdmin method createProxy.

private Object createProxy(Bundle requestingBundle, ServiceReference serviceReference, IRemoteService remoteService, Map<String, Version> interfaceVersions) {
    // Get symbolicName once for possible use below
    String bundleSymbolicName = requestingBundle.getSymbolicName();
    // Get String[] via OBJECTCLASS constant property
    String[] serviceClassnames = (String[]) serviceReference.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
    // Load as many of the serviceInterface classes as possible
    Collection<Class> serviceInterfaceClasses = loadServiceInterfacesViaBundle(requestingBundle, serviceClassnames);
    // load...otherwise the service can't be accessed
    if (serviceInterfaceClasses.size() < 1)
        throw new RuntimeException(// $NON-NLS-1$
        "ProxyServiceFactory cannot load any serviceInterfaces=" + serviceInterfaceClasses + " for serviceReference=" + // $NON-NLS-1$
        serviceReference + " via clientBundle=" + // $NON-NLS-1$
        bundleSymbolicName);
    // Now verify that the classes are of valid versions
    if (!verifyServiceInterfaceVersionsForProxy(requestingBundle, serviceInterfaceClasses, interfaceVersions))
        return null;
    // Now create/get class loader for proxy. This will typically
    // be an instance of ProxyClassLoader
    ClassLoader cl = getProxyClassLoader(requestingBundle);
    try {
        return remoteService.getProxy(cl, (Class[]) serviceInterfaceClasses.toArray(new Class[serviceInterfaceClasses.size()]));
    } catch (ECFException e) {
        throw new ServiceException(// $NON-NLS-1$
        "ProxyServiceFactory cannot create proxy for clientBundle=" + bundleSymbolicName + // $NON-NLS-1$
        " from serviceReference=" + serviceReference, e);
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) ServiceException(org.osgi.framework.ServiceException)

Example 24 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class ResourcesShareHandler method run.

private void run(Shell shell, final ResourcesShare share, final String projectName) {
    final boolean[] ret = { false };
    try {
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
        dialog.open();
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Sharing " + projectName, IProgressMonitor.UNKNOWN);
                    monitor.subTask("Sending request...");
                    share.startShare(getRosterEntry().getRoster().getUser().getID(), getRosterEntry().getUser().getID(), projectName);
                    monitor.subTask("Waiting for acknowledgement...");
                    while (true) {
                        if (monitor.isCanceled()) {
                            throw new InterruptedException();
                        }
                        Thread.sleep(50);
                        Boolean response = share.getResponse();
                        if (response != null) {
                            ret[0] = response.booleanValue();
                            return;
                        }
                    }
                } catch (ECFException e) {
                    throw new InvocationTargetException(e);
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (InvocationTargetException e) {
        IStatus status = new Status(IStatus.ERROR, SyncResourcesUI.PLUGIN_ID, "Could not send share request", e.getCause());
        StatusManager.getManager().handle(status);
        SyncResourcesUI.log(status);
    } catch (InterruptedException e) {
        // operation canceled, stop sharing this project
        share.stopSharing(projectName);
        return;
    }
    if (ret[0]) {
        IRosterManager manager = getRosterEntry().getRoster().getPresenceContainerAdapter().getRosterManager();
        manager.addRosterListener(new RosterListener(share, projectName, getRosterEntry()));
    } else {
        MessageDialog.openInformation(shell, null, "Sharing request denied.");
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IRosterManager(org.eclipse.ecf.presence.roster.IRosterManager) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) ECFException(org.eclipse.ecf.core.util.ECFException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 25 with ECFException

use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.

the class SynchronizeWithHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IRosterEntry selectedEntry = getRosterEntry();
    IRoster roster = selectedEntry.getRoster();
    final IUser remoteUser = roster.getUser();
    final ID localId = remoteUser.getID();
    final ID remoteId = selectedEntry.getUser().getID();
    IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
    final IResource[] resources = getResources(event);
    final RemoteShare share = TeamSynchronization.getShare(container.getID());
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    final IWorkbenchPartSite site = part == null ? null : part.getSite();
    final Shell shell = HandlerUtil.getActiveShellChecked(event);
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    final boolean[] response = { true };
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            if (resources.length == 1) {
                monitor.beginTask(NLS.bind(Messages.SynchronizeWithHandler_SynchronizeResourceTaskName, resources[0].getName()), IProgressMonitor.UNKNOWN);
            } else {
                monitor.beginTask(Messages.SynchronizeWithHandler_SynchronizeResourcesTaskName, IProgressMonitor.UNKNOWN);
            }
            try {
                if (share.sendShareRequest(localId, remoteId, resources, monitor)) {
                    scheduleRefreshJob(share, localId, remoteId, resources, remoteUser, site);
                } else {
                    response[0] = false;
                }
            } catch (ECFException e) {
                throw new InvocationTargetException(e);
            } catch (OperationCanceledException e) {
                // operation, but check for this just in case
                if (!monitor.isCanceled()) {
                    throw e;
                }
            }
        }
    };
    try {
        dialog.run(true, true, runnable);
        if (!response[0]) {
            MessageDialog.openInformation(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestDenial);
        }
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause instanceof ECFException) {
            MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestError);
        }
        // $NON-NLS-1$
        TeamSynchronization.log("Failed to contact remote peer", cause);
    } catch (InterruptedException e) {
        Thread.interrupted();
        MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestInterrupted);
        // $NON-NLS-1$
        TeamSynchronization.log("Synchronization request operation was interrupted", e);
    }
    return null;
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IRoster(org.eclipse.ecf.presence.roster.IRoster) Shell(org.eclipse.swt.widgets.Shell) ECFException(org.eclipse.ecf.core.util.ECFException) RemoteShare(org.eclipse.team.internal.ecf.core.RemoteShare) IUser(org.eclipse.ecf.core.user.IUser) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) IResource(org.eclipse.core.resources.IResource)

Aggregations

ECFException (org.eclipse.ecf.core.util.ECFException)42 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)9 Iterator (java.util.Iterator)5 IStatus (org.eclipse.core.runtime.IStatus)5 ID (org.eclipse.ecf.core.identity.ID)5 Status (org.eclipse.core.runtime.Status)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 IOException (java.io.IOException)3 IContainer (org.eclipse.ecf.core.IContainer)3 Action (org.eclipse.jface.action.Action)3 IAction (org.eclipse.jface.action.IAction)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 List (java.util.List)2 TimeoutException (java.util.concurrent.TimeoutException)2 Namespace (org.eclipse.ecf.core.identity.Namespace)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 IUser (org.eclipse.ecf.core.user.IUser)2 IChatRoomInfo (org.eclipse.ecf.presence.chatroom.IChatRoomInfo)2 IEcho (org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho)2