Search in sources :

Example 71 with Error

use of com.google.privacy.dlp.v2.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(com.fasterxml.jackson.databind.ObjectMapper) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 72 with Error

use of com.google.privacy.dlp.v2.Error in project ovirt-engine-sdk-java by oVirt.

the class SsoUtils method buildSsoRevokeUrl.

/**
 * Construct SSO URL to revoke SSO token
 *
 * @param url oVirt engine URL
 * @return URI to be used to revoke token
 */
public static URI buildSsoRevokeUrl(String url) {
    try {
        URI uri = new URI(url);
        URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/services/sso-logout", uri.getScheme(), uri.getAuthority()));
        return uriBuilder.build();
    } catch (URISyntaxException ex) {
        throw new Error("Failed to build SSO revoke 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)

Example 73 with Error

use of com.google.privacy.dlp.v2.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)

Example 74 with Error

use of com.google.privacy.dlp.v2.Error in project javacpp-presets by bytedeco.

the class FlyCapture2Test method main.

public static void main(String[] args) throws IOException {
    PrintBuildInfo();
    Error error;
    // Since this application saves images in the current folder
    // we must ensure that we have permission to write to this folder.
    // If we do not have permission, fail right away.
    File tempFile = new File("test.txt");
    try {
        new FileOutputStream(tempFile).close();
    } catch (IOException e) {
        System.out.println("Failed to create file in current folder.  " + "Please check permissions.");
        System.exit(-1);
    }
    tempFile.delete();
    BusManager busMgr = new BusManager();
    int[] numCameras = new int[1];
    error = busMgr.GetNumOfCameras(numCameras);
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        System.exit(-1);
    }
    System.out.println("Number of cameras detected: " + numCameras[0]);
    for (int i = 0; i < numCameras[0]; i++) {
        PGRGuid guid = new PGRGuid();
        error = busMgr.GetCameraFromIndex(i, guid);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
            System.exit(-1);
        }
        RunSingleCamera(guid);
    }
    System.out.println("Done! Press Enter to exit...");
    System.in.read();
}
Also used : Error(org.bytedeco.flycapture.FlyCapture2.Error)

Example 75 with Error

use of com.google.privacy.dlp.v2.Error in project javacpp-presets by bytedeco.

the class FlyCapture2Test method RunSingleCamera.

static int RunSingleCamera(PGRGuid guid) {
    final int k_numImages = 10;
    Error error;
    Camera cam = new Camera();
    // Connect to a camera
    error = cam.Connect(guid);
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        return -1;
    }
    // Get the camera information
    CameraInfo camInfo = new CameraInfo();
    error = cam.GetCameraInfo(camInfo);
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        return -1;
    }
    PrintCameraInfo(camInfo);
    // Start capturing images
    error = cam.StartCapture();
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        return -1;
    }
    Image rawImage = new Image();
    for (int imageCnt = 0; imageCnt < k_numImages; imageCnt++) {
        // Retrieve an image
        error = cam.RetrieveBuffer(rawImage);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
            continue;
        }
        System.out.println("Grabbed image " + imageCnt);
        // Create a converted image
        Image convertedImage = new Image();
        // Convert the raw image
        error = rawImage.Convert(PIXEL_FORMAT_MONO8, convertedImage);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
            return -1;
        }
        // Create a unique filename
        String filename = camInfo.serialNumber() + "-" + imageCnt + ".pgm";
        // Save the image. If a file format is not passed in, then the file
        // extension is parsed to attempt to determine the file format.
        error = convertedImage.Save(filename);
        if (error.notEquals(PGRERROR_OK)) {
            PrintError(error);
            return -1;
        }
    }
    // Stop capturing images
    error = cam.StopCapture();
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        return -1;
    }
    // Disconnect the camera
    error = cam.Disconnect();
    if (error.notEquals(PGRERROR_OK)) {
        PrintError(error);
        return -1;
    }
    return 0;
}
Also used : Error(org.bytedeco.flycapture.FlyCapture2.Error)

Aggregations

ArrayList (java.util.ArrayList)28 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)23 Test (org.junit.Test)23 ParseException (org.apache.commons.cli.ParseException)18 AbstractMessage (com.google.protobuf.AbstractMessage)16 DlpJob (com.google.privacy.dlp.v2.DlpJob)15 InfoType (com.google.privacy.dlp.v2.InfoType)13 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)12 ByteString (com.google.protobuf.ByteString)12 Error (dev.hawala.xns.level2.Error)12 Error (org.ovirt.engine.sdk4.Error)12 InspectConfig (com.google.privacy.dlp.v2.InspectConfig)11 Error (org.eclipse.bpmn2.Error)11 ContentItem (com.google.privacy.dlp.v2.ContentItem)10 ProjectName (com.google.privacy.dlp.v2.ProjectName)9 Iterator (java.util.Iterator)9 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)8 RootElement (org.eclipse.bpmn2.RootElement)8 Error (com.google.privacy.dlp.v2.Error)7 ServiceOptions (com.google.cloud.ServiceOptions)6