Search in sources :

Example 1 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class DnsSdDiscoveryLocator method connect.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
	 * org.eclipse.ecf.core.security.IConnectContext)
	 */
public void connect(ID aTargetID, IConnectContext connectContext) throws ContainerConnectException {
    // connect can only be called once
    if (targetID != null || getConfig() == null) {
        throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_Container_Already_Connected);
    }
    // fall back to the search path as last resort
    if (aTargetID == null || !(aTargetID instanceof DnsSdServiceTypeID)) {
        ResolverConfig config = new ResolverConfig();
        Name[] searchPaths = config.searchPath();
        if (searchPaths != null && searchPaths.length > 0) {
            targetID = new DnsSdServiceTypeID();
            targetID.setSearchPath(searchPaths);
        } else {
            throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_No_Target_ID);
        }
    } else {
        final Namespace ns = getConnectNamespace();
        try {
            targetID = (DnsSdServiceTypeID) ns.createInstance(new Object[] { aTargetID });
        } catch (IDCreateException e) {
            throw new ContainerConnectException(e);
        }
    }
    // instantiate a default resolver
    if (resolver == null) {
        try {
            resolver = new SimpleResolver();
        } catch (UnknownHostException e) {
            throw new ContainerConnectException(e);
        }
    }
    // read browsing domains for the given targetID/searchpath and merge with existing
    targetID.addSearchPath(getBrowsingDomains(targetID));
    // done setting up this provider, send event
    fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, connectContext));
    fireContainerEvent(new ContainerConnectedEvent(this.getID(), targetID));
}
Also used : ResolverConfig(org.xbill.DNS.ResolverConfig) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) UnknownHostException(java.net.UnknownHostException) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ContainerConnectedEvent(org.eclipse.ecf.core.events.ContainerConnectedEvent) ContainerConnectingEvent(org.eclipse.ecf.core.events.ContainerConnectingEvent) SimpleResolver(org.xbill.DNS.SimpleResolver) Namespace(org.eclipse.ecf.core.identity.Namespace) Name(org.xbill.DNS.Name)

Example 2 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PubSubAdapterFactory method getDirectory.

protected IPublishedServiceDirectory getDirectory(ISharedObjectContainer container) {
    ID directoryID;
    try {
        directoryID = IDFactory.getDefault().createStringID(PublishedServiceDirectory.SHARED_OBJECT_ID);
    } catch (IDCreateException e) {
        throw new RuntimeException(e);
    }
    final ISharedObjectManager mgr = container.getSharedObjectManager();
    IPublishedServiceDirectory directory = (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
    if (directory != null)
        return directory;
    try {
        SharedObjectDescription desc = createDirectoryDescription(directoryID);
        mgr.createSharedObject(desc);
        return (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
    } catch (SharedObjectCreateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
}
Also used : IPublishedServiceDirectory(org.eclipse.ecf.pubsub.IPublishedServiceDirectory) SharedObjectDescription(org.eclipse.ecf.core.sharedobject.SharedObjectDescription) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID)

Example 3 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class PubSubView method init.

public void init(IViewSite site) throws PartInitException {
    super.init(site);
    final Action shareSomethingAction = new Action("Share something") {

        public void run() {
            try {
                IMasterModel sds = SharedModelFactory.getInstance().createSharedDataSource(container, IDFactory.getDefault().createGUID(), new AppendableList(), ListAppender.ID);
                if (sds == null)
                    MessageDialog.openError(getSite().getShell(), "Error", "Could not share anything.");
                else {
                    sharedLists.add(sds);
                    sharedListViewer.add(sds);
                }
            } catch (SharedObjectCreateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IDCreateException e) {
                throw new RuntimeException(e);
            }
        }
    };
    shareSomethingAction.setEnabled(false);
    IMenuManager mgr = site.getActionBars().getMenuManager();
    mgr.add(new Action("Start") {

        public void run() {
            container = CollabClient.getContainer(ResourcesPlugin.getWorkspace().getRoot());
            if (container == null) {
                MessageDialog.openError(getSite().getShell(), "Error", "Collaboration environment not found.");
                return;
            }
            IPublishedServiceDirectory directory = (IPublishedServiceDirectory) container.getAdapter(IPublishedServiceDirectory.class);
            viewer.setInput(directory);
            setEnabled(false);
            shareSomethingAction.setEnabled(true);
        }
    });
    mgr.add(shareSomethingAction);
    menuManager = new MenuManager();
    subscribeAction = new BaseSelectionListenerAction("Subscribe") {

        public void run() {
            PublishedServiceDescriptor desc = (PublishedServiceDescriptor) getStructuredSelection().getFirstElement();
            IPublishedServiceRequestor requestor = (IPublishedServiceRequestor) container.getAdapter(IPublishedServiceRequestor.class);
            requestor.subscribe(desc.getContainerID(), desc.getSharedObjectID(), new SubscriptionViewOpener());
        }

        protected boolean updateSelection(IStructuredSelection selection) {
            return !selection.isEmpty();
        }
    };
    subscribeAction.setEnabled(false);
    menuManager.add(subscribeAction);
    sharedListMenuManager = new MenuManager();
    appendAction = new BaseSelectionListenerAction("Append...") {

        public void run() {
            InputDialog dlg = new InputDialog(getSite().getShell(), "Append to Shared List", "Enter element to append:", null, null);
            dlg.open();
            String value = dlg.getValue();
            if (value != null) {
                LocalAgent model = (LocalAgent) getStructuredSelection().getFirstElement();
                AppendableList list = (AppendableList) model.getData();
                if (list.add(value)) {
                    try {
                        model.update(value);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        }

        protected boolean updateSelection(IStructuredSelection selection) {
            return !selection.isEmpty();
        }
    };
    appendAction.setEnabled(false);
    sharedListMenuManager.add(appendAction);
}
Also used : IPublishedServiceDirectory(org.eclipse.ecf.pubsub.IPublishedServiceDirectory) LocalAgent(org.eclipse.ecf.pubsub.model.impl.LocalAgent) PublishedServiceDescriptor(org.eclipse.ecf.pubsub.PublishedServiceDescriptor) Action(org.eclipse.jface.action.Action) BaseSelectionListenerAction(org.eclipse.ui.actions.BaseSelectionListenerAction) InputDialog(org.eclipse.jface.dialogs.InputDialog) IMasterModel(org.eclipse.ecf.pubsub.model.IMasterModel) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) BaseSelectionListenerAction(org.eclipse.ui.actions.BaseSelectionListenerAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IPublishedServiceRequestor(org.eclipse.ecf.pubsub.IPublishedServiceRequestor) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 4 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class ConnectedTester method hasContainer.

private boolean hasContainer(Object receiver) {
    // get the container instance
    IServiceInfo serviceInfo = DiscoveryPropertyTesterUtil.getIServiceInfoReceiver(receiver);
    final String connectNamespace = getConnectNamespace(serviceInfo);
    final String connectId = getConnectID(serviceInfo);
    try {
        final ID createConnectId = IDFactory.getDefault().createID(connectNamespace, connectId);
        return (getContainerByConnectID(createConnectId) != null);
    } catch (IDCreateException e) {
        // Trace.trace(...);
        return false;
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) ID(org.eclipse.ecf.core.identity.ID)

Example 5 with IDCreateException

use of org.eclipse.ecf.core.identity.IDCreateException in project ecf by eclipse.

the class RemoteServiceHandlerUtil method getActiveConnectIDChecked.

public static ID getActiveConnectIDChecked(ExecutionEvent event) throws ExecutionException {
    final IServiceInfo serviceInfo = DiscoveryHandlerUtil.getActiveIServiceInfoChecked(event);
    final String connectNamespace = getConnectNamespace(serviceInfo);
    final String connectId = getConnectID(serviceInfo);
    try {
        return IDFactory.getDefault().createID(connectNamespace, connectId);
    } catch (IDCreateException e) {
        throw new ExecutionException(e.getMessage(), e);
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)34 ID (org.eclipse.ecf.core.identity.ID)16 Matcher (java.util.regex.Matcher)11 Namespace (org.eclipse.ecf.core.identity.Namespace)8 ThreadMessageID (org.eclipse.ecf.internal.provider.phpbb.identity.ThreadMessageID)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 ExecutionException (org.eclipse.core.commands.ExecutionException)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 UnknownHostException (java.net.UnknownHostException)3 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)3 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)3 ThreadMessageFactory (org.eclipse.ecf.internal.provider.vbulletin.internal.ThreadMessageFactory)3 URI (java.net.URI)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 NameValuePair (org.apache.commons.httpclient.NameValuePair)2 Job (org.eclipse.core.runtime.jobs.Job)2 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)2 IThreadMessage (org.eclipse.ecf.bulletinboard.IThreadMessage)2