public static InformationSource GetAsDefaultSource(IInformationObject informationObject) { CloudBlob blob = StorageSupport.GetInformationObjectBlobWithProperties(informationObject); InformationSource informationSource = FromBlob(blob); return(informationSource); }
public void SetDefaultSource(InformationSource defaultSource) { InformationSource currentDefaultSource = GetDefaultSource(defaultSource.SourceInformationObjectType); if (currentDefaultSource != null) CollectionContent.Remove(currentDefaultSource); CollectionContent.Add(defaultSource); currentDefaultSource = GetDefaultSource(defaultSource.SourceInformationObjectType); if(defaultSource != currentDefaultSource) throw new InvalidDataException("Invalid default source given to add (not maching the GetDefaultSource conditions)"); }
public static InformationSource FromBlob(CloudBlob blob) { InformationSource source = CreateDefault(); source.SourceLocation = blob.Name; source.SourceETag = blob.Properties.ETag; source.SourceName = ""; source.SourceType = blob.GetBlobInformationType(); source.SourceInformationObjectType = blob.GetBlobInformationObjectType(); source.SourceETag = blob.Properties.ETag; source.SourceMD5 = blob.Properties.ContentMD5; source.SourceLastModified = blob.Properties.LastModifiedUtc; return(source); }
public void SetDefaultSource(InformationSource defaultSource) { InformationSource currentDefaultSource = GetDefaultSource(defaultSource.SourceInformationObjectType); if (currentDefaultSource != null) { CollectionContent.Remove(currentDefaultSource); } CollectionContent.Add(defaultSource); currentDefaultSource = GetDefaultSource(defaultSource.SourceInformationObjectType); if (defaultSource != currentDefaultSource) { throw new InvalidDataException("Invalid default source given to add (not maching the GetDefaultSource conditions)"); } }
private static bool CallAssignCollaboratorRole(string targetObjectID, IContainerOwner owner, InformationSource groupContainerSource, NameValueCollection formSubmitContent) { if(groupContainerSource == null) throw new ArgumentNullException("groupContainerSource"); GroupContainer groupContainer = (GroupContainer) groupContainerSource.RetrieveInformationObject(); string roleToAssign = formSubmitContent["AssignRoleToCollaborator"]; string groupID = owner.LocationPrefix; string collaboratorID = targetObjectID; AssignCollaboratorRole.Execute(new AssignCollaboratorRoleParameters { CollaboratorID = collaboratorID, GroupContainer = groupContainer, GroupID = groupID, RoleToAssign = roleToAssign }); return true; }
private static ContentItem GetRootFromSource(InformationSource source) { ContentItem contentItem = new ContentItem { Source = source, RootName = source.SourceName, RootType = source.SourceInformationObjectType, IsDynamicRoot = source.IsDynamic }; return contentItem; }
public static void RenderTemplateWithContentToBlob(CloudBlob template, CloudBlob renderTarget, InformationSource setAsDefaultSource = null) { InformationSourceCollection sources = renderTarget.GetBlobInformationSources(); if(sources == null) { sources = CreateDefaultSources(template); } if (setAsDefaultSource != null) { sources.SetDefaultSource(setAsDefaultSource); } string templateContent = template.DownloadText(); List<ContentItem> existingRoots = GetExistingRoots(sources); string renderResult = RenderTemplateWithContentRoots(templateContent, existingRoots); bool rerenderRequired = UpdateMismatchedRootsToSources(sources, existingRoots, renderTarget); renderTarget.SetBlobInformationSources(sources); renderTarget.UploadBlobText(renderResult, StorageSupport.InformationType_RenderedWebPage); if(rerenderRequired) { RenderTemplateWithContentToBlob(template, renderTarget); } else { sources.SubscribeTargetToSourceChanges(renderTarget); } }
private static bool CallUnlinkEmailAddress(string targetObjectID, IContainerOwner owner, InformationSource accountContainerSource) { if(accountContainerSource == null) throw new ArgumentNullException("accountContainerSource"); AccountContainer accountContainer = (AccountContainer) accountContainerSource.RetrieveInformationObject(); string accountID = owner.LocationPrefix; string emailID = targetObjectID; UnlinkEmailAddress.Execute(new UnlinkEmailAddressParameters { AccountContainerBeforeGroupRemoval = accountContainer, AccountID = accountID, EmailAddressID = emailID }); return true; }
/// <summary> /// Creates default views and returns the one relative to the requester /// </summary> /// <param name="requesterLocation">Requester relative location</param> /// <param name="informationObject">Information object to create the view for</param> /// <param name="owner">Container owner</param> /// <returns></returns> public static CloudBlob CreateDefaultViewRelativeToRequester(string requesterLocation, IInformationObject informationObject, IContainerOwner owner) { bool isAccountOwner = owner.IsAccountContainer(); bool isGroupOwner = owner.IsGroupContainer(); bool isDeveloperView = owner.ContainerName == "dev"; string[] viewLocations; if (isAccountOwner) { viewLocations = FixedAccountSiteLocations; } else if (isGroupOwner) { viewLocations = FixedGroupSiteLocations; } else { throw new NotSupportedException("Invalid owner container type for default view (non acct, non group): " + owner.ContainerName); } string requesterDirectory = StorageSupport.GetLocationParentDirectory(requesterLocation); FileInfo fileInfo = new FileInfo(requesterLocation); //string viewRoot = fileInfo.Directory.Parent != null // ? fileInfo.Directory.Parent.Name // : fileInfo.Directory.Name; CloudBlob relativeViewBlob = null; bool hasException = false; bool allException = true; foreach (string viewLocation in viewLocations) { try { string viewRoot = isDeveloperView ? "developer-00000000000000000000000000" : GetViewRoot(viewLocation); string viewItemDirectory = Path.Combine(viewRoot, viewLocation).Replace("\\", "/") + "/"; string viewName = GetDefaultStaticViewName(informationObject); string viewTemplateName = GetDefaultStaticTemplateName(informationObject); // TODO: Relative from xyzsite => xyztemplate; now we only have website - also acct/grp specific //string viewTemplateLocation = "webtemplate/oip-viewtemplate/" + viewTemplateName; string viewTemplateLocation = viewItemDirectory + viewTemplateName; CloudBlob viewTemplate = StorageSupport.CurrActiveContainer.GetBlob(viewTemplateLocation, owner); string renderedViewLocation = viewItemDirectory + viewName; CloudBlob renderTarget = StorageSupport.CurrActiveContainer.GetBlob(renderedViewLocation, owner); InformationSource defaultSource = InformationSource.GetAsDefaultSource(informationObject); RenderWebSupport.RenderTemplateWithContentToBlob(viewTemplate, renderTarget, defaultSource); if (viewItemDirectory == requesterDirectory) { relativeViewBlob = renderTarget; } allException = false; } catch (Exception ex) { hasException = true; } } if (relativeViewBlob == null && hasException == false && false) { throw new InvalidDataException( String.Format("Default view with relative location {0} not found for owner type {1}", requesterLocation, owner.ContainerName)); } return(relativeViewBlob); }
private static bool CallRemoveImageFromImageGroup(string targetObjectId, IContainerOwner owner, InformationSource imageGroupSource) { ImageGroup imageGroup = (ImageGroup) imageGroupSource.RetrieveInformationObject(); var imageToDelete = imageGroup.ImagesCollection.CollectionContent.FirstOrDefault(img => img.ID == targetObjectId); imageGroup.ImagesCollection.CollectionContent.Remove(imageToDelete); imageToDelete.DeleteInformationObject(); imageGroup.StoreInformation(); return true; }