public async Task <IHttpActionResult> GetByUriAsync(string uri, PortalQueryField fields, CancellationToken cancellationToken)
        {
            var portal = await _portalManager.FindByUriAsync(uri, (PortalField)(fields & ~PortalQueryField.Pages), cancellationToken);

            await ApiSecurity.AuthorizeAsync(portal, AccessPermission.CanView, cancellationToken);

            return(Ok(ModelMapper.ToPortalDto(portal, fields.HasFlag(PortalQueryField.Pages) ? await _portalManager.GetPagesAsync(portal, cancellationToken) : null)));
        }
示例#2
0
        public async Task <System.Web.Mvc.ActionResult> Portal(
            string portalUri,
            string pageUri,
            string preview,
            [ModelBinder(typeof(ActionLinkModelBinder))] ActionLink actionLink,
            [ModelBinder(typeof(AuthTicketModelBinder))] AuthTicket authTicket,
            CancellationToken cancellationToken)
        {
            var portal = await _portalManager.FindByUriAsync(portalUri, PortalField.Project | PortalField.Owners, cancellationToken);

            if (portal == null)
            {
                return(HttpNotFound());
            }
            if (!string.IsNullOrEmpty(portal.Domain))
            {
                return(Redirect(string.Join("/", "http://www." + portal.Domain, pageUri)));
            }
            var security = await _securityManager.CheckAccessAsync(portal, User.Identity.Name, AccessPermission.CanView, cancellationToken);

            if (!security.AccessGranted)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }
            var pageLayers = await _portalManager.GetPageLayersByUriAsync(portal, pageUri, cancellationToken);

            if (pageLayers?.ContentPage == null)
            {
                return(HttpNotFound());
            }
            return(View("Content", await CreateResultAsync(security, portal, pageLayers, actionLink, authTicket, preview == null, cancellationToken)));
        }
示例#3
0
        public async Task <IHttpActionResult> GetByUriAsync([FromUri] MediaQueryDto model, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (model == null)
            {
                model = new MediaQueryDto();
            }

            var portal = await _portalManager.FindByUriAsync(model.PortalUri, cancellationToken);

            await ApiSecurity.AuthorizeAsync(portal, AccessPermission.CanView, cancellationToken);

            var parent = default(MediaItem);

            if (model.MediaUri != null)
            {
            }
            return(Ok(ModelMapper.ToMediaListDto(
                          await _portalManager.GetMediaAsync(portal, parent, model.Name, model.OrderBy, model.Fields, cancellationToken),
                          uri => _portalManager.GetMediaLinkByUri(portal.Uri, uri))));
        }
        /// <summary>
        /// Validates the specified <paramref name="portal" /> as an asynchronous operation.
        /// </summary>
        /// <param name="manager">The <see cref="PortalManager" /> that can be used to retrieve user properties.</param>
        /// <param name="portal">The portal to validate.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>
        /// The <see cref="Task" /> that represents the asynchronous operation, containing the <see cref="ValidationResult" /> of the validation operation.
        /// </returns>
        public virtual async Task <ValidationResult> ValidateAsync(PortalManager manager, PortalItem portal, CancellationToken cancellationToken)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            if (portal == null)
            {
                throw new ArgumentNullException(nameof(portal));
            }

            var otherPortal = await manager.FindByUriAsync(portal.Uri, cancellationToken);

            if (otherPortal == null || otherPortal.Id == portal.Id || !string.Equals(otherPortal.Uri, portal.Uri, StringComparison.Ordinal))
            {
                return(ValidationResult.Success);
            }
            return(ValidationResult.Failed(string.Format(CultureInfo.CurrentCulture, PortalResources.DuplicatedPortalUri, portal.Uri)));
        }
        public async Task <IHttpActionResult> GetAllAsync(string portalUri, CancellationToken cancellationToken)
        {
            var portal = await _portalManager.FindByUriAsync(portalUri, cancellationToken);

            await ApiSecurity.AuthorizeAsync(portal, AccessPermission.CanView, cancellationToken);

            var pages = await _portalManager.GetPagesAsync(portal, cancellationToken);

            if (pages == null)
            {
                return(NotFound());
            }
            return(Ok(ModelMapper.ToPageListDto(pages)));
        }