Ejemplo n.º 1
0
 public Version(Project project, string name)
 {
     Company = project.Company;
     Repository = project.Repository;
     Project = project.Name;
     Name = name;    
 }
 public void CreateProject(Project project)
 {
     throw new NotImplementedException();
 }
 public void SetProjectPermissions(User targetUser, Project project, Permission permission)
 {
     throw new NotImplementedException();
 }
 public Version[] GetVersions(ref Project project)
 {
     throw new NotImplementedException();
 }
        private void SynchronizePermissions(Caller caller, string company, PackageProject packageProject)
        {
            var permission = GetProjectPermission(caller, company, packageProject);

            if (permission.HasValue)
            {
                var configuration = configurationFactory.Create(company);

                if (string.IsNullOrEmpty(configuration.GatewayLogin) || string.IsNullOrEmpty(configuration.GatewayPassword))
                    throw new Exception("Missing gateway configuration");

                using (var session = backendFactory.Create(new Caller { Company = company, Name = configuration.GatewayLogin, KeyType = "API", KeyValue = configuration.GatewayPassword }))
                {
                    var project = new Project { Company = company, Repository = packageProject.Repository, Name = packageProject.Name };

                    if (permission.Value)
                    {
                        try
                        {
                            session.CreateProject(project);
                        }
                        catch (Exception)
                        {
                            //ignore if exists
                        }
                    }

                    try
                    {
                        session.SetProjectPermissions(new User { Company = caller.Company, Name = caller.Name }, project, new Permission { Grant = false, Read = false, Write = permission.Value });
                    }
                    catch (Exception)
                    {
                        //ignore if not exists
                    }

                    if (!permission.Value)
                        throw new Exception("External permission source denied publish access");
                }
            }
        }
 public ProjectPermission[] GetProjectPermissions(Project project)
 {
     return service.GetProjectPermissions(caller, project);
 }
 public void SetProjectPermissions(User targetUser, Project project, Permission permission)
 {
     service.SetProjectPermissions(caller, targetUser, project, permission);
 }
 public virtual Version[] GetVersions(ref Project project)
 {
     return service.GetVersions(caller, ref project);
 }
 public void DeleteProject(Project project)
 {
     service.DeleteProject(caller, project);
 }
 public void UpdateProject(Project project)
 {
     service.UpdateProject(caller, ref project);
 }
 public void CreateProject(Project project)
 {
     service.CreateProject(caller, ref project);
 }
 public virtual void CreateOrUpdateProject(Project project)
 {
     service.CreateOrUpdateProject(caller, ref project);
 }