/** * Helper function to create the Kaltura client object once and then reuse a static instance. * * @return a singleton of <code>KalturaClient</code> used in this case * @throws KalturaApiException if failed to generate session */ private static KalturaClient getKalturaClient() throws KalturaApiException { if (client != null) { return client; } // Set Constants int partnerId = testConfig.getPartnerId(); String adminSecret = testConfig.getAdminSecret(); String userId = testConfig.getUserId(); // Generate configuration KalturaConfiguration config = new KalturaConfiguration(); config.setEndpoint(testConfig.getServiceUrl()); try { // Create the client and open session client = new KalturaClient(config); String ks = client.generateSession(adminSecret, userId, KalturaSessionType.ADMIN, partnerId); client.setSessionId(ks); } catch (Exception ex) { client = null; throw new KalturaApiException("Failed to generate session"); } System.out.println("Generated KS locally: [" + client.getSessionId() + "]"); return client; }