001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Andre Justo 018 */ 019 020package org.nuxeo.ecm.media.publishing.wistia; 021 022import org.apache.commons.logging.Log; 023import org.apache.commons.logging.LogFactory; 024import org.jboss.seam.ScopeType; 025import org.jboss.seam.annotations.Name; 026import org.jboss.seam.annotations.Scope; 027import org.nuxeo.ecm.media.publishing.MediaPublishingProvider; 028import org.nuxeo.ecm.media.publishing.MediaPublishingService; 029import org.nuxeo.ecm.media.publishing.wistia.model.Project; 030import org.nuxeo.runtime.api.Framework; 031 032import java.io.Serializable; 033import java.util.List; 034 035/** 036 * @since 7.3 037 */ 038@Name("wistiaPublishingActions") 039@Scope(ScopeType.EVENT) 040public class WistiaPublishingActions implements Serializable{ 041 042 private static final long serialVersionUID = 1L; 043 044 private static final Log log = LogFactory.getLog(WistiaPublishingActions.class); 045 046 List<Project> projects; 047 048 /** 049 * Helper to retrieve a list of projects for a given Wistia account 050 */ 051 public List<Project> getProjects(String account) { 052 053 if (account == null || account.length() == 0) { 054 return null; 055 } 056 057 if (projects == null) { 058 MediaPublishingProvider service = getMediaPublishingService().getProvider("Wistia"); 059 projects = ((WistiaService) service).getProjects(account); 060 } 061 062 return projects; 063 } 064 065 private MediaPublishingService getMediaPublishingService() { 066 return Framework.getService(MediaPublishingService.class); 067 } 068}