public static void ExecuteOwnerWebPOST(IContainerOwner containerOwner, NameValueCollection form, HttpFileCollection fileContent) { bool isCancelButton = form["btnCancel"] != null; if (isCancelButton) { return; } string operationName = form["ExecuteOperation"]; if (operationName != null) { executeOperationWithFormValues(containerOwner, operationName, form, fileContent); return; } string contentSourceInfo = form["ContentSourceInfo"]; string[] contentSourceInfos = contentSourceInfo.Split(','); NameValueCollection fileEntries = new NameValueCollection(); NameValueCollection fieldEntries = new NameValueCollection(); NameValueCollection objectEntries = new NameValueCollection(); foreach (var key in form.AllKeys) { var value = form[key]; if (key.StartsWith("File_")) { fileEntries.Add(key, value); } else if (key.StartsWith("Object_")) { objectEntries.Add(key, value); } else { fieldEntries.Add(key, value); } } foreach (var key in fileContent.AllKeys) { if (key.StartsWith("File_") && fileEntries.AllKeys.Contains(key) == false) { fileEntries.Add(key, ""); } } foreach (string sourceInfo in contentSourceInfos) { string relativeLocation; string oldETag; retrieveDataSourceInfo(sourceInfo, out relativeLocation, out oldETag); VirtualOwner verifyOwner = VirtualOwner.FigureOwner(relativeLocation); if (verifyOwner.IsSameOwner(containerOwner) == false) { throw new SecurityException("Mismatch in ownership of data submission"); } IInformationObject rootObject = StorageSupport.RetrieveInformation(relativeLocation, oldETag, containerOwner); if (oldETag != rootObject.ETag) { throw new InvalidDataException("Information under editing was modified during display and save"); } // TODO: Proprely validate against only the object under the editing was changed (or its tree below) SetFieldValues(rootObject, fieldEntries); SetBinaryContent(rootObject, fileEntries, fileContent, containerOwner); SetObjectLinks(rootObject, objectEntries); /* Operation bridge model below - not used/needed with field assignment solution */ /* * var removeMediaList = form["cmdRemoveMedia"]; * if (String.IsNullOrWhiteSpace(removeMediaList) == false) * { * string[] removeList = removeMediaList.Split(','); * foreach (string contentInfo in removeList) * { * SetBinaryContent(containerOwner, contentInfo, rootObject, null); * } * } * */ rootObject.StoreInformationMasterFirst(containerOwner, false); } }
/// <summary> /// Creates default views and returns the one relative to the requester /// </summary> /// <param name="requesterLocation">Requester relative location</param> /// <param name="informationObject">Information object to create the view for</param> /// <param name="owner">Container owner</param> /// <returns></returns> public static CloudBlob CreateDefaultViewRelativeToRequester(string requesterLocation, IInformationObject informationObject, IContainerOwner owner) { bool isAccountOwner = owner.IsAccountContainer(); bool isGroupOwner = owner.IsGroupContainer(); bool isDeveloperView = owner.ContainerName == "dev"; string[] viewLocations; if (isAccountOwner) { viewLocations = FixedAccountSiteLocations; } else if (isGroupOwner) { viewLocations = FixedGroupSiteLocations; } else { throw new NotSupportedException("Invalid owner container type for default view (non acct, non group): " + owner.ContainerName); } string requesterDirectory = StorageSupport.GetLocationParentDirectory(requesterLocation); FileInfo fileInfo = new FileInfo(requesterLocation); //string viewRoot = fileInfo.Directory.Parent != null // ? fileInfo.Directory.Parent.Name // : fileInfo.Directory.Name; CloudBlob relativeViewBlob = null; bool hasException = false; bool allException = true; foreach (string viewLocation in viewLocations) { try { string viewRoot = isDeveloperView ? "developer-00000000000000000000000000" : GetViewRoot(viewLocation); string viewItemDirectory = Path.Combine(viewRoot, viewLocation).Replace("\\", "/") + "/"; string viewName = GetDefaultStaticViewName(informationObject); string viewTemplateName = GetDefaultStaticTemplateName(informationObject); // TODO: Relative from xyzsite => xyztemplate; now we only have website - also acct/grp specific //string viewTemplateLocation = "webtemplate/oip-viewtemplate/" + viewTemplateName; string viewTemplateLocation = viewItemDirectory + viewTemplateName; CloudBlob viewTemplate = StorageSupport.CurrActiveContainer.GetBlob(viewTemplateLocation, owner); string renderedViewLocation = viewItemDirectory + viewName; CloudBlob renderTarget = StorageSupport.CurrActiveContainer.GetBlob(renderedViewLocation, owner); InformationSource defaultSource = InformationSource.GetAsDefaultSource(informationObject); RenderWebSupport.RenderTemplateWithContentToBlob(viewTemplate, renderTarget, defaultSource); if (viewItemDirectory == requesterDirectory) { relativeViewBlob = renderTarget; } allException = false; } catch (Exception ex) { hasException = true; } } if (relativeViewBlob == null && hasException == false && false) { throw new InvalidDataException( String.Format("Default view with relative location {0} not found for owner type {1}", requesterLocation, owner.ContainerName)); } return(relativeViewBlob); }
private static void Main(string[] args) { try { //Console.WriteLine("Running test EKE..."); //TheBallEKE.TestExecution(); //Console.WriteLine("Running test EKE complete."); ////return; ////SecurityNegotiationManager.EchoClient().Wait(); //SecurityNegotiationManager.EchoClient(); //Console.ReadLine(); // Enter to exit //return; //return; if (args.Length != 4 || args[0].Length != 4) { Console.WriteLine("Usage: WebTemplateManager.exe <-pub name/-pri name> grp<groupID>/acc<acctID> <connection string>"); return; } //Debugger.Launch(); string pubPriPrefixWithDash = args[0]; string templateName = args[1]; if (String.IsNullOrWhiteSpace(templateName)) { throw new ArgumentException("Template name must be given"); } string connStr = args[3]; string grpacctID = args[2]; if (pubPriPrefixWithDash != "-pub" && pubPriPrefixWithDash != "-pri") { throw new ArgumentException("-pub or -pri misspelled or missing"); } string pubPriPrefix = pubPriPrefixWithDash.Substring(1); string ownerPrefix = grpacctID.Substring(0, 3); string ownerID = grpacctID.Substring(3); VirtualOwner owner = VirtualOwner.FigureOwner(ownerPrefix + "/" + ownerID); //string connStr = String.Format("DefaultEndpointsProtocol=http;AccountName=theball;AccountKey={0}", // args[0]); //connStr = "UseDevelopmentStorage=true"; bool debugMode = false; StorageSupport.InitializeWithConnectionString(connStr, debugMode); InformationContext.InitializeFunctionality(3, true); InformationContext.Current.InitializeCloudStorageAccess( Properties.Settings.Default.CurrentActiveContainerName); string directory = Directory.GetCurrentDirectory(); if (directory.EndsWith("\\") == false) { directory = directory + "\\"; } string[] allFiles = Directory.GetFiles(directory, "*", SearchOption.AllDirectories) .Select(str => str.Substring(directory.Length)) .ToArray(); if (pubPriPrefix == "pub" && templateName == "legacy") { FileSystemSupport.UploadTemplateContent(allFiles, owner, RenderWebSupport.DefaultPublicWwwTemplateLocation, true, Preprocessor, ContentFilterer, InformationTypeResolver); RenderWebSupport.RenderWebTemplate(owner.LocationPrefix, true, "AaltoGlobalImpact.OIP.Blog", "AaltoGlobalImpact.OIP.Activity"); } else { FileSystemSupport.UploadTemplateContent(allFiles, owner, templateName, true); } } catch (Exception exception) { Console.WriteLine("EXCEPTION: " + exception.ToString()); } Console.WriteLine("DONE"); }
public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files) { if (LocationName == "") { throw new InvalidDataException("Location name is mandatory"); } //IInformationObject container = sources.GetDefaultSource().RetrieveInformationObject(); AddressAndLocation location = AddressAndLocation.CreateDefault(); VirtualOwner owner = VirtualOwner.FigureOwner(this); location.SetLocationAsOwnerContent(owner, location.ID); location.Location.LocationName = LocationName; location.ReferenceToInformation.Title = location.Location.LocationName; location.ReferenceToInformation.URL = DefaultViewSupport.GetDefaultViewURL(location); StorageSupport.StoreInformationMasterFirst(location, owner, true); DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, location, owner); //LocationContainer locationContainer = LocationContainer.RetrieveFromOwnerContent(owner, "Locations"); //// Referencelocation etag in place //location.MasterETag = location.ETag; //locationContainer.Locations.CollectionContent.Add(location); //StorageSupport.StoreInformation(locationContainer); //AccountContainer accountContainer = container as AccountContainer; //GroupContainer groupContainer = container as GroupContainer; //if (accountContainer != null) //{ // accountContainer.AccountModule.LocationCollection.CollectionContent.Add(location); //} else if(groupContainer != null) //{ // //groupContainer.Locations.CollectionContent.Add(location); //} //StorageSupport.StoreInformation(container); return(true); /* * location.Address = Address; * location.Location.Longitude.TextValue = this.Longitude; * location.Location.Latitude.TextValue = this.Latitude; * location.Location.LocationName = this.LocationName; * container.AccountModule.LocationCollection.CollectionContent.Add(location); * StorageSupport.StoreInformation(container); * VirtualOwner owner = VirtualOwner.FigureOwner(this); * MapContainer mapContainer = MapContainer.RetrieveFromOwnerContent(owner, "default"); * mapContainer.MapMarkers.CollectionContent.Clear(); * mapContainer.MapMarkers.CollectionContent.AddRange( * container.AccountModule.LocationCollection.CollectionContent. * Select(loc => * { * MapMarker marker = MapMarker.CreateDefault(); * marker.Location = loc.Location; * marker.LocationText = string.Format("{0},{1}", * loc.Location.Latitude.TextValue, * loc.Location.Longitude.TextValue); * return marker; * })); * StorageSupport.StoreInformation(mapContainer); * LocationName = ""; * Address = StreetAddress.CreateDefault(); * Longitude = ""; * Latitude = ""; */ return(true); }
static void Main(string[] args) { try { string connStr = "DefaultEndpointsProtocol=https;AccountName=theballmichael;AccountKey=CWz4Sp47JIASPy99OMQX+MCdbc82pHqI0obsTAeRNb2k++YVhssKZ1RVAal8LVvA0ekXddWKIBQ7LA3Z0P6bAA=="; //connStr = "UseDevelopmentStorage=true"; bool debugMode = false; StorageSupport.InitializeWithConnectionString(connStr, debugMode); InformationContext.InitializeFunctionality(3, true); InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName); if (DataPatcher.DoPatching()) { Console.WriteLine("DONE"); Console.ReadLine(); return; } //ProcessErrors(false); //return; string templateLocation = "livetemplate"; string privateSiteLocation = "livesite"; string publicSiteLocation = "livepubsite"; const string accountNamePart = "oip-account\\"; const string publicGroupNamePart = "oip-public\\"; const string groupNamePart = "oip-group\\"; const string wwwNamePart = "www-public\\"; //DoMapData(webGroup); //return; string directory = Directory.GetCurrentDirectory(); if (directory.EndsWith("\\") == false) { directory = directory + "\\"; } string[] allFiles = Directory.GetFiles(directory, "*", SearchOption.AllDirectories).Select( str => str.Substring(directory.Length)).Where(str => str.StartsWith("theball-") == false).ToArray(); string[] groupTemplates = allFiles.Where(file => file.StartsWith(accountNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(wwwNamePart) == false). ToArray(); string[] publicGroupTemplates = allFiles.Where(file => file.StartsWith(accountNamePart) == false && file.StartsWith(groupNamePart) == false && file.StartsWith(wwwNamePart) == false). ToArray(); string[] accountTemplates = allFiles.Where(file => file.StartsWith(groupNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(wwwNamePart) == false). ToArray(); string[] wwwTemplates = allFiles.Where(file => file.StartsWith(groupNamePart) == false && file.StartsWith(publicGroupNamePart) == false && file.StartsWith(accountNamePart) == false). ToArray(); UploadAndMoveUnused(accountTemplates, groupTemplates, publicGroupTemplates, null); //UploadAndMoveUnused(null, null, null, wwwTemplates); //UploadAndMoveUnused(null, null, publicGroupTemplates, null); //UploadAndMoveUnused(accountTemplates, null, null); //DeleteAllAccountAndGroupContents(true); //RefreshAllAccounts(); // TODO: The delete above needs to go through first before the refresh one below RenderWebSupport.RefreshAllAccountAndGroupTemplates(true, "AaltoGlobalImpact.OIP.Blog", "AaltoGlobalImpact.OIP.Activity", "AaltoGlobalImpact.OIP.AddressAndLocation", "AaltoGlobalImpact.OIP.Image", "AaltoGlobalImpact.OIP.ImageGroup", "AaltoGlobalImpact.OIP.Category"); //RunTaskedQueueWorker(); //FileSystemSupport.UploadTemplateContent(groupTemplates, webGroup, templateLocation, true); Console.WriteLine("Starting to sync..."); //DoSyncs(templateLocation, privateSiteLocation, publicSiteLocation); //"grp/default/pub/", true); return; //doDataTest(connStr); //InitLandingPages(); //Console.WriteLine("Press enter to continue..."); //Console.ReadLine(); } catch (InvalidDataException ex) { Console.WriteLine("Error exit: " + ex.ToString()); } }
public static void ExecuteMethod_DeleteObject(IInformationObject objectToDelete) { StorageSupport.DeleteInformationObject(objectToDelete); }