/// <summary> /// Gets the URL to a document /// </summary> /// <param name="documentId">The document ID to get the URL for</param> /// <returns></returns> public GetDocumentUrlResult GetDocumentUrl(string documentId) { GetDocumentUrlResult result = new GetDocumentUrlResult(); result.Success = false; try { using (SPSite site = SPContext.Current.Site) { result.DocumentUrl = GetDocumentUrlFromId(site, documentId); if (!string.IsNullOrEmpty(result.DocumentUrl)) { result.Success = true; } else { result.ErrorMessage = string.Format("The document id service was unable to find a document for the id {0}", documentId == null ? "null" : documentId); Util.LogError(result.ErrorMessage, Util.ErrorLevel.Warning); } } } catch (Exception e) { Util.LogError("GetDocumentUrl errored with exception: " + e.Message); result.ErrorMessage = e.Message; } return(result); }
/// <summary> /// Gets the URL to a document. MimeType is used to assemble a URL that is compatible with Guidewire /// </summary> /// <param name="documentId">The document ID to get the URL for</param> /// <param name="mimeType">The MimeType as it is represented in ClaimCenter</param> /// <returns></returns> public GetDocumentUrlResult GetDocumentUrl(string documentId, string mimeType) { GetDocumentUrlResult result = GetDocumentUrl(documentId); if (result.Success) { // Check the extension of the document, and do additional processing if the extension is missing, contains a space or doesn't match a known extension from ClaimCenter string currentExtension = Path.GetExtension(result.DocumentUrl); using (MIMETypes mimeTypes = new MIMETypes()) { if (string.IsNullOrEmpty(currentExtension) || currentExtension.Contains(" ")) { //Document doesn't have an extension. Resolve this before attempting to access it. result.DocumentUrl = Util.ResolveMissingExtension(result.DocumentUrl, mimeType); } } } return(result); }