Esempio n. 1
0
        public PackageInstallResult CleanUp(PackageInstallModel model)
        {
            var definition = Services.PackagingService.GetInstalledPackageById(model.Id);

            if (definition == null)
            {
                throw new InvalidOperationException("Not package definition found with id " + model.Id);
            }

            var zipFile = new FileInfo(definition.PackagePath);

            var packageInfo = Services.PackagingService.GetCompiledPackageInfo(zipFile);

            zipFile.Delete();

            //bump cdf to be safe
            var clientDependencyConfig  = new ClientDependencyConfiguration(Logger);
            var clientDependencyUpdated = clientDependencyConfig.UpdateVersionNumber(
                UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");

            var redirectUrl = "";

            if (!packageInfo.PackageView.IsNullOrWhiteSpace())
            {
                redirectUrl = $"/packages/packages/options/{model.Id}";
            }

            return(new PackageInstallResult
            {
                Id = model.Id,
                ZipFileName = model.ZipFileName,
                PackageGuid = model.PackageGuid,
                PostInstallationPath = redirectUrl
            });
        }
        public PackageInstallResult CleanUp(PackageInstallModel model)
        {
            var ins     = new global::Umbraco.Web._Legacy.Packager.Installer(Security.CurrentUser.Id);
            var tempDir = IOHelper.MapPath(model.TemporaryDirectoryPath);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallCleanUp(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));

            var clientDependencyConfig  = new ClientDependencyConfiguration(Logger);
            var clientDependencyUpdated = clientDependencyConfig.UpdateVersionNumber(
                UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");


            var redirectUrl = "";

            if (ins.Control.IsNullOrWhiteSpace() == false)
            {
                redirectUrl = string.Format("/developer/framed/{0}",
                                            Uri.EscapeDataString(
                                                string.Format("/umbraco/developer/Packages/installer.aspx?installing=custominstaller&dir={0}&pId={1}&customControl={2}&customUrl={3}", tempDir, model.Id, ins.Control, ins.Url)));
            }

            return(new PackageInstallResult
            {
                Id = model.Id,
                ZipFilePath = model.ZipFilePath,
                PackageGuid = model.PackageGuid,
                RepositoryGuid = model.RepositoryGuid,
                TemporaryDirectoryPath = model.TemporaryDirectoryPath,
                PostInstallationPath = redirectUrl
            });
        }
        public PackageInstallModel InstallData(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallBusinessLogic(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));
            return(model);
        }
Esempio n. 4
0
        public PackageInstallModel Import(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, ins.Import(model.ZipFilePath));
            model.Id = ins.CreateManifest(IOHelper.MapPath(model.TemporaryDirectoryPath), model.PackageGuid.ToString(), model.RepositoryGuid.ToString());

            return(model);
        }
        public PackageInstallModel InstallFiles(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallFiles(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));

            //set a restarting marker and reset the app pool
            ApplicationContext.RestartApplicationPool(Request.TryGetHttpContext().Result);

            model.IsRestarting = true;

            return(model);
        }
        public PackageInstallModel CheckRestart(PackageInstallModel model)
        {
            if (model.IsRestarting == false)
            {
                return(model);
            }

            //check for the key, if it's not there we're are restarted
            if (Request.TryGetHttpContext().Result.Application.AllKeys.Contains("AppPoolRestarting") == false)
            {
                //reset it
                model.IsRestarting = false;
            }
            return(model);
        }
Esempio n. 7
0
        public PackageInstallModel InstallData(PackageInstallModel model)
        {
            var definition = Services.PackagingService.GetInstalledPackageById(model.Id);

            if (definition == null)
            {
                throw new InvalidOperationException("Not package definition found with id " + model.Id);
            }

            var zipFile = new FileInfo(definition.PackagePath);

            var installSummary = Services.PackagingService.InstallCompiledPackageData(definition, zipFile, Security.GetUserId().ResultOr(0));

            return(model);
        }
Esempio n. 8
0
        public PackageInstallModel Import(PackageInstallModel model)
        {
            var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Packages), model.ZipFileName));

            var packageInfo = Services.PackagingService.GetCompiledPackageInfo(zipFile);

            //now we need to check for version comparison
            if (packageInfo.UmbracoVersionRequirementsType == RequirementsType.Strict)
            {
                var packageMinVersion = packageInfo.UmbracoVersion;
                if (UmbracoVersion.Current < packageMinVersion)
                {
                    throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse(
                                                        Services.TextService.Localize("packager/targetVersionMismatch", new[] { packageMinVersion.ToString() })));
                }
            }

            var installType = Services.PackagingService.GetPackageInstallType(packageInfo.Name, SemVersion.Parse(packageInfo.Version), out var alreadyInstalled);

            var packageDefinition = PackageDefinition.FromCompiledPackage(packageInfo);

            packageDefinition.PackagePath = zipFile.FullName;
            packageDefinition.PackageId   = model.PackageGuid; //We must re-map the original package GUID that was generated

            switch (installType)
            {
            case PackageInstallType.AlreadyInstalled:
                throw new InvalidOperationException("The package is already installed");

            case PackageInstallType.NewInstall:
            case PackageInstallType.Upgrade:

                //save to the installedPackages.config, this will create a new entry with a new Id
                if (!Services.PackagingService.SaveInstalledPackage(packageDefinition))
                {
                    throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Could not save the package"));
                }

                model.Id = packageDefinition.Id;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }


            return(model);
        }
Esempio n. 9
0
        public PackageInstallModel CleanUp(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallCleanUp(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));

            var clientDependencyConfig  = new Umbraco.Core.Configuration.ClientDependencyConfiguration(ApplicationContext.ProfilingLogger.Logger);
            var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();

            //clear the tree cache - we'll do this here even though the browser will reload, but just in case it doesn't can't hurt.
            //these bits are super old, but cant find another way to do this currently
            global::umbraco.cms.presentation.Trees.TreeDefinitionCollection.Instance.ReRegisterTrees();
            global::umbraco.BusinessLogic.Actions.Action.ReRegisterActionsAndHandlers();


            return(model);
        }
Esempio n. 10
0
        public PackageInstallModel InstallFiles(PackageInstallModel model)
        {
            var definition = Services.PackagingService.GetInstalledPackageById(model.Id);

            if (definition == null)
            {
                throw new InvalidOperationException("Not package definition found with id " + model.Id);
            }

            var zipFile = new FileInfo(definition.PackagePath);

            var installedFiles = Services.PackagingService.InstallCompiledPackageFiles(definition, zipFile, Security.GetUserId().ResultOr(0));

            //set a restarting marker and reset the app pool
            UmbracoApplication.Restart(Request.TryGetHttpContext().Result);

            model.IsRestarting = true;

            return(model);
        }
        public PackageInstallModel Import(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            var tempPath = ins.Import(model.ZipFilePath);

            //now we need to check for version comparison
            if (ins.RequirementsType == RequirementsType.Strict)
            {
                var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
                if (UmbracoVersion.Current < packageMinVersion)
                {
                    throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse(
                                                        Services.TextService.Localize("packager/targetVersionMismatch", new[] { packageMinVersion.ToString() })));
                }
            }

            model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempPath);
            model.Id = ins.CreateManifest(IOHelper.MapPath(model.TemporaryDirectoryPath), model.PackageGuid.ToString(), model.RepositoryGuid.ToString());

            return(model);
        }
Esempio n. 12
0
        public PackageInstallModel Fetch(string packageGuid)
        {
            //Default path
            string path = Path.Combine("packages", packageGuid + ".umb");

            if (File.Exists(IOHelper.MapPath(Path.Combine(SystemDirectories.Data, path))) == false)
            {
                //our repo guid
                using (var our = Repository.getByGuid("65194810-1f85-11dd-bd0b-0800200c9a66"))
                {
                    path = our.fetch(packageGuid, Security.CurrentUser.Id);
                }
            }

            var p = new PackageInstallModel();

            p.PackageGuid    = Guid.Parse(packageGuid);
            p.RepositoryGuid = Guid.Parse("65194810-1f85-11dd-bd0b-0800200c9a66");
            p.ZipFilePath    = path;
            //p.ZipFilePath = Path.Combine("temp", "package.umb");

            return(p);
        }
        public PackageInstallResult CleanUp(PackageInstallModel model)
        {
            var ins     = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
            var tempDir = IOHelper.MapPath(model.TemporaryDirectoryPath);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallCleanUp(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));

            var clientDependencyConfig  = new Umbraco.Core.Configuration.ClientDependencyConfiguration(ApplicationContext.ProfilingLogger.Logger);
            var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();

            //clear the tree cache - we'll do this here even though the browser will reload, but just in case it doesn't can't hurt.
            //these bits are super old, but cant find another way to do this currently
            global::umbraco.cms.presentation.Trees.TreeDefinitionCollection.Instance.ReRegisterTrees();
            global::umbraco.BusinessLogic.Actions.Action.ReRegisterActionsAndHandlers();


            var redirectUrl = "";

            if (ins.Control.IsNullOrWhiteSpace() == false)
            {
                redirectUrl = string.Format("/developer/framed/{0}",
                                            Uri.EscapeDataString(
                                                string.Format("/umbraco/developer/Packages/installer.aspx?installing=custominstaller&dir={0}&pId={1}&customControl={2}&customUrl={3}", tempDir, model.Id, ins.Control, ins.Url)));
            }

            return(new PackageInstallResult
            {
                Id = model.Id,
                ZipFilePath = model.ZipFilePath,
                PackageGuid = model.PackageGuid,
                RepositoryGuid = model.RepositoryGuid,
                TemporaryDirectoryPath = model.TemporaryDirectoryPath,
                PostInstallationPath = redirectUrl
            });
        }