Beispiel #1
0
        private static InformationSource GetMissingRootAsNewSource(ContentItem root, string masterLocation, out bool foundExistingSource)
        {
            InformationSource  source            = root.Source ?? InformationSource.CreateDefault();
            IInformationObject informationObject = (IInformationObject)root.RootObject;

            if (informationObject == null)
            {
                foundExistingSource = false;
                return(null);
            }
            string sourceContentLocation = informationObject.GetLocationRelativeToContentRoot(masterLocation,
                                                                                              root.RootName);
            CloudBlob          blob;
            IInformationObject existingObject = StorageSupport.RetrieveInformationWithBlob(sourceContentLocation,
                                                                                           root.RootType, out blob);

            if (existingObject == null)
            {
                informationObject.SetLocationRelativeToContentRoot(masterLocation, root.RootName);
                blob = StorageSupport.StoreInformation(informationObject);
                foundExistingSource = false;
            }
            else
            {
                informationObject   = existingObject;
                root.RootObject     = existingObject;
                foundExistingSource = true;
            }
            source.SetBlobValuesToSource(blob);
            source.SetInformationObjectValuesToSource(root.RootName, informationObject.GetType().FullName);
            source.IsDynamic = root.IsDynamicRoot;
            return(source);
        }
Beispiel #2
0
        private void HandleAccountEmailValidation(HttpContext context, TBAccount account, TBEmailValidation emailValidation)
        {
            if (account.Emails.CollectionContent.Find(candidate => candidate.EmailAddress.ToLower() == emailValidation.Email.ToLower()) == null)
            {
                TBEmail email = TBEmail.CreateDefault();
                email.EmailAddress = emailValidation.Email;
                email.ValidatedAt  = DateTime.Now;
                account.Emails.CollectionContent.Add(email);
                account.StoreAccountToRoot();
                // TODO: Move Emailroot storage to account root syncs
                string       emailRootID = TBREmailRoot.GetIDFromEmailAddress(email.EmailAddress);
                TBREmailRoot emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);
                if (emailRoot == null)
                {
                    emailRoot    = TBREmailRoot.CreateDefault();
                    emailRoot.ID = emailRootID;
                    emailRoot.UpdateRelativeLocationFromID();
                }
                emailRoot.Account = account;
                StorageSupport.StoreInformation(emailRoot);

                string accountID = account.ID;
                UpdateAccountRootToReferences.Execute(new UpdateAccountRootToReferencesParameters
                {
                    AccountID = accountID
                });
                UpdateAccountContainerFromAccountRoot.Execute(new UpdateAccountContainerFromAccountRootParameters
                {
                    AccountID = accountID
                });
            }

            context.Response.Redirect("/auth/account/website/oip-account/oip-layout-account-welcome.phtml", true);
        }
Beispiel #3
0
        public static TBRAccountRoot CreateAndStoreNewAccount()
        {
            TBRAccountRoot accountRoot = TBRAccountRoot.CreateDefault();

            accountRoot.ID = accountRoot.Account.ID;
            accountRoot.UpdateRelativeLocationFromID();
            StorageSupport.StoreInformation(accountRoot);
            return(accountRoot);
        }
Beispiel #4
0
        private static void AddLegacyGroupWithInitiator(string groupID, string initiatorEmailAddress)
        {
            var groupRoot = TBRGroupRoot.CreateLegacyNewWithGroup(groupID);

            groupRoot.Group.JoinToGroup(initiatorEmailAddress, TBCollaboratorRole.InitiatorRoleValue);
            //groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
            StorageSupport.StoreInformation(groupRoot);
            OIPDomain.EnsureMasterCollections(groupRoot.Group);
            OIPDomain.RefreshMasterCollections(groupRoot.Group);
            groupRoot.Group.ReconnectMastersAndCollectionsForOwner();
        }
Beispiel #5
0
        private static void UpdateCollectionFromDirectory(string collectionType, string collectionLocation, string directoryLocation)
        {
            IInformationObject collectionObject = StorageSupport.RetrieveInformation(collectionLocation, collectionType);

            if (collectionObject is IInformationCollection)
            {
                IInformationCollection collection = (IInformationCollection)collectionObject;
                collection.RefreshContent();
                StorageSupport.StoreInformation(collectionObject);
            }
        }
Beispiel #6
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);
 }
Beispiel #7
0
        static TBSystem()
        {
            TBSystem system = (TBSystem)StorageSupport.RetrieveInformation(SingletonRelativeLocation, typeof(TBSystem));

            if (system == null)
            {
                system    = CreateDefault();
                system.ID = "AAA";
                system.RelativeLocation = SingletonRelativeLocation;
                StorageSupport.StoreInformation(system);
            }
            currSystem = system;
        }
Beispiel #8
0
        private static void UpdateCollectionFromMasterCollection(string referenceCollectionType, string referenceCollectionLocation, string masterCollectionType, string masterCollectionLocation)
        {
            IInformationObject referenceCollectionObject = StorageSupport.RetrieveInformation(referenceCollectionLocation,
                                                                                              referenceCollectionType);
            IInformationCollection referenceCollection = (IInformationCollection)referenceCollectionObject;

            // TODO: Revisit why this can be null
            if (referenceCollection == null)
            {
                return;
            }
            referenceCollection.RefreshContent();
            StorageSupport.StoreInformation(referenceCollectionObject);
        }
Beispiel #9
0
        private static void UpdateContainerFromMasterCollection(string containerType, string containerLocation, string masterCollectionType, string masterCollectionLocation)
        {
            IInformationObject containerObject        = StorageSupport.RetrieveInformation(containerLocation, containerType);
            IInformationObject masterCollectionObject = StorageSupport.RetrieveInformation(masterCollectionLocation,
                                                                                           masterCollectionType);
            IInformationCollection masterCollection = (IInformationCollection)masterCollectionObject;

            // TODO: Revisit why this can be null
            if (containerObject == null || masterCollection == null)
            {
                return;
            }
            containerObject.UpdateCollections(masterCollection);
            StorageSupport.StoreInformation(containerObject);
        }
Beispiel #10
0
        private static TBCollaboratingGroup InitializeDefaultOIPWebGroup()
        {
            TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(FixedGroupID);

            if (groupRoot == null)
            {
                groupRoot    = TBRGroupRoot.CreateDefault();
                groupRoot.ID = FixedGroupID;
                groupRoot.UpdateRelativeLocationFromID();
                groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
                groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
                StorageSupport.StoreInformation(groupRoot);
            }
            return(groupRoot.Group);
        }
Beispiel #11
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);
        }
Beispiel #12
0
        public static TBRLoginRoot GetOrCreateLoginRootWithAccount(string loginUrl, bool isAccountRequest)
        {
            string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginUrl);
            var    loginRoot   = RetrieveFromDefaultLocation(loginRootID);

            if (loginRoot == null)
            {
                // Storing loginroot
                loginRoot    = TBRLoginRoot.CreateDefault();
                loginRoot.ID = loginRootID;
                loginRoot.UpdateRelativeLocationFromID();
                StorageSupport.StoreInformation(loginRoot);

                // Creating login info for account and storing the account
                TBLoginInfo loginInfo = TBLoginInfo.CreateDefault();
                loginInfo.OpenIDUrl = loginUrl;

                TBRAccountRoot accountRoot = TBRAccountRoot.CreateAndStoreNewAccount();
                accountRoot.Account.Logins.CollectionContent.Add(loginInfo);
                string accountID = accountRoot.ID;
                accountRoot.StoreInformation();

                UpdateAccountRootToReferences.Execute(new UpdateAccountRootToReferencesParameters
                {
                    AccountID = accountID
                });
                UpdateAccountContainerFromAccountRoot.Execute(new UpdateAccountContainerFromAccountRootParameters
                {
                    AccountID = accountID
                });

                // If this request is for account, we propagate the pages immediately
                bool useBackgroundWorker = isAccountRequest == false;
                RenderWebSupport.RefreshAccountTemplates(accountRoot.ID, useBackgroundWorker);
                if (isAccountRequest)
                {
                    accountRoot.Account.InitializeAndConnectMastersAndCollections();
                }
            }
            loginRoot = RetrieveFromDefaultLocation(loginRootID);
            return(loginRoot);
        }
Beispiel #13
0
        private static void DoMapData(IContainerOwner owner)
        {
            MapContainer mapContainer =
                MapContainer.RetrieveMapContainer(
                    "livesite/oip-layouts/oip-layout-default-view.phtml/AaltoGlobalImpact.OIP/MapContainer/38b16ead-5851-484f-a367-bb215eb8e490",
                    owner);
            MapMarker marker1 = MapMarker.CreateDefault();

            marker1.LocationText = "8446198.6713314,2759433.3836466";
            MapMarker marker2 = MapMarker.CreateDefault();

            marker2.LocationText = "10000,10000";
            MapMarker marker3 = MapMarker.CreateDefault();

            marker3.LocationText = "0,0";
            //mapContainer.MapMarkers = MapMarkerCollection.CreateDefault();
            mapContainer.MapMarkers.CollectionContent.Add(marker1);
            mapContainer.MapMarkers.CollectionContent.Add(marker2);
            mapContainer.MapMarkers.CollectionContent.Add(marker3);
            StorageSupport.StoreInformation(mapContainer, owner);
        }
Beispiel #14
0
        public static void AddSubscriptionToObject(string targetLocation, string subscriberLocation, string subscriptionType, string targetTypeName = null, string subscriberTypeName = null)
        {
            if (targetLocation == subscriberLocation)
            {
                throw new InvalidDataException("Self-circular subscription targeting self attempted: " + targetLocation);
            }
            var sub = GetSubscriptionToObject(targetLocation, subscriberLocation, subscriptionType, targetTypeName: targetTypeName, subscriberTypeName: subscriberTypeName);
            SubscriptionCollection subscriptionCollection = GetSubscriptions(targetLocation);

            if (subscriptionCollection == null)
            {
                subscriptionCollection = new SubscriptionCollection();
                subscriptionCollection.SetRelativeLocationAsMetadataTo(targetLocation);
            }
            var alreadyExists =
                subscriptionCollection.CollectionContent.FirstOrDefault(
                    existing => existing.SubscriberRelativeLocation == sub.SubscriberRelativeLocation &&
                    existing.SubscriptionType == sub.SubscriptionType);

            if (alreadyExists != null)
            {
                // If the values match, don't save when there are no changes
                if (alreadyExists.SubscriberInformationObjectType == sub.SubscriberInformationObjectType &&
                    alreadyExists.TargetInformationObjectType == sub.TargetInformationObjectType)
                {
                    return;
                }
                // ... otherwise update the values
                alreadyExists.SubscriberInformationObjectType = sub.SubscriberInformationObjectType;
                alreadyExists.TargetInformationObjectType     = sub.TargetInformationObjectType;
            }
            else
            {
                subscriptionCollection.CollectionContent.Add(sub);
            }
            StorageSupport.StoreInformation(subscriptionCollection);
        }
Beispiel #15
0
        public void StoreAccountToRoot()
        {
            TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(this.ID);

            accountRoot.Account = this;
            StorageSupport.StoreInformation(accountRoot);
            return;

            AccountContainer accountContainer = AccountContainer.RetrieveFromOwnerContent(this, "default");

            if (accountContainer == null)
            {
                accountContainer = AccountContainer.CreateDefault();
                accountContainer.SetLocationAsOwnerContent(this, "default");
            }
            accountContainer.AccountModule.Security.LoginInfoCollection = this.Logins;
            foreach (var loginItem in this.Logins.CollectionContent)
            {
                string       loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginItem.OpenIDUrl);
                TBRLoginRoot loginRoot   = TBRLoginRoot.RetrieveFromDefaultLocation(loginRootID);
                loginRoot.Account = this;
                StorageSupport.StoreInformation(loginRoot);
                // TODO: Remove invalid group role logins at this stage
                foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent.Where(grpRole => TBCollaboratorRole.IsRoleStatusValidMember(grpRole.RoleStatus)))
                {
                    string            loginGroupID   = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID);
                    TBRLoginGroupRoot loginGroupRoot = TBRLoginGroupRoot.RetrieveFromDefaultLocation(loginGroupID);
                    if (loginGroupRoot == null)
                    {
                        loginGroupRoot    = TBRLoginGroupRoot.CreateDefault();
                        loginGroupRoot.ID = loginGroupID;
                        loginGroupRoot.UpdateRelativeLocationFromID();
                    }
                    loginGroupRoot.GroupID = groupRoleItem.GroupID;
                    loginGroupRoot.Role    = groupRoleItem.GroupRole;
                    StorageSupport.StoreInformation(loginGroupRoot);
                }
            }
            //accountContainer.AccountModule.Security.EmailCollection = this.Emails;
            foreach (var emailItem in this.Emails.CollectionContent)
            {
                string       emailRootID = TBREmailRoot.GetIDFromEmailAddress(emailItem.EmailAddress);
                TBREmailRoot emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);
                if (emailRoot == null)
                {
                    emailRoot    = TBREmailRoot.CreateDefault();
                    emailRoot.ID = emailRootID;
                    emailRoot.UpdateRelativeLocationFromID();
                }
                emailRoot.Account = this;
                StorageSupport.StoreInformation(emailRoot);
            }
            var roles = accountContainer.AccountModule.Roles;

            roles.MemberInGroups.CollectionContent.Clear();
            roles.ModeratorInGroups.CollectionContent.Clear();
            foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent)
            {
                var groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupRoleItem.GroupID);
                if (groupRoot == null)
                {
                    continue;
                }
                var grp = groupRoot.Group;
                ReferenceToInformation reference = ReferenceToInformation.CreateDefault();
                reference.URL = string.Format("/auth/grp/{0}/website/oip-group/oip-layout-groups-edit.phtml",
                                              groupRoot.ID);
                reference.Title = grp.Title + " - " + groupRoleItem.GroupRole;
                switch (groupRoleItem.GroupRole.ToLower())
                {
                case "initiator":
                case "moderator":
                    roles.ModeratorInGroups.CollectionContent.Add(reference);
                    break;

                case "collaborator":
                case "viewer":
                    roles.MemberInGroups.CollectionContent.Add(reference);
                    break;
                }
            }
            StorageSupport.StoreInformation(accountContainer);
        }