private async Task <UpdatedTagResult> UpdateTag(string sourceAzid, CloudBlobDirectory sourceDirectory, TagTable tagsTable, TagTransactionEntity tagTx) { var oldTagEntity = tagsTable.GetPrimaryTag(sourceAzid, tagTx.Id); var json = await this.GetBlobAsString(tagTx.StagedBlobUri); var softwareIdentity = SoftwareIdentity.LoadJson(json); var tagEntity = this.CreateTagEntityFromSoftwareIdentity(sourceAzid, tagTx, softwareIdentity); var redirects = UpdateInstallationMediaLinksInSoftwareIdentityAndReturnWithRedirects(sourceAzid, tagEntity.TagAzid, tagEntity.Uid, softwareIdentity); var tagUris = await WriteVersionedTag(sourceDirectory, tagEntity, softwareIdentity); tagEntity.JsonBlobName = tagUris.JsonUri.AbsoluteUri; tagEntity.XmlBlobName = tagUris.XmlUri.AbsoluteUri; var primaryTag = tagEntity.AsPrimary(); primaryTag.DownloadCount = oldTagEntity.DownloadCount; return(new UpdatedTagResult() { NewSourceUris = tagUris, OldSourceUris = new TagBlobUris { JsonUri = new Uri(oldTagEntity.JsonBlobName), XmlUri = new Uri(oldTagEntity.XmlBlobName) }, Redirects = redirects, Tag = tagEntity, PrimaryTag = primaryTag }); }
private static bool TryLoadJsonTag(string text, out SoftwareIdentity tag) { try { tag = SoftwareIdentity.LoadJson(text); } catch (Exception) { tag = null; } return(tag != null); }
private async Task <SoftwareIdentity> GetIndexSoftwareIdentity(CloudBlobDirectory sourcesDirectory, string contentType) { var extension = (contentType == FearTheCowboy.Iso19770.Schema.MediaType.SwidTagJsonLd) ? "json" : "xml"; var indexBlob = sourcesDirectory.GetBlockBlobReference(String.Format("index.{0}.SoftwareIdentity", extension)); if (indexBlob.Exists()) { var text = await indexBlob.DownloadTextAsync(); return((contentType == FearTheCowboy.Iso19770.Schema.MediaType.SwidTagJsonLd) ? SoftwareIdentity.LoadJson(text) : SoftwareIdentity.LoadXml(text)); } return(new SoftwareIdentity() { Name = "AppSyndication Index", TagId = indexBlob.Uri.AbsoluteUri }); }