Search in sources :

Example 21 with Error

use of org.bytedeco.javacpp.FlyCapture2.Error in project javacv by bytedeco.

the class FlyCapture2FrameGrabber method getDeviceDescriptions.

public static String[] getDeviceDescriptions() throws FrameGrabber.Exception {
    tryLoad();
    BusManager busMgr = new BusManager();
    int[] numCameras = new int[1];
    busMgr.GetNumOfCameras(numCameras);
    String[] descriptions = new String[numCameras[0]];
    for (int i = 0; i < numCameras[0]; i++) {
        PGRGuid guid = new PGRGuid();
        Error error = busMgr.GetCameraFromIndex(i, guid);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
            System.exit(-1);
        }
        Camera cam = new Camera();
        // Connect to a camera
        error = cam.Connect(guid);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
        }
        // Get the camera information
        CameraInfo camInfo = new CameraInfo();
        error = cam.GetCameraInfo(camInfo);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
        }
        descriptions[i] = CameraInfo(camInfo);
    }
    return descriptions;
}
Also used : Error(org.bytedeco.javacpp.FlyCapture2.Error)

Example 22 with Error

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

the class ConnectionBuilder42 method createConnectionSocketFactoryRegistry.

private SchemeRegistry createConnectionSocketFactoryRegistry() {
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    SSLSocketFactory sf;
    // Create SSL/TLS or plain connection:
    if (HTTP_PROTOCOL.equals(getProtocol())) {
        schemeRegistry.register(new Scheme(HTTP_PROTOCOL, getPort(), PlainSocketFactory.getSocketFactory()));
    } else if (HTTPS_PROTOCOL.equals(getProtocol())) {
        try {
            if (this.insecure) {
                SSLContext sslcontext = SSLContext.getInstance("TLS");
                sslcontext.init(null, new TrustManager[] { noCaTrustManager }, null);
                sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            } else {
                KeyStore truststore = null;
                InputStream in = null;
                if (this.trustStoreFile != null) {
                    truststore = KeyStore.getInstance(KeyStore.getDefaultType());
                    try {
                        in = new FileInputStream(this.trustStoreFile);
                        truststore.load(in, this.trustStorePassword != null ? this.trustStorePassword.toCharArray() : null);
                    } finally {
                        if (in != null) {
                            in.close();
                        }
                    }
                }
                sf = new SSLSocketFactory(SSLSocketFactory.TLS, null, null, truststore, null, null, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
            }
            schemeRegistry.register(new Scheme(HTTPS_PROTOCOL, getPort(), sf));
        } 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);
        } catch (UnrecoverableKeyException e) {
            throw new Error(UNRECOVERABLE_KEY_ERROR, e);
        }
    }
    return schemeRegistry;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) Error(org.ovirt.engine.sdk4.Error) CertificateException(java.security.cert.CertificateException) SSLContext(javax.net.ssl.SSLContext) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) KeyManagementException(java.security.KeyManagementException) TrustManager(javax.net.ssl.TrustManager) UnrecoverableKeyException(java.security.UnrecoverableKeyException) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SSLSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory)

Example 23 with Error

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

the class HttpConnection method checkContentType.

/**
 * Checks the given content type and raises an exception if it isn't the
 * expected one.
 *
 * @param pattern The regular expression used to check the expected content type.
 * @param expectedName The name of the expected content type.
 * @param actual The actual value of the `Content-Type` header.
 * @throws MalformedURLException When URL isn't correct.
 */
private void checkContentType(Pattern pattern, String expectedName, String actual) throws MalformedURLException {
    if (!pattern.matcher(actual).matches()) {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("The response content type '%1$s' isn't the expected %2$s", actual, expectedName));
        URL url = new URL(getUrl());
        if (!url.getPath().equals(TYPICAL_PATH)) {
            sb.append(String.format(". Is the path '%1$s' included in the 'url' parameter correct?", url.getPath()));
            sb.append(String.format(" The typical one is '%1$s'", TYPICAL_PATH));
        }
        throw new Error(sb.toString());
    }
}
Also used : Error(org.ovirt.engine.sdk4.Error) URL(java.net.URL)

Example 24 with Error

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

the class HttpConnection method getSsoResponse.

private JsonNode getSsoResponse(URI uri, List<NameValuePair> params) {
    HttpResponse response = null;
    try {
        // Send request and parse token:
        HttpPost requestToken = new HttpPost(uri);
        requestToken.addHeader("User-Agent", "JavaSDK");
        requestToken.addHeader("Accept", "application/json");
        requestToken.setEntity(new UrlEncodedFormEntity(params));
        response = client.execute(requestToken);
        checkContentType(JSON_CONTENT_TYPE_RE, "JSON", response.getFirstHeader("content-type").getValue());
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readTree(response.getEntity().getContent());
    } catch (IOException ex) {
        throw new Error("Failed to parse JSON response", ex);
    } catch (Exception ex) {
        throw new Error("Failed to send SSO request", ex);
    } finally {
        if (response != null) {
            EntityUtils.consumeQuietly(response.getEntity());
        }
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpResponse(org.apache.http.HttpResponse) Error(org.ovirt.engine.sdk4.Error) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 25 with Error

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

the class SsoUtils method buildSsoUrlKerberos.

/**
 * Construct SSO URL to obtain token from kerberos authentication.
 *
 * @param url oVirt engine URL
 * @return URI to be used to obtain token
 */
public static URI buildSsoUrlKerberos(String url) {
    try {
        URI uri = new URI(url);
        URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/sso/oauth/%3$s", uri.getScheme(), uri.getAuthority(), ENTRY_POINT_HTTP));
        return uriBuilder.build();
    } catch (URISyntaxException ex) {
        throw new Error("Failed to build SSO authentication URL", ex);
    }
}
Also used : Error(org.ovirt.engine.sdk4.Error) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

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