Ejemplo n.º 1
0
 public Installer(IInstallerConfiguration configuration)
 {
     Configuration = configuration;
     DefaultConfigurationSetter.ApplyDefaults(configuration);
     DyndleFolder         = Client.Read(configuration.DyndleFolder, DefaultReadOptions) as FolderData;
     DyndleStructureGroup = Client.Read(configuration.DyndleStructureGroup, DefaultReadOptions) as StructureGroupData;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StructureGroup"/> class.
        /// </summary>
        /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
        /// <param name="structureGroupData"><see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" /></param>
        protected StructureGroup(Client client, StructureGroupData structureGroupData)
            : base(client, structureGroupData)
        {
            if (structureGroupData == null)
                throw new ArgumentNullException("structureGroupData");

            mStructureGroupData = structureGroupData;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StructureGroup"/> class.
        /// </summary>
        /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
        /// <param name="structureGroupData"><see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" /></param>
        protected StructureGroup(Client client, StructureGroupData structureGroupData) : base(client, structureGroupData)
        {
            if (structureGroupData == null)
            {
                throw new ArgumentNullException("structureGroupData");
            }

            mStructureGroupData = structureGroupData;
        }
        internal void CreateOrIgnoreRootStructureGroup(string rootStructureGroupTitle, string publicationId)
        {
            PublicationData publication = (PublicationData)_client.Read(publicationId, _readOptions);

            if (publication.RootStructureGroup.IdRef == TcmUri.UriNull)
            {
                StructureGroupData structureGroup =
                    //(StructureGroupData)_client.GetDefaultData(ItemType.StructureGroup, publicationId, _readOptions);
                    (StructureGroupData)_client.GetDefaultData(ItemType.StructureGroup, publicationId);
                structureGroup.Title = rootStructureGroupTitle;
                _client.Save(structureGroup, null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reload the <see cref="StructureGroup" /> with the specified <see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" />
        /// </summary>
        /// <param name="structureGroupData"><see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" /></param>
        protected void Reload(StructureGroupData structureGroupData)
        {
            if (structureGroupData == null)
            {
                throw new ArgumentNullException("structureGroupData");
            }

            mStructureGroupData = structureGroupData;
            base.Reload(structureGroupData);

            mDefaultPageTemplate = null;
            mPageBundleProcess   = null;
            mPageProcess         = null;
        }
        public string GetStructureGroup(string sgTitle, string parentStructureGroup)
        {
            OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();

            filter.ItemTypes = new[] { ItemType.StructureGroup };
            foreach (XElement node in _client.GetListXml(parentStructureGroup, filter).Nodes())
            {
                if (node.Attribute("Title").Value.Equals(sgTitle))
                {
                    return(node.Attribute("ID").Value);
                }
            }
            StructureGroupData sg =
                (StructureGroupData)
                _client.GetDefaultData(ItemType.StructureGroup, parentStructureGroup);

            sg.Title     = sgTitle;
            sg.Directory = Regex.Replace(sgTitle, "\\W", "").ToLowerInvariant().Replace("á", "a").Replace("ó", "o");
            sg           = (StructureGroupData)_client.Save(sg, _readOptions);
            return(sg.Id);
        }
Ejemplo n.º 7
0
        public static StructureGroupResult From(StructureGroupData item, string currentUserId)
        {
            var result = new StructureGroupResult
            {
                Directory     = TextEntry.From(string.IsNullOrWhiteSpace(item.Directory) ? Resources.EmptyLabel : item.Directory, Resources.LabelDirectory),
                Template      = LinkEntry.From(item.DefaultPageTemplate, Resources.LabelTemplate, currentUserId),
                PathOnWebsite = GetPublishPath(item.LocationInfo as PublishLocationInfo, item.Directory)
            };

            if (item.IsActiveResolvedValue == false)
            {
                string publishable = Resources.CannotBePublished;
                if (item.IsActive == true)
                {
                    publishable = Resources.CannotBePublishedDueToAncestor;
                }
                result.Publishable = TextEntry.From(publishable, Resources.LabelPublishable);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
Ejemplo n.º 8
0
        public static StructureGroupResult From(StructureGroupData item, string currentUserId)
        {
            var result = new StructureGroupResult
            {
                Directory = TextEntry.From(string.IsNullOrWhiteSpace(item.Directory) ? Resources.EmptyLabel : item.Directory, Resources.LabelDirectory),
                Template = LinkEntry.From(item.DefaultPageTemplate, Resources.LabelTemplate, currentUserId),
                PathOnWebsite = GetPublishPath(item.LocationInfo as PublishLocationInfo, item.Directory)
            };

            if (item.IsActiveResolvedValue == false)
            {
                string publishable = Resources.CannotBePublished;
                if (item.IsActive == true)
                {
                    publishable = Resources.CannotBePublishedDueToAncestor;
                }
                result.Publishable = TextEntry.From(publishable, Resources.LabelPublishable);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return result;
        }
        public static bool CreateStructureGroup(MappingInfo mapping, string title, string tcmContainer)
        {
            if (!EnsureValidClient(mapping))
                return false;

            try
            {
                StructureGroupData sgData = new StructureGroupData
                {
                    Title = title,
                    Directory = title,
                    LocationInfo = new LocationInfo { OrganizationalItem = new LinkToOrganizationalItemData { IdRef = tcmContainer } },
                    Id = "tcm:0-0-0"
                };

                sgData = Client.Save(sgData, new ReadOptions()) as StructureGroupData;
                if (sgData == null)
                    return false;

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Ejemplo n.º 10
0
        private static void PurgeStructureGroups(CoreServiceClient client, string structureGroups, PurgeOldVersionsInstructionData purgeIntructions, UInt16 versionsToKeep, string pubUri)
        {
            int totalPageVersionsRemoved = 0;

            string[] structureGroupUris = structureGroups.Split(',');

            List <LinkToIdentifiableObjectData> itemsToPurge = new List <LinkToIdentifiableObjectData>();

            for (int i = 0; i < structureGroupUris.Length; i++)
            {
                StructureGroupData structureGroup = null;

                try
                {
                    string localUri = GetLocalUri(pubUri.Trim(), structureGroupUris[i]);

                    // Add sub and subsub-folders to list to prevent timeouts...
                    structureGroup = (StructureGroupData)client.Read(localUri, null);
                }
                catch (Exception ex)
                {
                    continue;
                }

                LinkToIdentifiableObjectData subfolderLink = new LinkToIdentifiableObjectData();
                subfolderLink.IdRef = structureGroup.Id;
                itemsToPurge.Add(subfolderLink);

                var itemTypes = new List <ItemType>();
                itemTypes.Add(ItemType.StructureGroup);

                var filter = new OrganizationalItemItemsFilterData();
                filter.Recursive = true;
                filter.ItemTypes = itemTypes.ToArray();
                purgeIntructions.VersionsToKeep = versionsToKeep;
                purgeIntructions.Recursive      = false;

                IdentifiableObjectData[] subSGs = client.GetList(structureGroup.Id, filter);

                foreach (var subSubSG in subSGs)
                {
                    LinkToIdentifiableObjectData structureGroupLink = new LinkToIdentifiableObjectData();
                    structureGroupLink.IdRef = subSubSG.Id;
                    itemsToPurge.Add(structureGroupLink);
                    purgeIntructions.Containers = itemsToPurge.ToArray();

                    try
                    {
                        int versionsCleaned = client.PurgeOldVersions(purgeIntructions);
                        totalPageVersionsRemoved = totalPageVersionsRemoved + versionsCleaned;
                        WriteOutput("Removed " + versionsCleaned.ToString() + " Page Versions");
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    itemsToPurge.Clear();
                }
            }
            WriteOutput("Total Page versions removed is " + totalPageVersionsRemoved.ToString());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Reload the <see cref="StructureGroup" /> with the specified <see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" />
        /// </summary>
        /// <param name="structureGroupData"><see cref="T:Tridion.ContentManager.CoreService.Client.StructureGroupData" /></param>
        protected void Reload(StructureGroupData structureGroupData)
        {
            if (structureGroupData == null)
                throw new ArgumentNullException("structureGroupData");

            mStructureGroupData = structureGroupData;
            base.Reload(structureGroupData);

            mDefaultPageTemplate = null;
            mPageBundleProcess = null;
            mPageProcess = null;
        }
        protected override void OnLoad(EventArgs e)
        {
            Initialize();
            if (!IsPostBack)
            {
                base.OnLoad(e);
                if (!String.IsNullOrEmpty(StartFromUri))
                {
                    TcmUri uri = new TcmUri(StartFromUri);
                    switch (uri.ItemType)
                    {
                    case ItemType.Publication:
                        PublicationData pub = (PublicationData)_client.Read(StartFromUri, new ReadOptions());
                        EmbeddedTreeView.Nodes[0].Text = pub.Title;
                        break;

                    case ItemType.Folder:
                        FolderData fol = (FolderData)_client.Read(StartFromUri, new ReadOptions());
                        EmbeddedTreeView.Nodes[0].Text = fol.Title;
                        break;

                    case ItemType.StructureGroup:
                        StructureGroupData sg = (StructureGroupData)_client.Read(StartFromUri, new ReadOptions());
                        EmbeddedTreeView.Nodes[0].Text = sg.Title;
                        break;

                    case ItemType.Category:
                        CategoryData cat = (CategoryData)_client.Read(StartFromUri, new ReadOptions());
                        EmbeddedTreeView.Nodes[0].Text = cat.Title;
                        break;
                    }
                    // root node, disable select action (set to expand)
                    EmbeddedTreeView.Nodes[0].Value        = StartFromUri;
                    EmbeddedTreeView.Nodes[0].ImageUrl     = UriImage(uri);
                    EmbeddedTreeView.Nodes[0].SelectAction = TreeNodeSelectAction.Expand;
                    //EmbeddedTreeView.Nodes[0].Text += " (" + LogonUser + ")";

                    // translate the logical mask value for 'SelectItems' into a list of item types
                    _selectedItemTypes = new List <ItemType>();
                    _showItemTypes     = new List <ItemType>();
                    foreach (int type in ItemTypeIds.Keys)
                    {
                        if (type == 0)
                        {
                            continue;
                        }

                        ItemType curType = ItemTypeIds[type];

                        // select types 0 means all (selecting none makes no sense)
                        if (SelectTypes == 0)
                        {
                            _selectedItemTypes.Add(curType);
                            _showItemTypes.Add(curType);
                            continue;
                        }
                        if ((SelectTypes & type) != type)
                        {
                            continue;
                        }

                        _selectedItemTypes.Add(curType);
                        _showItemTypes.Add(curType);
                        switch (curType)
                        {
                        case ItemType.Publication:
                            break;

                        case ItemType.Folder:
                        case ItemType.StructureGroup:
                        case ItemType.Category:
                            if (!_showItemTypes.Contains(ItemType.Publication))
                            {
                                _showItemTypes.Add(ItemType.Publication);
                            }
                            break;

                        case ItemType.Page:
                            if (!_showItemTypes.Contains(ItemType.StructureGroup))
                            {
                                _showItemTypes.Add(ItemType.StructureGroup);
                            }
                            if (!_showItemTypes.Contains(ItemType.Publication))
                            {
                                _showItemTypes.Add(ItemType.Publication);
                            }
                            break;

                        case ItemType.Keyword:
                            if (!_showItemTypes.Contains(ItemType.Category))
                            {
                                _showItemTypes.Add(ItemType.Category);
                            }
                            if (!_showItemTypes.Contains(ItemType.Publication))
                            {
                                _showItemTypes.Add(ItemType.Publication);
                            }
                            break;

                        default:
                            if (!_showItemTypes.Contains(ItemType.Folder))
                            {
                                _showItemTypes.Add(ItemType.Folder);
                            }
                            if (!_showItemTypes.Contains(ItemType.Publication))
                            {
                                _showItemTypes.Add(ItemType.Publication);
                            }
                            break;
                        }
                    }
                    // always add workitem type for categories and keyword section
                    if (SelectTypes != 0)
                    {
                        _showItemTypes.Add(ItemType.WorkItem);
                    }
                }
                Session["showitemtypes"]     = _showItemTypes;
                Session["selecteditemtypes"] = _selectedItemTypes;
            }
            else
            {
                _showItemTypes     = (List <ItemType>)Session["showitemtypes"];
                _selectedItemTypes = (List <ItemType>)Session["selecteditemtypes"];
            }
        }