// Get content browse custom targeting key ID.
long contentBrowseCustomTargetingKeyId =
networkService.getCurrentNetwork().getContentBrowseCustomTargetingKeyId();
// Create a statement to select the categories matching the name comedy.
Statement categoryFilterStatement = new StatementBuilder(
"WHERE customTargetingKeyId = :contentBrowseCustomTargetingKeyId " +
" and name = :category LIMIT 1")
.putValue("contentBrowseCustomTargetingKeyId", contentBrowseCustomTargetingKeyId)
.putValue("category", "comedy").toStatement();
// Get categories matching the filter statement.
CustomTargetingValuePage customTargetingValuePage =
customTargetingService.getCustomTargetingValuesByStatement(categoryFilterStatement);
// Get the custom targeting value ID for the comedy category.
long categoryCustomTargetingValueId = customTargetingValuePage.getResults()[0].getId();
// Set defaults for page and filterStatement.
ContentPage page = new ContentPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all active content.
filterStatement.setQuery("WHERE status = 'ACTIVE' LIMIT 500 OFFSET " + offset);
// Get content by statement.
page = contentService.getContentByStatementAndCustomTargetingValue(filterStatement,
categoryCustomTargetingValueId);