public ActionResult Terms(string alias, int maxLevel = 10)
        {
            var content = _commonServices.GetContentByAlias(alias);
            var json    = _contentSerializationServices.Terms(content, maxLevel);

            return(Content(json.ToString(Newtonsoft.Json.Formatting.None), "application/json"));
        }
Ejemplo n.º 2
0
        private IContent CurrentContent()
        {
            var      routeData      = HttpContext.Current.Request.RequestContext.RouteData;
            string   areaName       = (routeData.Values["area"] ?? string.Empty).ToString();
            string   controllerName = (routeData.Values["controller"] ?? string.Empty).ToString();
            string   actionName     = (routeData.Values["action"] ?? string.Empty).ToString();
            string   alias;
            IContent content = null;

            if (areaName.Equals("Laser.Orchard.WebServices", StringComparison.InvariantCultureIgnoreCase) &&
                controllerName.Equals("WebApi", StringComparison.InvariantCultureIgnoreCase) &&
                actionName.Equals("display", StringComparison.InvariantCultureIgnoreCase))
            {
                // For our webapi, we determine the content through its alias
                alias   = (HttpContext.Current.Request.Params["alias"] ?? string.Empty).ToString();
                content = _commonServices.GetContentByAlias(alias);
            }
            else if (areaName.Equals("Laser.Orchard.Policy", StringComparison.InvariantCultureIgnoreCase) &&
                     controllerName.Equals("Policies", StringComparison.InvariantCultureIgnoreCase) &&
                     actionName.Equals("Index", StringComparison.InvariantCultureIgnoreCase))
            {
                // since we also cache the page where we ask to accept the policies,
                // and that's on a specific controller, we do need to figure out the content item
                // we are preventing the used to see
                alias   = (HttpContext.Current.Request.Params["alias"] ?? string.Empty).ToString();
                content = _commonServices.GetContentByAlias(alias);
            }
            else
            {
                // this is the "normal" case, in which we are accessing a contentitem
                // directly on its display view
                content = _currenContent.CurrentContentItem;
            }
            return(content);
        }
        private void SetPendingPolicies()
        {
            if (pendingPolicies != null)
            {
                return;
            }
            var      routeData      = HttpContext.Current.Request.RequestContext.RouteData;
            string   areaName       = (routeData.Values["area"] ?? string.Empty).ToString();
            string   controllerName = (routeData.Values["controller"] ?? string.Empty).ToString();
            string   actionName     = (routeData.Values["action"] ?? string.Empty).ToString();
            string   alias;
            IContent content;

            if (areaName.Equals("Laser.Orchard.WebServices", StringComparison.InvariantCultureIgnoreCase) &&
                controllerName.Equals("WebApi", StringComparison.InvariantCultureIgnoreCase) &&
                actionName.Equals("display", StringComparison.InvariantCultureIgnoreCase))
            {
                // For our webapi, we determine the content through its alias
                alias   = (HttpContext.Current.Request.Params["alias"] ?? string.Empty).ToString();
                content = _commonServices.GetContentByAlias(alias);
            }
            else if (areaName.Equals("Laser.Orchard.Policy", StringComparison.InvariantCultureIgnoreCase) &&
                     controllerName.Equals("Policies", StringComparison.InvariantCultureIgnoreCase) &&
                     actionName.Equals("Index", StringComparison.InvariantCultureIgnoreCase))
            {
                // since we also cache the page where we ask to accept the policies,
                // and that's on a specific controller, we do need to figure out the content item
                // we are preventing the used to see
                alias   = (HttpContext.Current.Request.Params["alias"] ?? string.Empty).ToString();
                content = _commonServices.GetContentByAlias(alias);
            }
            else
            {
                // this is the "normal" case, in which we are accessing a contentitem
                // directly on its display view
                content = _currenContent.CurrentContentItem;
            }
            //_maxLevel = maxLevel;
            if (content != null)
            {
                // content would be null if rather than on a content item we are trying
                // to go to a controller aciton. Those should manage their own permissions
                // and caching so they would not have to be handled here
                var policy = content.As <Models.PolicyPart>();
                if (policy != null && (_policyServices.HasPendingPolicies(content.ContentItem) ?? false))   // Se l'oggetto ha delle pending policies allora devo scrivere la lista delle pending policies
                {
                    pendingPolicies = _policyServices.PendingPolicies(content.ContentItem);
                }
                else
                {
                    pendingPolicies = new List <IContent>();
                }
            }
        }
        public ActionResult Terms(string alias, int maxLevel = 10)
        {
            var content = _commonServices.GetContentByAlias(alias);

            if (content == null)
            {
                return(new HttpStatusCodeResult(404));
            }
            // TODO: Permissions
            var json = _contentSerializationServices.Terms(content, maxLevel);

            return(Content(json.ToString(Newtonsoft.Json.Formatting.None), "application/json"));
        }
Ejemplo n.º 5
0
        private void SetPendingPolicies()
        {
            if (pendingPolicies != null)
            {
                return;
            }
            var    routeData      = HttpContext.Current.Request.RequestContext.RouteData;
            string areaName       = (routeData.Values["area"] ?? string.Empty).ToString();
            string controllerName = (routeData.Values["controller"] ?? string.Empty).ToString();
            string actionName     = (routeData.Values["action"] ?? string.Empty).ToString();

            if (areaName.Equals("Laser.Orchard.WebServices", StringComparison.InvariantCultureIgnoreCase) &&
                controllerName.Equals("WebApi", StringComparison.InvariantCultureIgnoreCase) &&
                actionName.Equals("display", StringComparison.InvariantCultureIgnoreCase))
            {
                string alias = (HttpContext.Current.Request.Params["alias"] ?? string.Empty).ToString();

                var content = _commonServices.GetContentByAlias(alias);
                //_maxLevel = maxLevel;
                if (content != null)
                {
                    var policy = content.As <Models.PolicyPart>();
                    if (policy != null && (policy.HasPendingPolicies ?? false))   // Se l'oggetto ha delle pending policies allora devo serivre la lista delle pending policies
                    {
                        pendingPolicies = policy.PendingPolicies;
                    }
                    else
                    {
                        pendingPolicies = new List <IContent>();
                    }
                }
            }
        }