예제 #1
0
        private string ProcessPageText(SPSite site, SPList list, String pageText)
        {
            pageText = pageText.Replace("<h5>", "<h2>");
            pageText = pageText.Replace("</h5>", "</h2>");


            List <String> referencedURLs = WBUtils.GetReferencedURLs(pageText);

            foreach (String referencedURL in referencedURLs)
            {
                string withTrailing = WBUtils.EnsureHasHostHeader("http://izzi/", referencedURL);
                withTrailing = WBUtils.EnsureTrailingForwardSlash(withTrailing);

                SPListItem mappedPage = WBUtils.FindItemByColumn(site, list, RemotePageURLColumn, withTrailing);

                if (mappedPage == null)
                {
                    string withoutTrailing = WBUtils.EnsureNoTrailingForwardSlash(withTrailing);
                    mappedPage = WBUtils.FindItemByColumn(site, list, RemotePageURLColumn, withoutTrailing);
                }

                if (mappedPage != null)
                {
                    string newURLToUse = mappedPage.WBxGetColumnAsString(LOCAL_PAGE_URL);

                    if (newURLToUse == "")
                    {
                        string mappedPageNewLogicalLocation = mappedPage.WBxGetColumnAsString(NEW_LOGICAL_LOCATION);
                        string mappedPageSiteOrPage         = mappedPage.WBxGetColumnAsString(SITE_OR_PAGE);

                        newURLToUse = MakeLocalPageURL(mappedPageNewLogicalLocation, mappedPageSiteOrPage);
                    }

                    newURLToUse = WBUtils.GetURLWithoutHostHeader(newURLToUse);

                    WBLogging.Migration.Verbose("Replacing URL -> URL: " + referencedURL + " -> " + newURLToUse);

                    pageText = pageText.Replace(referencedURL, newURLToUse);
                }
                else
                {
                    WBLogging.Migration.Verbose("NOT Replacing URL: " + referencedURL);
                }
            }

            return(pageText);
        }
예제 #2
0
        private void AddChildrenForPage(SPSite site, SPWeb web, SPList list, SPListItem item, String username, String password)
        {
            string currentLocation    = item.WBxGetColumnAsString(CURRENT_LOCATION);
            string newLogicalLocation = item.WBxGetColumnAsString(NEW_LOGICAL_LOCATION);
            string remotePageURL      = item.WBxGetColumnAsString(REMOTE_PAGE_URL);

            if (currentLocation == "")
            {
                item.WBxSetColumnAsString(SITE_OR_PAGE, SITE);
                item.Update();

                return;
            }

            if (newLogicalLocation == "")
            {
                WBLogging.Migration.Verbose("The new location for this item was blank! :" + currentLocation);
                return;
            }

            if (remotePageURL == "")
            {
                remotePageURL = "http://izzi/alfresco/web/izzi" + currentLocation;
                item.WBxSetColumnAsString(REMOTE_PAGE_URL, remotePageURL);
            }

            string remotePageURLToUse = remotePageURL.Replace("/alfresco/web/izzi/", "/alfresco/service/mizzi/");

            // Let's make sure that our parent URLs end with a forward slash:
            currentLocation    = WBUtils.EnsureTrailingForwardSlash(currentLocation);
            newLogicalLocation = WBUtils.EnsureTrailingForwardSlash(newLogicalLocation);
            remotePageURL      = WBUtils.EnsureTrailingForwardSlash(remotePageURL);

            string childrenListString = WBUtils.GetURLContents(remotePageURLToUse + "?JUST_CHILD_PAGES=true", username, password);

            string parentIsSiteOrPage = PAGE;

            if (childrenListString.WBxTrim() != "")
            {
                parentIsSiteOrPage = SITE;

                string comments = item.WBxGetColumnAsString(COMMENTS);

                String[] children = childrenListString.Split(';');

                foreach (String child in children)
                {
                    if (child.WBxTrim() == "")
                    {
                        continue;
                    }

                    string cleanChild = child.Trim().Replace("&", "and").Replace(" ", "-").Replace(",", "-");

                    string childCurrentLocation    = currentLocation + child + "/";
                    string childNewLogicalLocation = newLogicalLocation + cleanChild + "/";
                    string childRemotePageURL      = remotePageURL + child + "/";

                    // OK so we need to check if another line item is already mapping to this new logical location:
                    SPListItem currentLocationExists = WBUtils.FindItemByColumn(site, list, CurrentLocationColumn, childCurrentLocation);
                    SPListItem newLocationExists     = WBUtils.FindItemByColumn(site, list, NewLogicalLocationColumn, childNewLogicalLocation);

                    if (newLocationExists == null && currentLocationExists == null)
                    {
                        // OK so this logical location isn't yet mapped to so we can create the child item:
                        WBLogging.Migration.Verbose("No duplicates found for current | new : " + childCurrentLocation + " | " + childNewLogicalLocation);

                        SPListItem childItem = list.AddItem();

                        childItem.WBxSetColumnAsString(CURRENT_LOCATION, childCurrentLocation);
                        childItem.WBxSetColumnAsString(NEW_LOGICAL_LOCATION, childNewLogicalLocation);
                        childItem.WBxSetColumnAsString(REMOTE_PAGE_URL, childRemotePageURL);
                        childItem.WBxSetColumnAsString(MIGRATION_ACTION, MIGRATION_ACTION__NOTHING);

                        childItem.Update();

                        AddChildrenForPage(site, web, list, childItem, username, password);
                    }
                    else
                    {
                        string duplicateComment = " Found duplication of";
                        if (currentLocationExists != null)
                        {
                            duplicateComment += " current location (" + currentLocationExists.ID + " : " + childCurrentLocation + ")";

                            if (newLocationExists != null)
                            {
                                duplicateComment += " and";
                            }
                        }

                        if (newLocationExists != null)
                        {
                            duplicateComment += " new logical location (" + newLocationExists.ID + " : " + childNewLogicalLocation + ")";
                        }

                        WBLogging.Migration.Verbose("Duplicates found comment: " + duplicateComment);
                        comments += duplicateComment;
                    }
                }

                item.WBxSetColumnAsString(COMMENTS, comments);
            }

            item.WBxSetColumnAsString(SITE_OR_PAGE, parentIsSiteOrPage);
            item.Update();
        }