Search in sources :

Example 31 with ECFException

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

the class AbstractRemoteServiceTest method testBadCallSynch.

public void testBadCallSynch() throws Exception {
    final IRemoteService service = registerAndGetRemoteService();
    if (service == null)
        return;
    // exist
    try {
        service.callSync(createRemoteCall("concat1", new Object[] { "first", "second" }));
        fail();
    } catch (final ECFException e) {
    // Exception should occur
    }
    // concat
    try {
        service.callSync(createRemoteCall("concat", new Object[] { "first" }));
        fail();
    } catch (final ECFException e) {
    // Exception should occur
    }
    Thread.sleep(SLEEPTIME);
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 32 with ECFException

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

the class TwitterRemoteServiceTest method testGetProxy.

public void testGetProxy() {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    try {
        IUserTimeline userTimeline = (IUserTimeline) restClientService.getProxy();
        assertNotNull(userTimeline);
    } catch (ECFException e) {
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 33 with ECFException

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

the class TwitterRemoteServiceTest method testSyncCall.

public void testSyncCall() {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    try {
        Object result = restClientService.callSync(RestCallFactory.createRestCall(IUserTimeline.class.getName() + ".getUserStatuses"));
        assertNotNull(result);
    } catch (ECFException e) {
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) JSONObject(org.json.JSONObject) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 34 with ECFException

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

the class TwitterRemoteServiceTest method testSyncCallWithCountParameter.

public void testSyncCallWithCountParameter() {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    try {
        Object result = restClientService.callSync(RestCallFactory.createRestCall(IUserTimeline.class.getName() + ".getUserStatuses", new IRemoteCallParameter[] { new RemoteCallParameter("count", "1") }));
        assertNotNull(result);
        assertTrue(result instanceof IUserStatus[]);
        assertTrue(((IUserStatus[]) result).length == 1);
    } catch (ECFException e) {
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IRemoteCallParameter(org.eclipse.ecf.remoteservice.client.IRemoteCallParameter) RemoteCallParameter(org.eclipse.ecf.remoteservice.client.RemoteCallParameter) IRemoteCallParameter(org.eclipse.ecf.remoteservice.client.IRemoteCallParameter) JSONObject(org.json.JSONObject) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 35 with ECFException

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

the class SyncResourcesCore method distributeChanges.

private void distributeChanges() {
    for (Iterator it = resourceChanges.entrySet().iterator(); it.hasNext(); ) {
        Entry entry = (Entry) it.next();
        ResourcesShare share = (ResourcesShare) entry.getKey();
        List changes = (List) entry.getValue();
        List messages = new ArrayList();
        for (int i = 0; i < changes.size(); i++) {
            ResourceChangeMessage change = (ResourceChangeMessage) changes.get(i);
            switch(change.getKind()) {
                case IResourceDelta.ADDED:
                    if (getInt(PreferenceConstants.LOCAL_RESOURCE_ADDITION) == PreferenceConstants.IGNORE_VALUE) {
                        change.setIgnored(true);
                        continue;
                    }
                    break;
                case IResourceDelta.CHANGED:
                    if (getInt(PreferenceConstants.LOCAL_RESOURCE_CHANGE) == PreferenceConstants.IGNORE_VALUE) {
                        change.setIgnored(true);
                        continue;
                    }
                    break;
                case IResourceDelta.REMOVED:
                    if (getInt(PreferenceConstants.LOCAL_RESOURCE_DELETION) == PreferenceConstants.IGNORE_VALUE) {
                        change.setIgnored(true);
                        continue;
                    }
                    break;
            }
            IModelChangeMessage[] changeMessages = ResourcesSynchronizationStrategy.getInstance().registerLocalChange(change);
            messages.addAll(Arrays.asList(changeMessages));
        }
        try {
            if (!messages.isEmpty()) {
                IModelChangeMessage[] messagesArray = (IModelChangeMessage[]) messages.toArray(new IModelChangeMessage[messages.size()]);
                BatchModelChange batchChange = new BatchModelChange(messagesArray);
                share.send(Message.serialize(batchChange));
                add(batchChange);
            }
        } catch (ECFException e) {
            getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Could not send resource change message", // $NON-NLS-1$
            e));
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Entry(java.util.Map.Entry) ECFException(org.eclipse.ecf.core.util.ECFException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) IModelChangeMessage(org.eclipse.ecf.sync.IModelChangeMessage)

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