Ejemplo n.º 1
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            if (GroupName == "")
            {
                throw new InvalidDataException("Group name must be given");
            }
            //throw new NotImplementedException("Old implementation not converted to managed group structures");
            //AccountContainer container = (AccountContainer) sources.GetDefaultSource(typeof(AccountContainer).FullName).RetrieveInformationObject();
            VirtualOwner owner = VirtualOwner.FigureOwner(this);

            if (owner.ContainerName != "acc")
            {
                throw new NotSupportedException("Group creation only supported from account");
            }
            string         accountID   = owner.LocationPrefix;
            TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(accountID);
            TBAccount      account     = accountRoot.Account;

            if (account.Emails.CollectionContent.Count == 0)
            {
                throw new InvalidDataException("Account needs to have at least one email address to create a group");
            }
            CreateGroup.Execute(new CreateGroupParameters {
                AccountID = accountID, GroupName = this.GroupName
            });
            this.GroupName = "";
            return(true);
        }
 public static bool ExecuteMethod_ExecuteActualOperation(string targetObjectID, string commandName, IContainerOwner owner, InformationSourceCollection informationSources, string[] formSourceNames, NameValueCollection formSubmitContent)
 {
     switch(commandName)
     {
         case "RemoveCollaborator":
             return CallRemoveGroupMember(targetObjectID, owner);
         case "PublishGroupPublicContent":
             return CallPublishGroupContentToPublicArea(owner);
         case "PublishGroupWwwContent":
             return CallPublishGroupContentToWww(owner);
         case "AssignCollaboratorRole":
             return CallAssignCollaboratorRole(targetObjectID, owner, informationSources.GetDefaultSource(typeof(GroupContainer).FullName) ,formSubmitContent);
         case "DeleteBlog":
             return CallDeleteBlog(targetObjectID, owner);
         case "DeleteActivity":
             return CallDeleteActivity(targetObjectID, owner);
         case "UnlinkEmailAddress":
             return CallUnlinkEmailAddress(targetObjectID, owner,
                                           informationSources.GetDefaultSource(typeof (AccountContainer).FullName));
         case "CreateHelloWorld":
             return CallCreateHelloWorld(owner, helloText: formSubmitContent["tHelloText"]);
         case "DeleteHelloWorld":
             return CallDeleteHelloWorld(owner, helloWorldId: formSubmitContent["HelloWorldID"]);
         default:
             throw new NotImplementedException("Operation mapping for command not implemented: " + commandName);
     }
 }
Ejemplo n.º 3
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     string[] cmdIDList = commandName.Split('_');
     if (cmdIDList.Length < 2)
         return false;
     string cmd = cmdIDList[0];
     string cmdID = cmdIDList[1];
     if (cmdID != this.ID)
         return false;
     var defaultSource = sources.GetDefaultSource(typeof(ImageGroup).FullName);
     ImageGroup currImageGroup = (ImageGroup) defaultSource.RetrieveInformationObject();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     Image addedImage = Image.CreateDefault();
     addedImage.CopyContentFrom(this);
     addedImage.ImageData = MediaContent.CreateDefault();
     HttpPostedFile postedFile = files[this.ImageData.ID];
     if (postedFile != null && String.IsNullOrWhiteSpace(postedFile.FileName) == false)
     {
         addedImage.SetMediaContent(owner, addedImage.ImageData.ID,
             new MediaFileData { HttpFile = postedFile});
     }
     currImageGroup.ImagesCollection.CollectionContent.Add(addedImage);
     currImageGroup.StoreInformationMasterFirst(owner, true);
     return true;
 }
Ejemplo n.º 4
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            string[] cmdIDList = commandName.Split('_');
            if (cmdIDList.Length < 2)
            {
                return(false);
            }
            string cmd   = cmdIDList[0];
            string cmdID = cmdIDList[1];

            if (cmdID != this.ID)
            {
                return(false);
            }
            var          defaultSource  = sources.GetDefaultSource(typeof(ImageGroup).FullName);
            ImageGroup   currImageGroup = (ImageGroup)defaultSource.RetrieveInformationObject();
            VirtualOwner owner          = VirtualOwner.FigureOwner(this);
            Image        addedImage     = Image.CreateDefault();

            addedImage.CopyContentFrom(this);
            addedImage.ImageData = MediaContent.CreateDefault();
            HttpPostedFile postedFile = files[this.ImageData.ID];

            if (postedFile != null && String.IsNullOrWhiteSpace(postedFile.FileName) == false)
            {
                addedImage.SetMediaContent(owner, addedImage.ImageData.ID, postedFile);
            }
            currImageGroup.ImagesCollection.CollectionContent.Add(addedImage);
            currImageGroup.StoreInformationMasterFirst(owner, true);
            return(true);
        }
Ejemplo n.º 5
0
 public static void SetInformationSources(string targetLocation, InformationSourceCollection sourceCollection)
 {
     if(sourceCollection == null)
     {
         // Delete existing
         string blobPath = InformationSourceCollection.GetRelativeLocationAsMetadataTo(targetLocation);
         CloudBlob blob = StorageSupport.CurrActiveContainer.GetBlobReference(blobPath);
         blob.DeleteWithoutFiringSubscriptions();
         return;
     }
     sourceCollection.SetRelativeLocationAsMetadataTo(targetLocation);
     StorageSupport.StoreInformation(sourceCollection);
 }
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if(ImageGroupTitle == "")
         throw new InvalidDataException("Image group title is mandatory");
     //IInformationObject container = sources.GetDefaultSource().RetrieveInformationObject();
     ImageGroup imageGroup = ImageGroup.CreateDefault();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     imageGroup.SetLocationAsOwnerContent(owner, imageGroup.ID);
     imageGroup.Title = ImageGroupTitle;
     StorageSupport.StoreInformationMasterFirst(imageGroup, owner, true);
     DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, imageGroup, owner);
     return true;
 }
Ejemplo n.º 7
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            if (ImageTitle == "")
            {
                throw new InvalidDataException("Image title is mandatory");
            }
            //IInformationObject container = sources.GetDefaultSource().RetrieveInformationObject();
            Image        image = Image.CreateDefault();
            VirtualOwner owner = VirtualOwner.FigureOwner(this);

            image.SetLocationAsOwnerContent(owner, image.ID);
            image.Title = ImageTitle;
            StorageSupport.StoreInformationMasterFirst(image, owner, true);
            DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, image, owner);
            return(true);
        }
Ejemplo n.º 8
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if(CategoryName == "")
         throw new InvalidDataException("Category name is mandatory");
     Category category = new Category();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     category.SetLocationAsOwnerContent(owner, category.ID);
     category.CategoryName = CategoryName;
     StorageSupport.StoreInformationMasterFirst(category, owner, true);
     //DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, category, owner);
     //BlogContainer blogContainer = BlogContainer.RetrieveFromOwnerContent(owner, "default");
     //blogContainer.AddNewBlogPost(blog);
     //StorageSupport.StoreInformation(blogContainer);
     CategoryName = "";
     return true;
 }
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if (ActivityName == "")
         throw new InvalidDataException("Activity name is mandatory");
     Activity activity = Activity.CreateDefault();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     activity.SetLocationAsOwnerContent(owner, activity.ID);
     activity.ActivityName = ActivityName;
     activity.ReferenceToInformation.Title = activity.ActivityName;
     activity.ReferenceToInformation.URL = DefaultViewSupport.GetDefaultViewURL(activity);
     StorageSupport.StoreInformationMasterFirst(activity, owner, true);
     DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, activity, owner);
     //ActivitySummaryContainer summaryContainer = ActivitySummaryContainer.RetrieveFromOwnerContent(owner, "default");
     //summaryContainer.AddNewActivity(activity);
     //StorageSupport.StoreInformation(summaryContainer);
     return true;
 }
Ejemplo n.º 10
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if(GroupName == "")
         throw new InvalidDataException("Group name must be given");
     //throw new NotImplementedException("Old implementation not converted to managed group structures");
     //AccountContainer container = (AccountContainer) sources.GetDefaultSource(typeof(AccountContainer).FullName).RetrieveInformationObject();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     if(owner.ContainerName != "acc")
         throw new NotSupportedException("Group creation only supported from account");
     string accountID = owner.LocationPrefix;
     TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(accountID);
     TBAccount account = accountRoot.Account;
     if (account.Emails.CollectionContent.Count == 0)
         throw new InvalidDataException("Account needs to have at least one email address to create a group");
     CreateGroup.Execute(new CreateGroupParameters { AccountID = accountID, GroupName = this.GroupName });
     this.GroupName = "";
     return true;
 }
Ejemplo n.º 11
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     // TODO: Properly separate acct add email and grp invite
     EmailAddress = EmailAddress.ToLower();
     if (RelativeLocation.StartsWith("acc/"))
     {
         AddAccountEmailAddressHandling();
     }
     else if (RelativeLocation.StartsWith("grp/"))
     {
         GroupInvitationHandling();
     }
     else
     {
         throw new InvalidDataException("Relative location of AddEmailAddressInfo is not acc or grp context bound");
     }
     this.EmailAddress = "";
     return(true);
 }
Ejemplo n.º 12
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            if (CategoryName == "")
            {
                throw new InvalidDataException("Category name is mandatory");
            }
            Category     category = new Category();
            VirtualOwner owner    = VirtualOwner.FigureOwner(this);

            category.SetLocationAsOwnerContent(owner, category.ID);
            category.CategoryName = CategoryName;
            StorageSupport.StoreInformationMasterFirst(category, owner, true);
            DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, category, owner);
            //BlogContainer blogContainer = BlogContainer.RetrieveFromOwnerContent(owner, "default");
            //blogContainer.AddNewBlogPost(blog);
            //StorageSupport.StoreInformation(blogContainer);
            CategoryName = "";
            return(true);
        }
Ejemplo n.º 13
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if(Title == "")
         throw new InvalidDataException("Blog title is mandatory");
     Blog blog = Blog.CreateDefault();
     VirtualOwner owner = VirtualOwner.FigureOwner(this);
     blog.SetLocationAsOwnerContent(owner, blog.ID);
     blog.Title = Title;
     blog.ReferenceToInformation.Title = blog.Title;
     blog.ReferenceToInformation.URL = blog.RelativeLocation; // DefaultViewSupport.GetDefaultViewURL(blog);
     blog.Published = DateTime.Now;
     StorageSupport.StoreInformationMasterFirst(blog, owner, true);
     //DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, blog, owner);
     //BlogContainer blogContainer = BlogContainer.RetrieveFromOwnerContent(owner, "default");
     //blogContainer.AddNewBlogPost(blog);
     //StorageSupport.StoreInformation(blogContainer);
     Title = "";
     return true;
 }
Ejemplo n.º 14
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            if (ActivityName == "")
            {
                throw new InvalidDataException("Activity name is mandatory");
            }
            Activity     activity = Activity.CreateDefault();
            VirtualOwner owner    = VirtualOwner.FigureOwner(this);

            activity.SetLocationAsOwnerContent(owner, activity.ID);
            activity.ActivityName = ActivityName;
            activity.ReferenceToInformation.Title = activity.ActivityName;
            activity.ReferenceToInformation.URL   = DefaultViewSupport.GetDefaultViewURL(activity);
            StorageSupport.StoreInformationMasterFirst(activity, owner, true);
            DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, activity, owner);
            //ActivitySummaryContainer summaryContainer = ActivitySummaryContainer.RetrieveFromOwnerContent(owner, "default");
            //summaryContainer.AddNewActivity(activity);
            //StorageSupport.StoreInformation(summaryContainer);
            return(true);
        }
Ejemplo n.º 15
0
        public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
        {
            if (Title == "")
            {
                throw new InvalidDataException("Blog title is mandatory");
            }
            Blog         blog  = Blog.CreateDefault();
            VirtualOwner owner = VirtualOwner.FigureOwner(this);

            blog.SetLocationAsOwnerContent(owner, blog.ID);
            blog.Title = Title;
            blog.ReferenceToInformation.Title = blog.Title;
            blog.ReferenceToInformation.URL   = DefaultViewSupport.GetDefaultViewURL(blog);
            blog.Published = DateTime.Now;
            StorageSupport.StoreInformationMasterFirst(blog, owner, true);
            DefaultViewSupport.CreateDefaultViewRelativeToRequester(requesterLocation, blog, owner);
            //BlogContainer blogContainer = BlogContainer.RetrieveFromOwnerContent(owner, "default");
            //blogContainer.AddNewBlogPost(blog);
            //StorageSupport.StoreInformation(blogContainer);
            Title = "";
            return(true);
        }
Ejemplo n.º 16
0
 public static void SetBlobInformationSources(this CloudBlob blob, InformationSourceCollection informationSourceCollection)
 {
     //if(informationSourceCollection == null)
     //{
     //    blob.Attributes.Metadata.Remove(InformationSourcesKey);
     //    return;
     //}
     //string stringValue = informationSourceCollection.SerializeToXml(noFormatting:true);
     //blob.Attributes.Metadata[InformationSourcesKey] = stringValue;
     string blobInformationType = blob.GetBlobInformationType();
     if(blobInformationType == InformationType_GenericContentValue)
         throw new InvalidDataException("Blob type of GenericContent cannot have information sources: " + blob.Name);
     InformationSourceSupport.SetInformationSources(blob.Name, informationSourceCollection);
 }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Updates mismatched (new and removed) roots to sources
 /// </summary>
 /// <param name="sources">Information sources</param>
 /// <param name="existingRoots">Current roots</param>
 /// <param name="renderTarget">Render target</param>
 /// <returns>True, if existing sources were spotted and re-rendering is required</returns>
 private static bool UpdateMismatchedRootsToSources(InformationSourceCollection sources, List<ContentItem> existingRoots, CloudBlob renderTarget)
 {
     var newSources =
         existingRoots.Where(root => root.WasMissing).Select(root =>
                                                                 {
                                                                     bool foundExistingSource;
                                                                     var source = GetMissingRootAsNewSource(
                                                                         root, renderTarget.Name,
                                                                         out foundExistingSource);
                                                                     // If error, returns null
                                                                     if (source == null)
                                                                         return null;
                                                                     return new
                                                                                {
                                                                                    Source = source,
                                                                                    FoundExistingSource =
                                                                                        foundExistingSource
                                                                                };
                                                                 }
             ).Where(res => res != null).ToArray();
     sources.CollectionContent.AddRange(newSources.Select(item => item.Source));
     foreach (var item in existingRoots.Where(root => root.WasNeeded == false))
         sources.CollectionContent.Remove(item.Source);
     // Don't delete the missing blobs just now
     return newSources.Any(source => source.FoundExistingSource);
 }
Ejemplo n.º 19
0
 private static List<ContentItem> GetExistingRoots(InformationSourceCollection sources)
 {
     return
         sources.CollectionContent.Where(
             source => source.SourceType == StorageSupport.InformationType_InformationObjectValue).Select(
                 GetRootFromSource).ToList();
 }
Ejemplo n.º 20
0
 public bool PerformAddOperation(string commandName, InformationSourceCollection sources, string requesterLocation, HttpFileCollection files)
 {
     if(ImageGroupTitle == "")
         throw new InvalidDataException("Image group title is mandatory");
     throw new NotSupportedException();
 }
        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;
        }
Ejemplo n.º 22
0
        public static bool ExecuteMethod_ExecuteActualOperation(string targetObjectID, string commandName,
                                                                IContainerOwner owner, InformationSourceCollection informationSources, string[] formSourceNames,
                                                                NameValueCollection formSubmitContent)
        {
            switch (commandName)
            {
            case "ChangeIsFavouriteStatus":
                bool isFavourite;
                bool.TryParse(formSubmitContent["IsFavourite"] ?? string.Empty, out isFavourite);
                return(CallSetFavouriteStatus(formSubmitContent["ID"], isFavourite));

            default:
                throw new NotImplementedException("Operation mapping for command not implemented: " + commandName);
            }
        }