private static bool CallDeleteAddressAndLocation(string addressAndLocationID, IContainerOwner owner) { AddressAndLocation addressAndLocation = AddressAndLocation.RetrieveFromOwnerContent(owner, addressAndLocationID); addressAndLocation.DeleteInformationObject(); return false; }
public static void ReconnectMastersAndCollectionsForOwner(this IContainerOwner owner) { //string myLocalAccountID = "0c560c69-c3a7-4363-b125-ba1660d21cf4"; //string acctLoc = "acc/" + myLocalAccountID + "/"; string ownerLocation = owner.ContainerName + "/" + owner.LocationPrefix + "/"; var informationObjects = StorageSupport.CurrActiveContainer.GetInformationObjects(ownerLocation, null, 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; } } } }
private static bool CallDeleteActivity(string targetObjectID, IContainerOwner owner) { Activity activity = Activity.RetrieveFromOwnerContent(owner, targetObjectID); //Activity.RetrieveFromOwnerContent(owner, ) DeleteInformationObject.Execute(new DeleteInformationObjectParameters { ObjectToDelete = activity }); return false; }
public static void ExecuteMethod_InitializeGroupWithDefaultObjects(IContainerOwner groupAsOwner) { // Initialize nodesummarycontainer NodeSummaryContainer nodeSummaryContainer = NodeSummaryContainer.CreateDefault(); nodeSummaryContainer.SetLocationAsOwnerContent(groupAsOwner, "default"); nodeSummaryContainer.StoreInformationMasterFirst(groupAsOwner, 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); } }
private void HandleFileSystemGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { var response = context.Response; string contentType = StorageSupport.GetMimeType(Path.GetExtension(contentPath)); response.ContentType = contentType; string prefixStrippedContent = contentPath; //.Substring(AuthGroupPrefixLen + GuidIDLen + 1); string LocalWebRootFolder = @"C:\Users\Michael\WebstormProjects\OIPTemplates\UI\groupmanagement\"; string LocalWwwSiteFolder = @"C:\Users\Michael\WebstormProjects\TitanWeb\UI\TitanWeb\"; string fileName; if (prefixStrippedContent.Contains("oipcms/")) { fileName = prefixStrippedContent.Replace("oipcms/", LocalWebRootFolder); } else { fileName = prefixStrippedContent.Replace("wwwsite/", LocalWwwSiteFolder); } if (File.Exists(fileName)) { var fileStream = File.OpenRead(fileName); fileStream.CopyTo(context.Response.OutputStream); fileStream.Close(); } else { response.StatusCode = 404; } response.End(); }
public static void ExecuteMethod_PerformIndexing(IContainerOwner owner, IndexingRequest indexingRequest, string luceneIndexFolder) { string indexName = indexingRequest.IndexName; List<Document> documents = new List<Document>(); List<string> removeDocumentIDs = new List<string>(); foreach (var objLocation in indexingRequest.ObjectLocations) { IInformationObject iObj = StorageSupport.RetrieveInformation(objLocation, null, owner); if (iObj == null) { var lastSlashIX = objLocation.LastIndexOf('/'); var objectID = objLocation.Substring(lastSlashIX + 1); removeDocumentIDs.Add(objectID); continue; } IIndexedDocument iDoc = iObj as IIndexedDocument; if (iDoc != null) { var luceneDoc = iDoc.GetLuceneDocument(indexName); if (luceneDoc == null) continue; luceneDoc.RemoveFields("ObjectDomainName"); luceneDoc.RemoveFields("ObjectName"); luceneDoc.RemoveFields("ObjectID"); luceneDoc.RemoveFields("ID"); luceneDoc.Add(new Field("ObjectDomainName", iObj.SemanticDomainName, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); luceneDoc.Add(new Field("ObjectName", iObj.Name, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); luceneDoc.Add(new Field("ObjectID", iObj.ID, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); luceneDoc.Add(new Field("ID", iObj.ID, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); documents.Add(luceneDoc); } } FieldIndexSupport.AddAndRemoveDocuments(luceneIndexFolder, documents.ToArray(), removeDocumentIDs.ToArray()); }
public static void PutQueryRequestToQueue(string storageContainerName, string indexName, IContainerOwner owner, string requestID) { var queueName = GetQueryRequestQueueName(indexName); string ownerstring = owner.ToParseableString(); string messageText = storageContainerName + ":" + ownerstring + ":" + requestID; QueueSupport.PutMessageToQueue(queueName, messageText); }
public static IInformationObject GetTarget_ObjectToDelete(IContainerOwner owner, string objectDomainName, string objectName, string objectId) { IInformationObject objectToDelete = StorageSupport.RetrieveInformationObjectFromDefaultLocation(objectDomainName, objectName, objectId, owner); return objectToDelete; }
public static void EnsureMasterCollections(IContainerOwner owner) { { var masterCollection = ProductUsageCollection.GetMasterCollectionInstance(owner); if(masterCollection == null) { masterCollection = ProductUsageCollection.CreateDefault(); masterCollection.RelativeLocation = ProductUsageCollection.GetMasterCollectionLocation(owner); StorageSupport.StoreInformation(masterCollection, owner); } IInformationCollection collection = masterCollection; collection.SubscribeToContentSource(); } { var masterCollection = ProductCollection.GetMasterCollectionInstance(owner); if(masterCollection == null) { masterCollection = ProductCollection.CreateDefault(); masterCollection.RelativeLocation = ProductCollection.GetMasterCollectionLocation(owner); StorageSupport.StoreInformation(masterCollection, owner); } IInformationCollection collection = masterCollection; collection.SubscribeToContentSource(); } }
public void ClearCurrentContent(IContainerOwner containerOwner) { CloudBlob blob = StorageSupport.CurrActiveContainer.GetBlob(RelativeLocation, containerOwner); blob.DeleteWithoutFiringSubscriptions(); RemoveAdditionalMediaFormats(); }
public static void SetMediaContent(this IInformationObject rootObject, IContainerOwner containerOwner, string containerID, string containedField, object mediaContent) { 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)); } MediaContent propValue = (MediaContent)prop.GetValue(iObj, null); if (propValue == null && mediaContent == null) { continue; } if (propValue != null && mediaContent == null) { propValue.ClearCurrentContent(containerOwner); prop.SetValue(iObj, null, null); continue; } if (propValue == null && mediaContent != null) { propValue = MediaContent.CreateDefault(); prop.SetValue(iObj, propValue, null); } propValue.SetMediaContent(containerOwner, propValue.ID, mediaContent); } }
public static IInformationObject GetTarget_ObjectToDelete(IContainerOwner owner, string objectDomainName, string objectName, string objectId) { IInformationObject objectToDelete = StorageSupport.RetrieveInformationObjectFromDefaultLocation(objectDomainName, objectName, objectId, owner); return(objectToDelete); }
public static object ExecuteOwnerWebPOST(IContainerOwner containerOwner, NameValueCollection form, HttpFileCollection fileContent) { bool reloadPageAfter = form["NORELOAD"] == null; bool isCancelButton = form["btnCancel"] != null; if (isCancelButton) return reloadPageAfter; string operationName = form["ExecuteOperation"]; if (operationName != null) { var operationResult = executeOperationWithFormValues(containerOwner, operationName, form, fileContent); if(operationResult != null) return operationResult; return reloadPageAfter; } string adminOperationName = form["ExecuteAdminOperation"]; if (adminOperationName != null) { var adminResult = executeAdminOperationWithFormValues(containerOwner, adminOperationName, form, fileContent); if(adminResult != null) return adminResult; return reloadPageAfter; } string contentSourceInfo = form["ContentSourceInfo"]; var rootSourceAction = form["RootSourceAction"]; if (rootSourceAction != null && rootSourceAction != "Save") return reloadPageAfter; var filterFields = new string[] { "ContentSourceInfo", "RootSourceAction", "NORELOAD" }; string[] contentSourceInfos = contentSourceInfo.Split(','); var filteredForm = filterForm(form, filterFields); 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) SetObjectTreeValues.Execute(new SetObjectTreeValuesParameters { RootObject = rootObject, HttpFormData = filteredForm, HttpFileData = fileContent }); } return reloadPageAfter; }
public static IInformationObject GetTarget_CreatedObject(IContainerOwner owner, string objectDomainName, string objectName) { string objectTypeName = objectDomainName + "." + objectName; Type objectType = Type.GetType(objectTypeName); IInformationObject iObj = (IInformationObject) Activator.CreateInstance(objectType); var relativeLocation = StorageSupport.GetOwnerContentLocation(owner, objectDomainName + "/" + objectName + "/" + iObj.ID); iObj.RelativeLocation = relativeLocation; return iObj; }
public static void ExecuteMethod_SetBinaryContent(IContainerOwner owner, IInformationObject createdObject, Dictionary <string, HttpPostedFile> binaryContentFiles) { foreach (var fileKey in binaryContentFiles.Keys) { string contentInfo = fileKey.Substring(5); // Substring("File_".Length); ModifyInformationSupport.SetBinaryContent(owner, contentInfo, createdObject, binaryContentFiles[fileKey]); } }
public static DeviceMembership GetTarget_CreatedDeviceMembership(IContainerOwner owner, string deviceDescription, byte[] activeSymmetricAesKey) { DeviceMembership deviceMembership = new DeviceMembership(); deviceMembership.SetLocationAsOwnerContent(owner, deviceMembership.ID); deviceMembership.DeviceDescription = deviceDescription; deviceMembership.ActiveSymmetricAESKey = activeSymmetricAesKey; return(deviceMembership); }
public static InformationInput GetTarget_CreatedInformationInput(IContainerOwner owner, string inputDescription, string locationUrl) { InformationInput informationInput = new InformationInput(); informationInput.SetLocationAsOwnerContent(owner, informationInput.ID); informationInput.Description = inputDescription; informationInput.LocationURL = locationUrl; return(informationInput); }
public static IInformationObject GetTarget_CreatedObject(IContainerOwner owner, string objectDomainName, string objectName) { string objectTypeName = objectDomainName + "." + objectName; Type objectType = Type.GetType(objectTypeName); IInformationObject iObj = (IInformationObject)Activator.CreateInstance(objectType); var relativeLocation = StorageSupport.GetBlobOwnerAddress(owner, objectDomainName + "/" + objectName + "/" + iObj.ID); iObj.RelativeLocation = relativeLocation; return(iObj); }
public static void RefreshMasterCollections(IContainerOwner owner) { { IInformationCollection masterCollection = HelloWorldCollection.GetMasterCollectionInstance(owner); if (masterCollection == null) throw new InvalidDataException("Master collection HelloWorldCollection missing for owner"); masterCollection.RefreshContent(); StorageSupport.StoreInformation((IInformationObject) masterCollection, owner); } }
private static void FixGroupMastersAndCollections(string groupID) { TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupID); IContainerOwner owner = groupRoot.Group; owner.InitializeAndConnectMastersAndCollections(); //OIPDomain.EnsureMasterCollections(groupRoot.Group); //OIPDomain.RefreshMasterCollections(groupRoot.Group); //groupRoot.Group.ReconnectMastersAndCollectionsForOwner(); }
public static AuthenticatedAsActiveDevice GetTarget_AuthenticatedAsActiveDevice(IContainerOwner owner, string authenticationDeviceDescription, string negotiationUrl, string connectionUrl) { AuthenticatedAsActiveDevice activeDevice = new AuthenticatedAsActiveDevice(); activeDevice.SetLocationAsOwnerContent(owner, activeDevice.ID); activeDevice.AuthenticationDescription = authenticationDeviceDescription; //activeDevice.SharedSecret = sharedSecret; activeDevice.NegotiationURL = negotiationUrl; activeDevice.ConnectionURL = connectionUrl; return activeDevice; }
public static InformationInput GetTarget_CreatedInformationInput(IContainerOwner owner, string inputDescription, string locationUrl, string localContentName, string authenticatedDeviceId) { InformationInput informationInput = new InformationInput(); informationInput.SetLocationAsOwnerContent(owner, informationInput.ID); informationInput.InputDescription = inputDescription; informationInput.LocationURL = locationUrl; informationInput.LocalContentName = localContentName; informationInput.AuthenticatedDeviceID = authenticatedDeviceId; return informationInput; }
public static void ExecuteMethod_RemoveExpiredEntries(IContainerOwner owner, string[] ensureUpdateOnStatusSummaryOutput) { foreach (string changeItemID in ensureUpdateOnStatusSummaryOutput) { string relativeLocationFromOwner = InformationChangeItem.GetRelativeLocationFromID(changeItemID); var blob = StorageSupport.GetOwnerBlobReference(owner, relativeLocationFromOwner); blob.DeleteWithoutFiringSubscriptions(); var jsonBlob = StorageSupport.GetOwnerBlobReference(owner, relativeLocationFromOwner + ".json"); jsonBlob.DeleteWithoutFiringSubscriptions(); } }
public static void InitializeAndConnectMastersAndCollections(this IContainerOwner owner) { Type myType = typeof(OwnerInitializer); var myMethods = myType.GetMethods(BindingFlags.Static | BindingFlags.NonPublic); foreach (var myMethod in myMethods.Where(method => method.Name.StartsWith("DOMAININIT_"))) { myMethod.Invoke(null, new object[] { owner }); } owner.ReconnectMastersAndCollectionsForOwner(); }
public static WebPublishInfo GetTarget_PublishInfo(IContainerOwner owner) { WebPublishInfo publishInfo = WebPublishInfo.RetrieveFromOwnerContent(owner, "default"); if (publishInfo == null) { publishInfo = WebPublishInfo.CreateDefault(); publishInfo.SetLocationAsOwnerContent(owner, "default"); publishInfo.StoreInformation(); } return publishInfo; }
public static string[] GetChainRequestList(IContainerOwner owner) { string directory = owner != null ? ChainRequestDirectory + owner.ContainerName + "/" + owner.LocationPrefix + "/" : ChainRequestDirectory; var blobListing = StorageSupport.CurrActiveContainer.GetBlobListing(directory, false); return(blobListing.Cast <CloudBlob>().Select(blob => blob.Name).Where(str => IsLock(str) == false).ToArray()); }
public static void ExecuteMethod_FetchInputToStorage(IContainerOwner owner, string queryParameters, InformationInput informationInput, string inputFetchLocation, string inputFetchName) { string url = string.IsNullOrEmpty(queryParameters) ? informationInput.LocationURL : informationInput.LocationURL + queryParameters; WebRequest getRequest = WebRequest.Create(url); var response = getRequest.GetResponse(); var stream = response.GetResponseStream(); var targetBlob = StorageSupport.CurrActiveContainer.GetBlob(inputFetchLocation + "/" + inputFetchName, owner); targetBlob.UploadFromStream(stream); }
public static PackageOwnerContentParameters PackageOwnerContentToZip_GetParameters(IContainerOwner owner, string packageRootFolder, string[] includedFolders) { return new PackageOwnerContentParameters { Owner = owner, PackageName = "Full export", Description = "Full export done by ExportOwnerContentToZip", PackageType = "FULLEXPORT", IncludedFolders = includedFolders, PackageRootFolder = packageRootFolder }; }
public static WebPublishInfo GetTarget_PublishInfo(IContainerOwner owner) { WebPublishInfo publishInfo = WebPublishInfo.RetrieveFromOwnerContent(owner, "default"); if (publishInfo == null) { publishInfo = WebPublishInfo.CreateDefault(); publishInfo.SetLocationAsOwnerContent(owner, "default"); publishInfo.StoreInformation(); } return(publishInfo); }
public static void ExecuteMethod_EnsureUpdateOnStatusSummary(IContainerOwner owner, DateTime updateTime, string[] changedIdList, int removeExpiredEntriesSeconds) { int retryCount = 10; while (retryCount-- >= 0) { try { var statusSummary = StatusSummary.RetrieveFromOwnerContent(owner, "default"); if (statusSummary == null) { statusSummary = new StatusSummary(); statusSummary.SetLocationAsOwnerContent(owner, "default"); } string latestTimestampEntry = statusSummary.ChangeItemTrackingList.FirstOrDefault(); long currentTimestampTicks = updateTime.ToUniversalTime().Ticks; if (latestTimestampEntry != null) { long latestTimestampTicks = Convert.ToInt64(latestTimestampEntry.Substring(2)); if (currentTimestampTicks <= latestTimestampTicks) currentTimestampTicks = latestTimestampTicks + 1; } string currentTimestampEntry = "T:" + currentTimestampTicks; var timestampedList = statusSummary.ChangeItemTrackingList; // Remove possible older entries of new IDs timestampedList.RemoveAll(changedIdList.Contains); // Add Timestamp and new IDs timestampedList.Insert(0, currentTimestampEntry); timestampedList.InsertRange(1, changedIdList); var removeOlderThanTicks = currentTimestampTicks - TimeSpan.FromSeconds(removeExpiredEntriesSeconds).Ticks; int firstBlockToRemoveIX = timestampedList.FindIndex(candidate => { if (candidate.StartsWith("T:")) { long candidateTicks = Convert.ToInt64(candidate.Substring(2)); return candidateTicks < removeOlderThanTicks; } return false; }); if (firstBlockToRemoveIX > -1) { timestampedList.RemoveRange(firstBlockToRemoveIX, timestampedList.Count - firstBlockToRemoveIX); } statusSummary.StoreInformation(); return; // Break from while loop } catch (Exception ex) { } } }
/// <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 void HandleOwnerRequest(IContainerOwner containerOwner, HttpContext context, string contentPath, string role) { if (context.Request.RequestType == "POST") { // Do first post, and then get to the same URL if (TBCollaboratorRole.HasCollaboratorRights(role) == false) { throw new SecurityException("Role '" + role + "' is not authorized to do changing POST requests to web interface"); } HandleOwnerPostRequest(containerOwner, context, contentPath); } HandleOwnerGetRequest(containerOwner, context, contentPath); }
public static QueueEnvelope GetTarget_RequestEnvelope(string processId, IContainerOwner owner, string activeContainerName) { var envelope = new QueueEnvelope { OwnerPrefix = owner.ToFolderName(), ActiveContainerName = activeContainerName, SingleOperation = new OperationRequest { ProcessIDToExecute = processId } }; return envelope; }
public void SetMediaContent(IContainerOwner containerOwner, string contentObjectID, object mediaContent) { if(ID != contentObjectID) return; ClearCurrentContent(containerOwner); HttpPostedFile postedContent = (HttpPostedFile) mediaContent; FileExt = Path.GetExtension(postedContent.FileName); ContentLength = postedContent.ContentLength; string locationFileName = ID + FileExt; SetLocationAsOwnerContent(containerOwner, locationFileName); postedContent.InputStream.Seek(0, SeekOrigin.Begin); StorageSupport.CurrActiveContainer.UploadBlobStream(RelativeLocation, postedContent.InputStream, StorageSupport.InformationType_GenericContentValue); UpdateAdditionalMediaFormats(); }
public static void SetBinaryContent(IContainerOwner containerOwner, string contentInfo, IInformationObject rootObject, HttpPostedFile postedFile) { int firstIX = contentInfo.IndexOf('_'); if (firstIX < 0) { throw new InvalidDataException("Invalid field data on binary content"); } string containerID = contentInfo.Substring(0, firstIX); string containerField = contentInfo.Substring(firstIX + 1); rootObject.SetMediaContent(containerOwner, containerID, containerField, postedFile); }
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); } }
private static TitanLock GetLock(IContainerOwner owner) { var titanLock = TitanLock.RetrieveFromOwnerContent(owner, "lock"); if (titanLock == null) { titanLock = new TitanLock(); titanLock.SetLocationAsOwnerContent(owner, "lock"); titanLock.IsLocked = false; titanLock.LastLocked = DateTime.MinValue; titanLock.StoreInformation(); titanLock = TitanLock.RetrieveFromOwnerContent(owner, "lock"); } return(titanLock); }
public static void AddPendingRequests(IContainerOwner owner, string[] subscriptionTargets) { if (owner == null) throw new ArgumentNullException("owner"); var requestContent = SubscriptionChainRequestContent.CreateDefault(); DateTime submitTime = DateTime.UtcNow; string dateTimePrefix = submitTime.ToString("yyyyMMdd_HHmmss"); requestContent.ID = dateTimePrefix + "_" + requestContent.ID; requestContent.SubscriptionTargetCollection.CollectionContent. AddRange(subscriptionTargets.Select(target => new SubscriptionTarget() { BlobLocation = target })); requestContent.SubmitTime = submitTime; string ownerSubscriptionLocation = GetOwnerIDStatusBasedLocation(owner, requestContent.ID, StatusValue_Pending); requestContent.RelativeLocation = ownerSubscriptionLocation; requestContent.StoreInformation(); }
public static InformationChangeItem GetTarget_ChangeItem(IContainerOwner owner, DateTime startTime, DateTime endTime, string[] changedIdList) { startTime = startTime.ToUniversalTime(); endTime = endTime.ToUniversalTime(); string id = string.Format("{0}_{1}_{2}", startTime.ToString("yyyy-MM-dd_HH-mm-ss"), endTime.ToString("yyyy-MM-dd_HH-mm-ss"), Guid.NewGuid().ToString()); InformationChangeItem changeItem = new InformationChangeItem(); changeItem.ID = id; changeItem.SetLocationAsOwnerContent(owner, id); changeItem.StartTimeUTC = startTime; changeItem.EndTimeUTC = endTime; changeItem.ChangedObjectIDList.AddRange(changedIdList); return changeItem; }
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; }
public static UsageMonitorItem[] GetTarget_SourceItems(IContainerOwner owner, int amountOfDays) { string filterPrefix = "TheBall.CORE/UsageMonitorItem/"; DateTime today = DateTime.UtcNow.Date; List<UsageMonitorItem> result = new List<UsageMonitorItem>(); Type type = typeof (UsageMonitorItem); for (DateTime fromDate = today.AddDays(-amountOfDays); fromDate <= today; fromDate = fromDate.AddDays(1)) { string dateStr = fromDate.ToString("yyyyMMdd"); var dayBlobs = owner.ListBlobsWithPrefix(filterPrefix + dateStr).Cast<CloudBlockBlob>().ToArray(); foreach (var blob in dayBlobs) { UsageMonitorItem item = (UsageMonitorItem) StorageSupport.RetrieveInformation(blob.Name, type); result.Add(item); } } return result.ToArray(); }
public void SetMediaContent(IContainerOwner containerOwner, string contentObjectID, object mediaContent) { if (ID != contentObjectID) { return; } ClearCurrentContent(containerOwner); HttpPostedFile postedContent = (HttpPostedFile)mediaContent; FileExt = Path.GetExtension(postedContent.FileName); ContentLength = postedContent.ContentLength; string locationFileName = ID + FileExt; SetLocationAsOwnerContent(containerOwner, locationFileName); postedContent.InputStream.Seek(0, SeekOrigin.Begin); StorageSupport.CurrActiveContainer.UploadBlobStream(RelativeLocation, postedContent.InputStream, StorageSupport.InformationType_GenericContentValue); UpdateAdditionalMediaFormats(); }
public static string[] UploadTemplateContent(string[] allFiles, IContainerOwner owner, string targetLocation, bool clearOldTarget, Action <BlobStorageContent> preprocessor = null, Predicate <BlobStorageContent> contentFilterer = null, InformationTypeResolver informationTypeResolver = null) { if (informationTypeResolver == null) { informationTypeResolver = GetBlobInformationType; } if (clearOldTarget) { StorageSupport.DeleteBlobsFromOwnerTarget(owner, targetLocation); } var processedDict = allFiles.Where(file => file.EndsWith(".txt")).Where(File.Exists).ToDictionary(file => Path.GetFullPath(file), file => false); List <ErrorItem> errorList = new List <ErrorItem>(); var fixedContent = allFiles.Where(fileName => fileName.EndsWith(".txt") == false) .Select(fileName => new BlobStorageContent { FileName = fileName, BinaryContent = GetBlobContent(fileName, errorList, processedDict) }) .ToArray(); if (preprocessor != null) { foreach (var content in fixedContent) { preprocessor(content); } } foreach (var content in fixedContent) { if (contentFilterer != null && contentFilterer(content) == false) { // TODO: Properly implement delete above continue; } string webtemplatePath = Path.Combine(targetLocation, content.FileName).Replace("\\", "/"); Console.WriteLine("Uploading: " + webtemplatePath); string contentInformationType; contentInformationType = informationTypeResolver(content); StorageSupport.UploadOwnerBlobBinary(owner, webtemplatePath, content.BinaryContent, contentInformationType); } return(processedDict.Keys.ToArray()); }
public static void ExecuteMethod_FetchInputToStorage(IContainerOwner owner, string queryParameters, InformationInput informationInput, string inputFetchLocation, string inputFetchName, AuthenticatedAsActiveDevice authenticatedAsActiveDevice) { string url = string.IsNullOrEmpty(queryParameters) ? informationInput.LocationURL : informationInput.LocationURL + queryParameters; if (authenticatedAsActiveDevice == null) { WebRequest getRequest = WebRequest.Create(url); var response = getRequest.GetResponse(); var stream = response.GetResponseStream(); var targetBlob = StorageSupport.CurrActiveContainer.GetBlob(inputFetchLocation + "/" + inputFetchName, owner); targetBlob.UploadFromStream(stream); } else { HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url); request.Method = "GET"; request.Headers.Add("Authorization", "DeviceAES::" + authenticatedAsActiveDevice.EstablishedTrustID + ":"); HttpWebResponse response = (HttpWebResponse) request.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) throw new InvalidOperationException("Authroized fetch failed with non-OK status code"); string ivStr = response.Headers["IV"]; string contentRoot = inputFetchLocation; string blobName = contentRoot + "/" + inputFetchName; var blob = StorageSupport.GetOwnerBlobReference(owner, blobName); if (blob.Name != blobName) throw new InvalidDataException("Invalid content name"); var respStream = response.GetResponseStream(); AesManaged aes = new AesManaged(); aes.KeySize = SymmetricSupport.AES_KEYSIZE; aes.BlockSize = SymmetricSupport.AES_BLOCKSIZE; aes.IV = Convert.FromBase64String(ivStr); aes.Key = authenticatedAsActiveDevice.ActiveSymmetricAESKey; aes.Padding = SymmetricSupport.PADDING_MODE; aes.Mode = SymmetricSupport.AES_MODE; aes.FeedbackSize = SymmetricSupport.AES_FEEDBACK_SIZE; var decryptor = aes.CreateDecryptor(aes.Key, aes.IV); CryptoStream cryptoStream = new CryptoStream(respStream, decryptor, CryptoStreamMode.Read); blob.UploadFromStream(cryptoStream); } }
public static bool ProcessOwnerSubscriptionChains(IContainerOwner lockedOwner, string acquiredEtag, string containerName) { try { if (containerName != null) { InformationContext.Current.InitializeCloudStorageAccess(containerName: containerName); } string[] blobs = SubscribeSupport.GetChainRequestList(lockedOwner); var chainContent = blobs.Select(blob => StorageSupport.RetrieveInformation(blob, typeof(SubscriptionChainRequestContent))).Cast <SubscriptionChainRequestContent>().ToArray(); const double invalidSubscriptionSubmissionTimeInSeconds = 600; if (chainContent.Any(item => item.SubmitTime < DateTime.UtcNow.AddSeconds(-invalidSubscriptionSubmissionTimeInSeconds))) { return(false); } WorkerSupport.ExecuteSubscriptionChains(chainContent); foreach (string blob in blobs) { StorageSupport.DeleteBlob(blob); } } catch (Exception ex) { ErrorSupport.ReportException(ex); throw; } finally { SubscribeSupport.ReleaseChainLock(lockedOwner, acquiredEtag); if (containerName != null) { InformationContext.ProcessAndClearCurrent(); } } counter++; if (counter >= 1000) { QueueSupport.ReportStatistics("Processed " + counter + " messages..."); counter = 0; } return(true); }
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); }
public static string[] UploadTemplateContent(string[] allFiles, IContainerOwner owner, string targetLocation, bool clearOldTarget) { if (clearOldTarget) { StorageSupport.DeleteBlobsFromOwnerTarget(owner, targetLocation); } var processedDict = allFiles.Where(file => file.EndsWith(".txt")).Where(File.Exists).ToDictionary(file => Path.GetFullPath(file), file => false); List<ErrorItem> errorList = new List<ErrorItem>(); var fixedContent = allFiles.Where(fileName => fileName.EndsWith(".txt") == false) .Select(fileName => new { FileName = fileName, TextContent = GetFixedContent(fileName, errorList, processedDict), BinaryContent = GetBinaryContent(fileName) }) .ToArray(); foreach (var content in fixedContent) { if (content.FileName.EndsWith(".txt")) continue; string webtemplatePath = Path.Combine(targetLocation, content.FileName).Replace("\\", "/"); Console.WriteLine("Uploading: " + webtemplatePath); string blobInformationType = GetBlobInformationType(webtemplatePath); if (content.TextContent != null) { StorageSupport.UploadOwnerBlobText(owner, webtemplatePath, content.TextContent, blobInformationType); } else { StorageSupport.UploadOwnerBlobBinary(owner, webtemplatePath, content.BinaryContent); } } return processedDict.Keys.ToArray(); }
public static void AddPendingRequests(IContainerOwner owner, string[] subscriptionTargets) { if (owner == null) { throw new ArgumentNullException("owner"); } var requestContent = SubscriptionChainRequestContent.CreateDefault(); DateTime submitTime = DateTime.UtcNow; string dateTimePrefix = submitTime.ToString("yyyyMMdd_HHmmss"); requestContent.ID = dateTimePrefix + "_" + requestContent.ID; requestContent.SubscriptionTargetCollection.CollectionContent. AddRange(subscriptionTargets.Select(target => new SubscriptionTarget() { BlobLocation = target })); requestContent.SubmitTime = submitTime; string ownerSubscriptionLocation = GetOwnerIDStatusBasedLocation(owner, requestContent.ID, StatusValue_Pending); requestContent.RelativeLocation = ownerSubscriptionLocation; requestContent.StoreInformation(); }
public static string[] UploadTemplateContent(string[] allFiles, IContainerOwner owner, string targetLocation, bool clearOldTarget, Action<BlobStorageContent> preprocessor = null, Predicate<BlobStorageContent> contentFilterer = null) { if (clearOldTarget) { StorageSupport.DeleteBlobsFromOwnerTarget(owner, targetLocation); } var processedDict = allFiles.Where(file => file.EndsWith(".txt")).Where(File.Exists).ToDictionary(file => Path.GetFullPath(file), file => false); List<ErrorItem> errorList = new List<ErrorItem>(); var fixedContent = allFiles.Where(fileName => fileName.EndsWith(".txt") == false) .Select(fileName => new BlobStorageContent { FileName = fileName, BinaryContent = File.ReadAllBytes(fileName) // BinaryContent = GetBlobContent(fileName, errorList, processedDict) }) .ToArray(); if (preprocessor != null) { foreach (var content in fixedContent) { preprocessor(content); } } foreach (var content in fixedContent) { if (contentFilterer != null && contentFilterer(content) == false) { // TODO: Properly implement delete above continue; } string webtemplatePath = Path.Combine(targetLocation, content.FileName).Replace("\\", "/"); Console.WriteLine("Uploading: " + webtemplatePath); StorageSupport.UploadOwnerBlobBinary(owner, webtemplatePath, content.BinaryContent); } return processedDict.Keys.ToArray(); }
private void HandleOwnerGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath) { if (context.Request.Url.Host == "localhost" && (contentPath.Contains("oipcms/") || contentPath.Contains("wwwsite/"))) { HandleFileSystemGetRequest(containerOwner, context, contentPath); return; } CloudBlob blob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath); var response = context.Response; // Read blob content to response. response.Clear(); try { blob.FetchAttributes(); response.ContentType = blob.Properties.ContentType; response.Headers.Add("ETag", blob.Properties.ETag); blob.DownloadToStream(response.OutputStream); } catch (StorageClientException scEx) { if (scEx.ErrorCode == StorageErrorCode.BlobNotFound || scEx.ErrorCode == StorageErrorCode.ResourceNotFound || scEx.ErrorCode == StorageErrorCode.BadRequest) { response.Write("Blob not found or bad request: " + blob.Name + " (original path: " + context.Request.Path + ")"); response.StatusCode = (int)scEx.StatusCode; } else { response.Write("Error code: " + scEx.ErrorCode.ToString() + Environment.NewLine); response.Write(scEx.ToString()); response.StatusCode = (int)scEx.StatusCode; } } catch (Exception ex) { response.Write(ex.ToString()); } response.End(); }
public static void ExecuteMethod_StoreInitialObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, true); }
public static void ExecuteMethod_StoreCompleteObject(IContainerOwner owner, IInformationObject createdObject) { createdObject.StoreInformationMasterFirst(owner, false); }
public static void ExecuteMethod_CreateUsageMonitoringSummaries(IContainerOwner owner, int amountOfDays, UsageMonitorItem[] sourceItems) { var groupedByDay = sourceItems.OrderBy(item => item.RelativeLocation) .GroupBy(item => item.TimeRangeInclusiveStartExclusiveEnd.StartTime.Date); if(amountOfDays < 31) throw new ArgumentException("Amount of days needs to be at least 31 so that last month makes sense with data"); // Last 7 days UsageSummary lastWeekHourlySummary = null; DateTime today = DateTime.UtcNow.Date; DateTime weekAgoStartDay = today.AddDays(-7); DateTime todayEndTime = today.AddDays(1); lastWeekHourlySummary = new UsageSummary { SummaryName = "Last Week (7 days) Summary", SummaryMonitoringItem = UsageMonitorItem.Create(weekAgoStartDay, todayEndTime, 60) }; lastWeekHourlySummary.SetLocationAsOwnerContent(owner, "LastWeekSummary_Hourly"); // Last month DateTime monthAgoStartDay = today.AddMonths(-1); UsageSummary lastMonthDailySummary = new UsageSummary { SummaryName = "Last Week Summary", SummaryMonitoringItem = UsageMonitorItem.Create(monthAgoStartDay, todayEndTime, 60 * 24) }; lastMonthDailySummary.SetLocationAsOwnerContent(owner, "LastMonthSummary_Daily"); foreach (var dayList in groupedByDay) { //UsageMonitorItemCollection hourlyCollection = new UsageMonitorItemCollection(); //hourlyCollection. string hourlySummaryName = "Hourly Summary of " + dayList.Key.ToShortDateString(); DateTime startTime = dayList.Key; DateTime endTime = startTime.AddDays(1); var currDaysData = dayList.ToArray(); UsageSummary dailyHourlySummary = new UsageSummary { SummaryName = hourlySummaryName, SummaryMonitoringItem = UsageMonitorItem.Create(startTime, endTime, 60) }; dailyHourlySummary.SummaryMonitoringItem.AggregateValuesFrom(currDaysData); string prefixName = startTime.ToString("yyyyMMdd"); dailyHourlySummary.SetLocationAsOwnerContent(owner, prefixName + "_Hourly"); dailyHourlySummary.StoreInformation(null, true); string detailedSummaryName = "Detailed (5 min) Summary of " + dayList.Key.ToShortDateString(); UsageSummary dailyDetailedSummary = new UsageSummary { SummaryName = detailedSummaryName, SummaryMonitoringItem = UsageMonitorItem.Create(startTime, endTime, 5) }; dailyDetailedSummary.SummaryMonitoringItem.AggregateValuesFrom(currDaysData); dailyDetailedSummary.SetLocationAsOwnerContent(owner, prefixName + "_Detailed"); dailyDetailedSummary.StoreInformation(null, true); // Weekly summary if (startTime >= lastWeekHourlySummary.SummaryMonitoringItem.TimeRangeInclusiveStartExclusiveEnd.StartTime) { lastWeekHourlySummary.SummaryMonitoringItem.AggregateValuesFrom(currDaysData); } if (startTime >= lastMonthDailySummary.SummaryMonitoringItem.TimeRangeInclusiveStartExclusiveEnd.StartTime) { lastMonthDailySummary.SummaryMonitoringItem.AggregateValuesFrom(currDaysData); } } lastWeekHourlySummary.StoreInformation(null, true); lastMonthDailySummary.StoreInformation(null, true); }
partial void DoPostStoringExecute(IContainerOwner owner) { return; }
public bool IsSameOwner(IContainerOwner containerOwner) { return(ContainerName == containerOwner.ContainerName && LocationPrefix == containerOwner.LocationPrefix); }
private static void DOMAININIT_TheBall_Admin(IContainerOwner owner) { DOM.DomainInformationSupport.EnsureMasterCollections(owner); DOM.DomainInformationSupport.RefreshMasterCollections(owner); }
public static void RefreshMasterCollections(IContainerOwner owner) { }
private static string GetOwnerIDStatusBasedLocation(IContainerOwner owner, string id, string status) { return(ChainRequestDirectory + owner.ContainerName + "/" + owner.LocationPrefix + "/" + id + "." + status); }
partial void DoPostDeleteExecute(IContainerOwner owner) { ImageData.ClearCurrentContent(owner); }