public Yield SiteImport(DreamContext context, DreamMessage request, Result <DreamMessage> response) { var forceOverwrite = context.GetParam("forceoverwrite", false); // Retrieve the title used for path normalization (if any) Title relToTitle = Utils.GetRelToTitleFromUrl(context) ?? Title.FromDbPath(NS.MAIN, String.Empty, null); // Retrieve the manifest describing the import XDoc manifestDoc = request.ToDocument(); if (manifestDoc == null || manifestDoc.IsEmpty || !manifestDoc.HasName("manifest")) { throw new PostedDocumentInvalidArgumentException("manifest"); } // Perform the import MindTouch.Deki.Export.SiteImportBuilder importBuilder = new MindTouch.Deki.Export.SiteImportBuilder(relToTitle, forceOverwrite); importBuilder.Append(manifestDoc); response.Return(DreamMessage.Ok(importBuilder.ToDocument())); yield break; }
public Yield SiteImport(DreamContext context, DreamMessage request, Result<DreamMessage> response) { var forceOverwrite = context.GetParam("forceoverwrite", false); // Retrieve the title used for path normalization (if any) Title relToTitle = Utils.GetRelToTitleFromUrl(context) ?? Title.FromDbPath(NS.MAIN, String.Empty, null); // Retrieve the manifest describing the import XDoc manifestDoc = request.ToDocument(); if(manifestDoc == null || manifestDoc.IsEmpty || !manifestDoc.HasName("manifest")) { throw new DreamBadRequestException(String.Format(DekiResources.INVALID_POSTED_DOCUMENT_1, "manifest")); } // Perform the import MindTouch.Deki.Export.SiteImportBuilder importBuilder = new MindTouch.Deki.Export.SiteImportBuilder(relToTitle, forceOverwrite); importBuilder.Append(manifestDoc); response.Return(DreamMessage.Ok(importBuilder.ToDocument())); yield break; }