0
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    SiteInfo site = siteService.getSite(req.getParameter(PARAM_SITE));

    //Making sure that the site exists
    if(site!=null){
        //Making sure that the site preset is of type municipality
        String preset = site.getSitePreset();
        if(preset.equals(PARAM_MUNICIPALITY)){
            NodeRef noderef = site.getNodeRef();
            WebScriptRequest req2 = req;
            //dreamscenario req2.setParameter("nodeRef", nodeRef);
            super.serviceRegistry = this.serviceRegistry;
            super.execute(req2, res);

        }else{
            res.getWriter().write("Site preset is not of municipality");            
        }
    }else{
        res.getWriter().write("Site was not found");            
    }
}

This is my class that overrides/extends the web script method called execute. I want to change the parameter WebScriptRequest req

//dreamscenario req2.setParameter("nodeRef", nodeRef);

is basically what I want to achieve. So whenever the super class calls:

req.getParameter("nodeRef") 

it will get whatever parameter I put in my method.

Obviously this approach is not working. I could just override the entire super class that im extending, but that doesn't feel like the correct solution if "all" I want to do is change the parameter.

Michael Bui
  • 190
  • 2
  • 12
  • Override `execute`, wrap the `WebScriptRequest` object in a proxy that gives a different answer to that method, then call onto the superclass `execute` method? – Gagravarr Feb 26 '16 at 18:28
  • Yes, that is what I want to achieve..but how? – Michael Bui Feb 26 '16 at 19:38
  • 1
    Whole bunch of ways. Extend the class and delegate all other methods. Use a mocking framework. Use the spring dynamic proxy stuff. Whatever you prefer! – Gagravarr Feb 26 '16 at 23:29

0 Answers0