public static int GetIdFromPublicationUrl(string publicationUrl) { //Prepend leading '/' if (!publicationUrl.StartsWith("/")) { publicationUrl = string.Concat("/", publicationUrl); } //Append '/' if (!publicationUrl.EndsWith("/")) { publicationUrl = string.Concat(publicationUrl, "/"); } PublicationMetaFactory m = new PublicationMetaFactory(); var pubMeta = m.GetMetaByPublicationUrl(publicationUrl); if (pubMeta != null && pubMeta.Count() > 0) { //Get the first pubmeta with this publicationUrl var publicationMeta = pubMeta.FirstOrDefault(); if (publicationMeta != null) { return(publicationMeta.Id); } } return(0); }
public static int GetIdFromPublicationUrl(string publicationUrl) { //Prepend leading '/' if (!publicationUrl.StartsWith("/")) { publicationUrl = string.Concat("/", publicationUrl); } //Append '/' if (!publicationUrl.EndsWith("/")) { publicationUrl = string.Concat(publicationUrl, "/"); } PublicationMetaFactory m = new PublicationMetaFactory(); var pubMeta = m.GetMetaByPublicationUrl(publicationUrl); if (pubMeta != null && pubMeta.Count() > 0) { //Get the first pubmeta with this publicationUrl var publicationMeta = pubMeta.FirstOrDefault(); if (publicationMeta != null) { return publicationMeta.Id; } } return 0; }
public static string GetPublicationUrlByUri(string pubUri) { PublicationMetaFactory m = new PublicationMetaFactory(); var pubMeta = m.GetMeta(pubUri); if (pubMeta != null) { return(pubMeta.PublicationUrl); } return(String.Empty); }
public static string GetPublicationUrlByUri(string pubUri) { PublicationMetaFactory m = new PublicationMetaFactory(); var pubMeta = m.GetMeta(pubUri); if (pubMeta != null) { return pubMeta.PublicationUrl; } return String.Empty; }
public void CheckPublicationOnline(int publicationId) { PublicationMeta meta = null; PublicationMetaFactory factory = new PublicationMetaFactory(); try { meta = factory.GetMeta(publicationId); } catch (Exception) { Log.Error("Couldn't find publication metadata for id: " + publicationId); } if (meta == null || !IsPublicationOnline(meta)) { throw new TridionDocsApiException($"Unable to find publication {publicationId}"); } }
private string GetMetadata(int publicationId, string metadataName) { try { PublicationMetaFactory factory = new PublicationMetaFactory(); PublicationMeta meta = factory.GetMeta(publicationId); if (meta?.CustomMeta == null) { throw new TridionDocsApiException( $"Metadata '{metadataName}' is not found for publication {publicationId}."); } object metadata = meta.CustomMeta.GetFirstValue(metadataName); string metadataString = metadata != null ? (string)metadata : "{}"; return(metadataString); } catch (Exception) { throw new TridionDocsApiException( $"Metadata '{metadataName}' is not found for publication {publicationId}."); } }