public void InitApiConnection(IVideoCloudConfig configProvider) { if (configProvider == null) { return; } else { try { if (string.IsNullOrEmpty(configProvider.PublisherId) || string.IsNullOrEmpty(configProvider.ReadToken) || string.IsNullOrEmpty(configProvider.WriteToken)) { return; } } catch { return; } } try { this.accountConfig = new AccountConfigElement("brightcove"); this.accountConfig.PublisherID = Convert.ToInt64(configProvider.PublisherId); this.readTokenList = configProvider.ReadToken.Split(tokenDelim); this.writeTokenList = configProvider.WriteToken.Split(tokenDelim); if (this.readTokenList.Length > 0) { this.accountConfig.ReadToken.Value = this.readTokenList[0]; } else { this.accountConfig.ReadToken.Value = configProvider.ReadToken; } if (this.writeTokenList.Length > 0) { this.accountConfig.WriteToken.Value = this.writeTokenList[0]; } else { this.accountConfig.WriteToken.Value = configProvider.WriteToken; } this.accountConfig.ReadURL.Value = configProvider.ReadUrl; this.accountConfig.WriteURL.Value = configProvider.WriteUrl; // Set default values for player this.DefaultVideoPlayerId = configProvider.DefaultVideoPlayerId; this.DefaultPlaylistPlayerId = configProvider.DefaultPlaylistPlayerId; } catch { // Alert user there is a problem with their site settings //throw new Exception("Brightcove Configuration is not setup. Please enter your Brightcove Video Cloud account settings in this site's Site Settings."); return; } ResetApiConnection(); }
public BCAPI CreateAPI(IVideoCloudConfig configProvider) { InitApiConnection(configProvider); return this.bcApi; }
protected override void CreateChildControls() { // Init config using (SPWeb web = SPContext.Current.Web) { if (_cachedConfigProvider == null) { _cachedConfigProvider = new Hashtable(); } if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty) { this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url]; } else { // Init Brightcove site settings string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl, KeyVideoPlayerId, KeyPlaylistPlayerId }; bool madeChanges = false; foreach (string key in keys) { if (!web.AllProperties.ContainsKey(key)) { web.AllProperties.Add(key, string.Empty); madeChanges = true; } } if (web.AllProperties[KeyReadUrl].Equals(string.Empty)) { web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library"; madeChanges = true; } if (web.AllProperties[KeyWriteUrl].Equals(string.Empty)) { web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post"; madeChanges = true; } // Get Brightcove settings VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig(); this.PublisherId = bvcConfig.PublisherId; this.ReadToken = bvcConfig.ReadToken; this.WriteToken = bvcConfig.WriteToken; this.ReadUrl = bvcConfig.ReadUrl; this.WriteUrl = bvcConfig.WriteUrl; this.DefaultVideoPlayerId = bvcConfig.DefaultVideoPlayerId; this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId; this.configProvider = this; // Only write the config if the requested site matches the current site if (_cachedConfigProvider.ContainsKey(web.Url)) { _cachedConfigProvider[web.Url] = this.configProvider; } else { _cachedConfigProvider.Add(web.Url, this.configProvider); } if (madeChanges) { web.AllowUnsafeUpdates = true; web.Update(); } } } // Handle AJAX call to get a video list if (!this._isAsyncCall) { this._isAsyncCall = AsyncVideoList(); //if (!this._isAsyncCall) //{ // this._isAsyncCall = AsyncChooser(); //} } this.ChromeType = PartChromeType.None; }
public BCAPI CreateAPI(IVideoCloudConfig configProvider) { InitApiConnection(configProvider); return(this.bcApi); }
private void GetOldConfiguration() { using (SPSite site = new SPSite(SPContext.Current.Web.Url)) { SPWeb web = site.OpenWeb(); if (_cachedConfigProvider == null) { _cachedConfigProvider = new Hashtable(); } if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty) { this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url]; } else { // Init Brightcove site settings string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl, KeyVideoPlayerId, KeyPlaylistPlayerId }; bool madeChanges = false; foreach (string key in keys) { if (!web.AllProperties.ContainsKey(key)) { web.AllProperties.Add(key, string.Empty); madeChanges = true; } } if (web.AllProperties[KeyReadUrl].Equals(string.Empty)) { web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library"; madeChanges = true; } if (web.AllProperties[KeyWriteUrl].Equals(string.Empty)) { web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post"; madeChanges = true; } // Get Brightcove settings VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig(); this.PublisherId = bvcConfig.PublisherId; this.ReadToken = bvcConfig.ReadToken; this.WriteToken = bvcConfig.WriteToken; this.ReadUrl = bvcConfig.ReadUrl; this.WriteUrl = bvcConfig.WriteUrl; this.DefaultVideoPlayerId = bvcConfig.DefaultVideoPlayerId; this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId; this.configProvider = this; // Only write the config if the requested site matches the current site if (_cachedConfigProvider.ContainsKey(web.Url)) { _cachedConfigProvider[web.Url] = this.configProvider; } else { _cachedConfigProvider.Add(web.Url, this.configProvider); } if (madeChanges) { web.AllowUnsafeUpdates = true; web.Update(); } } } }
private void GetConfigurationfromList() { string accountSelected = ""; if (Context.Request.QueryString["Account"] != null) { accountSelected = Context.Request.QueryString["Account"]; } using (SPSite site = new SPSite(SPContext.Current.Web.Url)) { SPWeb web = site.OpenWeb(); SPList list = web.GetList(SPContext.Current.Site.Url + "/" + accountListAddress); SPListItemCollection listItem = list.Items; SPSecurity.RunWithElevatedPrivileges(delegate() { foreach (SPListItem item in listItem) { //if user belongs to viewer or authors group load configuration if (!string.IsNullOrEmpty(item["Title"].ToString())) { if (string.IsNullOrEmpty(accountSelected) || accountSelected == item["Title"].ToString()) { //if user belongs to viewer or authors group load configuration if ((item["AccountViewersGroupName"] != null && !string.IsNullOrEmpty(item["AccountViewersGroupName"].ToString())) && (item["AccountAuthorsGroupName"] != null && !string.IsNullOrEmpty(item["AccountAuthorsGroupName"].ToString()))) { try { // if (web.Groups[item["AccountViewersGroupName"].ToString()].ContainsCurrentUser) if (belongstoGroup(web, item["AccountViewersGroupName"].ToString()) || belongstoGroup(web, item["AccountAuthorsGroupName"].ToString())) { if (item["PublisherId"] != null && !string.IsNullOrEmpty(item["PublisherId"].ToString())) { this.PublisherId = item["PublisherId"].ToString(); } if (item["DefaultVideoPlayerId"] != null && !string.IsNullOrEmpty(item["DefaultVideoPlayerId"].ToString())) { this.DefaultVideoPlayerId = item["DefaultVideoPlayerId"].ToString(); } if (item["DefaultPlaylistPlayerId"] != null && !string.IsNullOrEmpty(item["DefaultPlaylistPlayerId"].ToString())) { this.DefaultPlaylistPlayerId = item["DefaultPlaylistPlayerId"].ToString(); } if (item["ReadAPIServiceURL"] != null && !string.IsNullOrEmpty(item["ReadAPIServiceURL"].ToString())) { this._readUrl = item["ReadAPIServiceURL"].ToString(); } if (item["WriteAPIServiceURL"] != null && !string.IsNullOrEmpty(item["WriteAPIServiceURL"].ToString())) { this._writeUrl = item["WriteAPIServiceURL"].ToString(); } if (item["Tokens"] != null && !string.IsNullOrEmpty(item["Tokens"].ToString())) { this.ReadToken = getReadToken(item["Tokens"].ToString(), "Read-"); this.WriteToken = getReadToken(item["Tokens"].ToString(), "Write-"); } } this.configProvider = this; } catch { } } //End belongsgroup } // end test acccount was selected on chooser.aspx } // end test account name is not null } //End foreach }); } }
private void GetConfigurationfromList() { string accountSelected = ""; if (Context.Request.QueryString["Account"] != null) { accountSelected = Context.Request.QueryString["Account"]; } using (SPSite site = new SPSite(SPContext.Current.Web.Url)) { SPWeb web = site.OpenWeb(); SPList list = web.GetList(SPContext.Current.Site.Url + "/" + accountListAddress); SPListItemCollection listItem = list.Items; SPSecurity.RunWithElevatedPrivileges(delegate() { foreach (SPListItem item in listItem) { //if user belongs to viewer or authors group load configuration if (!string.IsNullOrEmpty(item["Title"].ToString())) { if (string.IsNullOrEmpty(accountSelected) || accountSelected == item["Title"].ToString()) { //if user belongs to viewer or authors group load configuration if ((item["AccountViewersGroupName"] != null && !string.IsNullOrEmpty(item["AccountViewersGroupName"].ToString())) && (item["AccountAuthorsGroupName"] != null && !string.IsNullOrEmpty(item["AccountAuthorsGroupName"].ToString()))) { try { // if (web.Groups[item["AccountViewersGroupName"].ToString()].ContainsCurrentUser) if (belongstoGroup(web, item["AccountViewersGroupName"].ToString()) || belongstoGroup(web, item["AccountAuthorsGroupName"].ToString())) { if (item["PublisherId"] != null && !string.IsNullOrEmpty(item["PublisherId"].ToString())) { this.PublisherId = item["PublisherId"].ToString(); } if (item["DefaultVideoPlayerId"] != null && !string.IsNullOrEmpty(item["DefaultVideoPlayerId"].ToString())) { this.DefaultVideoPlayerId = item["DefaultVideoPlayerId"].ToString(); } if (item["DefaultPlaylistPlayerId"] != null && !string.IsNullOrEmpty(item["DefaultPlaylistPlayerId"].ToString())) { this.DefaultPlaylistPlayerId = item["DefaultPlaylistPlayerId"].ToString(); } if (item["ReadAPIServiceURL"] != null && !string.IsNullOrEmpty(item["ReadAPIServiceURL"].ToString())) { this._readUrl = item["ReadAPIServiceURL"].ToString(); } if (item["WriteAPIServiceURL"] != null && !string.IsNullOrEmpty(item["WriteAPIServiceURL"].ToString())) { this._writeUrl = item["WriteAPIServiceURL"].ToString(); } if (item["Tokens"] != null && !string.IsNullOrEmpty(item["Tokens"].ToString())) { this.ReadToken = getReadToken(item["Tokens"].ToString(), "Read-"); this.WriteToken = getReadToken(item["Tokens"].ToString(), "Write-"); } } this.configProvider = this; } catch { } } //End belongsgroup }// end test acccount was selected on chooser.aspx } // end test account name is not null } //End foreach }); } }