private void HandleFileSystemGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { var response = context.Response; string contentType = StorageSupport.GetMimeType(Path.GetExtension(contentPath)); response.ContentType = contentType; string prefixStrippedContent = contentPath; //.Substring(AuthGroupPrefixLen + GuidIDLen + 1); string LocalWebRootFolder = @"C:\Users\Michael\WebstormProjects\OIPTemplates\UI\groupmanagement\"; string LocalWwwSiteFolder = @"C:\Users\Michael\WebstormProjects\TitanWeb\UI\TitanWeb\"; string fileName; if (prefixStrippedContent.Contains("oipcms/")) { fileName = prefixStrippedContent.Replace("oipcms/", LocalWebRootFolder); } else { fileName = prefixStrippedContent.Replace("wwwsite/", LocalWwwSiteFolder); } if (File.Exists(fileName)) { var fileStream = File.OpenRead(fileName); fileStream.CopyTo(context.Response.OutputStream); fileStream.Close(); } else { response.StatusCode = 404; } response.End(); }
private void HandleOwnerGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { //CloudBlob blob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath); // Read blob content to response. context.Response.Clear(); try { string contentType = StorageSupport.GetMimeType(Path.GetExtension(contentPath)); context.Response.ContentType = contentType; string prefixStrippedContent = contentPath; //contentPath.Substring(AuthDeveloperPrefixLen + GuidIDLen + 1); string fileName = Path.Combine(DeveloperWebRootFolder, prefixStrippedContent); //blob.FetchAttributes(); var matches = defaultViewRegex.Matches(contentPath); if (matches.Count > 0) { var match = matches[0]; string informationObjectType = match.Groups["typename"].Value; string objectID = match.Groups["id"].Value; Type objectType = typeof(IInformationObject).Assembly.GetType(informationObjectType); MethodInfo retrieveFromDefaultLocation = objectType.GetMethod("RetrieveFromDefaultLocation"); IInformationObject iObject = (IInformationObject)retrieveFromDefaultLocation.Invoke(null, new object[] { objectID, containerOwner }); string templateName = DefaultViewSupport.GetDefaultStaticTemplateName(iObject); foreach (string groupTemplateDirectory in DefaultViewSupport.FixedGroupSiteLocations) { string filesystemDirectory = Path.Combine(DeveloperWebRootFolder, groupTemplateDirectory); string templateFileName = Path.Combine(filesystemDirectory, templateName); string templateContent; try { templateContent = GetTemplateContent(templateFileName); } catch { continue; } string blobDirectory = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(contentPath)), groupTemplateDirectory); string templateBlobPath = Path.Combine(blobDirectory, templateName).Replace("\\", "/"); var templateBlob = StorageSupport.UploadOwnerBlobText(containerOwner, templateBlobPath, templateContent, StorageSupport. InformationType_WebTemplateValue); } var blob = DefaultViewSupport.CreateDefaultViewRelativeToRequester(contentPath, iObject, containerOwner); blob.DownloadToStream(context.Response.OutputStream); } else { string templateContent = GetTemplateContent(fileName); if (templateContent != null) { string templateBlobPath = Path.Combine("template", contentPath).Replace("\\", "/"); var templateBlob = StorageSupport.UploadOwnerBlobText(containerOwner, templateBlobPath, templateContent, StorageSupport. InformationType_WebTemplateValue); var targetBlob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath); RenderWebSupport.RenderTemplateWithContentToBlob(templateBlob, targetBlob); targetBlob.DownloadToStream(context.Response.OutputStream); //List<RenderWebSupport.ContentItem> contentRoots = new List<RenderWebSupport.ContentItem>(); //string rendered = RenderWebSupport.RenderTemplateWithContentRoots(fixedContent, contentRoots); //RenderWebSupport.Ren //context.Response.Output.Write(rendered); } else { if (File.Exists(fileName)) { var fileStream = File.OpenRead(fileName); fileStream.CopyTo(context.Response.OutputStream); fileStream.Close(); } else { var targetBlob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath); targetBlob.DownloadToStream(context.Response.OutputStream); } } } } catch (Exception ex) { context.Response.Write(ex.ToString()); } context.Response.End(); }