Search in sources :

Example 11 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testProcessReply2.

@Test
public void testProcessReply2() {
    final Xid dummyXid = new Xid(DUMMY_XID);
    final Error mockedError = mock(Error.class);
    deviceContext.processReply(dummyXid, Lists.newArrayList(mockedError));
    verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_FAILURE));
    final MultipartReply mockedMultipartReply = mock(MultipartReply.class);
    deviceContext.processReply(dummyXid, Lists.newArrayList(mockedMultipartReply));
    verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS));
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) Test(org.junit.Test)

Example 12 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project openflowplugin by opendaylight.

the class AbstractRequestCallback method onFailure.

@Override
public final void onFailure(@Nonnull final Throwable throwable) {
    final RpcResultBuilder<T> builder;
    if (null != eventIdentifier) {
        EventsTimeCounter.markEnd(eventIdentifier);
    }
    if (throwable instanceof DeviceRequestFailedException) {
        final Error err = ((DeviceRequestFailedException) throwable).getError();
        final String errorString = String.format("Device reported error type %s code %s", err.getTypeString(), err.getCodeString());
        builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errorString, throwable);
        spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_FAILURE);
    } else {
        builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
        spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_ERROR);
    }
    context.setResult(builder.build());
    RequestContextUtil.closeRequestContext(context);
}
Also used : DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 13 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.

the class ConnectionBuilder45 method createConnectionSocketFactoryRegistry.

private Registry createConnectionSocketFactoryRegistry() {
    String protocol = getProtocol();
    Registry registry = null;
    // Create SSL/TLS or plain connection:
    if (HTTP_PROTOCOL.equals(protocol)) {
        ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
        registry = RegistryBuilder.<ConnectionSocketFactory>create().register(HTTP_PROTOCOL, plainsf).build();
    } else if (HTTPS_PROTOCOL.equals(protocol)) {
        try {
            LayeredConnectionSocketFactory sslsf = null;
            if (this.insecure) {
                SSLContext sslcontext = SSLContext.getInstance("TLS");
                sslcontext.init(null, new TrustManager[] { noCaTrustManager }, null);
                sslsf = new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE);
            } else {
                SSLContextBuilder sslContextBuilder = SSLContexts.custom();
                if (trustStoreFile != null) {
                    sslContextBuilder.loadTrustMaterial(new File(trustStoreFile), this.trustStorePassword != null ? this.trustStorePassword.toCharArray() : null);
                }
                SSLContext sslContext = sslContextBuilder.build();
                sslsf = new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
            }
            registry = RegistryBuilder.<ConnectionSocketFactory>create().register(HTTPS_PROTOCOL, sslsf).build();
        } catch (NoSuchAlgorithmException e) {
            throw new Error(NO_TLS_ERROR, e);
        } catch (KeyManagementException e) {
            throw new Error(BAD_KEY_ERROR, e);
        } catch (KeyStoreException e) {
            throw new Error(KEY_STORE_ERROR, e);
        } catch (FileNotFoundException e) {
            throw new Error(KEY_STORE_FILE_NOT_FOUND_ERROR, e);
        } catch (CertificateException e) {
            throw new Error(CERTIFICATE_ERROR, e);
        } catch (IOException e) {
            throw new Error(IO_ERROR, e);
        }
    } else {
        throw new Error(BAD_PROTOCOL_ERROR + protocol);
    }
    return registry;
}
Also used : LayeredConnectionSocketFactory(org.apache.http.conn.socket.LayeredConnectionSocketFactory) FileNotFoundException(java.io.FileNotFoundException) Error(org.ovirt.engine.sdk4.Error) CertificateException(java.security.cert.CertificateException) Registry(org.apache.http.config.Registry) SSLContext(javax.net.ssl.SSLContext) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) KeyManagementException(java.security.KeyManagementException) TrustManager(javax.net.ssl.TrustManager) PlainConnectionSocketFactory(org.apache.http.conn.socket.PlainConnectionSocketFactory) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) LayeredConnectionSocketFactory(org.apache.http.conn.socket.LayeredConnectionSocketFactory) ConnectionSocketFactory(org.apache.http.conn.socket.ConnectionSocketFactory) DefaultHostnameVerifier(org.apache.http.conn.ssl.DefaultHostnameVerifier) SSLContextBuilder(org.apache.http.ssl.SSLContextBuilder) File(java.io.File)

Example 14 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.

the class HttpConnection method revokeAccessToken.

private void revokeAccessToken() {
    // Build SSO revoke URL:
    URI ssoRevokeURI = ssoRevokeUrl != null ? SsoUtils.buildUrl(ssoRevokeUrl) : ssoToken != null ? SsoUtils.buildSsoRevokeUrl(url) : null;
    // Construct POST body:
    List<NameValuePair> params = new ArrayList<>(2);
    params.add(new BasicNameValuePair("scope", "ovirt-app-api"));
    params.add(new BasicNameValuePair("token", ssoToken));
    // Send request to revoke SSO token:
    if (ssoRevokeURI != null) {
        JsonNode node = getSsoResponse(ssoRevokeURI, params);
        if (node.isArray()) {
            node = node.get(0);
        }
        if (node.get("error") != null) {
            throw new Error(String.format("Error during SSO token revoke %1$s : %2$s", node.get("error_code"), node.get("error")));
        }
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList) Error(org.ovirt.engine.sdk4.Error) JsonNode(org.codehaus.jackson.JsonNode) URI(java.net.URI)

Example 15 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project ovirt-engine-sdk-java by oVirt.

the class HttpConnection method followLink.

@Override
public <TYPE> TYPE followLink(TYPE object) {
    if (!isLink(object)) {
        throw new Error("Can't follow link because object don't have any");
    }
    String href = getHref(object);
    if (href == null) {
        throw new Error("Can't follow link because the 'href' attribute does't have a value");
    }
    try {
        URL url = new URL(getUrl());
        String prefix = url.getPath();
        if (!prefix.endsWith("/")) {
            prefix += "/";
        }
        if (!href.startsWith(prefix)) {
            throw new Error("The URL '" + href + "' isn't compatible with the base URL of the connection");
        }
        // Get service based on path
        String path = href.substring(prefix.length());
        Service service = systemService().service(path);
        // Obtain method which provides result object and invoke it:
        Method get;
        if (object instanceof ListWithHref) {
            get = service.getClass().getMethod("list");
        } else {
            get = service.getClass().getMethod("get");
        }
        Object getRequest = get.invoke(service);
        Method send = getRequest.getClass().getMethod("send");
        send.setAccessible(true);
        Object getResponse = send.invoke(getRequest);
        Method obtainObject = getResponse.getClass().getDeclaredMethods()[0];
        obtainObject.setAccessible(true);
        return (TYPE) obtainObject.invoke(getResponse);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        throw new Error(String.format("Unexpected error while following link \"%1$s\"", href), ex);
    } catch (MalformedURLException ex) {
        throw new Error(String.format("Error while creating URL \"%1$s\"", getUrl()), ex);
    }
}
Also used : ListWithHref(org.ovirt.api.metamodel.runtime.util.ListWithHref) MalformedURLException(java.net.MalformedURLException) Error(org.ovirt.engine.sdk4.Error) SystemService(org.ovirt.engine.sdk4.services.SystemService) Service(org.ovirt.engine.sdk4.Service) Method(java.lang.reflect.Method) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Error (org.ovirt.engine.sdk4.Error)11 Error (org.eclipse.bpmn2.Error)8 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)7 Escalation (org.eclipse.bpmn2.Escalation)7 Process (org.eclipse.bpmn2.Process)6 RootElement (org.eclipse.bpmn2.RootElement)6 Signal (org.eclipse.bpmn2.Signal)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 Entry (java.util.Map.Entry)5 Error (org.bytedeco.javacpp.FlyCapture2.Error)5 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 Activity (org.eclipse.bpmn2.Activity)4 CallActivity (org.eclipse.bpmn2.CallActivity)4 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)4 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)4 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)4