void OAuthSignIn.INotify.SuccessForConfigure( List <string> organizations, bool canCreateAnOrganization, string userName, string accessToken) { mEmail = userName; mPassword = accessToken; if (!organizations.Contains(mServer)) { CancelButtonAction(); return; } CloudEditionWelcomeWindow.JoinCloudServer( mServer, userName, accessToken); GetWindow <PlasticWindow>().InitializePlastic(); OkButtonAction(); }
internal static TokenExchangeResponse PlasticCredentials( string unityAccessToken, string serverName, string projectPath) { SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded(); bool isClientConfigConfigured = ClientConfig.IsConfigured(); if (!isClientConfigConfigured) { ConfigureClientConf.FromUnityAccessToken( unityAccessToken, serverName, projectPath); } TokenExchangeResponse tokenExchangeResponse = WebRestApiClient. PlasticScm.TokenExchange(unityAccessToken); if (tokenExchangeResponse.Error != null) { return(tokenExchangeResponse); } CloudEditionWelcomeWindow.JoinCloudServer( serverName, tokenExchangeResponse.User, tokenExchangeResponse.AccessToken); if (!isClientConfigConfigured) { return(tokenExchangeResponse); } ConfigureProfile.ForServerIfNeeded( serverName, tokenExchangeResponse.User); return(tokenExchangeResponse); }
void DownloadRepository(object state) { DownloadRepositoryParameters parameters = (DownloadRepositoryParameters)state; try { if (FindWorkspace.HasWorkspace(parameters.ProjectPath)) { // each domain reload, the package is reloaded. // way need to check if we already downloaded it return; } mDisplayProgress = true; IPlasticWebRestApi restApi = new PlasticWebRestApi(); string defaultCloudAlias = restApi.GetDefaultCloudAlias(); RepositorySpec repSpec = BuildRepSpec( parameters.CloudRepository, parameters.CloudOrganization, defaultCloudAlias); // we just download a cloud project, // so let's assume we're going to use Cloud Edition SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded(); if (!ClientConfig.IsConfigured()) { AutoConfigClientConf.FromUnityAccessToken( parameters.AccessToken, repSpec.Server, parameters.ProjectPath); } TokenExchangeResponse tokenExchangeResponse = WebRestApiClient. PlasticScm.TokenExchange(parameters.AccessToken); if (tokenExchangeResponse.Error != null) { mOperationFailed = true; UnityEngine.Debug.LogErrorFormat( PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject), string.Format("Unable to get TokenExchangeResponse: {0} [code {1}]", tokenExchangeResponse.Error.Message, tokenExchangeResponse.Error.ErrorCode)); return; } CloudEditionWelcomeWindow.JoinCloudServer( repSpec.Server, tokenExchangeResponse.User, tokenExchangeResponse.AccessToken); ClientConfigData clientConfigData = ClientConfig.Get().GetClientConfigData(); clientConfigData.WorkspaceServer = repSpec.Server; ClientConfig.Get().Save(clientConfigData); WorkspaceInfo wkInfo = CreateWorkspace( repSpec, parameters.ProjectPath); mLog.DebugFormat("Created workspace {0} on {1}", wkInfo.Name, wkInfo.ClientPath); PlasticGui.Plastic.API.Update( wkInfo.ClientPath, UpdateFlags.None, null, mUpdateNotifier); } catch (Exception ex) { LogException(ex); UnityEngine.Debug.LogErrorFormat( PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject), ex.Message); mOperationFailed = true; } finally { mOperationFinished = true; } }
void LaunchMigration( string unityAccessToken, string projectPath, string organizationName, RepId repId, long changesetId, long branchId, Action afterWorkspaceMigratedAction, IProgressControls progressControls) { string serverName = string.Format( "{0}@cloud", organizationName); progressControls.ShowProgress( "Migrating project to Plastic SCM..."); TokenExchangeResponse tokenExchangeResponse = null; WorkspaceInfo workspaceInfo = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { // we just migrate a cloud project, // so let's assume we're going to use Cloud Edition SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded(); if (!ClientConfig.IsConfigured()) { AutoConfigClientConf.FromUnityAccessToken( unityAccessToken, serverName, projectPath); } tokenExchangeResponse = WebRestApiClient. PlasticScm.TokenExchange(unityAccessToken); if (tokenExchangeResponse.Error != null) { return; } CloudEditionWelcomeWindow.JoinCloudServer( serverName, tokenExchangeResponse.User, tokenExchangeResponse.AccessToken); RepositoryInfo repInfo = new BaseCommandsImpl(). GetRepositoryInfo(repId, serverName); if (repInfo == null) { return; } repInfo.SetExplicitServer(serverName); workspaceInfo = CreateWorkspaceFromCollab.Create( projectPath, repInfo.Name, repInfo, changesetId, branchId, new CreateWorkspaceFromCollab.Progress()); }, /*afterOperationDelegate*/ delegate { progressControls.HideProgress(); if (waiter.Exception != null) { DisplayException(progressControls, waiter.Exception); return; } if (tokenExchangeResponse.Error != null) { mLog.ErrorFormat( "Unable to get TokenExchangeResponse: {0} [code {1}]", tokenExchangeResponse.Error.Message, tokenExchangeResponse.Error.ErrorCode); } if (tokenExchangeResponse.Error != null || workspaceInfo == null) { progressControls.ShowError( "Failed to migrate the project to Plastic SCM"); return; } progressControls.ShowSuccess( "The project migration to Plastic SCM is completed successfully"); mIsMigrationCompleted = true; afterWorkspaceMigratedAction(); }); }