Beispiel #1
0
 public RichTextBoxEditorModel(RichTextBoxPreValueModel preValues, IRebelApplicationContext appContext, HiveId currNodeId)
     : base(preValues)
 {
     _appContext   = appContext;
     CurrentNodeId = currNodeId;
     CreateToolbarButtons();
 }
        public FixedPropertyEditors(IRebelApplicationContext fakeRebelApplicationContext)
        {
            var fakeBackOfficeContext = new FakeBackOfficeRequestContext(fakeRebelApplicationContext);

            _propertyEditors = new PropertyEditor[]
            {
                new NonMandatoryPropertyEditor(Guid.Parse("D3DC1AC8-F83D-4D73-A13B-024E3100A600"), "rte", ""),
                new NonMandatoryPropertyEditor(Guid.Parse("781FA5A4-C26D-4BBB-9F58-6CBBE0A9D14A"), "cust", ""),
                new NonMandatoryPropertyEditor(Guid.Parse("3F5ED845-7018-4BDE-AB4E-C7106EE0992D"), "text", ""),
                new NonMandatoryPropertyEditor(Guid.Parse("9CCB7060-3550-11E0-8A80-074CDFD72085"), "swatch", ""),
                new NonMandatoryPropertyEditor(Guid.Parse("2B4DF3F1-C84E-4611-87EE-1D90ED437337"), "tags", ""),
                new NonMandatoryPropertyEditor(),
                new MandatoryPropertyEditor(),
                new RegexPropertyEditor(),
                new PreValueRegexPropertyEditor(),
                //ensure node name is there
                new NodeNameEditor(fakeBackOfficeContext.Application),
                new SelectedTemplateEditor(fakeBackOfficeContext),
                new UploadEditor(fakeBackOfficeContext),
                new LabelEditor(),
                new TrueFalseEditor(),
                new DateTimePickerEditor(),
                new NumericEditor(),
                new TreeNodePicker(Enumerable.Empty <Lazy <TreeController, TreeMetadata> >()),
                new ListPickerEditor(),
                new TestContentAwarePropertyEditor()
            };
        }
        private static void CopyFilesToPackage(IPackageBuilder builder, IRebelApplicationContext appContext,
                                               string storeUri, IEnumerable <HiveId> fileIds, string targetRootPath,
                                               Action <Rebel.Framework.Persistence.Model.IO.File, IPackageBuilder> callback = null)
        {
            using (var uow = appContext.Hive.OpenReader <IFileStore>(new Uri(storeUri)))
            {
                var root  = uow.Repositories.Get <Rebel.Framework.Persistence.Model.IO.File>(new HiveId("/"));
                var files = uow.Repositories.Get <Rebel.Framework.Persistence.Model.IO.File>(true, fileIds.ToArray())
                            .Where(x => !x.IsContainer);

                foreach (var file in files)
                {
                    builder.Files.Add(new ByteArrayPackageFile
                    {
                        Contents   = file.ContentBytes,
                        TargetPath = targetRootPath + file.RootRelativePath.TrimStart(root.RootRelativePath).TrimStart("/")
                    });

                    if (callback != null)
                    {
                        callback.Invoke(file, builder);
                    }
                }
            }
        }
        public FixedPropertyEditors(IRebelApplicationContext fakeRebelApplicationContext)
        {
            var fakeBackOfficeContext = new FakeBackOfficeRequestContext(fakeRebelApplicationContext);

            _propertyEditors = new PropertyEditor[]
                {
                    new NonMandatoryPropertyEditor(Guid.Parse("D3DC1AC8-F83D-4D73-A13B-024E3100A600"), "rte", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("781FA5A4-C26D-4BBB-9F58-6CBBE0A9D14A"), "cust", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("3F5ED845-7018-4BDE-AB4E-C7106EE0992D"), "text", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("9CCB7060-3550-11E0-8A80-074CDFD72085"), "swatch", ""),
                    new NonMandatoryPropertyEditor(Guid.Parse("2B4DF3F1-C84E-4611-87EE-1D90ED437337"), "tags", ""),
                    new NonMandatoryPropertyEditor(),
                    new MandatoryPropertyEditor(),
                    new RegexPropertyEditor(),
                    new PreValueRegexPropertyEditor(),
                    //ensure node name is there
                    new NodeNameEditor(fakeBackOfficeContext.Application),
                    new SelectedTemplateEditor(fakeBackOfficeContext),
                    new UploadEditor(fakeBackOfficeContext),
                    new LabelEditor(),
                    new TrueFalseEditor(),
                    new DateTimePickerEditor(),
                    new NumericEditor(),
                    new TreeNodePicker(Enumerable.Empty<Lazy<TreeController, TreeMetadata>>()),
                    new ListPickerEditor(),
                    new TestContentAwarePropertyEditor()
                };
        }
        /// <summary>
        ///   Returns true if all providers have a Completed installation status
        /// </summary>
        /// <param name="appContext"> </param>
        /// <returns> </returns>
        public static bool AllProvidersInstalled(this IRebelApplicationContext appContext)
        {
            return(appContext.FrameworkContext.ApplicationCache.GetOrCreate(
                       "all-providers-installed",
                       () =>
            {
                var isInstalled = appContext.GetInstallStatus().All(status => status.StatusType == InstallStatusType.Completed);

                // If not all providers are installed, basically don't cache it
                if (isInstalled)
                {
                    return new HttpRuntimeCacheParameters <bool>(true)
                    {
                        CacheItemPriority = CacheItemPriority.NotRemovable, AbsoluteExpiration = DateTime.MaxValue
                    };
                }
                else
                {
                    return new HttpRuntimeCacheParameters <bool>(false)
                    {
                        SlidingExpiration = TimeSpan.FromMilliseconds(1)
                    };
                }
            }));
        }
Beispiel #6
0
 public RenderRouteHandler(IControllerFactory controllerFactory,
                           IRebelApplicationContext applicationContext,
                           IRenderModelFactory modelFactory)
 {
     _modelFactory       = modelFactory;
     _applicationContext = applicationContext;
     _controllerFactory  = controllerFactory;
 }
 public RenderRouteHandler(IControllerFactory controllerFactory, 
     IRebelApplicationContext applicationContext, 
     IRenderModelFactory modelFactory)
 {
     _modelFactory = modelFactory;
     _applicationContext = applicationContext;
     _controllerFactory = controllerFactory;
 }
 public IgnorePluginRoute(string url, string areaName, IRebelApplicationContext appContext, IEnumerable<ControllerPluginMetadata> toIgnore)
     : base(url, new StopRoutingHandler())
 {
     _areaName = areaName;
     _appContext = appContext;
     _toIgnore = toIgnore;
     Constraints = new RouteValueDictionary { { "ignore-existing", new IgnoreExistingControllersConstraint(appContext, _areaName, _toIgnore) } };
 }
 public RenderBootstrapper(
     IRebelApplicationContext applicationContext, 
     IRouteHandler routeHandler, 
     IRenderModelFactory renderModelFactory)
 {
     _routeHandler = routeHandler;
     _renderModelFactory = renderModelFactory;
     _applicationContext = applicationContext;
 }
 public RenderBootstrapper(
     IRebelApplicationContext applicationContext,
     IRouteHandler routeHandler,
     IRenderModelFactory renderModelFactory)
 {
     _routeHandler       = routeHandler;
     _renderModelFactory = renderModelFactory;
     _applicationContext = applicationContext;
 }
        /// <summary>
        /// Creates a custom individual route for the specified controller plugin. Individual routes
        /// are required by controller plugins to map to a unique URL based on ID.
        /// </summary>
        /// <typeparam name="T">An PluginAttribute</typeparam>
        /// <param name="controllerName"></param>
        /// <param name="controllerType"></param>
        /// <param name="routes">An existing route collection</param>
        /// <param name="routeIdParameterName">the data token name for the controller plugin</param>
        /// <param name="controllerSuffixName">
        /// The suffix name that the controller name must end in before the "Controller" string for example:
        /// ContentTreeController has a controllerSuffixName of "Tree"
        /// </param>
        /// <param name="baseUrlPath">
        /// The base name of the URL to create for example: Rebel/[PackageName]/Trees/ContentTree/1 has a baseUrlPath of "Trees"
        /// </param>
        /// <param name="defaultAction"></param>
        /// <param name="defaultId"></param>
        /// <param name="isDefaultRebelPlugin">If it's a default (built in) Rebel plugin, then make the route with the GUID</param>
        /// <param name="area"></param>
        /// <param name="controllerId"></param>
        /// <param name="appContext"></param>
        /// <param name="rebelTokenValue">The DataToken value to set for the 'rebel' key, this defaults to 'backoffice' </param>
        internal static void RouteControllerPlugin(this AreaRegistration area, Guid controllerId, string controllerName, Type controllerType, RouteCollection routes,
                                                   string routeIdParameterName, string controllerSuffixName, string baseUrlPath, string defaultAction, object defaultId,
                                                   bool isDefaultRebelPlugin, IRebelApplicationContext appContext, string rebelTokenValue = "backoffice")
        {
            Mandate.ParameterNotNullOrEmpty(controllerName, "controllerName");
            Mandate.ParameterNotNullOrEmpty(routeIdParameterName, "routeIdParameterName");
            Mandate.ParameterNotNullOrEmpty(controllerSuffixName, "controllerSuffixName");
            Mandate.ParameterNotNullOrEmpty(defaultAction, "defaultAction");
            Mandate.ParameterNotNull(controllerType, "controllerType");
            Mandate.ParameterNotNull(routes, "routes");
            Mandate.ParameterNotNull(defaultId, "defaultId");

            //the url structure will change whether or not it is a built in Rebel plugin.
            //url to match - if it's a non-Rebel plugin use the GUID to route the request.
            //routes are explicitly name with controller names.
            //if its a plugin controller, then the route will always start with /Rebel/ (BackOfficePath)
            var url = isDefaultRebelPlugin
                          ? area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}"
                          : baseUrlPath.IsNullOrWhiteSpace()
                                ? appContext.Settings.RebelPaths.BackOfficePath + "/" + area.AreaName + "/" + controllerName + "/{action}/{id}"
                                : appContext.Settings.RebelPaths.BackOfficePath + "/" + area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}";

            //create a new route with custom name, specified url, and the namespace of the controller plugin
            var controllerPluginRoute = routes.MapRoute(
                //name
                string.Format("rebel-{0}-{1}", controllerName, controllerId),
                //url format
                url,
                //set the namespace of the controller to match
                new[] { controllerType.Namespace });

            //set defaults
            controllerPluginRoute.Defaults = new RouteValueDictionary(
                new Dictionary<string, object>
                    {
                        { "controller", controllerName },
                        { routeIdParameterName, controllerId.ToString("N") },
                        { "action", defaultAction },
                        { "id", defaultId }    
                    });

            //constraints: only match controllers ending with 'controllerSuffixName' and only match this controller's ID for this route            
            controllerPluginRoute.Constraints = new RouteValueDictionary(
                new Dictionary<string, object>
                    {
                        { "controller", @"(\w+)" + controllerSuffixName },
                        { routeIdParameterName, Regex.Escape(controllerId.ToString("N")) }
                    });
            //now add our custom back office route constraint
            controllerPluginRoute.Constraints.Add("backOffice", new BackOfficeRouteConstraint(appContext));

            //match this area
            controllerPluginRoute.DataTokens.Add("area", area.AreaName);
            controllerPluginRoute.DataTokens.Add("rebel", rebelTokenValue); //ensure the rebel token is set

        }
 public IgnorePluginRoute(string url, string areaName, IRebelApplicationContext appContext, IEnumerable <ControllerPluginMetadata> toIgnore)
     : base(url, new StopRoutingHandler())
 {
     _areaName   = areaName;
     _appContext = appContext;
     _toIgnore   = toIgnore;
     Constraints = new RouteValueDictionary {
         { "ignore-existing", new IgnoreExistingControllersConstraint(appContext, _areaName, _toIgnore) }
     };
 }
        public RoutableRequestContext(IRebelApplicationContext applicationContext, ComponentRegistrations components, IRoutingEngine routingEngine)
        {
            Mandate.ParameterNotNull(applicationContext, "applicationContext");
            Mandate.ParameterNotNull(components, "components");
            Mandate.ParameterNotNull(routingEngine, "routingEngine");

            Application = applicationContext;
            RegisteredComponents = components;
            RoutingEngine = routingEngine;
        }
        public RoutableRequestContext(IRebelApplicationContext applicationContext, ComponentRegistrations components, IRoutingEngine routingEngine)
        {
            Mandate.ParameterNotNull(applicationContext, "applicationContext");
            Mandate.ParameterNotNull(components, "components");
            Mandate.ParameterNotNull(routingEngine, "routingEngine");

            Application          = applicationContext;
            RegisteredComponents = components;
            RoutingEngine        = routingEngine;
        }
Beispiel #15
0
        /// <summary>
        /// Creates a custom individual route for the specified controller plugin. Individual routes
        /// are required by controller plugins to map to a unique URL based on ID.
        /// </summary>
        /// <typeparam name="T">An PluginAttribute</typeparam>
        /// <param name="controllerName"></param>
        /// <param name="controllerType"></param>
        /// <param name="routes">An existing route collection</param>
        /// <param name="routeIdParameterName">the data token name for the controller plugin</param>
        /// <param name="controllerSuffixName">
        /// The suffix name that the controller name must end in before the "Controller" string for example:
        /// ContentTreeController has a controllerSuffixName of "Tree"
        /// </param>
        /// <param name="baseUrlPath">
        /// The base name of the URL to create for example: Rebel/[PackageName]/Trees/ContentTree/1 has a baseUrlPath of "Trees"
        /// </param>
        /// <param name="defaultAction"></param>
        /// <param name="defaultId"></param>
        /// <param name="isDefaultRebelPlugin">If it's a default (built in) Rebel plugin, then make the route with the GUID</param>
        /// <param name="area"></param>
        /// <param name="controllerId"></param>
        /// <param name="appContext"></param>
        /// <param name="rebelTokenValue">The DataToken value to set for the 'rebel' key, this defaults to 'backoffice' </param>
        internal static void RouteControllerPlugin(this AreaRegistration area, Guid controllerId, string controllerName, Type controllerType, RouteCollection routes,
                                                   string routeIdParameterName, string controllerSuffixName, string baseUrlPath, string defaultAction, object defaultId,
                                                   bool isDefaultRebelPlugin, IRebelApplicationContext appContext, string rebelTokenValue = "backoffice")
        {
            Mandate.ParameterNotNullOrEmpty(controllerName, "controllerName");
            Mandate.ParameterNotNullOrEmpty(routeIdParameterName, "routeIdParameterName");
            Mandate.ParameterNotNullOrEmpty(controllerSuffixName, "controllerSuffixName");
            Mandate.ParameterNotNullOrEmpty(defaultAction, "defaultAction");
            Mandate.ParameterNotNull(controllerType, "controllerType");
            Mandate.ParameterNotNull(routes, "routes");
            Mandate.ParameterNotNull(defaultId, "defaultId");

            //the url structure will change whether or not it is a built in Rebel plugin.
            //url to match - if it's a non-Rebel plugin use the GUID to route the request.
            //routes are explicitly name with controller names.
            //if its a plugin controller, then the route will always start with /Rebel/ (BackOfficePath)
            var url = isDefaultRebelPlugin
                          ? area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}"
                          : baseUrlPath.IsNullOrWhiteSpace()
                                ? appContext.Settings.RebelPaths.BackOfficePath + "/" + area.AreaName + "/" + controllerName + "/{action}/{id}"
                                : appContext.Settings.RebelPaths.BackOfficePath + "/" + area.AreaName + "/" + baseUrlPath + "/" + controllerName + "/{action}/{id}";

            //create a new route with custom name, specified url, and the namespace of the controller plugin
            var controllerPluginRoute = routes.MapRoute(
                //name
                string.Format("rebel-{0}-{1}", controllerName, controllerId),
                //url format
                url,
                //set the namespace of the controller to match
                new[] { controllerType.Namespace });

            //set defaults
            controllerPluginRoute.Defaults = new RouteValueDictionary(
                new Dictionary <string, object>
            {
                { "controller", controllerName },
                { routeIdParameterName, controllerId.ToString("N") },
                { "action", defaultAction },
                { "id", defaultId }
            });

            //constraints: only match controllers ending with 'controllerSuffixName' and only match this controller's ID for this route
            controllerPluginRoute.Constraints = new RouteValueDictionary(
                new Dictionary <string, object>
            {
                { "controller", @"(\w+)" + controllerSuffixName },
                { routeIdParameterName, Regex.Escape(controllerId.ToString("N")) }
            });
            //now add our custom back office route constraint
            controllerPluginRoute.Constraints.Add("backOffice", new BackOfficeRouteConstraint(appContext));

            //match this area
            controllerPluginRoute.DataTokens.Add("area", area.AreaName);
            controllerPluginRoute.DataTokens.Add("rebel", rebelTokenValue); //ensure the rebel token is set
        }
 /// <summary>
 /// Constructor using a specific RebelSettings object
 /// </summary>
 /// <param name="applicationContext"></param>
 /// <param name="componentRegistrar"></param>
 public RebelAreaRegistration(
     IRebelApplicationContext applicationContext,
     ComponentRegistrations componentRegistrar)
 {
     _applicationContext = applicationContext;
     _rebelSettings      = _applicationContext.Settings;
     _componentRegistrar = componentRegistrar;
     _treeControllers    = _componentRegistrar.TreeControllers;
     _editorControllers  = _componentRegistrar.EditorControllers;
     _surfaceControllers = _componentRegistrar.SurfaceControllers;
 }
 public ContentCacheManager(IRebelApplicationContext context, Controller controller)
 {
     _context = context;
     _urlHelper = controller.Url;
     _controllerContext = controller.ControllerContext;
     _viewData = controller.ViewData;
     _tempData = controller.TempData;
     _requestContext = controller.HttpContext.Request;
     
     EnsureCacheWarmed();
 }
 /// <summary>
 /// Constructor using a specific RebelSettings object
 /// </summary>
 /// <param name="applicationContext"></param>
 /// <param name="componentRegistrar"></param>
 public RebelAreaRegistration(
     IRebelApplicationContext applicationContext,
     ComponentRegistrations componentRegistrar)
 {
     _applicationContext = applicationContext;
     _rebelSettings = _applicationContext.Settings;
     _componentRegistrar = componentRegistrar;
     _treeControllers = _componentRegistrar.TreeControllers;
     _editorControllers = _componentRegistrar.EditorControllers;
     _surfaceControllers = _componentRegistrar.SurfaceControllers;
 }
        public ContentCacheManager(IRebelApplicationContext context, Controller controller)
        {
            _context           = context;
            _urlHelper         = controller.Url;
            _controllerContext = controller.ControllerContext;
            _viewData          = controller.ViewData;
            _tempData          = controller.TempData;
            _requestContext    = controller.HttpContext.Request;

            EnsureCacheWarmed();
        }
        public PackageAreaRegistration(DirectoryInfo packageFolder,
                                       IRebelApplicationContext applicationContext,
                                       ComponentRegistrations componentRegistrar)
        {
            //TODO: do we need to validate the package name??

            _packageName = packageFolder.Name;

            _packageFolder      = packageFolder;
            _applicationContext = applicationContext;
            _componentRegistrar = componentRegistrar;
            _treeControllers    = _componentRegistrar.TreeControllers;
            _editorControllers  = _componentRegistrar.EditorControllers;
            _surfaceControllers = componentRegistrar.SurfaceControllers;
        }
        public DefaultBackOfficeRequestContext(IRebelApplicationContext applicationContext,
                                               HttpContextBase httpContext,
                                               ComponentRegistrations components,
                                               IPackageContext packageContext,
                                               IRoutingEngine routingEngine)
            : base(applicationContext, components, routingEngine)
        {
            //create the IO resolvers
            var urlHelper = new UrlHelper(httpContext.Request.RequestContext);

            DocumentTypeIconResolver      = new DocumentTypeIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            DocumentTypeThumbnailResolver = new DocumentTypeThumbnailFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            ApplicationIconResolver       = new ApplicationIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);

            PackageContext = packageContext;
        }
        public DefaultBackOfficeRequestContext(IRebelApplicationContext applicationContext,
            HttpContextBase httpContext,
            ComponentRegistrations components,
            IPackageContext packageContext,
            IRoutingEngine routingEngine)
            : base(applicationContext, components, routingEngine)
        {

            //create the IO resolvers
            var urlHelper = new UrlHelper(httpContext.Request.RequestContext);
            DocumentTypeIconResolver = new DocumentTypeIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            DocumentTypeThumbnailResolver = new DocumentTypeThumbnailFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);
            ApplicationIconResolver = new ApplicationIconFileResolver(httpContext.Server, applicationContext.Settings, urlHelper);

            PackageContext = packageContext;
        }
        private static void CopyFolderToPackage(IPackageBuilder builder, IRebelApplicationContext appContext,
                                                string rootPath, string path, Func <string, string, string> targetPathCallback)
        {
            var files = Directory.GetFiles(path);

            foreach (var file in files)
            {
                builder.Files.Add(new PhysicalPackageFile
                {
                    SourcePath = file,
                    TargetPath = targetPathCallback.Invoke(rootPath, file)
                });
            }

            var dirs = Directory.GetDirectories(path);

            foreach (var dir in dirs)
            {
                CopyFolderToPackage(builder, appContext, rootPath, dir, targetPathCallback);
            }
        }
Beispiel #24
0
        public virtual IRebelApplicationContext Start()
        {
            LogHelper.TraceIfEnabled <RebelWebApplication>("Start called. Product info: {0} build {1}", () => RebelWebApplication.ProductVersionInfo, () => RebelWebApplication.ProductVersion);
            using (var bootManager = CreateBootManager())
            {
                bootManager
                .AddAppErrorHandler(OnApplicationError)
                .InitializeContainer(() => _containerBuilder)
                .AddContainerBuildingHandler(OnContainerBuilding)
                .AddContainerBuildingCompleteHandler(OnContainerBuildingComplete)
                .SetMvcResolverFactory(_mvcResolverFactory)
                .MvcAreaRegistration(_registerAreas)
                .MvcCustomRouteRegistration(_registerCustomRoutes)
                .MvcDefaultRouteRegistration(_registerDefaultRoutes)
                .MvcGlobalFilterRegistration(_registerFilters);

                _appContext = Boot(bootManager);
                _isStarted  = true;
            }
            return(AppContext);
        }
 public RebelRenderModel(IRebelApplicationContext baseContext, Content renderItem)
 {
     _baseContext = baseContext;
     _renderItem = renderItem;
 }
 public FakeBackOfficeRequestContext(IRebelApplicationContext application)
     : base(application)
 {
 }
 public PluginControllerFactory(IRebelApplicationContext applicationContext)
 {
     Mandate.ParameterNotNull(applicationContext, "applicationContext");
     ApplicationContext = applicationContext;
 }
 public RenderRouteConstraint(IRebelApplicationContext applicationContext, IRenderModelFactory modelFactory)
     : base(applicationContext.Settings.RouteMatches)
 {
     _applicationContext = applicationContext;
     _modelFactory = modelFactory;
 }
Beispiel #29
0
 public static DevDataset GetDemoData(IRebelApplicationContext appContext, IAttributeTypeRegistry attributeTypeRegistry)
 {
     return new DevDataset(new MockedPropertyEditorFactory(appContext), appContext.FrameworkContext, attributeTypeRegistry);
 }
Beispiel #30
0
 public UserGroupUsersEditorModel(string userGroupName, IRebelApplicationContext appContext)
 {
     _userGroupName = userGroupName;
     _appContext    = appContext;
 }
 public MembersMembershipProvider(IHiveManager hiveManager, IRebelApplicationContext appContext)
 {
     base.HiveManager = hiveManager;
     this.AppContext = appContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRoutingEngine"/> class.
 /// </summary>
 /// <param name="appContext">The routable request context.</param>
 /// <param name="httpContext"></param>
 public DefaultRoutingEngine(IRebelApplicationContext appContext, HttpContextBase httpContext)
 {
     _applicationContext = appContext;
     _httpContext = httpContext;
 }
Beispiel #33
0
 public MembersMembershipProvider(IHiveManager hiveManager, IRebelApplicationContext appContext)
 {
     base.HiveManager = hiveManager;
     this.AppContext  = appContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationTaskBuilder"/> class.
 /// </summary>
 /// <param name="applicationContext">The application context.</param>
 public ConfigurationTaskBuilder(IRebelApplicationContext applicationContext)
     : base(applicationContext)
 {
 }
        public static CreatePackageResult CreatePackage(string id, PackageDefinition packageDef, IRebelApplicationContext appContext,
                                                        HttpContextWrapper httpContext)
        {
            var result = new CreatePackageResult();

            try
            {
                var packagePath = string.Format("~/App_Data/Rebel/CreatedPackages/{0}", id);
                var packageDir  = new DirectoryInfo(httpContext.Server.MapPath(packagePath));
                var packageFile = new FileInfo(Path.Combine(packageDir.FullName, "package.nupkg"));

                // Build package
                var builder = new PackageBuilder
                {
                    Id          = packageDef.Alias,
                    Title       = packageDef.Name,
                    Version     = new Version(packageDef.Version),
                    Description = packageDef.Description,
                    ProjectUrl  = new Uri(packageDef.ProjectUrl)
                };
                builder.Authors.Add(packageDef.Author);

                if (!string.IsNullOrWhiteSpace(packageDef.Tags))
                {
                    builder.Tags.AddRange(packageDef.Tags.Split(' '));
                }

                if (!string.IsNullOrWhiteSpace(packageDef.LicenseUrl))
                {
                    builder.LicenseUrl = new Uri(packageDef.LicenseUrl);
                }

                using (var uow = appContext.Hive.OpenReader <IContentStore>())
                {
                    var uploadedFilesToPackage = new List <HiveId>();

                    // Content
                    if (!packageDef.ContentNodeId.IsNullValueOrEmpty())
                    {
                        var relationsToSerialize = new List <IRelationById>();
                        var nodesToSerialize     = new List <TypedEntity>();

                        var contentNode = uow.Repositories.Get <TypedEntity>(packageDef.ContentNodeId);
                        nodesToSerialize.Add(contentNode);
                        var parentRelations = uow.Repositories.GetParentRelations(contentNode.Id, FixedRelationTypes.DefaultRelationType);
                        relationsToSerialize.AddRange(parentRelations);

                        if (packageDef.IncludeChildContentNodes)
                        {
                            var childrenRelations = uow.Repositories.GetDescendentRelations(contentNode.Id, FixedRelationTypes.DefaultRelationType);
                            nodesToSerialize.AddRange(uow.Repositories.Get <TypedEntity>(true, childrenRelations.Select(x => x.DestinationId).ToArray()));
                            relationsToSerialize.AddRange(childrenRelations);
                        }

                        foreach (var node in nodesToSerialize.Where(x => x.Attributes.Any(y => y.AttributeDefinition.AttributeType.RenderTypeProvider.InvariantEquals(CorePluginConstants.FileUploadPropertyEditorId))))
                        {
                            var attributes = node.Attributes.Where(x => x.AttributeDefinition.AttributeType.RenderTypeProvider.InvariantEquals(CorePluginConstants.FileUploadPropertyEditorId));
                            uploadedFilesToPackage.AddRange(attributes.Where(x => x.Values["Value"] != null).Select(attribute => HiveId.Parse(attribute.Values["Value"].ToString())));
                        }

                        CopySerializedObjectsToPackage(builder, appContext, nodesToSerialize,
                                                       node => "Data/Content/" + node.Id.ToString().ToMd5() + ".json");

                        // Relations
                        CopySerializedObjectsToPackage(builder, appContext, relationsToSerialize,
                                                       relation => "Data/Content/Relations/" + relation.SourceId.ToString().ToMd5() + "-" + relation.DestinationId.ToString().ToMd5() + ".json");
                    }

                    // Media
                    if (!packageDef.MediaNodeId.IsNullValueOrEmpty())
                    {
                        var relationsToSerialize = new List <IRelationById>();
                        var nodesToSerialize     = new List <TypedEntity>();

                        var mediaNode = uow.Repositories.Get <TypedEntity>(packageDef.MediaNodeId);
                        if (mediaNode != null)
                        {
                            nodesToSerialize.Add(mediaNode);
                            var parentRelations = uow.Repositories.GetParentRelations(mediaNode.Id, FixedRelationTypes.DefaultRelationType);
                            relationsToSerialize.AddRange(parentRelations);

                            if (packageDef.IncludeChildContentNodes)
                            {
                                var childrenRelations = uow.Repositories.GetDescendentRelations(mediaNode.Id, FixedRelationTypes.DefaultRelationType);
                                nodesToSerialize.AddRange(uow.Repositories.Get <TypedEntity>(true, childrenRelations.Select(x => x.DestinationId).ToArray()));
                                relationsToSerialize.AddRange(childrenRelations);
                            }
                        }

                        foreach (var node in nodesToSerialize.Where(x => x.Attributes.Any(y => y.AttributeDefinition.AttributeType.RenderTypeProvider.InvariantEquals(CorePluginConstants.FileUploadPropertyEditorId))))
                        {
                            var attributes = node.Attributes.Where(x => x.AttributeDefinition.AttributeType.RenderTypeProvider.InvariantEquals(CorePluginConstants.FileUploadPropertyEditorId));
                            uploadedFilesToPackage.AddRange(attributes.Where(x => x.Values["Value"] != null).Select(attribute => HiveId.Parse(attribute.Values["Value"].ToString())));
                        }

                        CopySerializedObjectsToPackage(builder, appContext, nodesToSerialize,
                                                       node => "Data/Media/" + node.Id.ToString().ToMd5() + ".json");

                        // Relations
                        CopySerializedObjectsToPackage(builder, appContext, relationsToSerialize,
                                                       relation => "Data/Media/Relations/" + relation.SourceId.ToString().ToMd5() + "-" + relation.DestinationId.ToString().ToMd5() + ".json");
                    }

                    // Files
                    CopyFilesToPackage(builder, appContext, "storage://file-uploader", uploadedFilesToPackage, "Content/Content/Media/");

                    // Dictionary Items
                    var dictionaryRelationsToSerialize = new List <IRelationById>();
                    var dictionaryItems = uow.Repositories.Get <TypedEntity>(true, packageDef.DictionaryItemIds.ToArray());
                    CopySerializedObjectsToPackage(builder, appContext, dictionaryItems,
                                                   dictionaryItem => "Data/DictionaryItems/" + dictionaryItem.Id.ToString().ToMd5() + ".json");

                    foreach (var parentRelations in dictionaryItems.Select(dictionaryItem => uow.Repositories.GetParentRelations(dictionaryItem.Id)))
                    {
                        dictionaryRelationsToSerialize.AddRange(parentRelations);
                    }

                    CopySerializedObjectsToPackage(builder, appContext, dictionaryRelationsToSerialize,
                                                   relation => "Data/DictionaryItems/Relations/" + relation.SourceId.ToString().ToMd5() + "-" + relation.DestinationId.ToString().ToMd5() + ".json");

                    // Doc Types
                    var docTypeRelationsToSerialize = new List <IRelationById>();
                    var docTypes = uow.Repositories.Schemas.Get <EntitySchema>(true, packageDef.DocumentTypeIds.ToArray());
                    CopySerializedObjectsToPackage(builder, appContext, docTypes, docType => "Data/DocumentTypes/" + docType.Alias + ".json");

                    foreach (var parentRelations in docTypes.Select(docType => uow.Repositories.Schemas.GetParentRelations(docType.Id)))
                    {
                        docTypeRelationsToSerialize.AddRange(parentRelations);
                    }

                    CopySerializedObjectsToPackage(builder, appContext, docTypeRelationsToSerialize,
                                                   relation => "Data/DocumentTypes/Relations/" + relation.SourceId.ToString().ToMd5() + "-" + relation.DestinationId.ToString().ToMd5() + ".json");

                    // Media Types
                    var mediaTypeRelationsToSerialize = new List <IRelationById>();
                    var mediaTypes = uow.Repositories.Schemas.Get <EntitySchema>(true, packageDef.MediaTypeIds.ToArray());
                    CopySerializedObjectsToPackage(builder, appContext, mediaTypes, mediaType => "Data/MediaTypes/" + mediaType.Alias + ".json");

                    foreach (var parentRelations in mediaTypes.Select(mediaType => uow.Repositories.Schemas.GetParentRelations(mediaType.Id)))
                    {
                        mediaTypeRelationsToSerialize.AddRange(parentRelations);
                    }

                    CopySerializedObjectsToPackage(builder, appContext, mediaTypeRelationsToSerialize,
                                                   relation => "Data/MediaTypes/Relations/" + relation.SourceId.ToString().ToMd5() + "-" + relation.DestinationId.ToString().ToMd5() + ".json");

                    // Data Types
                    var dataTypes = uow.Repositories.Schemas.Get <AttributeType>(true, packageDef.DataTypeIds.ToArray());
                    CopySerializedObjectsToPackage(builder, appContext, dataTypes, dataType => "Data/DataTypes/" + dataType.Alias + ".json");
                }

                // Templates
                CopyFilesToPackage(builder, appContext, "storage://templates", packageDef.TemplateIds, "Content/Views/");

                // Partials
                CopyFilesToPackage(builder, appContext, "storage://partials", packageDef.PartialIds, "Content/Views/Partials/");

                // Stylesheets
                CopyFilesToPackage(builder, appContext, "storage://stylesheets", packageDef.StylesheetIds, "Content/Content/Styles/");

                // Scripts
                CopyFilesToPackage(builder, appContext, "storage://scripts", packageDef.ScriptIds, "Content/Scripts/");

                // Macros
                CopyFilesToPackage(builder, appContext, "storage://macros", packageDef.MacroIds, "Content/App_Data/Rebel/Macros/",
                                   (file, packageBuilder) =>
                {
                    var macro = MacroSerializer.FromFile(file);
                    if (macro.MacroType == "PartialView")
                    {
                        var macroParts = macro.SelectedItem.Split('-');
                        var areaName   = macroParts.Length > 1 ? macroParts[0] : "";

                        var macroName = (areaName.IsNullOrWhiteSpace())
                            ? string.Join("", macroParts)
                            : macroParts[1];

                        var relativePath = (areaName.IsNullOrWhiteSpace())
                            ? "~/Views/MacroPartials/" + macroName + ".cshtml"
                            : "~/App_Plugins/Packages/" + areaName + "/Views/MacroPartials/" + macroName + ".cshtml";

                        var path = httpContext.Server.MapPath(relativePath);

                        packageBuilder.Files.Add(new PhysicalPackageFile
                        {
                            SourcePath = path,
                            TargetPath = "Content/Views/MacroPartials/" + macroName + ".cshtml"
                        });
                    }
                });

                // Languages
                var languages = appContext.Settings.Languages.Where(x => packageDef.LanguageIds.Contains(x.IsoCode));
                CopySerializedObjectsToPackage(builder, appContext, languages, lang => "Data/Languages/" + lang.IsoCode + ".json");

                // Misc files
                foreach (var file in packageDef.AdditionalFiles)
                {
                    var cleanFile     = "~/" + file.Replace('\\', '/').TrimStart('~', '/');
                    var cleanFilePath = httpContext.Server.MapPath(cleanFile);

                    if (!File.Exists(cleanFilePath) && !Directory.Exists(cleanFilePath))
                    {
                        continue;
                    }

                    var fileInfo    = File.GetAttributes(cleanFilePath);
                    var isDirectory = (fileInfo & FileAttributes.Directory) == FileAttributes.Directory;

                    if (cleanFile.StartsWith("~/App_Plugins/Packages/" + packageDef.Alias + "/", true, CultureInfo.InvariantCulture))
                    {
                        if (isDirectory)
                        {
                            CopyFolderToPackage(builder, appContext, httpContext.Server.MapPath("~/App_Plugins/Packages/" + packageDef.Alias + "/"),
                                                cleanFilePath, (rootPath, path) => path.TrimStart(rootPath).Replace('\\', '/'));
                        }
                        else
                        {
                            builder.Files.Add(new PhysicalPackageFile
                            {
                                SourcePath = httpContext.Server.MapPath(cleanFile),
                                TargetPath = Regex.Replace(cleanFile, "^~/App_Plugins/Packages/" + packageDef.Alias + "/", "", RegexOptions.IgnoreCase)
                            });
                        }
                    }
                    else if (cleanFile.StartsWith("~/Bin/", true, CultureInfo.InvariantCulture))
                    {
                        if (isDirectory)
                        {
                            CopyFolderToPackage(builder, appContext, httpContext.Server.MapPath("~/Bin/"),
                                                cleanFilePath, (rootPath, path) => "lib/" + path.TrimStart(rootPath).Replace('\\', '/'));
                        }
                        else
                        {
                            builder.Files.Add(new PhysicalPackageFile
                            {
                                SourcePath = httpContext.Server.MapPath(cleanFile),
                                TargetPath = "lib/" + Regex.Replace(cleanFile, "^~/Bin/", "", RegexOptions.IgnoreCase)
                            });
                        }
                    }
                    else
                    {
                        if (isDirectory)
                        {
                            CopyFolderToPackage(builder, appContext, httpContext.Server.MapPath("~/"),
                                                cleanFilePath, (rootPath, path) => "Content/" + path.TrimStart(rootPath).Replace('\\', '/'));
                        }
                        else
                        {
                            builder.Files.Add(new PhysicalPackageFile
                            {
                                SourcePath = httpContext.Server.MapPath(cleanFile),
                                TargetPath = "Content/" + Regex.Replace(cleanFile, "^~/", "", RegexOptions.IgnoreCase)
                            });
                        }
                    }
                }

                // Web.config
                if (!string.IsNullOrWhiteSpace(packageDef.Config))
                {
                    builder.Files.Add(new ByteArrayPackageFile
                    {
                        Contents   = Encoding.UTF8.GetBytes(packageDef.Config),
                        TargetPath = "Web.config"
                    });
                }

                // Write package to disc
                using (Stream stream = File.Create(packageFile.FullName))
                {
                    builder.Save(stream);
                }

                // If we've gotten this far, everything must have gone ok
                result.Success = true;
            }
            catch (global::System.Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }

            return(result);
        }
 public FakeBackOfficeRequestContext(IRebelApplicationContext application)
     : base(application)
 {
 }
 private static void CopySerializedObjectsToPackage <T>(IPackageBuilder builder, IRebelApplicationContext appContext,
                                                        IEnumerable <T> objects, Func <T, string> targetPathCallback)
 {
     foreach (var obj in objects)
     {
         var serializeResult = appContext.FrameworkContext.Serialization.ToStream(obj);
         if (serializeResult.Success)
         {
             builder.Files.Add(new StreamPackageFile
             {
                 Contents   = serializeResult.ResultStream,
                 TargetPath = targetPathCallback.Invoke(obj)
             });
         }
     }
 }
 public FakeRoutableRequestContext(IRebelApplicationContext application)
 {
     Application = application;
 }
 public DictionaryHelper(IRebelApplicationContext appContext)
     : this(appContext.Hive, appContext.Settings.Languages)
 {
 }
 public MockedPropertyEditorFactory(IRebelApplicationContext appContext)
 {
     _propEditors = new FixedPropertyEditors(appContext).GetPropertyEditorDefinitions();
 }
 public TypePickerEditor(IRebelApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
Beispiel #42
0
 public RichTextBoxEditor(IRebelApplicationContext appContext)
 {
     _appContext = appContext;
 }
Beispiel #43
0
 /// <summary>
 /// Creates a new instance of the MacroRender class that provides utility methods for compiling and rendering macros.
 /// </summary>
 public MacroRenderer(ComponentRegistrations componentRegistrations, IRoutableRequestContext routableRequestContext)
 {
     _componentRegistrations = componentRegistrations;
     _routableRequestContext = routableRequestContext;
     _applicationContext     = routableRequestContext.Application;
 }
 public FakeBackOfficeRequestContext(IRebelApplicationContext application, IRoutingEngine engine)
     : base(application, engine)
 {
     
 }
 public IgnoreExistingControllersConstraint(IRebelApplicationContext appContext, string areaName, IEnumerable<ControllerPluginMetadata> toIgnore)
 {
     _appContext = appContext;
     _areaName = areaName;
     _toIgnore = toIgnore.Select(x => x.ControllerName).ToArray();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationTaskBuilder"/> class.
 /// </summary>
 /// <param name="applicationContext">The application context.</param>
 public ConfigurationTaskBuilder(IRebelApplicationContext applicationContext)
     : base(applicationContext)
 {
 }
 public MockedPropertyEditorFactory(IRebelApplicationContext appContext)
 {
     _propEditors = new FixedPropertyEditors(appContext).GetPropertyEditorDefinitions();
 }
 public FakeRenderModelFactory(IRebelApplicationContext application)
 {
     _application = application;
 }
 public FakeBackOfficeRequestContext(IRebelApplicationContext application, IRoutingEngine engine)
     : base(application, engine)
 {
 }
 public ConfigurationTaskContext(IRebelApplicationContext applicationContext, IEnumerable<ITaskParameter> parameters, ITask task)
 {
     Parameters = parameters.ToDictionary(x => x.Name, x => x.Value);
     Task = task;
     ApplicationContext = applicationContext;
 }
 public RebelRenderModel(IRebelApplicationContext baseContext, Func<Content> renderItemDeferred)
 {
     _baseContext = baseContext;
     _renderItemDeferred = renderItemDeferred;
 }
Beispiel #52
0
 public ConfigurationTaskContext(IRebelApplicationContext applicationContext, IEnumerable <ITaskParameter> parameters, ITask task)
 {
     Parameters         = parameters.ToDictionary(x => x.Name, x => x.Value);
     Task               = task;
     ApplicationContext = applicationContext;
 }
        public virtual IRebelApplicationContext Start()
        {
            LogHelper.TraceIfEnabled<RebelWebApplication>("Start called. Product info: {0} build {1}", () => RebelWebApplication.ProductVersionInfo, () => RebelWebApplication.ProductVersion);
            using (var bootManager = CreateBootManager())
            {
                bootManager
                    .AddAppErrorHandler(OnApplicationError)
                    .InitializeContainer(() => _containerBuilder)
                    .AddContainerBuildingHandler(OnContainerBuilding)
                    .AddContainerBuildingCompleteHandler(OnContainerBuildingComplete)
                    .SetMvcResolverFactory(_mvcResolverFactory)
                    .MvcAreaRegistration(_registerAreas)
                    .MvcCustomRouteRegistration(_registerCustomRoutes)
                    .MvcDefaultRouteRegistration(_registerDefaultRoutes)
                    .MvcGlobalFilterRegistration(_registerFilters);

                _appContext = Boot(bootManager);
                _isStarted = true;
            }
            return AppContext;
        }
Beispiel #54
0
 protected AbstractWebTask(IRebelApplicationContext applicationContext) : base(applicationContext.FrameworkContext)
 {
     ApplicationContext = applicationContext;
 }
 public FakeRoutableRequestContext(IRebelApplicationContext application, IRoutingEngine engine)
 {
     _engine = engine;
     Application = application;
 }
 public BackOfficeRouteConstraint(IRebelApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
 public DocumentTypePropertyModelBinder(IRebelApplicationContext applicationContext)
 {
     _applicationContext = applicationContext;
 }
Beispiel #58
0
 public PluginControllerFactory(IRebelApplicationContext applicationContext)
 {
     Mandate.ParameterNotNull(applicationContext, "applicationContext");
     ApplicationContext = applicationContext;
 }
 public UserGroupUsersEditorModel(string userGroupName, IRebelApplicationContext appContext)
 {
     _userGroupName = userGroupName;
     _appContext = appContext;
 }
 public DictionaryHelper(IRebelApplicationContext appContext)
     : this(appContext.Hive, appContext.Settings.Languages)
 { }