using System;
using System.Collections.Generic;
using System.Globalization;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Web.Routing
{
public interface IPublishedRequest
{
///
/// Gets the UmbracoContext.
///
IUmbracoContext UmbracoContext { get; }
///
/// Gets or sets the cleaned up Uri used for routing.
///
/// The cleaned up Uri has no virtual directory, no trailing slash, no .aspx extension, etc.
Uri Uri { get; set; }
///
/// Gets or sets a value indicating whether the Umbraco Backoffice should ignore a collision for this request.
///
bool IgnorePublishedContentCollisions { get; set; }
///
/// Gets or sets the requested content.
///
/// Setting the requested content clears Template.
IPublishedContent PublishedContent { get; set; }
///
/// Gets the initial requested content.
///
/// The initial requested content is the content that was found by the finders,
/// before anything such as 404, redirect... took place.
IPublishedContent InitialPublishedContent { get; }
///
/// Gets value indicating whether the current published content is the initial one.
///
bool IsInitialPublishedContent { get; }
///
/// Gets or sets a value indicating whether the current published content has been obtained
/// from the initial published content following internal redirections exclusively.
///
/// Used by PublishedContentRequestEngine.FindTemplate() to figure out whether to
/// apply the internal redirect or not, when content is not the initial content.
bool IsInternalRedirectPublishedContent { get; }
///
/// Gets a value indicating whether the content request has a content.
///
bool HasPublishedContent { get; }
ITemplate TemplateModel { get; set; }
///
/// Gets the alias of the template to use to display the requested content.
///
string TemplateAlias { get; }
///
/// Gets a value indicating whether the content request has a template.
///
bool HasTemplate { get; }
void UpdateToNotFound();
///
/// Gets or sets the content request's domain.
///
/// Is a DomainAndUri object ie a standard Domain plus the fully qualified uri. For example,
/// the Domain may contain "example.com" whereas the Uri will be fully qualified eg "http://example.com/".
DomainAndUri Domain { get; set; }
///
/// Gets a value indicating whether the content request has a domain.
///
bool HasDomain { get; }
///
/// Gets or sets the content request's culture.
///
CultureInfo Culture { get; set; }
///
/// Gets or sets a value indicating whether the requested content could not be found.
///
/// This is set in the PublishedContentRequestBuilder and can also be used in
/// custom content finders or Prepared event handlers, where we want to allow developers
/// to indicate a request is 404 but not to cancel it.
bool Is404 { get; set; }
///
/// Gets a value indicating whether the content request triggers a redirect (permanent or not).
///
bool IsRedirect { get; }
///
/// Gets or sets a value indicating whether the redirect is permanent.
///
bool IsRedirectPermanent { get; }
///
/// Gets or sets the url to redirect to, when the content request triggers a redirect.
///
string RedirectUrl { get; }
///
/// Gets or sets the content request http response status code.
///
/// Does not actually set the http response status code, only registers that the response
/// should use the specified code. The code will or will not be used, in due time.
int ResponseStatusCode { get; }
///
/// Gets or sets the content request http response status description.
///
/// Does not actually set the http response status description, only registers that the response
/// should use the specified description. The description will or will not be used, in due time.
string ResponseStatusDescription { get; }
///
/// Gets or sets a list of Extensions to append to the Response.Cache object.
///
List CacheExtensions { get; set; }
///
/// Gets or sets a dictionary of Headers to append to the Response object.
///
Dictionary Headers { get; set; }
bool CacheabilityNoCache { get; set; }
///
/// Prepares the request.
///
void Prepare();
///
/// Triggers the Preparing event.
///
void OnPreparing();
///
/// Triggers the Prepared event.
///
void OnPrepared();
///
/// Sets the requested content, following an internal redirect.
///
/// The requested content.
/// Depending on UmbracoSettings.InternalRedirectPreservesTemplate, will
/// preserve or reset the template, if any.
void SetInternalRedirectPublishedContent(IPublishedContent content);
///
/// Indicates that the current PublishedContent is the initial one.
///
void SetIsInitialPublishedContent();
///
/// Tries to set the template to use to display the requested content.
///
/// The alias of the template.
/// A value indicating whether a valid template with the specified alias was found.
///
/// Successfully setting the template does refresh RenderingEngine.
/// If setting the template fails, then the previous template (if any) remains in place.
///
bool TrySetTemplate(string alias);
///
/// Sets the template to use to display the requested content.
///
/// The template.
/// Setting the template does refresh RenderingEngine.
void SetTemplate(ITemplate template);
///
/// Resets the template.
///
void ResetTemplate();
///
/// Indicates that the content request should trigger a redirect (302).
///
/// The url to redirect to.
/// Does not actually perform a redirect, only registers that the response should
/// redirect. Redirect will or will not take place in due time.
void SetRedirect(string url);
///
/// Indicates that the content request should trigger a permanent redirect (301).
///
/// The url to redirect to.
/// Does not actually perform a redirect, only registers that the response should
/// redirect. Redirect will or will not take place in due time.
void SetRedirectPermanent(string url);
///
/// Indicates that the content request should trigger a redirect, with a specified status code.
///
/// The url to redirect to.
/// The status code (300-308).
/// Does not actually perform a redirect, only registers that the response should
/// redirect. Redirect will or will not take place in due time.
void SetRedirect(string url, int status);
///
/// Sets the http response status code, along with an optional associated description.
///
/// The http status code.
/// The description.
/// Does not actually set the http response status code and description, only registers that
/// the response should use the specified code and description. The code and description will or will
/// not be used, in due time.
void SetResponseStatus(int code, string description = null);
}
}