Ejemplo n.º 1
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.º 2
0
        private void HandleInputJoinConfirmation(HttpContext context, TBAccount account, TBEmailValidation emailValidation)
        {
            ValidateAccountsEmailAddress(account, emailValidation);
            VirtualOwner owner;
            var          inputJoinInfo = emailValidation.InformationInputConfirmation;
            string       redirectUrl;

            if (String.IsNullOrEmpty(inputJoinInfo.AccountID) == false)
            {
                owner       = VirtualOwner.FigureOwner("acc/" + inputJoinInfo.AccountID);
                redirectUrl = "/auth/account/website/oip-account/oip-layout-account-welcome.phtml";
            }
            else
            {
                string groupID = inputJoinInfo.GroupID;
                owner       = VirtualOwner.FigureOwner("grp/" + groupID);
                redirectUrl = "/auth/grp/" + groupID + "/website/oip-group/oip-layout-groups-edit.phtml";
            }
            SetInformationInputValidationAndActiveStatus.Execute(
                new SetInformationInputValidationAndActiveStatusParameters
            {
                Owner = owner,
                InformationInputID = inputJoinInfo.InformationInputID,
                IsValidAndActive   = true
            });
            context.Response.Redirect(redirectUrl, true);
        }
Ejemplo n.º 3
0
        private static void ReconnectMastersAndCollections(string ownerLocation, string objectNamePart)
        {
            //string myLocalAccountID = "0c560c69-c3a7-4363-b125-ba1660d21cf4";
            //string acctLoc = "acc/" + myLocalAccountID + "/";

            VirtualOwner me = VirtualOwner.FigureOwner(ownerLocation);

            var informationObjects = StorageSupport.CurrActiveContainer.GetInformationObjects(ownerLocation, blobName => objectNamePart == null || blobName.Contains(objectNamePart),
                                                                                              nonMaster =>
                                                                                              nonMaster.
                                                                                              IsIndependentMaster ==
                                                                                              false && (nonMaster is TBEmailValidation == false)).ToArray();

            foreach (var iObj in informationObjects)
            {
                try
                {
                    iObj.ReconnectMastersAndCollections(true);
                } catch (Exception ex)
                {
                    bool ignoreException = false;
                    if (ignoreException == false)
                    {
                        throw;
                    }
                }
            }
        }
        public static AccountRootAndContainer[] GetTarget_AccountRootsAndContainers(TBRGroupRoot groupRoot)
        {
            var accountIDs = groupRoot.Group.Roles.CollectionContent.
                             Select(role => role.Email.EmailAddress).
                             Select(email =>
            {
                string emailRootID     = TBREmailRoot.GetIDFromEmailAddress(email);
                TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);
                return(emailRoot.Account.ID);
            }).Distinct().ToArray();
            List <AccountRootAndContainer> result = new List <AccountRootAndContainer>();

            foreach (var accountID in accountIDs)
            {
                TBRAccountRoot          accountRoot             = TBRAccountRoot.RetrieveFromDefaultLocation(accountID);
                VirtualOwner            owner                   = new VirtualOwner("acc", accountID);
                var                     accountContainer        = AccountContainer.RetrieveFromOwnerContent(owner, "default");
                AccountRootAndContainer accountRootAndContainer = new AccountRootAndContainer
                {
                    AccountContainer = accountContainer,
                    AccountRoot      = accountRoot
                };
                result.Add(accountRootAndContainer);
            }
            return(result.ToArray());
        }
Ejemplo n.º 5
0
        public static GroupSummaryContainer GetTarget_GroupSummaryContainer(string accountID)
        {
            VirtualOwner owner = new VirtualOwner("acc", accountID);
            var          groupSummaryContainer = GroupSummaryContainer.RetrieveFromOwnerContent(owner, "default");

            return(groupSummaryContainer);
        }
Ejemplo n.º 6
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.º 7
0
        public static AccountContainer GetTarget_AccountContainer(string accountID)
        {
            VirtualOwner owner            = new VirtualOwner("acc", accountID);
            var          accountContainer = AccountContainer.RetrieveFromOwnerContent(owner, "default");

            return(accountContainer);
        }
Ejemplo n.º 8
0
        private static void PatchBlogsAndActivitiesSelectedCollections()
        {
            var ownerLocations = GetAllOwnerLocations();
            int totalCount     = ownerLocations.Length;
            int currIX         = 0;

            foreach (var ownerLocation in ownerLocations)
            {
                Console.WriteLine("Updating number " + (++currIX) + " out of " + totalCount);
                VirtualOwner owner = VirtualOwner.FigureOwner(ownerLocation);
                var          informationObjects = StorageSupport.CurrActiveContainer.
                                                  GetInformationObjects(ownerLocation, null,
                                                                        iObj =>
                                                                        iObj is Blog ||
                                                                        iObj is Activity).ToArray();
                foreach (var iObj in informationObjects)
                {
                    try
                    {
                        //StorageSupport.StoreInformationMasterFirst(iObj, owner, true);
                        StorageSupport.StoreInformationMasterFirst(iObj, owner, false);
                    }
                    catch (Exception ex)
                    {
                        bool letThrow = false;
                        if (letThrow)
                        {
                            throw;
                        }
                    }
                }
            }
            InformationContext.ProcessAndClearCurrent();
            InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
        }
Ejemplo n.º 9
0
        public static void EnsureAndRefreshMasterCollections()
        {
            var accountIDs = TBRAccountRoot.GetAllAccountIDs();

            foreach (string accountID in accountIDs)
            {
                string       acctLocation = "acc/" + accountID + "/";
                VirtualOwner owner        = VirtualOwner.FigureOwner(acctLocation);
                //CoreDomain.EnsureMasterCollections(owner);
                //CoreDomain.RefreshMasterCollections(owner);
                OIPDomain.EnsureMasterCollections(owner);
                OIPDomain.RefreshMasterCollections(owner);
            }
            var groupIDs = TBRGroupRoot.GetAllGroupIDs();

            foreach (string groupID in groupIDs)
            {
                string       grpLocation = "grp/" + groupID + "/";
                VirtualOwner owner       = VirtualOwner.FigureOwner(grpLocation);
                //CoreDomain.EnsureMasterCollections(owner);
                //CoreDomain.RefreshMasterCollections(owner);
                OIPDomain.EnsureMasterCollections(owner);
                OIPDomain.RefreshMasterCollections(owner);
            }
        }
Ejemplo n.º 10
0
        public static GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot)
        {
            VirtualOwner groupOwner     = new VirtualOwner("grp", groupRoot.Group.ID);
            var          groupContainer = GroupContainer.RetrieveFromOwnerContent(groupOwner, "default");

            return(groupContainer);
        }
Ejemplo n.º 11
0
 private static void ProcessSingleOperation(OperationRequest operationRequest)
 {
     if (operationRequest.PublishWebContent != null)
     {
         ProcessPublishWebContent(operationRequest.PublishWebContent);
     }
     if (operationRequest.UpdateWebContentOperation != null)
     {
         ProcessUpdateWebContent(operationRequest.UpdateWebContentOperation);
     }
     if (operationRequest.SubscriberNotification != null)
     {
         WorkerSupport.ExecuteSubscription(operationRequest.SubscriberNotification);
     }
     if (operationRequest.RefreshDefaultViewsOperation != null)
     {
         WorkerSupport.RefreshDefaultViews(operationRequest.RefreshDefaultViewsOperation);
     }
     if (operationRequest.DeleteEntireOwner != null)
     {
         VirtualOwner virtualOwner = new VirtualOwner(operationRequest.DeleteEntireOwner.ContainerName,
                                                      operationRequest.DeleteEntireOwner.LocationPrefix);
         DeleteEntireOwner(virtualOwner);
     }
     if (operationRequest.DeleteOwnerContent != null)
     {
         VirtualOwner virtualOwner = new VirtualOwner(operationRequest.DeleteOwnerContent.ContainerName,
                                                      operationRequest.DeleteOwnerContent.LocationPrefix);
         DeleteOwnerContent(virtualOwner);
     }
     if (operationRequest.SubscriptionChainRequest != null)
     {
         WorkerSupport.ExecuteSubscriptionChain(operationRequest.SubscriptionChainRequest);
     }
 }
        public static GroupContainer GetTarget_GroupInternalContainer(string groupID)
        {
            VirtualOwner owner          = new VirtualOwner("grp", groupID);
            var          groupContainer = GroupContainer.RetrieveFromOwnerContent(owner, "default");

            return(groupContainer);
        }
Ejemplo n.º 13
0
        public static IContainerOwner[] GetOwnerChainsInOrderOfSubmission()
        {
            int indexStart      = ChainRequestDirectory.Length;
            int substringLength = StorageSupport.GuidLength + 4;

            string[] chainRequestList   = GetChainRequestList();
            var      groupedResult      = chainRequestList.GroupBy(item => item.Substring(indexStart, substringLength));
            var      resultsWithoutLock = groupedResult.Where(grp => grp.Any(item => IsLock(item) == false));

            return(resultsWithoutLock.Select(grp => VirtualOwner.FigureOwner(grp.Key)).ToArray());
        }
Ejemplo n.º 14
0
        public static void NotifySubscribers(string targetLocation)
        {
            var ictx = InformationContext.Current;

            if (ictx.IsExecutingSubscriptions)
            {
                return;
            }
            SubscriptionCollection subscriptionCollection = GetSubscriptions(targetLocation);
            string targetParentLocation = GetParentDirectoryTarget(targetLocation);
            SubscriptionCollection parentSubscriptionCollection = GetSubscriptions(targetParentLocation);

            if (subscriptionCollection == null && parentSubscriptionCollection == null)
            {
                return;
            }
            VirtualOwner          owner            = VirtualOwner.FigureOwner(targetLocation);
            OwnerSubscriptionItem subscriptionItem = new OwnerSubscriptionItem
            {
                Owner = owner, TargetLocation = targetLocation
            };

            ictx.AddSubscriptionUpdateTarget(subscriptionItem);
            return;

            if (subscriptionCollection != null)
            {
                foreach (var subscription in subscriptionCollection.CollectionContent)
                {
                    OperationRequest operationRequest = new OperationRequest
                    {
                        SubscriberNotification = subscription
                    };
                    //QueueSupport.PutToOperationQueue(operationRequest);
                    ictx.AddOperationRequestToFinalizingQueue(operationRequest);
                }
            }
            if (parentSubscriptionCollection != null)
            {
                foreach (var subscription in parentSubscriptionCollection.CollectionContent)
                {
                    OperationRequest operationRequest = new OperationRequest
                    {
                        SubscriberNotification = subscription
                    };
                    //QueueSupport.PutToOperationQueue(operationRequest);
                    ictx.AddOperationRequestToFinalizingQueue(operationRequest);
                }
            }
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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.º 17
0
        private void GroupInvitationHandling()
        {
            string       emailRootID = TBREmailRoot.GetIDFromEmailAddress(EmailAddress);
            TBREmailRoot emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);

            if (emailRoot == null)
            {
                throw new NotSupportedException("Email used for group invitation is not yet registered to the system");
            }
            VirtualOwner owner   = VirtualOwner.FigureOwner(this);
            string       groupID = owner.LocationPrefix;

            InviteMemberToGroup.Execute(new InviteMemberToGroupParameters
            {
                GroupID = groupID, MemberEmailAddress = EmailAddress
            });
        }
Ejemplo n.º 18
0
        public static void RefreshDefaultViews(string viewLocation, Type informationObjectType)
        {
            if (viewLocation.EndsWith("/") == false)
            {
                viewLocation = viewLocation + "/";
            }
            VirtualOwner owner = VirtualOwner.FigureOwner(viewLocation);

            //string typeDirectoryName = informationObjectType.FullName;
            IInformationObject[] informationObjects = (IInformationObject[])
                                                      informationObjectType.InvokeMember("RetrieveCollectionFromOwnerContent", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, new object[] { owner });

            foreach (IInformationObject informationObject in informationObjects)
            {
                CreateDefaultViewRelativeToRequester(viewLocation, informationObject, owner);
            }
        }
Ejemplo n.º 19
0
        private void AddAccountEmailAddressHandling()
        {
            string       emailRootID = TBREmailRoot.GetIDFromEmailAddress(EmailAddress);
            TBREmailRoot emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);

            if (emailRoot != null)
            {
                throw new InvalidDataException("Email address '" + EmailAddress + "' is already registered to the system.");
            }
            string            accountID       = StorageSupport.GetAccountIDFromLocation(this.RelativeLocation);
            VirtualOwner      owner           = VirtualOwner.FigureOwner(this);
            TBEmailValidation emailValidation = new TBEmailValidation();

            emailValidation.AccountID  = accountID;
            emailValidation.Email      = this.EmailAddress;
            emailValidation.ValidUntil = DateTime.UtcNow.AddMinutes(30);
            StorageSupport.StoreInformation(emailValidation);
            EmailSupport.SendValidationEmail(emailValidation);
        }
Ejemplo n.º 20
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.º 21
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.º 22
0
        private static void InitBlogProfileAndIconOnce()
        {
            var blogs = GetAllInformationObjects(name => name.Contains("/Blog/"), io => io is Blog).Cast <Blog>().ToArray();

            try
            {
                foreach (var blog in blogs)
                {
                    blog.IconImage    = Image.CreateDefault();
                    blog.ProfileImage = Image.CreateDefault();
                    VirtualOwner owner = VirtualOwner.FigureOwner(blog);
                    blog.StoreInformationMasterFirst(owner, false);
                }
            }
            finally
            {
                InformationContext.ProcessAndClearCurrent();
                InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
            }
        }
Ejemplo n.º 23
0
        /*
         * private static string GetBlobPath(HttpRequest request)
         * {
         *  string contentPath = request.Path;
         *  if (contentPath.StartsWith(AboutPrefix) == false)
         *      throw new NotSupportedException("Content path for other than about/ is not supported");
         *  return contentPath.Substring(1);
         * }*/

        private void HandleDeveloperRequest(HttpContext context)
        {
            string requestPath = context.Request.Path;
            string groupID     = GetGroupID(context.Request.Path);
            string roleValue   = TBCollaboratorRole.CollaboratorRoleValue;

            InformationContext.Current.CurrentGroupRole = roleValue;
            string contentPath;

            if (requestPath.Contains("MediaContent") || requestPath.Contains("AaltoGlobalImpact.OIP"))
            {
                contentPath = requestPath.Substring(AuthDeveloperPrefixLen);
            }
            else
            {
                contentPath = requestPath.Substring(AuthDeveloperPrefixLen + GuidIDLen + 1);
            }
            VirtualOwner owner = new VirtualOwner(DeveloperAuthPrefix, DeveloperGroupID);

            HandleOwnerRequest(owner, context, contentPath, roleValue);
        }
Ejemplo n.º 24
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.º 25
0
        private static void DeleteAllAccountAndGroupContents(bool useWorker)
        {
            var           accountIDs         = TBRAccountRoot.GetAllAccountIDs();
            var           groupIDs           = TBRGroupRoot.GetAllGroupIDs();
            List <string> referenceLocations = new List <string>();

            foreach (var accountID in accountIDs)
            {
                string referenceLocation = "acc/" + accountID + "/";
                referenceLocations.Add(referenceLocation);
            }
            foreach (var groupID in groupIDs)
            {
                string referenceLocation = "grp/" + groupID + "/";
                referenceLocations.Add(referenceLocation);
            }
            if (useWorker)
            {
                referenceLocations.ForEach(refLoc =>
                {
                    VirtualOwner owner = VirtualOwner.FigureOwner(refLoc);
                    QueueSupport.PutToOperationQueue(
                        new OperationRequest
                    {
                        DeleteOwnerContent = new DeleteOwnerContentOperation
                        {
                            ContainerName  = owner.ContainerName,
                            LocationPrefix = owner.LocationPrefix
                        }
                    }
                        );
                });
            }
            else
            {
                referenceLocations.ForEach(refLoc => StorageSupport.DeleteContentsFromOwner(refLoc));
            }
        }
Ejemplo n.º 26
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.º 27
0
        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");
        }
Ejemplo n.º 28
0
        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);
            }
        }
Ejemplo n.º 29
0
 private static void DeleteOwnerContent(VirtualOwner containerOwner)
 {
     StorageSupport.DeleteContentsFromOwner(containerOwner);
 }
Ejemplo n.º 30
0
        public static void SetObjectContent(this IInformationObject rootObject, string containerID,
                                            string containedField, string[] objectIDList)
        {
            List <IInformationObject> containerList = new List <IInformationObject>();

            rootObject.FindObjectsFromTree(containerList, iObj => iObj.ID == containerID, false);
            foreach (var iObj in containerList)
            {
                var type = iObj.GetType();
                var prop = type.GetProperty(containedField);
                if (prop == null)
                {
                    throw new InvalidDataException(String.Format("No property {0} found in type {1}", containedField, type.Name));
                }
                IInformationObject containedObject = (IInformationObject)prop.GetValue(iObj, null);
                if (containedObject == null && objectIDList.Length == 0)
                {
                    continue;
                }
                if (objectIDList.Length == 0)
                {
                    prop.SetValue(iObj, null, null);
                }
                else
                {
                    VirtualOwner owner            = VirtualOwner.FigureOwner(rootObject.RelativeLocation);
                    Type         contentType      = prop.PropertyType;
                    string       contentDomain    = contentType.Namespace;
                    string       contentTypeName  = contentType.Name;
                    bool         isCollectionType = typeof(IInformationCollection).IsAssignableFrom(contentType);
                    if (isCollectionType)
                    {
                        if (containedObject == null)
                        {
                            containedObject = (IInformationObject)Activator.CreateInstance(contentType);
                            prop.SetValue(iObj, containedObject, null);
                        }
                        dynamic dynObj     = containedObject;
                        object  listObject = dynObj.CollectionContent;
                        // Note the below works for List<T>, that we know the type is of ;-)
                        Type collectionItemType = listObject.GetType().GetGenericArguments()[0];
                        // This is assuming collections are referring within same domain only
                        contentTypeName = collectionItemType.Name;
                        IList contentList = (IList)listObject;
                        IEnumerable <IInformationObject> contentEnum     = (IEnumerable <IInformationObject>)listObject;
                        List <IInformationObject>        objectsToRemove = new List <IInformationObject>();
                        foreach (IInformationObject existingObject in contentList)
                        {
                            if (objectIDList.Contains(existingObject.ID) == false)
                            {
                                objectsToRemove.Add(existingObject);
                            }
                        }
                        objectsToRemove.ForEach(obj => contentList.Remove(obj));
                        foreach (string contentObjectID in objectIDList)
                        {
                            if (contentEnum.Any(item => item.ID == contentObjectID))
                            {
                                continue;
                            }
                            IInformationObject contentObject =
                                StorageSupport.RetrieveInformationObjectFromDefaultLocation(contentDomain, contentTypeName, contentObjectID,
                                                                                            owner);
                            if (contentObject == null)
                            {
                                continue;
                            }
                            contentList.Add(contentObject);
                        }
                    }
                    else
                    {
                        if (objectIDList.Length > 1)
                        {
                            throw new InvalidDataException("Object link name " + containedField + " of type " + contentTypeName + " does not allow multiple values");
                        }
                        string             contentObjectID = objectIDList[0];
                        IInformationObject contentObject   =
                            StorageSupport.RetrieveInformationObjectFromDefaultLocation(contentDomain, contentTypeName, contentObjectID,
                                                                                        owner);
                        prop.SetValue(iObj, contentObject, null);
                    }
                    //RetrieveInformationObjectFromDefaultLocation()
                }
            }
        }