Пример #1
0
        public PackageDependency(XPathNavigator dependencyRoot)
        {
            Type      = dependencyRoot.GetAttribute("type", "");
            Value     = dependencyRoot.Value;
            DnnMet    = false;
            DeployMet = false;

            IDependency dep = DependencyFactory.GetDependency(dependencyRoot);

            DnnMet = dep.IsValid;
        }
Пример #2
0
        public PackageDependency(XPathNavigator dependencyRoot)
        {
            IsPackageDependency = PackageTypes.Contains(dependencyRoot.GetAttribute("type", ""));
            PackageName         = dependencyRoot.Value;
            DependencyVersion   = dependencyRoot.GetAttribute("version", "");
            DnnMet    = false;
            DeployMet = false;

            IDependency dep = DependencyFactory.GetDependency(dependencyRoot);

            DnnMet = dep.IsValid;
        }
Пример #3
0
        public static void ParsePackage(string file, string installPath, Dictionary <string, PackageInfo> packages, List <string> invalidPackages)
        {
            Stream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);
            var    unzip       = new ZipInputStream(inputStream);

            try
            {
                ZipEntry entry = unzip.GetNextEntry();

                while (entry != null)
                {
                    if (!entry.IsDirectory)
                    {
                        var    fileName  = entry.Name;
                        string extension = Path.GetExtension(fileName);
                        if (extension != null && (extension.ToLower() == ".dnn" || extension.ToLower() == ".dnn5"))
                        {
                            //Manifest
                            var manifestReader = new StreamReader(unzip);
                            var manifest       = manifestReader.ReadToEnd();

                            var package = new PackageInfo {
                                Manifest = manifest
                            };
                            if (!string.IsNullOrEmpty(manifest))
                            {
                                var            doc         = new XPathDocument(new StringReader(manifest));
                                XPathNavigator rootNav     = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                                string         packageType = String.Empty;
                                if (rootNav.Name == "dotnetnuke")
                                {
                                    packageType = XmlUtils.GetAttributeValue(rootNav, "type");
                                }
                                else if (rootNav.Name.ToLower() == "languagepack")
                                {
                                    packageType = "LanguagePack";
                                }

                                XPathNavigator nav = null;
                                switch (packageType.ToLower())
                                {
                                case "package":
                                    nav = rootNav.SelectSingleNode("packages/package");
                                    break;

                                case "module":
                                case "languagepack":
                                case "skinobject":
                                    nav = Installer.ConvertLegacyNavigator(rootNav, new InstallerInfo()).SelectSingleNode("packages/package");
                                    break;
                                }

                                if (nav != null)
                                {
                                    package.Name            = XmlUtils.GetAttributeValue(nav, "name");
                                    package.PackageType     = XmlUtils.GetAttributeValue(nav, "type");
                                    package.IsSystemPackage = XmlUtils.GetAttributeValueAsBoolean(nav, "isSystem", false);
                                    package.Version         = new Version(XmlUtils.GetAttributeValue(nav, "version"));
                                    package.FriendlyName    = XmlUtils.GetNodeValue(nav, "friendlyName");
                                    if (String.IsNullOrEmpty(package.FriendlyName))
                                    {
                                        package.FriendlyName = package.Name;
                                    }
                                    package.Description = XmlUtils.GetNodeValue(nav, "description");
                                    package.FileName    = file.Replace(installPath + "\\", "");

                                    XPathNavigator foldernameNav;
                                    switch (package.PackageType)
                                    {
                                    case "Module":
                                        //In Dynamics moduels, a component:type=File can have a basePath pointing to the App_Conde folder. This is not a correct FolderName
                                        //To ensure that FolderName is DesktopModules...
                                        var folderNameValue = GetSpecificFolderName(nav, "components/component/files|components/component/resourceFiles", "basePath", "DesktopModules");
                                        if (!String.IsNullOrEmpty(folderNameValue))
                                        {
                                            package.FolderName = folderNameValue.Replace('\\', '/');
                                        }
                                        break;

                                    case "Auth_System":
                                        foldernameNav = nav.SelectSingleNode("components/component/files");
                                        if (foldernameNav != null)
                                        {
                                            package.FolderName = Util.ReadElement(foldernameNav, "basePath").Replace('\\', '/');
                                        }
                                        break;

                                    case "Container":
                                        foldernameNav = nav.SelectSingleNode("components/component/containerFiles");
                                        if (foldernameNav != null)
                                        {
                                            package.FolderName = Globals.glbContainersPath + Util.ReadElement(foldernameNav, "containerName").Replace('\\', '/');
                                        }
                                        break;

                                    case "Skin":
                                        foldernameNav = nav.SelectSingleNode("components/component/skinFiles");
                                        if (foldernameNav != null)
                                        {
                                            package.FolderName = Globals.glbSkinsPath + Util.ReadElement(foldernameNav, "skinName").Replace('\\', '/');
                                        }
                                        break;

                                    default:
                                        break;
                                    }

                                    XPathNavigator iconFileNav = nav.SelectSingleNode("iconFile");
                                    if (package.FolderName != string.Empty && iconFileNav != null)
                                    {
                                        if ((iconFileNav.Value != string.Empty) && (package.PackageType == "Module" || package.PackageType == "Auth_System" || package.PackageType == "Container" || package.PackageType == "Skin"))
                                        {
                                            package.IconFile = package.FolderName + "/" + iconFileNav.Value;
                                            package.IconFile = (!package.IconFile.StartsWith("~/")) ? "~/" + package.IconFile : package.IconFile;
                                        }
                                    }

                                    //Parse the Dependencies
                                    foreach (XPathNavigator dependencyNav in nav.CreateNavigator().Select("dependencies/dependency"))
                                    {
                                        var dependency       = DependencyFactory.GetDependency(dependencyNav);
                                        var packageDependecy = dependency as IManagedPackageDependency;

                                        if (packageDependecy != null)
                                        {
                                            package.Dependencies.Add(packageDependecy.PackageDependency);
                                        }
                                    }

                                    packages.Add(file, package);
                                }
                            }

                            break;
                        }
                    }
                    entry = unzip.GetNextEntry();
                }
            }
            catch (Exception)
            {
                invalidPackages.Add(file);
            }
            finally
            {
                unzip.Close();
                unzip.Dispose();
            }
        }
Пример #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadManifest method reads the manifest file and parses it into components.
        /// </summary>
        /// <history>
        ///     [cnurse]	07/24/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            //Get Name Property
            Package.Name = Util.ReadAttribute(manifestNav, "name", Log, Util.EXCEPTION_NameMissing);

            //Get Type
            Package.PackageType = Util.ReadAttribute(manifestNav, "type", Log, Util.EXCEPTION_TypeMissing);

            //If Skin or Container then set PortalID
            if (Package.PackageType == "Skin" || Package.PackageType == "Container")
            {
                Package.PortalID = Package.InstallerInfo.PortalID;
            }
            CheckSecurity();
            if (!IsValid)
            {
                return;
            }

            //Get IsSystem
            Package.IsSystemPackage = bool.Parse(Util.ReadAttribute(manifestNav, "isSystem", false, Log, "", bool.FalseString));

            //Get Version
            string strVersion = Util.ReadAttribute(manifestNav, "version", Log, Util.EXCEPTION_VersionMissing);

            if (string.IsNullOrEmpty(strVersion))
            {
                IsValid = false;
            }
            if (IsValid)
            {
                Package.Version = new Version(strVersion);
            }
            else
            {
                return;
            }

            //Attempt to get the Package from the Data Store (see if its installed)
            var packageType = PackageController.Instance.GetExtensionPackageType(t => t.PackageType == Package.PackageType);

            if (packageType.SupportsSideBySideInstallation)
            {
                _installedPackage = PackageController.Instance.GetExtensionPackage(Package.PortalID, p => p.Name == Package.Name && p.Version == Package.Version);
            }
            else
            {
                _installedPackage = PackageController.Instance.GetExtensionPackage(Package.PortalID, p => p.Name == Package.Name);
            }

            if (_installedPackage != null)
            {
                Package.InstalledVersion        = _installedPackage.Version;
                Package.InstallerInfo.PackageID = _installedPackage.PackageID;

                if (Package.InstalledVersion > Package.Version)
                {
                    Log.AddFailure(Util.INSTALL_Version + " - " + Package.InstalledVersion.ToString(3));
                    IsValid = false;
                }
                else if (Package.InstalledVersion == Package.Version)
                {
                    Package.InstallerInfo.Installed = true;
                    Package.InstallerInfo.PortalID  = _installedPackage.PortalID;
                }
            }

            Log.AddInfo(Util.DNN_ReadingPackage + " - " + Package.PackageType + " - " + Package.Name);
            Package.FriendlyName = Util.ReadElement(manifestNav, "friendlyName", Package.Name);
            Package.Description  = Util.ReadElement(manifestNav, "description");

            XPathNavigator foldernameNav = null;

            Package.FolderName = String.Empty;
            switch (Package.PackageType)
            {
            case "Module":
                //In Dynamics moduels, a component:type=File can have a basePath pointing to the App_Conde folder. This is not a correct FolderName
                //To ensure that FolderName is DesktopModules...
                var folderNameValue = PackageController.GetSpecificFolderName(manifestNav, "components/component/files|components/component/resourceFiles", "basePath", "DesktopModules");
                if (!String.IsNullOrEmpty(folderNameValue))
                {
                    Package.FolderName = folderNameValue.Replace('\\', '/');
                }
                break;

            case "Auth_System":
                foldernameNav = manifestNav.SelectSingleNode("components/component/files");
                if (foldernameNav != null)
                {
                    Package.FolderName = Util.ReadElement(foldernameNav, "basePath").Replace('\\', '/');
                }
                break;

            case "Container":
                foldernameNav = manifestNav.SelectSingleNode("components/component/containerFiles");
                if (foldernameNav != null)
                {
                    Package.FolderName = Globals.glbContainersPath + Util.ReadElement(foldernameNav, "containerName").Replace('\\', '/');
                }
                break;

            case "Skin":
                foldernameNav = manifestNav.SelectSingleNode("components/component/skinFiles");
                if (foldernameNav != null)
                {
                    Package.FolderName = Globals.glbSkinsPath + Util.ReadElement(foldernameNav, "skinName").Replace('\\', '/');
                }
                break;

            default:
                break;
            }

            ReadEventMessageNode(manifestNav);

            //Get Icon
            XPathNavigator iconFileNav = manifestNav.SelectSingleNode("iconFile");

            if (iconFileNav != null)
            {
                if (iconFileNav.Value != string.Empty)
                {
                    if (iconFileNav.Value.StartsWith("~/"))
                    {
                        Package.IconFile = iconFileNav.Value;
                    }
                    else if (iconFileNav.Value.StartsWith("DesktopModules", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Package.IconFile = string.Format("~/{0}", iconFileNav.Value);
                    }
                    else
                    {
                        Package.IconFile = (String.IsNullOrEmpty(Package.FolderName) ? "" :  Package.FolderName + "/") + iconFileNav.Value;
                        Package.IconFile = (!Package.IconFile.StartsWith("~/")) ? "~/" + Package.IconFile : Package.IconFile;
                    }
                }
            }
            //Get Author
            XPathNavigator authorNav = manifestNav.SelectSingleNode("owner");

            if (authorNav != null)
            {
                Package.Owner        = Util.ReadElement(authorNav, "name");
                Package.Organization = Util.ReadElement(authorNav, "organization");
                Package.Url          = Util.ReadElement(authorNav, "url");
                Package.Email        = Util.ReadElement(authorNav, "email");
            }

            //Get License
            XPathNavigator licenseNav = manifestNav.SelectSingleNode("license");

            if (licenseNav != null)
            {
                string licenseSrc = Util.ReadAttribute(licenseNav, "src");
                if (string.IsNullOrEmpty(licenseSrc))
                {
                    //Load from element
                    Package.License = licenseNav.Value;
                }
                else
                {
                    Package.License = ReadTextFromFile(licenseSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.License))
            {
                //Legacy Packages have no license
                Package.License = Util.PACKAGE_NoLicense;
            }

            //Get Release Notes
            XPathNavigator relNotesNav = manifestNav.SelectSingleNode("releaseNotes");

            if (relNotesNav != null)
            {
                string relNotesSrc = Util.ReadAttribute(relNotesNav, "src");
                if (string.IsNullOrEmpty(relNotesSrc))
                {
                    //Load from element
                    Package.ReleaseNotes = relNotesNav.Value;
                }
                else
                {
                    Package.ReleaseNotes = ReadTextFromFile(relNotesSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.ReleaseNotes))
            {
                //Legacy Packages have no Release Notes
                Package.ReleaseNotes = Util.PACKAGE_NoReleaseNotes;
            }

            //Parse the Dependencies
            foreach (XPathNavigator dependencyNav in manifestNav.CreateNavigator().Select("dependencies/dependency"))
            {
                var dependency       = DependencyFactory.GetDependency(dependencyNav);
                var packageDependecy = dependency as IManagedPackageDependency;

                if (packageDependecy != null)
                {
                    Package.Dependencies.Add(packageDependecy.PackageDependency);
                }

                if (!dependency.IsValid)
                {
                    Log.AddFailure(dependency.ErrorMessage);
                    return;
                }
            }

            //Read Components
            ReadComponents(manifestNav);
        }
Пример #5
0
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            Package.Name        = Util.ReadAttribute(manifestNav, "name", Log, Util.EXCEPTION_NameMissing);
            Package.PackageType = Util.ReadAttribute(manifestNav, "type", Log, Util.EXCEPTION_TypeMissing);
            if (Package.PackageType == "Skin" || Package.PackageType == "Container")
            {
                Package.PortalID = Package.InstallerInfo.PortalID;
            }
            CheckSecurity();
            if (!IsValid)
            {
                return;
            }
            InstalledPackage        = PackageController.GetPackageByName(Package.PortalID, Package.Name);
            Package.IsSystemPackage = bool.Parse(Util.ReadAttribute(manifestNav, "isSystem", false, Log, "", bool.FalseString));
            string strVersion = Util.ReadAttribute(manifestNav, "version", Log, Util.EXCEPTION_VersionMissing);

            ValidateVersion(strVersion);
            if (!IsValid)
            {
                return;
            }
            Log.AddInfo(Util.DNN_ReadingPackage + " - " + Package.PackageType + " - " + Package.Name);
            Package.FriendlyName = Util.ReadElement(manifestNav, "friendlyName", Package.Name);
            Package.Description  = Util.ReadElement(manifestNav, "description");
            XPathNavigator authorNav = manifestNav.SelectSingleNode("owner");

            if (authorNav != null)
            {
                Package.Owner        = Util.ReadElement(authorNav, "name");
                Package.Organization = Util.ReadElement(authorNav, "organization");
                Package.Url          = Util.ReadElement(authorNav, "url");
                Package.Email        = Util.ReadElement(authorNav, "email");
            }
            XPathNavigator licenseNav = manifestNav.SelectSingleNode("license");

            if (licenseNav != null)
            {
                string licenseSrc = Util.ReadAttribute(licenseNav, "src");
                if (string.IsNullOrEmpty(licenseSrc))
                {
                    Package.License = licenseNav.Value;
                }
                else
                {
                    Package.License = ReadTextFromFile(licenseSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.License))
            {
                Package.License = Util.PACKAGE_NoLicense;
            }
            XPathNavigator relNotesNav = manifestNav.SelectSingleNode("releaseNotes");

            if (relNotesNav != null)
            {
                string relNotesSrc = Util.ReadAttribute(relNotesNav, "src");
                if (string.IsNullOrEmpty(relNotesSrc))
                {
                    Package.ReleaseNotes = relNotesNav.Value;
                }
                else
                {
                    Package.ReleaseNotes = ReadTextFromFile(relNotesSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.License))
            {
                Package.License = Util.PACKAGE_NoReleaseNotes;
            }
            IDependency dependency = null;

            foreach (XPathNavigator dependencyNav in manifestNav.CreateNavigator().Select("dependencies/dependency"))
            {
                dependency = DependencyFactory.GetDependency(dependencyNav);
                if (!dependency.IsValid)
                {
                    Log.AddFailure(dependency.ErrorMessage);
                    return;
                }
            }
            ReadComponents(manifestNav);
        }
Пример #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadManifest method reads the manifest file and parses it into components.
        /// </summary>
        /// <history>
        ///     [cnurse]	07/24/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            //Get Name Property
            Package.Name = Util.ReadAttribute(manifestNav, "name", Log, Util.EXCEPTION_NameMissing);

            //Get Type
            Package.PackageType = Util.ReadAttribute(manifestNav, "type", Log, Util.EXCEPTION_TypeMissing);

            //If Skin or Container then set PortalID
            if (Package.PackageType == "Skin" || Package.PackageType == "Container")
            {
                Package.PortalID = Package.InstallerInfo.PortalID;
            }
            CheckSecurity();
            if (!IsValid)
            {
                return;
            }

            //Attempt to get the Package from the Data Store (see if its installed)
            _installedPackage = PackageController.GetPackageByName(Package.PortalID, Package.Name);

            //Get IsSystem
            Package.IsSystemPackage = bool.Parse(Util.ReadAttribute(manifestNav, "isSystem", false, Log, "", bool.FalseString));

            //Get Version
            string strVersion = Util.ReadAttribute(manifestNav, "version", Log, Util.EXCEPTION_VersionMissing);

            ValidateVersion(strVersion);
            if (!IsValid)
            {
                return;
            }
            Log.AddInfo(Util.DNN_ReadingPackage + " - " + Package.PackageType + " - " + Package.Name);
            Package.FriendlyName = Util.ReadElement(manifestNav, "friendlyName", Package.Name);
            Package.Description  = Util.ReadElement(manifestNav, "description");

            XPathNavigator foldernameNav = null;

            Package.FolderName = String.Empty;
            switch (Package.PackageType)
            {
            case "Module":
            case "Auth_System":
                foldernameNav = manifestNav.SelectSingleNode("components/component/files");
                if (foldernameNav != null)
                {
                    Package.FolderName = Util.ReadElement(foldernameNav, "basePath").Replace('\\', '/');
                }
                break;

            case "Container":
                foldernameNav = manifestNav.SelectSingleNode("components/component/containerFiles");
                if (foldernameNav != null)
                {
                    Package.FolderName = Globals.glbContainersPath + Util.ReadElement(foldernameNav, "containerName").Replace('\\', '/');
                }
                break;

            case "Skin":
                foldernameNav = manifestNav.SelectSingleNode("components/component/skinFiles");
                if (foldernameNav != null)
                {
                    Package.FolderName = Globals.glbSkinsPath + Util.ReadElement(foldernameNav, "skinName").Replace('\\', '/');
                }
                break;

            default:
                break;
            }

            //Get Icon
            XPathNavigator iconFileNav = manifestNav.SelectSingleNode("iconFile");

            if (iconFileNav != null)
            {
                if ((iconFileNav.Value != string.Empty) && (Package.PackageType == "Module" || Package.PackageType == "Auth_System" || Package.PackageType == "Container" || Package.PackageType == "Skin"))
                {
                    if (iconFileNav.Value.StartsWith("~/"))
                    {
                        Package.IconFile = iconFileNav.Value;
                    }
                    else
                    {
                        Package.IconFile = (String.IsNullOrEmpty(Package.FolderName) ? "" :  Package.FolderName + "/") + iconFileNav.Value;
                        Package.IconFile = (!Package.IconFile.StartsWith("~/")) ? "~/" + Package.IconFile : Package.IconFile;
                    }
                }
            }
            //Get Author
            XPathNavigator authorNav = manifestNav.SelectSingleNode("owner");

            if (authorNav != null)
            {
                Package.Owner        = Util.ReadElement(authorNav, "name");
                Package.Organization = Util.ReadElement(authorNav, "organization");
                Package.Url          = Util.ReadElement(authorNav, "url");
                Package.Email        = Util.ReadElement(authorNav, "email");
            }

            //Get License
            XPathNavigator licenseNav = manifestNav.SelectSingleNode("license");

            if (licenseNav != null)
            {
                string licenseSrc = Util.ReadAttribute(licenseNav, "src");
                if (string.IsNullOrEmpty(licenseSrc))
                {
                    //Load from element
                    Package.License = licenseNav.Value;
                }
                else
                {
                    Package.License = ReadTextFromFile(licenseSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.License))
            {
                //Legacy Packages have no license
                Package.License = Util.PACKAGE_NoLicense;
            }

            //Get Release Notes
            XPathNavigator relNotesNav = manifestNav.SelectSingleNode("releaseNotes");

            if (relNotesNav != null)
            {
                string relNotesSrc = Util.ReadAttribute(relNotesNav, "src");
                if (string.IsNullOrEmpty(relNotesSrc))
                {
                    //Load from element
                    Package.ReleaseNotes = relNotesNav.Value;
                }
                else
                {
                    Package.ReleaseNotes = ReadTextFromFile(relNotesSrc);
                }
            }
            if (string.IsNullOrEmpty(Package.ReleaseNotes))
            {
                //Legacy Packages have no Release Notes
                Package.ReleaseNotes = Util.PACKAGE_NoReleaseNotes;
            }

            //Parse the Dependencies
            IDependency dependency = null;

            foreach (XPathNavigator dependencyNav in manifestNav.CreateNavigator().Select("dependencies/dependency"))
            {
                dependency = DependencyFactory.GetDependency(dependencyNav);
                if (!dependency.IsValid)
                {
                    Log.AddFailure(dependency.ErrorMessage);
                    return;
                }
            }

            //Read Components
            ReadComponents(manifestNav);
        }