Exemple #1
0
        public static void ExecuteMethod_PublishGroupContentToWww(string groupID, bool useWorker, string currentContainerName, string wwwContainerName)
        {
            if (RenderWebSupport.WwwEnabledGroups.ContainsKey(groupID) == false) // Only controlled groups can have website/do web publishing
            {
                return;
            }
            string groupWwwPublicSiteLocation    = "grp/" + groupID + "/" + RenderWebSupport.DefaultPublicWwwSiteLocation;
            PublishWebContentOperation operation = PublishWebContentOperation.CreateDefault();

            operation.SourceContainerName = currentContainerName;
            operation.TargetContainerName = wwwContainerName;
            operation.SourceOwner         = "grp/" + groupID;
            operation.SourcePathRoot      = "wwwsite";
            if (useWorker)
            {
                //QueueSupport.PutToOperationQueue(localGroupTemplates, renderLocalTemplates);
                OperationRequest operationRequest = new OperationRequest();
                operationRequest.PublishWebContent = operation;
                QueueSupport.PutToOperationQueue(operationRequest);
            }
            else
            {
                WorkerSupport.ProcessPublishWebContent(operation);
            }
        }
Exemple #2
0
        public static void ProcessPublishWebContent(PublishWebContentOperation publishWebContent)
        {
            // Hardcoded security for now
            string targetContainerName = publishWebContent.TargetContainerName;

            if (targetContainerName != "www-aaltoglobalimpact-org" && targetContainerName != "www-weconomy-fi" &&
                targetContainerName != "hacktheball-protonit-net" &&
                targetContainerName != "www-protonit-net" && targetContainerName != "www-caloom-com" && targetContainerName != "www-earthhouse-fi" &&
                targetContainerName != "demowww-norssi-protonit-net" && targetContainerName != "demowww-foip-protonit-net" && targetContainerName != "b-base-protonit-net")
            {
                return;
            }
            DateTime currPublishTimeUtc   = DateTime.UtcNow;
            string   targetRootFolderName = currPublishTimeUtc.ToString("yyyy-MM-dd_hh-mm-ss");
            string   sourceOwner          = publishWebContent.SourceOwner;
            string   sourceRoot           = publishWebContent.SourcePathRoot;
            string   sourceContainerName  = publishWebContent.SourceContainerName;
            // Sync website
            string       targetWebsiteRoot = targetRootFolderName;
            VirtualOwner owner             = VirtualOwner.FigureOwner(sourceOwner);
            string       sourceWebsiteRoot = sourceOwner + "/" + sourceRoot;

            WebContentSync(sourceContainerName, sourceWebsiteRoot, targetContainerName, targetWebsiteRoot,
                           RenderWebSupport.CopyAsIsSyncHandler);
            // Copy Media
            string mediaFolderName = "AaltoGlobalImpact.OIP/MediaContent";
            string targetMediaRoot = targetRootFolderName + "/" + mediaFolderName;
            string sourceMediaRoot = sourceOwner + "/" + mediaFolderName;

            WebContentSync(sourceContainerName, sourceMediaRoot, targetContainerName, targetMediaRoot,
                           RenderWebSupport.CopyAsIsSyncHandler);
            // Copy render required data
            string[] renderRequiredFolders = new string[] { "AaltoGlobalImpact.OIP/NodeSummaryContainer", "AaltoGlobalImpact.OIP/TextContent",
                                                            "AaltoGlobalImpact.OIP/AddressAndLocationCollection" };
            foreach (string renderRequiredFolder in renderRequiredFolders)
            {
                string targetFolder = targetRootFolderName + "/" + renderRequiredFolder;
                string sourceFolder = sourceOwner + "/" + renderRequiredFolder;
                WebContentSync(sourceContainerName, sourceFolder, targetContainerName, targetFolder,
                               RenderWebSupport.CopyAsIsSyncHandler);
            }
            var lastUpdateFileBlob = StorageSupport.GetBlob(targetContainerName, RenderWebSupport.LastUpdateFileName);

            lastUpdateFileBlob.UploadBlobText(targetRootFolderName);
            var currentToServeBlob = StorageSupport.GetBlob(targetContainerName, RenderWebSupport.CurrentToServeFileName);

            currentToServeBlob.UploadBlobText(targetRootFolderName);
        }
Exemple #3
0
 public static void ProcessPublishWebContent(PublishWebContentOperation publishWebContent)
 {
     string targetContainerName = publishWebContent.TargetContainerName;
     // Hardcoded double-verify for valid container
     var blob = StorageSupport.GetBlob(targetContainerName, RenderWebSupport.CurrentToServeFileName);
     var blobData = blob.DownloadText();
     string[] contentArr = blobData.Split(':');
     if (contentArr.Length < 2 || contentArr[1] != publishWebContent.SourceOwner)
         return;
     DateTime currPublishTimeUtc = DateTime.UtcNow;
     string targetRootFolderName = currPublishTimeUtc.ToString("yyyy-MM-dd_HH-mm-ss");
     string sourceOwner = publishWebContent.SourceOwner;
     string sourceRoot = publishWebContent.SourcePathRoot;
     string sourceContainerName = publishWebContent.SourceContainerName;
     // Sync website
     string targetWebsiteRoot = targetRootFolderName;
     VirtualOwner owner = VirtualOwner.FigureOwner(sourceOwner);
     string sourceWebsiteRoot = sourceOwner + "/" + sourceRoot;
     WebContentSync(sourceContainerName, sourceWebsiteRoot, targetContainerName, targetWebsiteRoot,
                    RenderWebSupport.CopyAsIsSyncHandler);
     // Copy Media
     /*
     string mediaFolderName = "AaltoGlobalImpact.OIP/MediaContent";
     string targetMediaRoot = targetRootFolderName + "/" + mediaFolderName;
     string sourceMediaRoot = sourceOwner + "/" + mediaFolderName;
     WebContentSync(sourceContainerName, sourceMediaRoot, targetContainerName, targetMediaRoot,
                    RenderWebSupport.CopyAsIsSyncHandler);
      */
     // Copy required data to go with website stuff
     string[] foldersToCopy = new string[] {
         "AaltoGlobalImpact.OIP/NodeSummaryContainer",
         "AaltoGlobalImpact.OIP/TextContent",
         "AaltoGlobalImpact.OIP/AddressAndLocationCollection",
         "AaltoGlobalImpact.OIP/MediaContent",
         "AaltoGlobalImpact.OIP/GroupContainer",
         "AaltoGlobalImpact.OIP/AttachedToObjectCollection",
         "AaltoGlobalImpact.OIP/BinaryFileCollection",
     };
     foreach (string renderRequiredFolder in foldersToCopy)
     {
         string targetFolder = targetRootFolderName + "/" + renderRequiredFolder;
         string sourceFolder = sourceOwner + "/" + renderRequiredFolder;
         WebContentSync(sourceContainerName, sourceFolder, targetContainerName, targetFolder,
                        RenderWebSupport.CopyAsIsSyncHandler);
     }
     var lastUpdateFileBlob = StorageSupport.GetBlob(targetContainerName, RenderWebSupport.LastUpdateFileName);
     lastUpdateFileBlob.UploadBlobText(targetRootFolderName);
     var currentToServeBlob = StorageSupport.GetBlob(targetContainerName, RenderWebSupport.CurrentToServeFileName);
     currentToServeBlob.UploadBlobText(targetRootFolderName + ":" + sourceOwner);
 }