示例#1
0
 public IBinaryMeta GetBinaryMetaByUri(string uri)
 {
     Tridion.ContentDelivery.Meta.BinaryMeta binaryMeta = null;
     binaryMeta = BinaryMetaFactory.GetMeta(uri);
     if (binaryMeta == null)
     {
         LoggerService.Debug($"cannot find binary with uri {uri}");
         return(null);
     }
     DD4T.ContentModel.BinaryMeta bm = new ContentModel.BinaryMeta()
     {
         Id        = uri,
         VariantId = binaryMeta.VariantId,
     };
     Tridion.ContentDelivery.Meta.IComponentMeta componentMeta = GetTridionComponentMetaFactory(binaryMeta.PublicationId).GetMeta(binaryMeta.Id);
     if (componentMeta == null)
     {
         LoggerService.Debug($"no component metadata found for binary with uri {uri}");
         bm.HasLastPublishedDate = false;
         return(bm);
     }
     bm.HasLastPublishedDate = true;
     bm.LastPublishedDate    = componentMeta.LastPublicationDate;
     LoggerService.Debug(string.Format("returning binary for uri {0} with the following metadata: Id = {1}, VariantId = {2}, HasLastPublishDate = {3}, lastPublishDate = {4}", uri, bm.Id, bm.VariantId, bm.HasLastPublishedDate, bm.LastPublishedDate));
     return(bm);
 }
示例#2
0
        public IBinaryMeta GetBinaryMetaByUrl(string url)
        {
            LoggerService.Debug($"started GetBinaryMetaByUrl for url {url} with publication id {PublicationId}");
            string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now?

            LoggerService.Debug($"using encodedUrl: {encodedUrl}");
            Tridion.ContentDelivery.Meta.BinaryMeta binaryMeta = null;
            if (this.PublicationId == 0)
            {
                IList metas = BinaryMetaFactory.GetMetaByUrl(encodedUrl);
                if (metas.Count == 0)
                {
                    return(null);
                }

                binaryMeta = metas[0] as Tridion.ContentDelivery.Meta.BinaryMeta;
            }
            else
            {
                binaryMeta = BinaryMetaFactory.GetMetaByUrl(this.PublicationId, encodedUrl);
            }
            if (binaryMeta == null)
            {
                LoggerService.Debug($"cannot find binary with URL {url}");
                return(null);
            }
            LoggerService.Debug($"found binarymeta with ID {binaryMeta.Id}");

            string uri = string.Format("tcm:{0}-{1}", binaryMeta.PublicationId, binaryMeta.Id);

            DD4T.ContentModel.BinaryMeta bm = new ContentModel.BinaryMeta()
            {
                Id        = uri,
                VariantId = binaryMeta.VariantId,
            };
            LoggerService.Debug("about to call ComponentMetaFactory.GetMeta");
            Tridion.ContentDelivery.Meta.IComponentMeta componentMeta = GetTridionComponentMetaFactory(binaryMeta.PublicationId).GetMeta(binaryMeta.Id);
            if (componentMeta == null)
            {
                LoggerService.Debug($"no component metadata found for binary with url {url}");
                bm.HasLastPublishedDate = false;
                return(bm);
            }
            LoggerService.Debug($"found component meta with LastPublishDate {componentMeta.LastPublicationDate}");
            bm.HasLastPublishedDate = true;
            bm.LastPublishedDate    = componentMeta.LastPublicationDate;
            LoggerService.Debug(string.Format("returning binary for url {0} with the following metadata: Id = {1}, VariantId = {2}, HasLastPublishDate = {3}, lastPublishDate = {4}", url, bm.Id, bm.VariantId, bm.HasLastPublishedDate, bm.LastPublishedDate));
            return(bm);
        }
        public IBinaryMeta GetBinaryMetaByUrl(string url)
        {
            LoggerService.Debug($"started GetBinaryMetaByUrl for url {url} with publication id {PublicationId}");
            string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now?
            LoggerService.Debug($"using encodedUrl: {encodedUrl}");
            Tridion.ContentDelivery.Meta.BinaryMeta binaryMeta = null;
            if (this.PublicationId == 0)
            {
                IList metas = BinaryMetaFactory.GetMetaByUrl(encodedUrl);
                if (metas.Count == 0)
                    return null;

                binaryMeta = metas[0] as Tridion.ContentDelivery.Meta.BinaryMeta;
            }
            else
            {
                binaryMeta = BinaryMetaFactory.GetMetaByUrl(this.PublicationId, encodedUrl);
            }
            if (binaryMeta == null)
            {
                LoggerService.Debug($"cannot find binary with URL {url}");
                return null;
            }
            LoggerService.Debug($"found binarymeta with ID {binaryMeta.Id}");

            string uri = string.Format("tcm:{0}-{1}", binaryMeta.PublicationId, binaryMeta.Id);
            DD4T.ContentModel.BinaryMeta bm = new ContentModel.BinaryMeta()
            {
                Id = uri,
                VariantId = binaryMeta.VariantId,
            };
            LoggerService.Debug("about to call ComponentMetaFactory.GetMeta");
            Tridion.ContentDelivery.Meta.IComponentMeta componentMeta = GetTridionComponentMetaFactory(binaryMeta.PublicationId).GetMeta(binaryMeta.Id);
            if (componentMeta == null)
            {
                LoggerService.Debug($"no component metadata found for binary with url {url}");
                bm.HasLastPublishedDate = false;
                return bm;
            }
            LoggerService.Debug($"found component meta with LastPublishDate {componentMeta.LastPublicationDate}");
            bm.HasLastPublishedDate = true;
            bm.LastPublishedDate = componentMeta.LastPublicationDate;
            LoggerService.Debug(string.Format("returning binary for url {0} with the following metadata: Id = {1}, VariantId = {2}, HasLastPublishDate = {3}, lastPublishDate = {4}", url, bm.Id, bm.VariantId, bm.HasLastPublishedDate, bm.LastPublishedDate));
            return bm;
        }
 public IBinaryMeta GetBinaryMetaByUri(string uri)
 {
     Tridion.ContentDelivery.Meta.BinaryMeta binaryMeta = null;
     binaryMeta = BinaryMetaFactory.GetMeta(uri);
     if (binaryMeta == null)
     {
         LoggerService.Debug($"cannot find binary with uri {uri}");
         return null;
     }
     DD4T.ContentModel.BinaryMeta bm = new ContentModel.BinaryMeta()
     {
         Id = uri,
         VariantId = binaryMeta.VariantId,
     };
     Tridion.ContentDelivery.Meta.IComponentMeta componentMeta = GetTridionComponentMetaFactory(binaryMeta.PublicationId).GetMeta(binaryMeta.Id);
     if (componentMeta == null)
     {
         LoggerService.Debug($"no component metadata found for binary with uri {uri}");
         bm.HasLastPublishedDate = false;
         return bm;
     }
     bm.HasLastPublishedDate = true;
     bm.LastPublishedDate = componentMeta.LastPublicationDate;
     LoggerService.Debug(string.Format("returning binary for uri {0} with the following metadata: Id = {1}, VariantId = {2}, HasLastPublishDate = {3}, lastPublishDate = {4}", uri, bm.Id, bm.VariantId, bm.HasLastPublishedDate, bm.LastPublishedDate));
     return bm;
 }