import java.util.Iterator; import com.kaltura.client.enums.*; import com.kaltura.client.types.*; import com.kaltura.client.services.*; import com.kaltura.client.KalturaApiException; import com.kaltura.client.KalturaClient; import com.kaltura.client.KalturaConfiguration; public class ListChannelOwners { public static void main(String[] argv) { try { // Create the configuration object. // The KalturaClient is used to create the Kaltura Session which used behind the scenes // on all API calls. KalturaConfiguration config = new KalturaConfiguration(); config.setEndpoint("https://www.kaltura.com"); KalturaClient client = new KalturaClient(config); String userid = "useremail.com"; String password="password"; int partnerId = 99999999; // This should be setup to use the users login from the web page requesting this // or if we want to generate the report nightly we could setup a mech id // The user will need admin to get all the categories String session = client.getUserService().loginByLoginId(userid, password, partnerId); client.setSessionId(session); System.out.println("Session Created, Report running for PartnerID : " + partnerId); // Now we'll get all the categories. The filter by name ensures we only // get channels which are in a specific part of hierarchy KalturaCategoryFilter filter = new KalturaCategoryFilter(); filter.fullNameStartsWith = "MediaSpace>site>channels>"; KalturaFilterPager pager = null; KalturaCategoryListResponse result = client.getCategoryService() .list(filter, pager); // Iterate on the categories Iterator it = result.objects.iterator(); while (it.hasNext()) { KalturaCategory cat = (KalturaCategory) it.next(); //String channelName = cat.n System.out.println("Channel : " + cat.name); System.out.print("Owner: " + cat.owner); System.out.print(", Member Count: " + cat.membersCount); System.out.println(", Video Count: " + cat.entriesCount); // Get users with MANAGER permission for this categoryid KalturaCategoryUserFilter userfilter = new KalturaCategoryUserFilter(); userfilter.categoryIdEqual = cat.id; userfilter.permissionLevelEqual = KalturaCategoryUserPermissionLevel.MANAGER; KalturaCategoryUserListResponse userlist = client.getCategoryUserService().list(userfilter); System.out.print("Manager(s): " ); // skip if list is non-existent for some reason if (userlist.objects == null) continue; // For each manager user output them unless also owner Iterator userIt = userlist.objects.iterator(); while (userIt.hasNext()) { KalturaCategoryUser user = (KalturaCategoryUser) userIt.next(); if (!user.userId.equals(cat.owner)) { System.out.print(user.userId + " "); } else if (userlist.objects.size()<2) { System.out.print("None"); } } System.out.println("\n---------------------------------"); } } catch (Exception exc) { exc.printStackTrace(); } } }