Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            ObjectGiver objectGiver = CreateObjectGiver(context);

            ICruiseRequest cruiseRequest = (ICruiseRequest)objectGiver.GiveObjectByType(typeof(ICruiseRequest));

            if (cruiseRequest.ServerName == "" || cruiseRequest.ProjectName == "" || cruiseRequest.BuildName == "")
            {
                throw new Exception("All of Server, Project and Build Names must be specified on request in order to retrieve a build log");
            }

            string log = ((IBuildRetriever)objectGiver.GiveObjectByType(typeof(IBuildRetriever))).GetBuild(cruiseRequest.BuildSpecifier).Log;

            context.Response.ContentType = "Text/XML";

            // None of this seems to have an effect - doh!
//			context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
//			context.Response.Cache.SetCacheability(HttpCacheability.Public);
//			context.Response.Cache.VaryByParams[RequestWrappingCruiseRequest.ServerQueryStringParameter] = true;
//			context.Response.Cache.VaryByParams[RequestWrappingCruiseRequest.ProjectQueryStringParameter] = true;
//			context.Response.Cache.VaryByParams[RequestWrappingCruiseRequest.BuildQueryStringParameter] = true;

            context.Response.Write(log);
            context.Response.Flush();
        }
        public IResponse Execute(IRequest cruiseRequest)
        {
            Hashtable velocityContext         = new Hashtable();
            IResponse decoratedActionResponse = decoratedAction.Execute(cruiseRequest);

            if (decoratedActionResponse is HtmlFragmentResponse)
            {
                velocityContext["breadcrumbs"]      = (((TopControlsViewBuilder)objectGiver.GiveObjectByType(typeof(TopControlsViewBuilder))).Execute()).ResponseFragment;
                velocityContext["sidebar"]          = (((SideBarViewBuilder)objectGiver.GiveObjectByType(typeof(SideBarViewBuilder))).Execute()).ResponseFragment;
                velocityContext["mainContent"]      = ((HtmlFragmentResponse)decoratedActionResponse).ResponseFragment;
                velocityContext["dashboardversion"] = GetVersion();

                return(velocityViewGenerator.GenerateView("SiteTemplate.vm", velocityContext));
            }
            else
            {
                return(decoratedActionResponse);
            }
        }
Пример #3
0
        public IResponse Execute(IRequest cruiseRequest)
        {
            Hashtable velocityContext         = new Hashtable();
            IResponse decoratedActionResponse = decoratedAction.Execute(cruiseRequest);

            if (decoratedActionResponse is HtmlFragmentResponse)
            {
                ICruiseRequestFactory CruiseRequestFactory = (ICruiseRequestFactory)objectGiver.GiveObjectByType(typeof(ICruiseRequestFactory));
                IBuildNameFormatter   BuildNameFormatter   = (IBuildNameFormatter)objectGiver.GiveObjectByType(typeof(IBuildNameFormatter));
                ICruiseRequest        request = CruiseRequestFactory.CreateCruiseRequest(cruiseRequest);

                if (!string.IsNullOrEmpty(request.ServerName))
                {
                    velocityContext["serverName"] = request.ServerName;
                    if (!string.IsNullOrEmpty(request.ProjectName))
                    {
                        velocityContext["projectName"] = request.ProjectName;
                        if (!string.IsNullOrEmpty(request.BuildName))
                        {
                            velocityContext["prettybuildName"] = BuildNameFormatter.GetPrettyBuildName(request.BuildSpecifier);
                        }
                    }
                }

                velocityContext["breadcrumbs"]      = (((TopControlsViewBuilder)objectGiver.GiveObjectByType(typeof(TopControlsViewBuilder))).Execute()).ResponseFragment;
                velocityContext["sidebar"]          = (((SideBarViewBuilder)objectGiver.GiveObjectByType(typeof(SideBarViewBuilder))).Execute()).ResponseFragment;
                velocityContext["mainContent"]      = ((HtmlFragmentResponse)decoratedActionResponse).ResponseFragment;
                velocityContext["dashboardversion"] = GetVersion();

                return(velocityViewGenerator.GenerateView("SiteTemplate.vm", velocityContext));
            }
            else
            {
                return(decoratedActionResponse);
            }
        }
Пример #4
0
        public IAction Create(IRequest request)
        {
            string actionParam = request.FindParameterStartingWith(DefaultUrlBuilder.ACTION_PARAMETER_PREFIX);
            string actionName  = actionParam == "" ? "" : actionParam.Substring(DefaultUrlBuilder.ACTION_PARAMETER_PREFIX.Length);;

            if (actionName == "")
            {
                return(giver.GiveObjectByType(typeof(DefaultAction)) as IAction);
            }

            IAction action = giver.GiveObjectById(actionName) as IAction;

            if (action == null)
            {
                return(new UnknownActionAction());
            }
            return(action);
        }
Пример #5
0
 public ICruiseAction InstantiateAction(Type actionType)
 {
     return((ICruiseAction)objectGiver.GiveObjectByType(actionType));
 }
Пример #6
0
        // This all needs breaking up a bit (to make it testable, apart from anything else)
        public ObjectGiver SetupObjectGiverForRequest(HttpContext context)
        {
            ObjectGiver giver = (ObjectGiver)giverManager;              // Yuch - put this in Object Wizard somewhere

            giverManager.AddTypedInstance(typeof(ObjectGiver), giverManager);

            giverManager.AddTypedInstance(typeof(HttpContext), context);
            HttpRequest request = context.Request;

            giverManager.AddTypedInstance(typeof(HttpRequest), request);

            // Add functionality to object giver to handle this?
            giverManager.AddTypedInstance(typeof(IRequest), new AggregatedRequest(new NameValueCollectionRequest(request.Form), new NameValueCollectionRequest(request.QueryString)));

            giverManager.SetImplementationType(typeof(IUrlBuilder), typeof(DefaultUrlBuilder));
            giverManager.SetImplementationType(typeof(IMultiTransformer), typeof(PathMappingMultiTransformer));

            giverManager.SetDependencyImplementationForType(typeof(PathMappingMultiTransformer), typeof(IMultiTransformer), typeof(HtmlAwareMultiTransformer));

            IDashboardConfiguration config = (IDashboardConfiguration)giver.GiveObjectByType(typeof(IDashboardConfiguration));

            giverManager.AddTypedInstance(typeof(IDashboardConfiguration), config);

            IRemoteServicesConfiguration remoteServicesConfig = config.RemoteServices;

            giverManager.AddTypedInstance(typeof(IRemoteServicesConfiguration), remoteServicesConfig);

            IPluginConfiguration pluginConfig = config.PluginConfiguration;

            giverManager.AddTypedInstance(typeof(IPluginConfiguration), pluginConfig);

            // Need to get these into plugin setup
            // These plugins are currently disabled - this code will be required again when they are needed
//			giverAndRegistrar.SetDependencyImplementationForIdentifer(SaveNewProjectAction.ACTION_NAME, typeof(IPathMapper), typeof(PathMapperUsingHostName));
//			giverAndRegistrar.SetDependencyImplementationForIdentifer(SaveEditProjectAction.ACTION_NAME, typeof(IPathMapper), typeof(PathMapperUsingHostName));

            // ToDo - Refactor these plugin sections

            foreach (IPlugin plugin in pluginConfig.FarmPlugins)
            {
                foreach (INamedAction action in plugin.NamedActions)
                {
                    giverManager.CreateInstanceMapping(action.ActionName, action.Action)
                    .Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator));
                }
            }

            foreach (IPlugin plugin in pluginConfig.ServerPlugins)
            {
                foreach (INamedAction action in plugin.NamedActions)
                {
                    giverManager.CreateInstanceMapping(action.ActionName, action.Action)
                    .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator));
                }
            }

            foreach (IPlugin plugin in pluginConfig.ProjectPlugins)
            {
                foreach (INamedAction action in plugin.NamedActions)
                {
                    giverManager.CreateInstanceMapping(action.ActionName, action.Action)
                    .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator));
                }
            }

            // Even if the user hasn't specified to use this plugin, we still need it registered since there are links to it elsewhere
            try
            {
                giver.GiveObjectById(LatestBuildReportProjectPlugin.ACTION_NAME);
            }
            catch (ApplicationException)
            {
                IPlugin latestBuildPlugin = (IPlugin)giver.GiveObjectByType(typeof(LatestBuildReportProjectPlugin));
                giverManager.CreateInstanceMapping(latestBuildPlugin.NamedActions[0].ActionName, latestBuildPlugin.NamedActions[0].Action)
                .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator));
            }

            foreach (IPlugin plugin in pluginConfig.BuildPlugins)
            {
                foreach (INamedAction action in plugin.NamedActions)
                {
                    giverManager.CreateInstanceMapping(action.ActionName, action.Action)
                    .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(BuildCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator));
                }
            }

            // ToDo - make this kind of thing specifiable by Plugins (note that this action is not wrapped with a SiteTemplateActionDecorator
            // See BuildLogBuildPlugin for linked todo
            giverManager.CreateImplementationMapping(XmlBuildLogAction.ACTION_NAME, typeof(XmlBuildLogAction))
            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(BuildCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction));

            return(giver);
        }
Пример #7
0
 public object Instantiate(Type type)
 {
     return(objectGiver.GiveObjectByType(type));
 }